#discord-bots

1 messages · Page 447 of 1

slate swan
#

dont go hard on me

opaque trail
#
@client.command()
async def afk(ctx, mins: int):
  await ctx.send(...)
  await ctx.author.edit(...)
  
  await asyncio.sleep(mins * 60)
  await ctx.send(...)
  await ctx.author.edit(...)
frigid badge
#

can someone tell me how to get the voice channel in which the command user currently is instead of hardcoding the channel name

frigid badge
opaque trail
#

remember ctx.author.voice might be none so you should check if it is not none before getting the channel

slate swan
boreal ravine
slate swan
boreal ravine
slate swan
slate swan
frigid badge
#

how can i make my bot join the voice channel the user is currently ?

slate swan
opaque trail
#

then handle it

slate swan
#

you would have to use a database if you need an afk command

opaque trail
#

or save it in a cache

boreal ravine
slate swan
#

yeah , like using asyncio.sleep would help in telling the user that the afk is over , but wont help if you want the bot to reply if someone pings the user

visual island
slate swan
visual island
#

um, no, wait_for waits an event to be dispatched, not making api requests

frigid badge
#

i wrote this code to make my bot join the voice channel i am currently , but i doesnt join , please tell what did i do wrong

`@client.command()
async def join(ctx):

channelName = ctx.author.voice.channel

print(channelName)

voiceChannel = discord.utils.get(ctx.guild.voice_channels, name=f"{channelName}")

voice = discord.utils.get(client.voice_clients, guild=ctx.guild)

await voiceChannel.connect()`

slate swan
#

oh

slate swan
visual island
spring flax
#
@bot.command()
async def permissions(ctx, member:discord.Member=None):
    member = member or ctx.author
    await ctx.send(list(ctx.channel.overwrites_for(member)))

I'm trying to make a command that lists the member's permission for a channel, I've tried a lot of ways like permissions_in and permissions_for, but all of them return some guild permissions, like admin. I'm the server owner yes but I just watn channel perms

frigid badge
visual island
frigid badge
#

but the command is working

serene lynx
#
import discord
from discord.ext import commands
user_notfound = None


class unban(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command()
    @commands.has_permissions(ban_members=True)
    async def unban(self, ctx, *, member):
        global user_notfound
        user_notfound = member
        banned_users = await ctx.guild.bans()
        member_name, member_disc = member.split('#')
        description = f'''
**Information :**

Author : {ctx.author}
User : {member}```'''
for banned_entery in banned_users:
user = banned_entery.user

        if (user.name, user.discriminator) == (member_name, member_disc):
            embed = discord.Embed(
                title=f"{user} Has Been Unban", description=description, color=ctx.author.colour, timestamp=ctx.message.created_at,)
            embed.set_footer(text=f'command used by : {ctx.author}',
                             icon_url=str(ctx.author.avatar_url))
            await ctx.guild.unban(user)
            await ctx.send(embed=embed)
            await ctx.message.delete()
            return

    await ctx.send(member + 'not found')
    await ctx.message.delete()

@unban.error
async def unban_error(self, ctx, error):
    if isinstance(error, commands.errors.CommandInvokeError):
        await ctx.send(f'{user_notfound} not found')
        await ctx.message.delete()

def setup(bot):
bot.add_cog(unban(bot))

serene lynx
visual island
serene lynx
visual island
serene lynx
serene lynx
# serene lynx
import discord
from discord.ext import commands
user_notfound = None


class unban(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.user_notfound = None

    @commands.command()
    @commands.has_permissions(ban_members=True)
    async def unban(self, ctx, *, member):
        global self.user_notfound
        self.user_notfound = member
        banned_users = await ctx.guild.bans()
        member_name, member_disc = member.split('#')
        description = f'''
**Information :**

Author : {ctx.author}
User : {member}```'''
for banned_entery in banned_users:
user = banned_entery.user

        if (user.name, user.discriminator) == (member_name, member_disc):
            embed = discord.Embed(
                title=f"{user} Has Been Unban", description=description, color=ctx.author.colour, timestamp=ctx.message.created_at,)
            embed.set_footer(text=f'command used by : {ctx.author}',
                             icon_url=str(ctx.author.avatar_url))
            await ctx.guild.unban(user)
            await ctx.send(embed=embed)
            await ctx.message.delete()
            return

    await ctx.send(member + 'not found')
    await ctx.message.delete()

@unban.error
async def unban_error(self, ctx, error):
    if isinstance(error, commands.errors.CommandInvokeError):
        await ctx.send(f'{self.user_notfound} not found')
        await ctx.message.delete()

def setup(bot):
bot.add_cog(unban(bot))

visual island
#

you do not need to global it again

#

I pressed the wrong button

serene lynx
frigid badge
visual island
slate swan
#

what is the difference between users and members ?

plucky shoal
#

Member is a subclass of Userr

visual island
slate swan
plucky shoal
visual island
plucky shoal
#

!d discord.Member

unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User "discord.User").

`x == y` Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User "discord.User") instances too.

`x != y` Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User "discord.User") instances too.

`hash(x)` Returns the member’s hash.

`str(x)` Returns the member’s name with the discriminator.
slate swan
#

thanks

frigid badge
noble helm
#

is there any reason some urls of images cant load in an embed? cuz i need a lot of birb pictures

visual island
#

show code

gloomy pewter
#

Is it true that Discordpy will die in 2022?

spring flax
#

development has already stopped

sleek ore
#

It's already dead

spring flax
#

it's in the pins

spring flax
sleek ore
#

Yeah, it's like flash

#

Updates stopped, but you can still use it

shy schooner
slate swan
manic wing
#

what is a birb

open brook
#

how do I make cog help to work in lower case??
it works nly if I type help Moderation

primal birch
#

Somebody there can help me, with this error.

gloomy pewter
lone aurora
#
@client.command()
async def add(ctx, num1, num2):
    await ctx.send(f"The sum is {sum(num1, num2)})")``` where is my dumb butt going wrong
manic wing
#

num1: int

slate swan
gloomy pewter
lone aurora
gloomy pewter
slate swan
#

why is it don't delete the message?

#

i type ctx.message.delete()

spring flax
gloomy pewter
spring flax
#

change what?

lone aurora
#
@client.command()
async def add(ctx, num1, num2):
    num1 = int(input("Enter a numer"))
    num2 = int(input("Enter another numer"))
    result = num1 + num2
    await ctx.send(f"The answer is {result}")``` so this should work?
hasty iron
#

!d discord.Client.wait_for

unkempt canyonBOT
#

wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/stable/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
lone aurora
#

well im dumb af

hasty iron
#

look at the doc page

#

there are examples

spring flax
lone aurora
#

i c

gloomy pewter
odd pendant
slate swan
gloomy pewter
spring flax
# lone aurora i c

nevermind what i said

async def add(ctx, num1 : int, num2 : int):
  await ctx.send(num1 + num2)```
lone aurora
spring flax
gloomy pewter
spring flax
#

i have no clue what you are trying to say

spring flax
#

putting a string would give an error

gloomy pewter
#

Okey thanks @spring flax

odd pendant
#

or you could do await ctx.send(int(num1) + int(num2)) if you want to handle the errors

slate swan
#

someone know?

lone aurora
#

welp

opaque trail
opaque trail
lone aurora
#

i wanted to make it so that you have enter a number then another one then it gave the answer which i was able to do but it required me to enter it in terminal as well sadly

slate swan
#

@opaque trailwhat i need to do?

slate swan
odd pendant
lone aurora
#
@client.command()
async def add(ctx, num1: int, num2: int):
    await ctx.send(f"The answer is {num1 + num2}")``` but this work i can just do .add num1 num2- thanks for that @spring flax
lone aurora
odd pendant
#

what do you want to do?

#

!add 1 1

#

or !add
1
1

opaque trail
lone aurora
lone aurora
#

so like
me : .add
bot : Enter the first number
me : 1
bot : Enter the second number
me : 1
bot : the answer is : 2

odd pendant
#

so not what i just said then

#

you want to use wait_for

spring flax
#

you can also use wait_for to make the user say whether he wants to add divide multiply or subtract, and then give the two numbers

spring flax
unkempt canyonBOT
#

wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/stable/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
spring flax
#

there are examples in the docs to do what you want

lone aurora
#

ic ic ok

slate swan
#

how can i delete bot message? i tried to do this

#
msg = send_bot_message()
await msg.delete()
#

?

#

await after.delete()?

#

that should work

shy schooner
slate swan
#

if not try await after.message.delete()

#

You mean await ctx.send(..., delete_after=...)?

lone aurora
#

ok

#

it still not work

#

someone end me

slate swan
#

what?

slate swan
#

how can i loop this thing?

slate swan
slate swan
lone aurora
#

heh?

solemn ocean
shy schooner
solemn ocean
#

im new and dont understand

slate swan
#

your token

#

is there a event for when deleting a webhook in a text channel

shy schooner
slate swan
solemn ocean
slate swan
shy schooner
solemn ocean
#

which line is it

maiden fable
#

!rtfm on_webhook_update @slate swan

shy schooner
maiden fable
#

Breh

slate swan
solemn ocean
#

"token"

slate swan
#

@shy schooner like this?

solemn ocean
#

like that right

shy schooner
maiden fable
#

!d discord.on_webhooks_update

unkempt canyonBOT
#

discord.on_webhooks_update(channel)```
Called whenever a webhook is created, modified, or removed from a guild channel.

This requires [`Intents.webhooks`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.webhooks "discord.Intents.webhooks") to be enabled.
maiden fable
#

There :D

shy schooner
slate swan
maiden fable
slate swan
#

ok

slate swan
shy schooner
slate swan
solemn ocean
#

token is wrong

shy schooner
#

bruh dont reveal your token

#

ok

solemn ocean
#

yh

karmic totem
#

How do I save guild Id for something

slate swan
#

@shy schooner

solemn ocean
#

i'm lost

manic wing
karmic totem
#

oh db thanks

#

nvm

slate swan
#

What are you trying to do?

#

loop a command

shy schooner
#
while True:
  await asyncio.sleep(15)
  await msg.delete()
  await ctx.send....

do you have a solid understand of basic python

slate swan
#

loop a what..-

#

This is not how python works

shy schooner
#

there's no for while loop :v

solemn ocean
#

i need help with token

shy schooner
solemn ocean
#

is it

#

"" or ''

shy schooner
#

remove this line

#

the my_secret

slate swan
#

It is "learn python please blobpain"

shy schooner
#

:D

solemn ocean
#

😄 😔

slate swan
#

like this? i need to fix an command and i'm not so good at this

#

Insert your envvar in replit's console whatever, and put it's key value as an str in on.environ dict

shy schooner
gloomy coral
#

How can i get vps stats with vultr api in form of a command?

slate swan
shy schooner
slate swan
#

I don't tell people to not use replit anymore blobpain

#

Everybody does that

solemn ocean
shy schooner
shy schooner
slate swan
#

Depends, free trials are not that bad, and heroku is actually good for api and web related stuff but not discord bot

#

I myself have a free 1 yr azure subscription 👀

#

and it's free

shy schooner
slate swan
#

yes, their file system is ephemeral

#

and json is not meant to be used as a database

#

if you need to store secrets and don't update that file later, it will work

slate swan
shell wing
#

can the bot send hidden msg without slash commands ?

slate swan
#

With an interaction, yes

slate swan
#

slash command is type of interaction, but there are more like buttons and selects and context menu commands

shell wing
slate swan
#

In normal commands: Not possible

shell wing
#

alr

slate swan
slate swan
# solemn ocean

a discord bot using discord.py does not have a method or function get_channel, you are probably wanting to use fetch_channel

hallow zealot
slate swan
#

!d discord.Client.get_channel

unkempt canyonBOT
slate swan
#

@slate swan ^?

#

wa

#

lemme check

hallow zealot
slate swan
slate swan
#

You mean embeds?

#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(**kwargs)```
Represents a Discord embed.

`len(x)` Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
slate swan
hallow zealot
solemn ocean
#

got it running

slate swan
#

yay

slate swan
#

in title, you have an additional kwarg url=

slate swan
#

If it does not work test in the title of a field

#

oh

#

Field names also don't support most of the markdown iirc, it's just description and field values

slate swan
#

!raw json 883691680589574174

unkempt canyonBOT
#
== Raw embeds (1/1) ==

{'description': '`​`​`​py\n'
                '\n'
                'class discord.Embed(**kwargs)`​`​`​\n'
                'Represents a Discord embed.\n'
                '\n'
                '`​len(x)`​ Returns the total size of the embed. Useful for '
                'checking if it’s within the 6000 character limit.\n'
                '\n'
                'Certain properties return an `​EmbedProxy`​, a type that acts '
                'similar to a regular '
                '[`​dict`​](https://docs.python.org/3/library/stdtypes.html#dict '
                '"(in Python v3.9)") except using dotted access, e.g. '
                '`​embed.author.icon_url`​. If the attribute is invalid or '
                'empty, then a special sentinel value is returned, '
                '[`​Embed.Empty`​](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed.Empty '
                '"discord.Embed.Empty").\n'
                '\n'
                'For ease of use, all parameters that expect a '
                '[`​str`​](https://docs.python.org/3/library/stdtypes.html#str '
                '"(in Python v3.9)") are implicitly casted to '
                '[`​str`​](https://docs.python.org/3/library/stdtypes.html#str '
                '"(in Python v3.9)") for you.',
 'title': 'discord.Embed',
 'type': 'rich',
 'url': 'https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed'}
lone aurora
#
@client.event
async def on_message():
    if message.content.startswith('!add'):
        channel = message.channel
        await channel.send("Please enter a number")``` ok ive tried alot of things but i cant get past this can someone tell me what might be next
slate swan
slate swan
lone aurora
#

oh i did define it but i removed, lemme add it back

slate swan
#

pass in a message

lone aurora
#
@client.event
async def on_message(message):
    if message.content.startswith('!add'):
        channel = message.channel
        await channel.send("Please enter a number")

        msg = await client.wait_for('message')
        await channel.send(message)```
#

like that u man?

#

mean*

shy schooner
#

yes

shy schooner
shy schooner
#

define the check funciton

lone aurora
#
@client.event
async def on_message(message, ctx):
    if message.content.startswith('!add'):
        channel = message.channel
        await channel.send("Please enter a number")

        def check(m):  
            return m.content == #what do i add here to make it so that it can only be an integer

    
        msg = await client.wait_for('message', check=check)
        await ctx.send(message.content)```
#

@shy schooner sorry for the ping but any clue?

slate swan
#

!d str.isdigit

unkempt canyonBOT
#

str.isdigit()```
Return `True` if all characters in the string are digits and there is at least one character, `False` otherwise. Digits include decimal characters and digits that need special handling, such as the compatibility superscript digits. This covers digits which cannot be used to form numbers in base 10, like the Kharosthi numbers. Formally, a digit is a character that has the property value Numeric\_Type=Digit or Numeric\_Type=Decimal.
shy schooner
#
def check(msg):
  return msg.author == ctx.author and msg.channel == ctx.message.channel
fallen viper
slate swan
lone aurora
#

ill try em all ig.. thank you all ;))

shy schooner
#

try this

keen fox
#

Hey! I am trying to set an embed color to be my bot's current displayed color, but it doesn't seem to work - it keeps returning #000000.

I think the way that's supposed to be used is self.client.user.color, as the documentation says. This does return #000000 when it's supposed to be returning #d69420 (hey don't mind me, it's a nice color).

Trying to get a user's color with ctx.author.color does work, and it does return a color which is my displayed user color.

What exactly am i doing wrong?

My code:

@commands.command()
async def avatar(self, ctx, *, user: discord.Member = 'author'):
    if user == 'author':
        user = ctx.author
    ae = discord.Embed( # testing
        colour = discord.Color.default(), # i have to input the bot's color here
        title = 'title',
        description = 'description'
    )
    ae.add_field(name='field1',value='value1')
    await ctx.send(user.color) # debug, returns the working color
    await ctx.send(self.client.user.color) # debug, returns #000000 (why)
    await ctx.send(user.avatar_url) # returns the avatar
    await ctx.send(embed=ae) # test embed
slate swan
fallen viper
#

wdym

slate swan
#

!e int('test')

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | ValueError: invalid literal for int() with base 10: 'test'
lament mesa
#

!e py print(int('test', base=30)) hahaha

unkempt canyonBOT
#

@lament mesa :white_check_mark: Your eval job has completed with return code 0.

796469
polar dirge
#

how am i able to make my discord bot as FAST as possible

#

anything helps, trying to shave off every millisecond

lament mesa
#

dont do blocking stuff

#

try to use builtins instead of for ... while ... loops

slate swan
#

What's the name for base 30? tetradec? rooThink

#

try to use builtins instead... what builtins?

lament mesa
lament mesa
slate swan
#

um which functions? Can you please give an example?

polar dirge
lone aurora
#
@client.command()
async def add(ctx, num1:int, num2:int):
    if (not num1):
        await ctx.send("Please do **.add <number 1> <number 2>**")
    if (not num2):
        await ctx.send("Please do **.add <number 1> <number 2>**")
    
    await ctx.send(f"__{num1}__ + __{num2}__ = **__{num1 + num2}__**")``` eh am i doing something wrong (yes i gave up on trying to make it  ask for 2 numbers)
lament mesa
slate swan
slate swan
lament mesa
slate swan
lament mesa
#

You can also cache api requests

lament mesa
slate swan
#

cache api requests... redis... google time

fallen viper
#

whats the point

pale turtle
keen fox
fallen viper
#

u can get ctx on on_message but there is no point

slate swan
#

bot's color is it's top role color. You sure it isn't black?

full lily
fallen viper
#

it used only for commands extensions

keen fox
slate swan
unkempt canyonBOT
lament mesa
#

like dpy does

full lily
pale turtle
#

You are trying to do a User.color kind of thing

keen fox
#

but a ClientUser does

slate swan
lone aurora
#
@client.command()
async def add(ctx, num1:int, num2:int):
    if not Arguments:
        await ctx.send("Please do **.add <number 1> <number 2>**")``` where am i going wrong now ;(((
fallen viper
#

what is Arguments

keen fox
pale turtle
#

There is a difference between a User(or ClientUser).color, and Member.color

lone aurora
#

isnt arguments for like num1 and num2?..

fallen viper
#

oh

lone aurora
#

i just want to do it so that if the user doesn't provide num1 and num2, it sends an error msg

pale turtle
fallen viper
#
@client.command()
async def add(ctx, num1:int = None, num2:int = None):
    if not num1 or not num2:
        await ctx.send("Please do **.add <number 1> <number 2>**")
lone aurora
#

oh

#

ima test this

pale turtle
slate swan
pale turtle
#

Which is why I think the docs that it always returns a default color (0)

slate swan
#

Yes

lament mesa
slate swan
#

rooThink oops I mean in dpy's internal cache (ConnectionState)..

lament mesa
#

even a list can be used to cache the data

lone aurora
#
@client.command()
async def add(ctx, num1:int, num2:int):
    await ctx.send(f"__{num1}__ + __{num2}__ = **__{num1 + num2}__**")
    if not num1 or not num2:
        await ctx.send("Please do **.add <number 1> <number 2>**")```
umm this isnt working either, just shows an error on terminal saying that num1 and num2 are missing
slate swan
#

Yeah all the stuff for subclassing list I was asking yesterday was for caching only blobpain

lament mesa
lone aurora
#

oh wait nvm

#

ok nvm again, its not working

slate swan
lone aurora
#
@client.command()
async def add(ctx, num1:int, num2:int):
    await ctx.send(f"__{num1}__ + __{num2}__ = **__{num1 + num2}__**")
    if MissingRequiredArgument:
        await ctx.send("Please do **.add <number 1> <number 2>**")``` i tried this still not working
lone aurora
#

i tried that too

fallen viper
#

also if u want use that u need error handler

lone aurora
#

ic

fallen viper
#
@client.command()
async def add(ctx, num1:int, num2:int):
    await ctx.send(f"__{num1}__ + __{num2}__ = **__{num1 + num2}__**")

@add.error
async def add_error(ctx, error):
    if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send("Please do **.add <number 1> <number 2>**")
#

may not work as i havent used the library for long

spring flax
#

that should work

slate swan
#

unwrap the error

#

what is the rate limit per second on retriving pined messages

lone aurora
#

i was about to go look for it myself.. but then i saw u alr did it

#

legend

pale turtle
#

Should I create a bot that anyone who wants can host it and use it? Modmail one

slate swan
#

class NIR(NoBotIdeas) I too need some ideas other than bots rooOhNo

fallen viper
#

if u want

slate swan
#

My poor net

lone aurora
#

one more thing, ive been trying to find a way for this but i haven't found anything on it yet- is it possible to make cmds case insensitive?

slate swan
slate swan
lone aurora
#

hm

slate swan
#

guys the one who press the button , whats his name

#

i mean

#

i want to make if someone press the button

#

to mention his name

#

what button?

#

reactions? or new buttons thing

#

component

#

new butt

#

Which library are you using? rooThink

#

discord components

#

No idea for that blobpain

#

sorry

#

its okay

#

anyone else ??

pale turtle
#

Um I have no idea about that lib, but maybe interaction.user?

lone aurora
#

ok im dumb is it supposed to be like this

@client.command()
async def cmds(ctx, case_insensitive=True):``` 
or this 
```py
@client.command()
async def cmds(ctx):
case_insensitive=True```
slate swan
pale turtle
pale turtle
lone aurora
#

o h

#

me looking like an idiot for the past 3 hours :
brain : seems about right

slate swan
#

Lol you can just search their docs or I think they also have a support server

mental nova
#

if I want to make a bot that fetch give them from a site so that at the time a content is posting it on my discord server how to do it? if you have a bot that does this with another site I invite you to send me the code pls

pale turtle
#

You'd need to somehow wait for a response from some Api

visual island
#

no I believe

lament mesa
#

PascalCase

#

pep 8 lemon_fingerguns_shades

pale turtle
#

Imagine camelCase 🤮

lament mesa
#

function names should be snake_case

pale turtle
#

Like the amazing words written by lemon: "And camelCase is not for Python, never ever, never everrrr, and comments are important...."

lament mesa
pale turtle
#

Oh shit sorry

pale turtle
#

Yeah it's part of the song lmao

lament mesa
#

lol

#

i rarely write comments

pale turtle
#

It goes like: And comment are important, as long as they're maintained, if comments are misleading it'll drive people insane

slate swan
#

as long as they're maintained.. (which I can't blobpain )

pale turtle
slate swan
#

scoop You remember whole lyrics

pale turtle
slate swan
#

I see luck

pale turtle
#

If I do:

role = ctx.guild.get_role(ctx.guild.id)``` This would return everyone role right?
slate swan
#

yes

lament mesa
opaque trail
#
def PoopInMyMouth(POOPERMoUNTH, PoopValue):
  for i in range(10324):LF
    print(PooppperMounthm, Poopvalue)

what is wrong with my code guys!! it no work

pale turtle
#

I hate the fact I'll be learning js in school, but for web development

opaque trail
#

israeli teachers

slate swan
#

Our school taught us basic variable types like int and str, and next chapter was numpy and pandas notlikeblob

pale turtle
opaque trail
#

he was a pretty cool teacher 😦

slate swan
#
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "/home/runner/omfg/cogs/level.py", line 49, in on_message
    result = await self.find_or_insert_user(message.author)
  File "/home/runner/omfg/cogs/level.py", line 23, in find_or_insert_user
    await cursor.execute('Select * from users where user_id = ?', (member.id,))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/aiosqlite/cursor.py", line 37, in execute
Traceback (most recent call last):
  File "main.py", line 3, in <module>
Traceback (most recent call last):
  File "main.py", line 3, in <module>
Traceback (most recent call last):
  File "main.py", line 3, in <module>
Traceback (most recent call last):
  File "main.py", line 3, in <module>
Traceback (most recent call last):
  File "main.py", line 3, in <module>
    import discord
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/__init__.py", line 23, in <module>
    from .client import *
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 27, in <module>
    import asyncio
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/asyncio/__init__.py", line 21, in <module>
    from .base_events import *
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/asyncio/base_events.py", line 296
    future = tasks.async(future, loop=self)
                   ^
SyntaxError: invalid syntax
 
#

is it because im in main?

opaque trail
#

you should try reinstalling python or reinstalling the asyncio package

slate swan
opaque trail
#

oh

#

i guess you can try to create a new project? idk

shy schooner
opaque trail
#

i meant delete it and download it again

slate swan
#

w- what?

shy schooner
opaque trail
lament mesa
#

yeah

slate swan
#

that error usually show up when you install pip install discord instead of discord.py

lament mesa
#

update python

opaque trail
shy schooner
slate swan
#

i have the latest version guys

opaque trail
#

it must be possibl

#

e

lament mesa
slate swan
#

but replit have the latest version or no?

lament mesa
#

latest is 3.9.7

shy schooner
slate swan
#

:/

shy schooner
opaque trail
#

use the repl.it console and install the latest version there

opaque trail
slate swan
#

and my pc can't handle vsc

shy schooner
opaque trail
#

its not related to his code

shy schooner
#

ok

opaque trail
#

its related to the python installation

slate swan
#

what should i do?

#
AttributeError: 'NoneType' object has no attribute 'send_json'```
shy schooner
#

package

slate swan
#

ok

slate swan
opaque trail
#

try to make a new repl.it project and paste your code there that might work

shy schooner
opaque trail
keen fox
#

continuing to mess around with the avatar command and um...

where does it even see 2 arguments?

slate swan
#

can anyone help me with this

shy schooner
opaque trail
keen fox
#

!d discord.Embed.set_image

unkempt canyonBOT
#

set_image(*, url)```
Sets the image for the embed content.

This function returns the class instance to allow for fluent-style chaining.

Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
opaque trail
#

oh yea sorry

slate swan
opaque trail
keen fox
opaque trail
opaque trail
slate swan
#

so what to do rn

opaque trail
#

well where is event defined?

#

its discord.Client.user not USER

slate swan
#

@opaque trailcan y help me to define it

opaque trail
#

!d discord.Member.guild

unkempt canyonBOT
opaque trail
#

discord.User does not have a guild

slate swan
#

i forget all thing

opaque trail
slate swan
#

any good free tier for music bot hosting? in aws

opaque trail
#

i guess you can do webscraping?

mental nova
#

I supose yes

boreal ravine
#

nice grammer

upbeat otter
#

Guys, is there a way to save avatars of members

boreal ravine
#

why?

slate swan
#

!d discord.Asset.save

unkempt canyonBOT
#

await save(fp, *, seek_begin=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Saves this asset into a file-like object.
upbeat otter
#

ohh

stiff knot
#
        for channel in ctx.guild.text_channels.items():
            if str(channel.type) == 'text':
                text_channel_list.append(channel)``` Does anyone know how to fix too many values to unpack?
opaque trail
#

why dont you just

text_channel_list = ctx.guild.text_channels
```?
stiff knot
opaque trail
#

you still have the for loop. delete the for loop. just use the code i sent

stiff knot
#

I removed the for loop already

slate swan
#

this works different in each guild

stiff knot
#

It still doesnt work

opaque trail
#

send the new code and the whole traceback..

slate swan
opaque trail
#

what do you mean work different

slate swan
broken turtle
#

I got punged

slate swan
stiff knot
# opaque trail send the new code and the whole traceback..
class FunctionServerInfo(commands.Cog):

    def _init_(self, client):
        self.client = client

    @commands.command(pass_context = True)
    async def serverinfo(self, ctx):
                
        embed = Embed(title = "Server information",
                      colour = 0xFF5733,
                      timestamp = datetime.utcnow())
        
        text_channel_list = ctx.guild.text_channels

        embed.set_thumbnail(url=ctx.guild.icon_url)
        
        fields = [("Owner", ctx.guild.owner, False),
                  ("Created At", ctx.guild.created_at.strftime("%d/%m/%Y %H:%M:%S"), False),
                  ("Region", ctx.guild.region, True),
                  ("Member Count", str(len([m for m in ctx.guild.members if not m.bot])) + " Humans | " + str(len([m for m in ctx.guild.members if m.bot])) + " Bots | " + str(len(ctx.guild.members)) + " Total", False),
                  ("Channel Count", str(len(ctx.guild.text_channels)) + " Text Channels | " + str(len(ctx.guild.voice_channels) )+ " Voice Channels | " + str(len(ctx.guild.voice_channels) + len(ctx.guild.text_channels)) + " Total", False ),
                  ("Text Channels", "[" + str(len(ctx.guild.text_channels)) + "]", text_channel_list, False),
                  ("Roles" + "[" + str(len(ctx.guild.roles)-1) + "]",  ", ".join([str(r.mention) for r in ctx.guild.roles if r.name != "@everyone"]), False),
                  ("Emojis" + "[" + str(len(ctx.guild.emojis)) + "]", ", ".join([str(emoji) for emoji in ctx.guild.emojis]), False)
                 ]
        
        for name, value, inline in fields:
                embed.add_field(name=name, value=value, inline=inline)
                    
        await ctx.send(embed = embed)
        
                
def setup(client):
    client.add_cog(FunctionServerInfo(client))```
opaque trail
opaque trail
stiff knot
#

Nope

#

I was hoping to make it look like this

opaque trail
#

Your roles field is + instead of ,

#

yes it does

stiff knot
#

Lemme show ya how it looks

opaque trail
#

i understand how it is supposed to look like

#

but you typed , instead of +

stiff knot
#

Really?

#

OHHHH

#

I see what u mean XD

slate swan
stiff knot
#

Bruhh

#

Do u know how to fix that?

slate swan
opaque trail
opaque trail
# slate swan

mutedRole = await ctx.guild.create_role(name="Muted", permissions=discord.Permissions(8))

high flame
#

is psutil blocking?

clever wind
#
@client.command(pass_context=True)
async def start(ctx):
  try:
    channel_id = ctx.author.voice.channel.id
    channel = client.get_channel(channel_id)

    vc_members = channel.members

    vc_member_list = []
    for member in vc_members:
        vc_member_list.append(member.mention)

    vc_member_list.random.shuffle()

    embed = discord.Embed(title="Teams")
    embed.add_field(
        name="Team A",
        value=
        f'{vc_member_list[0]} \n {vc_member_list[3]} \n {vc_member_list[4]} \n {vc_member_list[7]}',
        inline=True)
    embed.add_field(
        name="Team B",
        value=
        f'{vc_member_list[1]} \n {vc_member_list[2]} \n {vc_member_list[5]} \n {vc_member_list[6]}',
        inline=True)
    await ctx.send(embed=embed)
  except:
    await ctx.send("Wait for 8 people in the queue.")

can someone help with this code in general? theres a few things i wanna fix

high flame
#

i use psutil.virtual_memory() and psutil.cpu_percent()

opaque trail
high flame
#

alr

slate swan
high flame
#

its admin

opaque trail
high flame
#

lol

slate swan
high flame
#

nice bot

slate swan
#

whai

#

?

slate swan
high flame
#

nvm you can get the perms integer in oauth tab

#

oops

upbeat otter
#

why is this not working?

greyEmbed.set_image(image="finalim.jpg")```
opaque trail
#

set_image needs to be a url

upbeat otter
opaque trail
#

you could either upload it to the web and then provide the url, or do this:

file = discord.File("finalim.jpg", filename="finalim.jpg")
greyEmbed.set_image(url="attachment://finalim.jpg")
await ctx.send(file=file, embed=embed)
upbeat otter
#

but then the image will come outside of embed

opaque trail
#

is finalim a static image?

polar dirge
#

how am i able to make my bot as FAST as possible. anything helps, trying to save milliseconds

opaque trail
#

optimize it

polar dirge
#

it is pretty optimized, im talking anything about dbs, functions

#

calls

pallid terrace
opaque trail
#

no

pallid terrace
#

☹️

slate swan
deft hill
#
@client.command()
async def kill(ctx):
    if client.is_owner:
        channel = client.get_channel(874657555656368138)
        await ctx.send("Turning off. See you on the other side!")
        await channel.edit(name="Server Status: Unknown")
        await asyncio.sleep(1)
        await client.close()
    else:
        pass

Current code.

Problem: Anyone can run the command. Even if not owner.
Question: Am I missing something? Im looking for a 2nd pair of eyes.

I have owner specified in this client = commands.Bot(command_prefix="c!", owner_id=693661517824131172)

opaque trail
#

is_owner is a function

#

and you can use the decorator instead

slate swan
#

maybe try using @commands.is_owner()
so it would be like this ```py
@bot.command()
@commands.is_owner()
async def kill(ctx):

deft hill
#

Ahhh

#

Thank you!

neon pawn
#

im trying to sell my skills with discord bot development. im in school rn and its of of the few programming skills i feel comfortable with. were would you recommend i start?

#

and it anyone wants a discord bot just dm me

neon pawn
#

quite a lot

#

ive been doing alot

maiden fable
#

Well, can I get some more context? A lot can be used differently but different people 😅

slate swan
#

how to find the audio bitrate of my bot??

neon pawn
#

im asuimg i cant send the link of the one im working on rn cause it would be self promo

plucky shoal
maiden fable
slate swan
maiden fable
plucky shoal
slate swan
plucky shoal
#

But that's something I'm clueless about since I never tried it

plucky shoal
neon pawn
#

only stuff you can regulate

plucky shoal
#

thisMakes sense

hallow socket
#

Is there a way to check if the bot was manually disconnected by a user ?

neon pawn
#

if your using youtubedl then it probable has a bitrate value in the object

pallid terrace
plucky shoal
halcyon bison
#

is it possible to create a command for like unscramble without making a .json file?
like for example:

i would do b!unscramble (b! being my prefix)
the bot would respond with a random scrambled word like:

etintap

and if i were to say the correct answer (patient) then it would say "you answered correctly!" and if i said it wrong then it would say "you were wrong. you have 1 more try left~"
the reason i dont want to use .json files is because i dont know HOW to use .json files

plucky shoal
#

Oh yep, your code uses ytdl

#

We won't help with that

#

!y

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
slate swan
#

kk xd

neon pawn
slate swan
#

and btw, u remember me, i was making a bot with custom replies??

neon pawn
slate swan
#

i at last made it 😛

#

i used github webhook, and did the stuff :3

#

do u wanna see ?

maiden fable
#

Cool!

#

Sure! :D

opaque trail
#

you leaked a token?

slate swan
opaque trail
#

your youtube one

pallid terrace
slate swan
#

oh yes

plucky shoal
#

thisDelete the message with the code link

#

It has some key

slate swan
#

lol i did again sad

#

i'll have to change now :C

plucky shoal
#

Also, against tos code like that one aren't allowed here anyway

slate swan
#

Guys

#

I need help

#

Can domeone?

slate swan
#

Someone*

maiden fable
#

Cool

slate swan
#

In my bot every command works

#

ty lol

#

But only warn and mute never does even every new command i add!

unkempt canyonBOT
slate swan
#

My file is too long

dense walrus
#

How can I check if a message being sent is a channel mention? for example #help-apple

opaque trail
open brook
#

How do u disable a option when it is selected?

dense walrus
open brook
#

!d discord.TextChannel

unkempt canyonBOT
#

class discord.TextChannel```
Represents a Discord guild text channel.

`x == y` Checks if two channels are equal.

`x != y` Checks if two channels are not equal.

`hash(x)` Returns the channel’s hash.

`str(x)` Returns the channel’s name.
open brook
#

@dense walrus

slate swan
#

does discord.Member.add_roles work like a list of type Role
[roles object] or [role id]

opaque trail
#

!d discord.Member.add_roles

unkempt canyonBOT
#

await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
dense walrus
#

channel = await self.bot.wait_for('message', check=check)

how can I ensure its a text channel mention / id?

opaque trail
#

!d discord.ext.commands.TextChannelConverter

unkempt canyonBOT
#

class discord.ext.commands.TextChannelConverter```
Converts to a [`TextChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.TextChannel "discord.TextChannel").

All lookups are via the local guild. If in a DM context, then the lookup is done by the global cache.

The lookup strategy is as follows (in order)...
slate swan
#

because i have [role object] and it says AttributeError: 'list' object has no attribute 'id'

opaque trail
opaque trail
slate swan
#

ok

opaque trail
#

member.add_roles(*roles)

dense walrus
opaque trail
#
def check(msg):
  try:
    await commands.TextChannelConverter.convert(msg.content)
    return True
  except commands.BadArgument:
    pass
dense walrus
#

await in non async function @opaque trail

#

can the check function be async?

opaque trail
#

i am not sure.

#

i guess you can

bot.loop.run_until_complete(commands.TextChannelConverter.convert(msg.content))
#

and that will make it sync

slate swan
opaque trail
# dense walrus How can I use it exactly in my `check` function?

you could alternatively, put it outside of your check function

message = await self.bot.wait_for('message', check=check)

try:
  channel = await commands.TextChannelConverter.convert(message.content)
except commands.BadArgument:
  await ctx.send("The channel argument is invalid, please try again")
  return
#

but its up to you

opaque trail
dense walrus
opaque trail
#

but the user might be confused

dense walrus
#

actually that's fine ig

slate swan
#

what's the problem

agile goblet
#

exactly that, get_server is not an attribute of the discord.Bot object

slate swan
#

what can i use then

agile goblet
#

i think you mean get_guild

slate swan
agile goblet
#

and ids are always integers

slate swan
#

it's guild

#

now it gives same error for create_invite

#

so just do bot.get_guild instead

slate swan
#

don't use () lol

agile goblet
#

it indicates its a method to the docs command

#

doesnt matter if its () or (args)

slate swan
#
      server = bot.get_guild(883453532878028860)
      link = bot.create_invite(server)
      await print(link) 
#

Oh okay, my bad

#

Thanks

agile goblet
#

oh yeah its

#

bruh

slate swan
#

huh

slate swan
#

see i don't think () works lmao

agile goblet
#

invites are created for channels not guilds

#

hm weird, it used to

slate swan
#

i think i tried it before, and was wondering why it didn't come blobpain

agile goblet
#

as far as i remember

#

or im tripping lmao

slate swan
#

let me try

#

yeah. and it's not bot.create_invite btw

#

i'm high lmao

#

wait

#

how i am gonna use it then

#

it's guild

#

not bot

#

as the class Guild has a create_invite method

agile goblet
#

get a textchannel from the guild

stiff knot
#

Anyone know why await is wrong?

agile goblet
#

nah invites are created for channels not guilds themselves

#

so get the guild and then a channel

slate swan
#

ah yeah

agile goblet
#

for example:
guild.text_channels[0]

#

will just get the first channel

slate swan
#

so i need to get channel before creating the url?

slate swan
agile goblet
#

yeah since invites are created for channels

#

not for guilds themselves

dense walrus
#

I get this error when trying to use await channel.send(embed=embed

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Object of type Message is not JSON serializable
slate swan
agile goblet
#

your Guild object is called server

slate swan
#

oh i forgot

agile goblet
#

i was just saying guild since thats what theyre called lmao

slate swan
stiff knot
slate swan
#

undefined name **fields

stiff knot
#

Do u know whats wrong?

#

Some sort of indentation error it ses

opaque trail
dense walrus
agile goblet
#

**fields are optional, the double asterisk indicates that. In the docs you can see what arguments you can use. I screenshotted them for you this time

#

sevrer is also not necessary as an argument btw

opaque trail
#

can you send a chunk of your code?

dense walrus
#

yeah sec

opaque trail
#

where you define the embed and where you send it

slate swan
dense walrus
#

this is a function

async def create_poll(self, channel, title, option1, option2):
        embed = discord.Embed(title=title,
         description=f"1️⃣ {option1}\n2️⃣ {option2}",
          color=0xff6f00)
        msg = await channel.send(embed=embed)
        await msg.add_reaction('1️⃣')
        await msg.add_reaction('2️⃣')

I use this function inside of a command

opaque trail
agile goblet
#

yeah point

agile goblet
#

!d discord.Invite

unkempt canyonBOT
#

class discord.Invite```
Represents a Discord [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild "discord.Guild") or [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel") invite.

Depending on the way this object was created, some of the attributes can have a value of `None`.

`x == y` Checks if two invites are equal.

`x != y` Checks if two invites are not equal.

`hash(x)` Returns the invite hash.

`str(x)` Returns the invite URL...
pliant gulch
slate swan
#

uhh what

dense walrus
#

slash commands 🤮

opaque trail
pliant gulch
#

Alright, cause that error is what you can get from those libraries

#

Just checking

agile goblet
dense walrus
#

I will try to create the embed in the command function, not from another function

#

Pretty sure its not the problem but ill try

slate swan
#

whats awaserver

dense walrus
#

that's so weird

vagrant brook
#

Can you send full traceback

dense walrus
#

u talking to me or him?

vagrant brook
#

You

dense walrus
#

Traceback (most recent call last):
File "C:\Users\Yarin\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\ext\commands\bot.py", line 935, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Yarin\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Yarin\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Object of type Message is not JSON serializable

agile goblet
#

you also put awa infront of server somewhere

dense walrus
#

I printed the type(embed) and it's <class 'discord.embeds.Embed'>, so I meann

#

oh wait

agile goblet
slate swan
#

oh wait

#

@agile goblet tysm

dense walrus
#
Traceback (most recent call last):
  File "C:\Users\Yarin\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\Yarin\Desktop\xxx\xxx\xxx-bot\cogs\commands\admin.py", line 57, in poll
    await self.create_poll(channel, title, option1, option2)
  File "c:\Users\Yarin\Desktop\xxx\xxx\xxx-bot\cogs\commands\admin.py", line 64, in create_poll
    msg = await channel.send(embed=embed)
  File "C:\Users\Yarin\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\abc.py", line 938, in send
    message_reference=reference)
  File "C:\Users\Yarin\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\http.py", line 156, in request
    kwargs['data'] = utils.to_json(kwargs.pop('json'))
  File "C:\Users\Yarin\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\utils.py", line 316, in to_json
    return json.dumps(obj, separators=(',', ':'), ensure_ascii=True)
  File "C:\Users\Yarin\AppData\Local\Programs\Python\Python37\lib\json\__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "C:\Users\Yarin\AppData\Local\Programs\Python\Python37\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Users\Yarin\AppData\Local\Programs\Python\Python37\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "C:\Users\Yarin\AppData\Local\Programs\Python\Python37\lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Message is not JSON serializable```
I changed path names if you don't mind @vagrant brook
agile goblet
#

no problemo

agile goblet
vagrant brook
#

I can't see whats wrong lmao

agile goblet
#

if its a command it will pass all arguments as strings unless said otherwise

dense walrus
#

you meant discord.TextChannel right?

agile goblet
#

Yeah my bad

#

i dont see anything else weird so u can always try yk

dense walrus
#

nah it's still throwing that error

#

never seen that error wtf

vagrant brook
#

I think it could be some lib that youre using messing up

dense walrus
#

I am using d.py not anything else

agile goblet
#

show the full command or is that it

dense walrus
#
@commands.command()
    @commands.guild_only()
    async def poll(self, ctx):
        def check(m):
            return m.author == ctx.message.author and m.channel == ctx.message.channel

        await ctx.send("Enter the channel you want the poll to be in")
        msg = await self.bot.wait_for('message', check=check)
        try:
            converter = commands.TextChannelConverter()
            channel = await converter.convert(ctx, msg.content)
            await msg.add_reaction('✔️')
        except commands.BadArgument:
            await ctx.send("The channel argument is invalid, please try again")
            return
        await ctx.send("Enter the title of the poll")
        title = await self.bot.wait_for('message', check=check)
        await title.add_reaction('✔️')
        await ctx.send("Enter the first option")
        option1 = await self.bot.wait_for('message', check=check)
        await option1.add_reaction('✔️')
        await ctx.send("Enter the second option")
        option2 = await self.bot.wait_for('message', check=check)
        await option2.add_reaction('✔️')
        await self.create_poll(channel, title, option1, option2)
        await ctx.send(f"Poll created in {channel.mention}")
        
    async def create_poll(self, channel: discord.TextChannel, title: str, option1, option2):
        embed = discord.Embed(title=title,
         description=f"1️⃣ {option1}\n2️⃣ {option2}",
          color=0xff6f00)
        msg = await channel.send(embed=embed)
        await msg.add_reaction('1️⃣')
        await msg.add_reaction('2️⃣')
stiff knot
#

Does anyone know how to make a channel within a category

#

When I do it, it just makes the channel and category separate

pale turtle
unkempt canyonBOT
#

await create_text_channel(name, *, overwrites=None, category=None, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.TextChannel "discord.TextChannel") for the guild.

Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.

The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/stable/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
agile goblet
#

print the channel variable

dense walrus
#

k

vagrant brook
#

Oh i see why now

dense walrus
#

show me!

vagrant brook
#

Your title is a Message object

#

Should be title.content

dense walrus
#

oh so title.content

#

oh wow

#

lemme see

stiff knot
dense walrus
#

actually all of them are message objects

#

so use .content for every one of them

slate swan
#

anyone here wanna make a bot with me? im rewriting my whole bot since its just a mess that needs rewriting

agile goblet
#

hm idk why it didnt throw an error when typehinting string

dense walrus
#

because the create_poll function aint a command ig

agile goblet
#

typehinting is regular python tho

dense walrus
#

yeah but it's just for the programmer

#

its not actually doing anything I think

agile goblet
#

it is lmao

vagrant brook
#

Smh using discord on iphone 5 is a pain

dense walrus
#

💀

#

yeah guys it's working now tysm

agile goblet
#

Lets say you have a method like this:
async def command(ctx, channel, integer)
With discord its very important to typehint since just doing that will make every argument except for ctx a string.
doing this:
async def command(ctx, channel: discord.TextChannel, integer: int)
Will make channel and integer, a textchannel and integer respectively

pliant gulch
#

But create_poll isn't a command

vagrant brook
#

Yes

pliant gulch
#

In regular python they do nothing other then add readability

grim oar
#

typehints to commands

pliant gulch
#

for commands

stark hearth
#
    @commands.command(aliases=["whois"])
    async def userinfo(self, ctx, member: discord.Member):

        roles = [role for role in member.roles][1:]

        embed = discord.Embed(
            description = f'**User Infomation - **{member.mention}',
            colour=member.color, 
            timestamp=ctx.message.created_at
            )

        embed.set_thumbnail(url = member.avatar_url)
        embed.set_footer(text=f'Requested by {ctx.author}', icon_url=ctx.author.avatar_url)

        embed.add_field(name='ID:', value=f'`{member.id}`')
        embed.add_field(name='Nickname:', value=member.display_name)

        embed.add_field(name='Created at:', value=member.created_at.strftime('%a, %#d %B %Y, %I:%M %p UTC'))
        embed.add_field(name='Joined at:', value=member.joined_at.strftime('%a, %#d %B %Y, %I:%M %p UTC'))

        embed.add_field(name=f'Roles ({len(roles)})', value=" ".join([role.mention for role in roles]))
        embed.add_field(name='Top Role:', value=member.top_role.mention)

        embed.add_field(name = 'Bot:', value = member.bot)

how would i make the member = ctx.author when you only do #whois

grim oar
#

You tried Andy, give up, you are bad helper

stark hearth
#

i tried so many forms and it does not work

pliant gulch
#

Nova you barely know how to typehint saddd

grim oar
#

:(

opaque trail
#

wtf does TypeVar mean hackerman

dapper cobalt
opaque trail
grim oar
#

^

dapper cobalt
agile goblet
stark hearth
#

let me try it

dapper cobalt
stark hearth
#

ty though

grim oar
dapper cobalt
#

No problem. a_thumbsup

pliant gulch
grim oar
#

Why you booli me

pliant gulch
#

Cause your PR for 0x42 had like 5 or 6 something type errors

#

I had to fix every one of them

grim oar
#

cuz I don't live life in hardcore mode

dapper cobalt
#

Novia, why are you scared of green color?

stiff knot
grim oar
slate swan
#

Can we just use ids in methods like Guild.ban/unban or is it required to make a discord.Object with the ID first?

novel rampart
#

how will i get nessage athour tag

dapper cobalt
novel rampart
pale turtle
grim oar
#

Ohh that, that's an opcode

dapper cobalt
unkempt canyonBOT
#

discriminator```
Equivalent to [`User.discriminator`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User.discriminator "discord.User.discriminator")
pliant gulch
slate swan
#

Means just doing ban(1234) won't work..

grim oar
pliant gulch
#

Yea, since the http method gets passed user.id rather then user

#

So you need an object with an ID at the very least

slate swan
#

Oh okay, Thanks

dapper cobalt
pliant gulch
grim oar
#

I'm not like steve or someone, you know

opaque trail
#

Yo?

pliant gulch
slate swan
grim oar
#

Probably, who knows

hasty iron
#

can you make discord on discord though

grim oar
#

Blanket can do it

hasty iron
#

no

pliant gulch
#

Blanket do it

hasty iron
#

wtf

#

why me

grim oar
#

Your smart

hasty iron
#

no

stark hearth
#

also why does this command do not work

    @commands.command(aliases=['guildinfo', 'guild'])
    async def serverinfo(self, ctx):
        
        em = discord.Embed(
            title=f'{ctx.guild.name}',
            colour = ctx.author.color
            )
        
        em.set_thumbnail(url=f'{ctx.guild.icon_url}')
        em.add_field(name='Owner', value=f'{ctx.guild.owner}')
        em.set_field(name='Region', value=f'`{ctx.guild.region}`')
        em.add_field(name='Member Count', value=f'{ctx.guild.member_count}')
        em.set_footer(icon_url=f'{ctx.guild.icon_url}', text=f'Guild ID: {ctx.guild.id}')

        await ctx.send(embed=em)
flint forum
#
@bot.command()
async def ifstate(ctx):
    optionembed = discord.Embed(title='Please choose an option', description="hug, high 5", color=c.purple())
    await ctx.send(embed=optionembed)

    available_options = ["hug"]

    available_options2 = ["high 5"]
    def check(msg):
        return msg.author == ctx.author and msg.content in available_options

    options = await bot.wait_for("message", check=check)
    hugembed = discord.Embed(title=f"You just got yourself a", description=f"{options.content}" + " little dude",
                                color=c.purple())
    hugembed.add_image(url='https://media.giphy.com/media/DjczAlIcyK1Co/giphy.gif')
    await ctx.send(embed=hugembed)

    def check(msg):
        return msg.author == ctx.author and msg.content in available_options2

    options = await bot.wait_for("message", check=check)
    high5embed = discord.Embed(title=f"Nice what a strong", description=f"{options.content}" + " dude",
                                color=c.purple())
    high5embed.add_image(url='https://giphy.com/clips/true-and-the-rainbow-kingdom-true-and-the-rainbow-kingdom-yetis-terrific-tales-TdFjwc7qDTUFEDX7i1')
    await ctx.send(embed=high5embed)
stark hearth
dapper cobalt
# hasty iron can you make discord on discord though

Make a friends system, make a dm command, make a servermsg command that sends a dm to all the users that joined a "server" on your own bot's database.

But keep in mind one thing - once you finish that bot, it's going to get banned immediately. a_thumbsup

flint forum
#

It won't work cuz it says add_image has no attribute to embed

dapper cobalt
unkempt canyonBOT
#

set_image(*, url)```
Sets the image for the embed content.

This function returns the class instance to allow for fluent-style chaining.

Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
hasty iron
flint forum
#

I've read that yesterday

stark hearth
#

wait

hasty iron
#

i dont see how it breaks any tos

flint forum
#

oh discord

stark hearth
#

nm im stupid

dapper cobalt
grim oar
#

Cli based discord 🧠

pliant gulch
#

Naw just make bot read messages and send content to API which displays everything on a website

dapper cobalt
dapper cobalt
flint forum
#
 raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: set_image() missing 1 required positional argument: 'self'
pliant gulch
grim oar
#

pixels_snek_2 wtf really

pliant gulch
#

Yea there is a few

#

I know on the AUR theres like a lot of discord TUI's

grim oar
#

O

pliant gulch
dapper cobalt
#

yay discord tui

flint forum
#
 raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: set_image() missing 1 required positional argument: 'self'
pliant gulch
#

yay is a AUR helper

grim oar
#

i use arch btw

pliant gulch
#

arch is my daily driver

hasty iron
#

🤢

pliant gulch
dapper cobalt
hasty iron
#

not the class itself

flint forum
#

hm?

dapper cobalt
#

Oh right that's the error.

dapper cobalt
grim oar
#

embed being an discord.Embed obj

dapper cobalt
grim oar
#

English is my -1th language btw

dapper cobalt
#

1th? That made me so mad. kekw

grim oar
#

Astonishing

hasty iron
#

nova is bad at both anime picks and english

grim oar
#

At least I don't pick miku 😩

#

pick on

hasty iron
#

the Optional actually does nothing, in discord.py if the argument is not given it gives it a value of None

flint forum
#

so define embed = discord.Embed

stiff knot
#
name = "Management"
name1 = "Logs"

await ctx.guild.create_category_channel(name, overwrites=None, reason=None, position=None)

await ctx.guild.create_text_channel(name1, overwrites=None, reason=None, position=None)``` Does anyone know how to join these 2
#

The category and channel are created separately

grim oar
hasty iron
#

typehinting doesn't matter, it doesn't change how a function behaves

stiff knot
#

I wanna put the channel under the category

hasty iron
#

its only there for linters and doc purposes

pliant gulch
hasty iron
#

no

grim oar
#

Exactly

#

Listen to me

pliant gulch
#
category = create category channel here
await category.create_text_channel(. . .)
hasty iron
#

dont listen to nova

grim oar
#

Static typing is future

flint forum
#

oh my f'ing god

hasty iron
#

nova just writes bad code

grim oar
#

and it works

hasty iron
#

anyways listen to whatever you like

pliant gulch
pliant gulch
hasty iron
#

if you like linters and colors then typehint

grim oar
pliant gulch
#

if you want more readability typehint as well

#

Yes

hasty iron
#

it can also tell users which argument type to pass in

grim oar
#

typehint makes readability worse

#

if it's too complicated

flint forum
#
@bot.command()
async def ifstate(ctx):
    optionembed = discord.Embed(title='Please choose an option', description="hug, high 5", color=c.purple())
    await ctx.send(embed=optionembed)

    available_options = ["hug"]

    available_options2 = ["high 5"]

    embed = discord.embed
    def check(msg):
        return msg.author == ctx.author and msg.content in available_options

    options = await bot.wait_for("message", check=check)
    hugembed = discord.Embed(title=f"You just got yourself a", description=f"{options.content}" + " little dude",
                                color=c.purple())
    embed = discord.Embed 
    embed.set_image(url='https://media.giphy.com/media/DjczAlIcyK1Co/giphy.gif')
    await ctx.send(embed=hugembed)

    def check(msg):
        return msg.author == ctx.author and msg.content in available_options2

    options = await bot.wait_for("message", check=check)
    high5embed = discord.Embed(title=f"Nice what a strong", description=f"{options.content}" + " dude",
                                color=c.purple())
    embed = discord.Embed
    embed.set_image(url="https://giphy.com/clips/true-and-the-rainbow-kingdom-true-and-the-rainbow-kingdom-yetis-terrific-tales-TdFjwc7qDTUFEDX7i1")
#

Helpppppp

pliant gulch
#

Oh yes esp decorator typehints

#

ohhh my gooddd those are the worst

grim oar
#

am telling you, stop torturing yourself

hasty iron
#

i just create aliases for stuff like Callable[..., Coroutine[Any, Any, Any]]

crude crater
#

when i do "import DiscordEconomy" it says no module named discord

grim oar
#

😩

flint forum
#

Errorrr