#discord-bots

1 messages · Page 786 of 1

brisk brook
#

for time don't specify it as a float

tardy plume
#

how can i store channel id to my variable?

light violet
#

ok lemme try

frank tartan
#
  1. ok
  2. well even if its in the same folder as main.py, I do what the docs say, and it doesnt work
brisk brook
#

Can someone tell me why the beg command won't work?

light violet
#

how to remove timeout

tardy plume
#

atm i have this

async def setup(ctx, *, channelID=int()):

i need to get user messsage channel id value and put it to my variable

boreal ravine
#

JSON. Why?

frank tartan
#
  1. i honestly forget... i tried it like 2 hours ago... 2) i kinda deleted it after it didnt work...
brisk brook
tardy plume
#

then use that variable to my get_channel(here)

boreal ravine
brisk brook
#

and I'm a beginner programmer

#

why won't it work tho

boreal ravine
brisk brook
#

It temporarily changes the wallet's amount

boreal ravine
brisk brook
#

i don't know why

frank tartan
brisk brook
#

is it because of the function?

boreal ravine
#

You didn't save the data in the update_wallet method

brisk brook
#

should I remove it in the command itself or in the method?

boreal ravine
#

try saving it by dumping users into the json file

boreal ravine
brisk brook
brisk brook
boreal ravine
#

whats wrong now

brisk brook
#

the amount won't update

boreal ravine
frank tartan
#

how do i upload an emoji that is in a different folder? (like a folder in the same folder main.py is in)

brisk brook
#

it looks like my code has more issues

green bluff
#

how do i get the amount of ppl in my server

maiden fable
unkempt canyonBOT
#

property member_count: int```
Returns the true member count regardless of it being loaded fully or not.

Warning

Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified.
green bluff
#

oh okay

frank tartan
boreal ravine
#

show code/whats wrong

boreal ravine
#

that symbolizes that everything after that is a kwarg

boreal ravine
brisk brook
#
class eco(commands.Cog):
    def __init__(self,bot):
        self.bot = bot

    async def open_data(self):
        with open("economy.json","r") as f:
            users = json.load(f)
        return users

    async def close_data(self, users):
        with open("economy.json","w") as f:
            json.dump(users,f)

    async def update_wallet(self,ctx,member,op,am):
        users = await self.open_data()
        if op == "-":
            users[str(ctx.guild.id)][str(member.id)]["wallet"] -= am
        elif op ==  "+":
            users[str(ctx.guild.id)][str(member.id)]["wallet"] += am
        return users[str(ctx.guild.id)][str(member.id)]["wallet"]

    @commands.command()
    async def beg(self, ctx):
        user = ctx.author
        await self.open_account(ctx,user)
        users = await self.open_data()
        num = random.randrange(0,101)
        quote = [f"A stranger gives you {self.num(num)}.", f"A mysteriously man knows that you have money, but he still gives you {self.num(num)}", f"I'm poor, but I still give you {self.num(num)}", f"Stop being a beggar!! {self.num(num)}"]
        await ctx.send(random.choice(quote))
        await self.update_wallet(ctx,user,"+",num)
        await self.close_data(users)
#

@boreal ravine

#

what's wrong with the code

boreal ravine
#

try inserting the new data into your json file

frank tartan
thorn leaf
#

What library should I replace discord.py with that has similar syntax?

brisk brook
boreal ravine
thorn leaf
boreal ravine
thorn leaf
slate swan
#

!pypi disnake

unkempt canyonBOT
thorn leaf
slate swan
#

biased

boreal ravine
boreal ravine
thorn leaf
#

What do you mean?

frank tartan
boreal ravine
thorn leaf
#

Not being updated anymore and it's having a stroke or something

boreal ravine
thorn leaf
#

My one bot keeps loading twice

#

Other one doesn't and they load cogs the same

#

Nothing has changed recently

boreal ravine
thorn leaf
#

It isn't

#

I'm running it, and it's running two instances in one

#

Everything that prints in on_ready runs once, then anything after that runs twice

boreal ravine
thorn leaf
#

Don't think it'll matter

#

I've run exit three plus times, and it went offline every time

slate swan
#

It will

boreal ravine
#

why wouldn't it

thorn leaf
#

And it hasn't changed anything, every time it starts it does the same thing

slate swan
#

do not ask for help if you think you're smarter ¯\_(ツ)_/¯

frank tartan
frank tartan
#

emojis

slate swan
frank tartan
thorn leaf
frank tartan
boreal ravine
thorn leaf
#

I don't, I checked that and restarted my computer which both did nothing

slate swan
boreal ravine
slate swan
frank tartan
#

i added an "a" to it cuz there are other things in the file

slate swan
#

Damn, show all of it

boreal ravine
thorn leaf
#

It's doubling everything

boreal ravine
slate swan
#

Woah

frank tartan
thorn leaf
#

The only thing that isn't doubled is the things in on_ready

slate swan
slate swan
frank tartan
# slate swan ;-; okay then, help yourself

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte
i just got this error... wtf does it mean?

thorn leaf
boreal ravine
frank tartan
#
with open("emojis/check_mark", "r") as file:
      file = file.read()
await create_custom_emoji(name="check_mark",image=file)
thorn leaf
#

omg

slate swan
thorn leaf
frank tartan
maiden fable
#

@thorn leaf do u have an on_message event?

thorn leaf
#

Yes

maiden fable
#

Mind showing it?

thorn leaf
#

Ah shit

#

That's it

maiden fable
#

There you go (:

frank tartan
thorn leaf
#

process commands

maiden fable
#

Yes

#

(:

#

Was an easy one

slate swan
frank tartan
slate swan
#

You can actually make a better system to check if the author exists in the D.A.T.A.B.A.S.E. or not

maiden fable
#
with open("image", "rb") as image:
   . . . 
slate swan
#

Create*

maiden fable
#

Rip

#

!d discord.Guild.create_custom_emoji

unkempt canyonBOT
#

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

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

There is currently a limit of 50 static and animated emojis respectively per guild, unless the guild has the `MORE_EMOJI` feature which extends the limit to 200.

You must have the [`manage_emojis`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_emojis "discord.Permissions.manage_emojis") permission to do this.
frank tartan
slate swan
#

;-;

maiden fable
#

Never told u to refer to it

frank tartan
# slate swan ;-;

i changed the directory, "r") as file that you gave me to directory, "rb") as file, and now I get a new error.

'create_custom_emoji' is not defined
yet I import here
import asyncio

frank tartan
maiden fable
#

It's fine

frank tartan
maiden fable
#

With?

frank tartan
#

i changed the directory, "r") as file that you gave me to directory, "rb") as file, and now I get a new error.

'create_custom_emoji' is not defined
yet I import here
import asyncio

maiden fable
#

guild.create_custom_emoji

frank tartan
maiden fable
#

ctx.guild

frank tartan
maiden fable
#

Cool

hot echo
#

.

frank tartan
slate swan
#

!d discord.Guild.emojis is a thing?

unkempt canyonBOT
slate swan
#

Use the len() function on the returned list

frank tartan
frank tartan
slate swan
frank tartan
#

emojiNum = len(discord.Guild.emojis)

#

ive used len before

slate swan
#

Use an instance of the Guild class

#

Not the class itself

maiden fable
slate swan
#

Lol

frank tartan
ebon island
#

What is the Syntax for having Discord play an MP3 in a voice Channel? Additionally, if Discord is already playing a sound, can you tell it to play another sound and it will layer the two or can only one audio file be played at a given moment?

primal salmon
#

yo

#

what if I use this for something?

#

if_________________
else if________________
else________?

#

I forgot if else if even exist lmao

ebon island
#

The else if case in python is just elif

primal salmon
#

but does that mean if the first one is right then it will go to the elif?

#

and if the else if is right it will go to else?

#

yert or u cant use 3 of those at 1 commands hahaha

ebon island
#

No, it will try the if first and then go sequentially down each elif and if none return true it will then hit the else block

primal salmon
#

ah

ebon island
#

It will only do one of the contained conditionals

primal salmon
#

hmm

unkempt canyonBOT
#

play(source, *, after=None)```
Plays an [`AudioSource`](https://discordpy.readthedocs.io/en/master/api.html#discord.AudioSource "discord.AudioSource").

The finalizer, `after` is called after the source has been exhausted or an error occurred.

If an error happens while the audio player is running, the exception is caught and the audio player is then stopped. If no after callback is passed, any caught exception will be displayed as if it were raised.
ebon island
#

So if it hits the if block it will only hit the if statement, if it hits an elif statement it will only hit the elif, and finally if none of the conditions above are not it will hit the else

primal salmon
#

lemme test it out

ebon island
#

Excellent! I appreciate that Hunter!

#

What formats does it except for the source?

maiden fable
#

Always welcome

maiden fable
unkempt canyonBOT
#

class discord.AudioSource```
Represents an audio stream.

The audio stream can be Opus encoded or not, however if the audio stream is not Opus encoded then the audio format must be 16-bit 48KHz stereo PCM.

Warning

The audio source reads are done in a separate thread.
maiden fable
#

Actually there are a few formats it supports. They all are given in the docs of the discord module (not discord.ext but discord)

untold token
#

Most of it used ffmpeg

#

PCMVolumeTransformer

ebon island
#

Excellent. The main thing I see is the Opus encoding, so I will look into converting the audio files we need into Opus encoded files

primal salmon
#

how do I make if the error like MissingRequiredArgument on a commands?

#

im trying to make it for each commands

#

I can do it for all commands but im trying to figure out how to make it saperately

ebon island
#

type hint it

primal salmon
#

hu

vale wing
primal salmon
vale wing
#

Yeah

primal salmon
#

thats what I already did

#

sadly im finding a way how to make it custom for each commands

vale wing
#

Oh

#

!d isinstance

unkempt canyonBOT
#

isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") exception is raised.

Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
primal salmon
#

lemme show ya the code

#
@client.event    
async def on_command_error(ctx, error):
    if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send(embed=discord.Embed(title='Missing Argument', description='Please include all the requirement!'))
    if isinstance(error, commands.MissingPermissions):
        await ctx.send(embed=discord.Embed(title='Missing permission', description='You do not have permissions to do this!'))

this one is global (all type of commands)

vale wing
#

So basically its usage would be like

response = None
if isinstance(error, commands.CommandNotFound):
    response = 'This command doesn't exist'
elif isinstance(error, commands.MissingRequiredArgument):
    response = 'This command is missing a required argument'
if response:
    await ctx.send(response)```
#

@primal salmon I don't get what are you trying to make

#

Also elif is a thing

untold token
#

This will eat up all the error that you are not handling

vale wing
#

Perhaps you meant local error handler?

untold token
#

You need to either log / raise the error that is raised

vale wing
#

!d discord.ext.commands.Command.error

unkempt canyonBOT
#

@error```
A decorator that registers a coroutine as a local error handler.

A local error handler is an [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event limited to a single command. However, the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") is still invoked afterwards as the catch-all.
vale wing
#

@primal salmon this is what you need most likely

primal salmon
untold token
#

Here, this is a good example on how to make a proper error handler

rancid stump
#

willl selenium works with chromium ?

echo wasp
#

How do i get an invite to this channel

knotty mason
#

hi

#

could anyone tell me what is wrong with this code

#
if message.content.startswith('>channels'):
      await message.channel.send('text or voice?')
      @client.event
      async def on_message(message):
        if message.content == 'text':
          for i in current_guild.text_channels:
            await message.channel.send(i)
          return
        else:
          await message.channel.send('invalid response')
          return ```
slate swan
slate swan
echo wasp
slate swan
#

¯_(ツ)_/¯

echo wasp
#

@silk lynx this is the channel

knotty mason
#

apologies, let me send the entire code

silk lynx
knotty mason
# slate swan but but....... how are you getting the message object outside the on_message
@client.event
async def on_message(message):

  current_guild = message.author.guild 

  if message.author == client.user:
    return
  else:
    if 'ssf' in message.content:
      await message.add_reaction('🌸')
      await message.channel.send('SSF IS COOL')
      time.sleep(5)
      await message.channel.send('but san is not . -.')

    if message.content.startswith('>channels'):
      await message.channel.send('text or voice?')
      @client.event
      async def on_message(message):
        if message.content == 'text':
          for i in current_guild.text_channels:
            await message.channel.send(i)
          return
        else:
          await message.channel.send('invalid response')
          return ```
#

the bot is spamming invalid response

winter geyser
#

why do you have an event inside an event

#

i think you want wait_for

slate swan
winter geyser
#

yep

spring flax
#

There isn't a method more reliable than on_bulk_delete to get the list of messages that were purged upon a channel.purge right?

spring flax
# slate swan dont think so

and the on_bulk_delete would probably be better than the on_raw_bulk_delete something right for that purpose

slate swan
#

it wont depend on the messages in cache

knotty mason
#

with text/voice

spring flax
#

that is very very inefficient

#

!d discord.ext.commands.Bot.wait_for Use this. @knotty mason

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/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
velvet tinsel
slate swan
velvet tinsel
#

I had sleep paralysis yesterday

#

Well

#

I met sleep paralysis demons yesterday

slate swan
velvet tinsel
slate swan
#

lol

slate swan
#

I'm gonna go make my cursed bot

velvet tinsel
#

Anyone need help

slate swan
velvet tinsel
#

With

slate swan
#

wait

velvet tinsel
#

wait_for?

slate swan
velvet tinsel
#

well

#

why are you trying your best to hide it

slate swan
velvet tinsel
#

you don’t really need to hide it in your code

#

Unless you’re providing code

#

but if you need help with wait

spring flax
#

If I wanted to make an eval command, although not using snekbox, for reasons, anyone mind giving references please?

velvet tinsel
#

!d discord.ext.commands.Bot.wait_for /j

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/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
velvet tinsel
#

Just do bot.run(TOKEN)

slate swan
boreal ravine
slate swan
#

pithink Cool functions, right?

boreal ravine
#

useless*

#

I'm pretty sure returning Context, would return the class since you can only get context from messages/commands

velvet tinsel
#

the fuck

spring flax
velvet tinsel
#

what

slate swan
boreal ravine
velvet tinsel
#

lol engineer man

slate swan
boreal ravine
velvet tinsel
#

Piston bot wtf

boreal ravine
#

it runs code using an API

velvet tinsel
#

Kayle are you ok

slate swan
#

minecraft?

boreal ravine
boreal ravine
boreal ravine
spring flax
spring flax
boreal ravine
spring flax
boreal ravine
#

well like I said earlier, you can

  1. use the exec (built-in function)
  2. use an api
  3. use snekbox
spring flax
boreal ravine
spring flax
#

Also I'm not that worried about others using my eval, it's a private bot

humble shore
#

hi, i've got a problem with my code, they say that the "()" is not closed, someone know how to fix it ? thanks

humble shore
river flare
#

hello. I have this command with a sql and get this error ```python
mycursor.execute(f"SELECT gen FROM customers WHERE name = {user.name}")
myresult = mycursor.fetchall()
for x in myresult:
print(x)
emb=nextcord.Embed(title="Ainta Gen", description=f"{acc}, left: {x}", color=color, timestamp=datetime.now())
await channel.send(embed=emb)

Command raised an exception: ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''J1mk0lakos' at line 1

primal salmon
#

your commands literally said dice there ;-;

primal salmon
river flare
#

wdym?

primal salmon
#

whats that commands do

river flare
#

it gives a random string from a txt file

primal salmon
#

tbh idk bout that type of stuff

boreal ravine
# spring flax do you know any APi's?

yeah, these are the one that I use/know of. There are probably more though

https://github.com/engineer-man/piston 
https://emkc.org/api/v1/piston/execute
river flare
#

Hey, i have this, but instead of printing 5, it prints ('5',) ```python
for x in myresult:
print(x)

quick gust
#

probably because its a tuple

visual island
#

fetchall returns list of tuples

stable igloo
#

Hi, I'am a complete beginner, and I would like help with cooldown.
Here is my problem:

@client.command
async def command1(ctx, arg):
   if arg == "arg1":
      await ctx.send("hello1")
      # add a cooldown of 60 seconds here
   if arg == "arg2":
      await ctx.send("hello2")
      #add a second cooldown of 60 seconds here
   if arg == "arg3":
      await ctx.send("hello3")
      # add a third cooldown of v60 seconds here

I would like to have a cooldown so that I can do '!command1 arg1' every minutes, but during this minute, I can still do '!command1 arg2'
can someone help me

river flare
river flare
#

yes

cedar stream
#

result = x[0] - 1

cedar stream
stable igloo
#

Ok thanks, I will try

cedar stream
#

No wait it must be current_time >= last_used + 1min

#

@stable igloo

stable igloo
#

ok

river flare
# cedar stream result = x[0] - 1

okay it works. I made it also update it in my sql. But if i run the command twice without closing the program, it gives this result: Command raised an exception: InternalError: Unread result found raise errors.InternalError("Unread result found") mysql.connector.errors.InternalError: Unread result found

river flare
#

everytime someone uses the command, it will remove 1 from x (which is 5) till it reaches 0

brave ravine
#

i cant figure out how to add my bot to my server for testing

#

discord changed their dev portal since last time i used it and i cant seem to find a link to copy into my browser to add it

brave ravine
#

ohh thank you

#

im so tired i didnt even realize it was a drop down menu 💀

river flare
#

haha its fine

velvet tinsel
slate swan
#

Hello I need help

#

I wanna make a bot command that edits a message and it does loading…

#

And the dots edit

clever pivot
#

how to use on_message event to like:
on_ready, it posts hi on a specific channel. then everytime a message is sent into that channel, it deletes the hi message and resend it to be the latest message on the channel (how to do this)

clever pivot
# slate swan And the dots edit
s = await ctx.send('hello!')
s
await s.edit(content='loading.....')
await asyncio.sleep(3)
await s.edit(content='done!')```
slate swan
#

Ok I’ll try that

tidal hawk
#

Does discord have guild invites rate limiter? (return's all active invites in current guild)

maiden fable
#

Every API/ws call has a rate limit

clever pivot
#

how to use on_message event to like:
on_ready, it posts hi on a specific channel. then everytime a message is sent into that channel, it deletes the hi message and resend it to be the latest message on the channel (how to do this)

tidal hawk
maiden fable
#

Well, there are buckets. It works like send message and edit message have the same bucket. So if u do it, it will be counted in one group. fetching invites is another bucket and so on

maiden fable
tidal hawk
#

Hmm, but can you bypass it by using some sort of proxy?

maiden fable
#

No

oblique cobalt
tidal hawk
#

Tried to create invite tracker system, and in order to get all active invites i need to use guild.invites(), but after some time it returns nothing

oblique cobalt
maiden fable
#

Instead

#

!d discord.on_invite_create

unkempt canyonBOT
#

discord.on_invite_create(invite)```
Called when an [`Invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite "discord.Invite") is created. You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to receive this.

New in version 1.3.

Note

There is a rare possibility that the [`Invite.guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite.guild "discord.Invite.guild") and [`Invite.channel`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite.channel "discord.Invite.channel") attributes will be of [`Object`](https://discordpy.readthedocs.io/en/master/api.html#discord.Object "discord.Object") rather than the respective models.

This requires [`Intents.invites`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.invites "discord.Intents.invites") to be enabled.
tidal hawk
#

Nope, had like 100 invites and suddenly 0

maiden fable
#

!d discord.on_invite_delete

unkempt canyonBOT
#

discord.on_invite_delete(invite)```
Called when an [`Invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite "discord.Invite") is deleted. You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to receive this.

New in version 1.3.

Note

There is a rare possibility that the [`Invite.guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite.guild "discord.Invite.guild") and [`Invite.channel`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite.channel "discord.Invite.channel") attributes will be of [`Object`](https://discordpy.readthedocs.io/en/master/api.html#discord.Object "discord.Object") rather than the respective models.

Outside of those two attributes, the only other attribute guaranteed to be filled by the Discord gateway for this event is [`Invite.code`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite.code "discord.Invite.code").

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

Use these (:

tidal hawk
#

Uuu

oblique cobalt
tidal hawk
#

These are good

clever pivot
#

how to use on_message event to like:
on_ready, it posts hi on a specific channel. then everytime a message is sent into that channel, it deletes the hi message and resend it to be the latest message on the channel (how to do this)
does anyone know

oblique cobalt
# clever pivot how to use on_message event to like: on_ready, it posts hi on a specific channel...

Don't change_presence (or make API calls) in on_ready within your Bot or Client.
Discord has a high chance to completely disconnect you during the READY or GUILD_CREATE events (1006 close code) and there is nothing you can do to prevent it.

Instead set the activity and status kwargs in the constructor of these Classes.

bot = commands.Bot(command_prefix="!", activity=..., status=...)

As noted in the docs, on_ready is also triggered multiple times, not just once.

Basically: don't 👏 do 👏 shit 👏 in 👏 on_ready.

oblique cobalt
clever pivot
#

im so dumb that i dont know how to make it send stuff in specific channel

slate swan
#

How do I send message content from command

#

So that I don’t include command and prefix

oblique cobalt
clever pivot
#

get_role get_channel get_member all the same?

#

get_user too?

oblique cobalt
#

i dont know about get_role*, but other than that yes. (note that get_member is only usable if u have guild object)

clever pivot
#

someone explained to me a long time ago

oblique cobalt
#

then ur all fine 👍

clever pivot
#

i havent tried get_user

oblique cobalt
#

just dont do shit in on_ready

clever pivot
#
async def on_message(message):
    c = bot.get_channel(ID HERE)
    s = await c.send('hello')
    s
    else:
        await s.delete()
        s```
oblique cobalt
#

you dont await bot.get_channel

#

get_xxxx gets stuff from cache

clever pivot
#

i forgot

#

ok so this works?

oblique cobalt
#

dont do this everytime user sends message, other than that, it works ye

#

except where is if statement ?

slate swan
#

Hello i want to send message content for example = !hello say car
And bot sends say car

#

Would that be message.content?

clever pivot
slate swan
cold sonnet
oblique cobalt
slate swan
#

So message.object?

oblique cobalt
oblique cobalt
cold sonnet
slate swan
#

I’m dumb sorry

clever pivot
oblique cobalt
# slate swan I’m dumb sorry

you have message, use message.content
but again, use commands

let me give you example

@bot.command()
async def hi(context):
 await context.send("hi")

do (prefix)hi and bot will say "hi"

slate swan
#

Yes

#

Thx

cold sonnet
#

you can pass in a parameter after context

oblique cobalt
#

^

cold sonnet
#

which would save everything that's after the command

oblique cobalt
cold sonnet
#

and send that

clever pivot
oblique cobalt
#

ok bro dont murder me!111

oblique cobalt
#

(discord.js moment)

clever pivot
slate swan
oblique cobalt
cold sonnet
#

ay stop

maiden fable
#

Whenever I come here, why is there always RPing happening?

oblique cobalt
clever pivot
maiden fable
#

!ot

unkempt canyonBOT
slate swan
#

@oblique cobalt ty

oblique cobalt
#

np

oblique cobalt
#

you can add *, text after context and you can use await context.send(text) to do that easily

slate swan
#

Ok

slate swan
oblique cobalt
#

oh then do on_message

slate swan
#

Ok

slate swan
oblique cobalt
#

no bruh

slate swan
#

Ok

oblique cobalt
#

that is for command, and always will be (prefix)(function name) arguments..

slate swan
#

O yes I forgot that mb

clever pivot
# oblique cobalt yeah, just dont do it everytime user says :kek:
async def on_message(message):
    c = bot.get_channel(936850185462644739)
    s = await c.send('hello')
    if message.author == bot.user:
        return
    if message.content == 'yes':
        await s.delete()
        s
        return
    else:
        await s.delete()
        s
        return```
the bot keeps spamming hello how fix
oblique cobalt
#

because u made it send it everytime user sends message

slate swan
#

LOL

oblique cobalt
#

i told u to dont do it in on_message :kek:

slate swan
#

I mean it’s good for nuking

clever pivot
#

yeah so i sent "s" and the bot legit spammed hello forever

oblique cobalt
#

because

slate swan
clever pivot
slate swan
#

I’m joking

oblique cobalt
#

you send message
bot sends it
bot gets on_message dispatched
because there is no proper check to not respond to bots, bot responds to itself over and over

oblique cobalt
#

bro

#

i know what your code does

clever pivot
#

i typed if message.author == bot.user return

oblique cobalt
#

idk that isn't how u do it

clever pivot
#

how then

oblique cobalt
#

ClientUser and Member is different thing

oblique cobalt
visual island
clever pivot
#

u mean this? ^^^

oblique cobalt
oblique cobalt
visual island
#

Member and ClientUser are subclass of User

oblique cobalt
#

do that instead

clever pivot
#

trying

oblique cobalt
clever pivot
oblique cobalt
#

did u restart bot first ?

clever pivot
#

yeah im smart

oblique cobalt
#

seems like not

unkempt canyonBOT
#

discord/user.py lines 99 to 100

def __eq__(self, other: Any) -> bool:
    return isinstance(other, _UserTag) and other.id == self.id```
visual island
#

they compared it with id

oblique cobalt
#

@clever pivot please use commands for that instead lmao

clever pivot
clever pivot
oblique cobalt
#

but why u wanna do that

clever pivot
#

its for something u dont know

#

but im trying to do it

oblique cobalt
#

move that if statement at top

#

(one that checks if user is bot)

clever pivot
#

ok

#

now it sends 1 message and instantly deletes its own message back :/

clever pivot
#

?

#
async def on_message(message):
    if message.author.id == 777052626449596437:
        return
    c = bot.get_channel(936850185462644739)
    s = await c.send('hello')
    if message.content == 'yes':
        await s.delete()
        await c.send('hello')
        
    else:
        await s.delete()
        await c.send('hello')``` this code kind of worked
oblique cobalt
#

it works

#

its just, you dont do if statements correctly

clever pivot
#

but the thing is it sent one mesage, deleted that own message, resent the message, and it didnt delete the last message before the human's message

#

for example |
me: sls
bot: hello
me: slsls
bot: hello

#

it didnt delete the first message it sent

oblique cobalt
#

this is supposed to delete it's own message everytime it sends

clever pivot
#

how do i make the first message delete and resend another everytime it detects a message in the channel except for its OWN message

oblique cobalt
#

use bot variables for that, im too lazy to explain

#

brb gonna copy paste

#

Need to keep track of a variable between functions? No problem!

⚠️ Careful what you name it though, else you might overwrite something ⚠️

Just add it to your commands.Bot or discord.Client instance like so:

bot = commands.Bot(...)
bot.my_variable = 0

async def foo():
    bot.my_variable += 1

# In a cog
@commands.command()
async def counter(self,ctx):
    await ctx.send("Current Counter is at {}".format(ctx.bot.my_variable))

This also allows you to access this from other cogs/extensions/functions. Anywhere you have access to the bot instance

quick gust
#

!bot-var btw

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

oblique cobalt
quick gust
#

no worries

dense oasis
#

hi

clever pivot
dense oasis
#

how do i make a time stamp in 24 hour clock?

clever pivot
dense oasis
clever pivot
#

how!!

dense oasis
#

...

#

ping?

#

kk wait

slate swan
#

!discord webhooks

cold sonnet
slate swan
cold sonnet
#

huh

slate swan
#

ctx.author returns both discrim and name

dense oasis
slate swan
#

I got command that you do .Tt user

And then I want it to send back user

cold sonnet
#

so a member object converted to a str is the name?

#

and that description doesn't need an f-string

keen talon
slate swan
#

lol

#
from discord.ext import commands
import os
import time
from discord_webhook import DiscordWebhook, DiscordEmbed
from keep_alive import keep_alive
keep_alive()

bot = commands.Bot(command_prefix= "!")

@bot.event
async def on_connect():
  print('online')

@bot.command(name="tt")
async def tt(ctx):
   await ctx.message.delete()
   message = await ctx.send("**loading.**")
   time.sleep(0.3)
   await message.edit(content="**loading..**")
   time.sleep(0.3)
   await message.edit(content="**loading...**")
   time.sleep(0.3)
   await message.edit(content="**loading.**")
   time.sleep(0.3)
   await message.edit(content="**loading..**")
   time.sleep(0.3)
   await message.edit(content="**loading...**")
   time.sleep(0.3)
   await message.edit(content="**loading.**")
   time.sleep(0.3)
   await message.edit(content="**alexlol**")
   time.sleep(0.5)
   os.system("python3 web.py")
   await message.edit(content=f"**webhook request sent!!**");









bot.run(os.getenv('TOKEN'))```
#

I want it to take the word after .tt and turn it into variable

slate swan
maiden fable
#

don't

keen talon
maiden fable
#

it will block the whole bot

#

!blocking will tell u more about it

slate swan
#

Wdym

unkempt canyonBOT
#

Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.

What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:

import discord

# Bunch of bot code

async def ping(ctx):
    await ctx.send("Pong!")

What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.

async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!

slate swan
#

Fine

keen talon
#

Pymongo is async right ?

maiden fable
#

no

#

motor is, but it is made by combining pymongo and asyncio, so ig just use run_in_executor

slate swan
#

Whats the attribute for server regions? i tried using ctx.guild.region, but that returns deprecated.

cold sonnet
#

!d discord.Guild.region

unkempt canyonBOT
#

The region the guild belongs on. There is a chance that the region will be a str if the value is not recognised by the enumerator.

maiden fable
unkempt canyonBOT
#
Nah.

No documentation found for the requested symbol.

maiden fable
#

Tf

#

!d discord.Guild.region

#

Wait

slate swan
#

yeah

maiden fable
#

!d discord.VoiceChannel.rtc_region this?

unkempt canyonBOT
#

The region for the voice channel’s voice communication. A value of None indicates automatic voice region detection.

New in version 1.7.

slate swan
#

thanks

maiden fable
#

Since each VC can now have separate regions

slate swan
#

thank you

cold sonnet
#

check it actually for the guild

#

!e

boolean = True
if boolean:
    print("yes")
unkempt canyonBOT
#

@cold sonnet :white_check_mark: Your eval job has completed with return code 0.

yes
cold sonnet
#

iterate through the roles

#

and check for each of them if they are in ctx.guild.roles

#

no

#

if any of the roles in ctx.guild.roles has that name

slate swan
#

See user isn’t defined even tho I did !tt alexlol

cold sonnet
#
for role in ctx.guild.roles:
    if role.name in list:
river flare
#

yo. I have this command, but when i use it 2 times i get this error ```python
mycursor.execute(f"SELECT gen FROM customers WHERE name = '{user.name}'")
myresult = mycursor.fetchall()
for x in myresult:
print(x[0])
result = int(x[0]) - 1
print(result)
sql = f"UPDATE customers SET gen = '{result}' WHERE name = '{user.name}'"
mycursor.execute(sql)
mydb.commit()
mycursor.execute(f"SELECT gen FROM customers WHERE name = '{user.name}'")
emb=nextcord.Embed(title="Ainta Gen", description=f"Your account is: {acc}\n**Gens left:** {result}", color=color, timestamp=datetime.now())
await channel.send(embed=emb)

File "C:\Users\Δημήτρης Κολιόπουλος\Desktop\ainta\main.py", line 158, in gen
cursor = mydb.cursor()
File "D:\coding_things\pythonV2\lib\site-packages\mysql\connector\connection_cext.py", line 569, in cursor
self.handle_unread_result(prepared)
File "D:\coding_things\pythonV2\lib\site-packages\mysql\connector\connection_cext.py", line 785, in handle_unread_result
raise errors.InternalError("Unread result found")
mysql.connector.errors.InternalError: Unread result found

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "D:\coding_things\pythonV2\lib\site-packages\nextcord\ext\commands\bot.py", line 1055, in invoke
await ctx.command.invoke(ctx)
File "D:\coding_things\pythonV2\lib\site-packages\nextcord\ext\commands\core.py", line 933, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "D:\coding_things\pythonV2\lib\site-packages\nextcord\ext\commands\core.py", line 177, in wrapped
raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: InternalError: Unread result found

cold sonnet
cold sonnet
#

no

#

this is the exact same thing as before

nimble plume
#

help i want to put user avatar in a f string

#

embed mainly

potent spear
clever pivot
#

how to make a bot send "hi" in a channel, then if someone sends a message in that channel the bot deletes its hi message and resends it to make it the newest message in the channel, how do that everytime someone sends message in channel?

river flare
#

yo. I have this command, but when i use it 2 times i get this error ```python
mycursor.execute(f"SELECT gen FROM customers WHERE name = '{user.name}'")
myresult = mycursor.fetchall()
for x in myresult:
print(x[0])
result = int(x[0]) - 1
print(result)
sql = f"UPDATE customers SET gen = '{result}' WHERE name = '{user.name}'"
mycursor.execute(sql)
mydb.commit()
mycursor.execute(f"SELECT gen FROM customers WHERE name = '{user.name}'")
emb=nextcord.Embed(title="Ainta Gen", description=f"Your account is: {acc}\n**Gens left:** {result}", color=color, timestamp=datetime.now())
await channel.send(embed=emb)

File "C:\Users\Δημήτρης Κολιόπουλος\Desktop\ainta\main.py", line 158, in gen
cursor = mydb.cursor()
File "D:\coding_things\pythonV2\lib\site-packages\mysql\connector\connection_cext.py", line 569, in cursor
self.handle_unread_result(prepared)
File "D:\coding_things\pythonV2\lib\site-packages\mysql\connector\connection_cext.py", line 785, in handle_unread_result
raise errors.InternalError("Unread result found")
mysql.connector.errors.InternalError: Unread result found

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "D:\coding_things\pythonV2\lib\site-packages\nextcord\ext\commands\bot.py", line 1055, in invoke
await ctx.command.invoke(ctx)
File "D:\coding_things\pythonV2\lib\site-packages\nextcord\ext\commands\core.py", line 933, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "D:\coding_things\pythonV2\lib\site-packages\nextcord\ext\commands\core.py", line 177, in wrapped
raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: InternalError: Unread result found

uncut comet
#

Hey does anyone have any good working code for a invite tracker? I coded one but it's buggy and doesn't always work so would be nice to refer to someone else's code

maiden fable
thorny tangle
#

How do use python make self bot

slate swan
#

¯_(ツ)_/¯

clever pivot
#

how to make a bot send "hi" in a channel, then if someone sends a message in that channel the bot deletes its hi message and resends it to make it the newest message in the channel, how do that everytime someone sends message in channel?

slate swan
clever pivot
slate swan
clever pivot
#
async def on_message(message):
    if message.author.id == 777052626449596437:
        return
    c = bot.get_channel(936850185462644739)
    s = await c.send('hello')
    if message.content == 'yes':
        await s.delete()
        await c.send('hello')
        
    else:
        await s.delete()
        await c.send('hello')``` this was my code but it obv just sent a msg when i send something and then it deletes the message and resent it, i wanted it to delete the message BEFORE and resend a new one so its the latest one in channel
potent spear
clever pivot
potent spear
clever pivot
#

is there something like
s = await ctx.send('hi') s msg = bot.get_message(s) msg.delete()

slate swan
#

Ik it’s not asyncio but just ignore that how do I fix

#

I don’t see problem

novel apexBOT
#

This is not a Modmail thread.

slate swan
#

Huh

potent spear
#

that's just terrible in general

#

skip the bot

#

just import a loading animated emoji instead

#

editing a message to make it look like it's loading is bad

slate swan
#

Na I like if

steady cliff
#

Best discord python library and why?

slate swan
#

Nextcord

potent spear
#

dpy, rest are forks

slate swan
#

Well obviously

#

But if your gonna go with forked version what’s best @potent spear

#

Personally I like Nextcord

potent spear
#

I don't use forks, can't say

slate swan
primal salmon
#

what do u guys use to make music bit

#

bot*

slate swan
#

Personally I dont use them but I heard lava is good

steady cliff
#

Pycord vs nextcord?

slate swan
#

Yes

primal salmon
#

ah lavalink?

slate swan
#

Yes

steady cliff
#

I don’t want to rewrite my discord.py code that much

primal salmon
#

welp I wish I can make button in pydroid

slate swan
steady cliff
#

However I need to

slate swan
steady cliff
#

Why nextcord? Why not pycord or any other fork

slate swan
slate swan
steady cliff
#

Wht about buttons?

slate swan
#

I’m not sure about that I don’t really use buttons

#

But most likely the same

#

buttons are same for all of them.

steady cliff
#

That’s so bad when you have a lot of new options and you don’t want to use the wrong one. You don’t know if the library collapses the next day you choose it

slate swan
#

but libraries like disnake lets you have more functionalities

#

its not in discord

#

!d disnake.ui.ActionRow

unkempt canyonBOT
#

class disnake.ui.ActionRow(*items)```
Represents a UI action row. Useful for lower level component manipulation.

New in version 2.4.
slate swan
#

but here it is

primal salmon
#

hi hikari!

slate swan
#

hey

#

👀 and thats not my name, hikari is a python library

primal salmon
#

;-; I know

#
import Hikari
import love
import like
print("Hikari Lover")
slate swan
#

I’ve never seen this error before

#

What does it mean

primal salmon
#

ur indent

#

aka your spaces

slate swan
#

Ok thx

primal salmon
#

np

slate swan
#

@primal salmon they are all the same spaces out

primal salmon
#

ma goal ;-;

primal salmon
slate swan
#

Kk

#

WAIF LMAO

#

I fixed it trying to send it to you

primal salmon
#

lmaooo

#

I wanna try game bot but kinda lazy TwT

#

imma try Music bot ig

slate swan
#

@primal salmon

#

message = await ctx.send("Loading.. ")
time.sleep(0.3)
await message.edit(content="Loading..")
time.sleep(0.3)
await message.edit(content="Loading...")
time.sleep(0.3)
await message.edit(content="Loading.")
time.sleep(0.3)
await message.edit(content="Loading..")
time.sleep(0.3)
await message.edit(content="Loading...")
time.sleep(0.3)
await message.edit(content="Loading.")
time.sleep(0.3)
await message.edit(content="Alexlol")
time.sleep(0.5)
await message.edit(content=f"webhook request sent!!");

webhook = DiscordWebhook(url= os.environ['TOKEN'])

embed = DiscordEmbed(title='alexlol2fast', description=f'{user} was too fast for you and claimed [{usernameclaimed} (https://tiktok.com/@{usernameclaimed})', color='264dd9')
webhook.add_embed(embed)

response = webhook.execute()

bot.run(os.getenv('TOKEN'))

cedar stream
slate swan
#

Wdym

cedar stream
#

All the await message.edit

#

Put that in a loop

#

To make code cleaner

slate swan
#

Yes but it’s loading… for some and loading.. for others

#

So that won’t work

cedar stream
#

Have a list with .. and … and on 1st iteration use list[0] etc…

slate swan
#

That takes patience I don’t have XD

cedar stream
#

Lmao okok

#

Whats the error with the code tho

slate swan
slate swan
#

Ok

#

What will I use

#

and your error means you used await outside an async function

#

asyncio.sleep

potent spear
#

don't sleep and edit to "simulate" loading, use an animated loading emoji instead

slate swan
#

^^

cedar stream
cedar stream
slate swan
#

Ok

#
async def tt(ctx, *, reason=None):
  userc, user = reason.split(':')
  
message = await ctx.send("Loading.. ")
asyncio.sleep(0.3)
await message.edit(content="Loading..")
time.sleep(0.3)
await message.edit(content="Loading...")
asyncio.sleep(0.3)
await message.edit(content="Loading.")
asyncio.sleep(0.3)
await message.edit(content="Loading..")
asyncio.sleep(0.3)
await message.edit(content="Loading...")
asyncio.sleep(0.3)
await message.edit(content="Loading.")
asyncio.sleep(0.3)
await message.edit(content="Alexlol")
asyncio.sleep(0.5)
await message.edit(content=f"webhook request sent!!");```
#

See message send

#

That’s problem

potent spear
#

definitely not that

#

also, the message stuff isn't IN the tt command

slate swan
#

Wdym

potent spear
cedar stream
potent spear
#

if you don't know what that means, you're definitely new

slate swan
potent spear
#

any indent command?

#

like to show what an indent is

cedar stream
#

!indent

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

slate swan
#

What is that 😅

#

O

potent spear
#

this ^^

slate swan
#

async def tt(ctx, *, reason=None):

#

@potent spear

potent spear
#

that's irrelevant

slate swan
#

Ok

potent spear
#

=> it has nothing to do with intents

#

read what the bot says, it isn't there for show

slate swan
#

@bot.command()
async def tt(ctx, *, reason=None):
userc, user = reason.split(':')

message = await ctx.send("Loading.. ")

#

Kk

#

@slate swan you should probably learn a bit of python first

#

Ok

slate swan
#

I’m not the best I’ve only got decent grasp

#

I need to learn python better

oblique cobalt
#

if user doesnt give it anything. youll get error since you cant .split on NoneType

daring delta
#

help plz

quick gust
#

awit...

daring delta
quick gust
#

you're on dpy 2.0+ right?

#

That changed in 2.0+

#

uh

#

the dpy version

#

Yeah ok so you're probably 2.0+

#

Check the docs, it changed but i forgor it

#

!d disnake.Asset.with_format

unkempt canyonBOT
quick gust
#

@slate swan

dusty vale
#

is there a way to change a webhook channel?

trail oxide
#

Someone who can help?

potent spear
#

also calling a Member object a user is monkey brain

trail oxide
#

but what to search, im from denmark and not the best for english

potent spear
#

nothing to search, just read from the link

trail oxide
#

but can you pls help me

oak warren
#

i am getting this very weird error NoneType' object has no attribute 'bot' i use disnake
and i am using cogs and yes i have self.bot defined

trail oxide
#

Maybe "from discord.ext.commands import bot"

oak warren
#

if member.id == self.bot.user.id: this part for the code giving error

oak warren
trail oxide
potent spear
oak warren
#

no one does that anyways

#

other than maybe lucas

#

idk

trail oxide
#

@potent spear can you pls help me with my code problem

potent spear
trail oxide
#

nvm i found out

slate swan
#
user = await client.fetch_user(id).send(embed=embed)

This doesnt work and nor does it print any errors ;-;

slim ibex
#

whats the whole command

slate swan
slim ibex
#

and could the users dmchannel possibly be closed? I'd imagine it would throw an error if it was closed

slate swan
slim ibex
#

ok so the channel is open

slate swan
#

Yes

slim ibex
#

hmm

#

is there a user/member param in the function? it seems like there isn't as you said user = ...

slate swan
#

there is just, ctx, id and message

slim ibex
#

oh ok i see

#

thats weird then, it should work

slate swan
#

Yeah welp ;-;

arctic wraith
slate swan
slim ibex
#

she had await ctx.send before but that still didn'yt work

slate swan
#

Yep

arctic wraith
#

as in equivalent to

user = await client.fetch_user(id)
await user.send(...)
```?
slate swan
#

Yea

arctic wraith
#

hm, that's odd then

devout iris
#

What is wrong?

slim ibex
#

indentation

#
@client.event
async def on_ready():
  ...
devout iris
#

Ah thx

#

it gives syntax error....

full lily
#

check the lines above @devout iris

devout iris
#

i fixed it 👍

slate swan
slim ibex
#

true

#

but he should fix the indentation too

slate swan
#

yeah ofc lol

slim ibex
#

🙃

velvet tinsel
#

!indents

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

slate swan
velvet tinsel
#

😳 how to indent easy 2022 (for beginners)

slate swan
#

you can atleast make it a one liner

brisk brook
#

how do I construct a blackjack command?

arctic wraith
velvet tinsel
#

One liners are pretty convenient

arctic wraith
#

clarity over brevity imo

slim ibex
brisk brook
#

make sure to click on tab when you want to indent

velvet tinsel
#

One liners can be clear as well

slate swan
#
await (await client.fetch_user(id).send(...) )

since youre getting a user obj just send it from there

arctic wraith
#

they sure can

arctic wraith
#

but await (await ...) ... is ugly as all heck

slate swan
#

not really

velvet tinsel
#

can’t you also do await ctx.send(client.fetch_user(id))?

slate swan
#

making a useless var is garbo

velvet tinsel
#

just….wondering

velvet tinsel
#

oh

slate swan
#

there both coros

#

you need to await them separately

velvet tinsel
#

ahhh

arctic wraith
# slate swan making a useless var is garbo

the performance impact of binding an extra variable is in the microseconds, the memory impact of binding a variable to something that's already in memory is near nihil as well

#

if that little optimization is truly relevant to you, you probably should be using rust lmao

velvet tinsel
#

list comps ❤️

slate swan
velvet tinsel
#

they’re my wife

arctic wraith
#

it literally doesn't matter

slate swan
#

and yes ik making a useless var doesnt impact much but if you can make it

solid crypt
#

hello Wavege

slate swan
#

hi

velvet tinsel
#

Greetings

solid crypt
#

do any of u gentlemen know how to help me with discord py?

velvet tinsel
#

I now have awake paralysis

slate swan
#

isnt getting better learning how to make everything compact

velvet tinsel
solid crypt
solid crypt
#

well started it already

arctic wraith
slate swan
#

dek drop the tutorial

velvet tinsel
#

Which one

solid crypt
#

just couple of problems with a game im creating

slim ibex
#

if you don't know python basics, learn that first

velvet tinsel
#

there are lots

slate swan
solid crypt
velvet tinsel
#

maybe 😳

slate swan
#

dek

#

bro

solid crypt
#

thought id get help to make it easier cause people here are probably familiar with it

velvet tinsel
#

?

slim ibex
slate swan
#

dont follow that

velvet tinsel
#

you said to drop a tutorial

slim ibex
#

that tutorial is rlly old

velvet tinsel
#

You didn’t pass all the necessary arguments

slate swan
#

a good updated tutorial

#

you need to know oop btw

solid crypt
#

btw they arent continuing to update discord.py are they?

slim ibex
#

also i would prolly use a dpy fork tbh

slate swan
velvet tinsel
arctic wraith
#

yeah, dpy is no longer maintained

velvet tinsel
#

I thought it was a video

slim ibex
velvet tinsel
unkempt canyonBOT
arctic wraith
#

there's a couple good forks though, and hikari is a great alternative

velvet tinsel
#

other than list comps

slim ibex
#

!pypi nextcord

unkempt canyonBOT
velvet tinsel
#

Wait hold it

slate swan
#

hikari is better than dpy imo (i use disnake)

velvet tinsel
velvet tinsel
slim ibex
#

watch out for pincer too

slate swan
arctic wraith
#

yeah hikari is probably the best choice for python atm

velvet tinsel
arctic wraith
#

imo, that is

slim ibex
#

i'

velvet tinsel
#

Ok I’ll get started on hikari then

slim ibex
#

ill be using pincer and hikari prolly

slate swan
arctic wraith
#

it's more difficult to use and get into than dpy forks, but yeah

arctic wraith
#

personally still chugging along with disnake

vivid jetty
#

Is there any way to switch off of dpy without rewriting hella code tho?

slate swan
#

everything in hikari is mostly raw endpoint

unkempt canyonBOT
arctic wraith
#

but may rewrite to hikari when exams are over ig

velvet tinsel
#

!pypi hikari

unkempt canyonBOT
slim ibex
#

!pypi pincer

unkempt canyonBOT
velvet tinsel
#

!pypi shutup

unkempt canyonBOT
slim ibex
#

lmao

velvet tinsel
#

lmao

arctic wraith
slim ibex
#

is dekky mad

arctic wraith
#

1.7 to a fork is gonna be a bit more rough

#

but can generally be done in a couple hours

velvet tinsel
#

idk why people didn’t see that

slim ibex
#

🗿

velvet tinsel
#

“Dek”

slate swan
#

1.7 vs a fork isnt really that hard

vivid jetty
#

How fucked am I

slate swan
#

lol

velvet tinsel
#

nice

#

Okimii, how’s uhh aiosqite

slate swan
#

2.0 is the main branch

solid crypt
#

ok so basically what im creating is a Russian roullute game. im trying to send a ctx send message with embed file which the bot reacts to first with an emoji. It requires 7 members to react to the emoji to start the game unless after perhaps 60 seconds it times out and therefore the game ends there. but if 7 people reacetd (meaning 8 reactions in total including the bot) the game continues. my goal is to put everyone who reacted with the emoji in a list, give 6 people (1) and one person (2). Whoever gets 2 gets punished possibly banned for a day then will be unbanned. the part im having problems with is the reaction part. Im trying to register whoever is reacting and put them in a list but i dont know how to get their username or @ put into that list. dont know the specific commands or methods used for it so plz gib help thanks

arctic wraith
slate swan
arctic wraith
#

somewhere between a little fucked and many hours of fucked

vivid jetty
arctic wraith
#

mostly depends on whether you were using slash commands from something like discord-interactions

#

there's been a couple other breaking changes, but most of the old text command schmuck should still work

slate swan
#

discord components smh i hate them

vivid jetty
#

I mean I already have my own slash commands wrapper that works w/ d.py on the side, I just cant use any of the new shit when my bot is responding to a message command.

quaint epoch
#

anyone know what hosting and dtbase provider this servers bots use? bc i wanted to have an idea of where i should start for hosting

solid crypt
velvet tinsel
arctic wraith
#

purely for slash command implementation I'd recommend disnake, probably

#

as dpy fork

vivid jetty
#

Ill look into it

#

If its gonna be a lot of effort im sticking w/ my own system tho

slate swan
#

but go with digital ocean

solid crypt
#

or just have a shitty laptop that runs the code 24/7

#

like never turn it off

slim ibex
#

for hosting my bot, i use vultr

vivid jetty
velvet tinsel
slate swan
#

i don't even host my bots

slim ibex
#

does require some setup and linux knowledge though

solid crypt
#

probably wont work tho if u are trying for ur bot to go big scale

solid crypt
weary birch
#

ok finally found the channel

arctic wraith
#

allows you to quite literally do

@commands.slash_command()
async def command_name(self, inter: disnake.CommandInteraction, strarg: str, intarg: int, memberarg: disnake.Member, ...):
    """command description

    Parameters
    ----------
    strarg:
        arg that takes a str
    intarg:
        arg that takes an int
    memberarg:
        arg that takes a Member
    """
    ...
```and it'll do all the heavy lifting for you
weary birch
#

okay can anyone tell me why clonechannel thing dont move channel to the place where it was before?

slim ibex
#

@solid crypt there are docs yk

arctic wraith
#

it's pretty neat

solid crypt
slate swan
#

there's examples on everything in disnakea git

velvet tinsel
#

docs for what

solid crypt
#

wait actually I JUST FOUND IT

vapid dragon
#

are there message/reaction collectors in disnake?

solid crypt
#

LMAOOOOOOOOOOOO 💀

slate swan
#

i havent checked src

vivid jetty
#

@arctic wraith my current system: ```py
prefix_cmd = slash_int.BotClient.add_slash_command(
'prefix',
'Check your server prefix.'
)

@prefix_cmd.on_run
async def interact(i):
...

vapid dragon
#

oh

slate swan
#

check ig

vapid dragon
#

how would i implement a command that waits for a message?

vivid jetty
cobalt bluff
#

Why are you writting your own

slate swan
vivid jetty
#

it took a long time

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/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
arctic wraith
vapid dragon
#

ah okay

#

thanks

slate swan
#

just rename discord to disnake

vivid jetty
arctic wraith
#

don't even have to, afaik

#

you can install disnake with a discord shim

#

so you can quite literally just import discord

velvet tinsel
slate swan
#

the bsd practice

vivid jetty
#

Or import disnake as discord

velvet tinsel
#

“Just replace discord with ____”