#discord-bots

1 messages · Page 923 of 1

junior verge
#

I dont use replit

slate swan
#

S.M.H. stop cringing kek
just help Daxles, I'm going on a stroll 😔

#

dax

#

did u load the extension??

junior verge
#

Yeah

slate swan
#

show

junior verge
#

from the main file?

slate swan
#

yes

junior verge
#

I mean other cogs work

#
@client.command()
async def load(ctx, extension):
    client.load_extension(f'cogs.{extension}')

@client.command()
async def unload(ctx, extension):
    client.unload_extension(f'cogs.{extension}')

for filename in os.listdir('./cogs'):
    if filename.endswith('.py'):
        client.load_extension(f'cogs.{filename[:-3]}')

#

But that won't be the problem right

hollow badger
#

Please don't use ableist language.

slate swan
#

saad

slate swan
#

who called mods

slate swan
#

yes

velvet compass
#

Filters called us

slate swan
#

ok.

hollow badger
#

Our bot is a snitch 🙂

slate swan
#

:>

slate swan
slate swan
#

..

slate swan
slate swan
#

dax

#

😐

junior verge
#

So I don't get it

slate swan
velvet tinsel
#

Ok

slate swan
#

huh?

velvet tinsel
#

Greetings Ashley.

slate swan
#

?

#

..

velvet tinsel
slate swan
slate swan
velvet tinsel
slate swan
velvet tinsel
#

Cool

slate swan
slate swan
junior verge
#

uh lemme try

slate swan
#

bruh?

#

salad is typing...

#

@clear flicker

velvet tinsel
#

Who tf is salad

slate swan
velvet compass
#

I see a Saad in the chat

brisk zodiac
#

import discord
from discord.ext import commands
import os

@bot.event
async def on_ready():
    print("Logged in as", bot.user.name)

@bot.event
async def on_member_join(member):
    try:
        channel = bot.get_channel(WELCOME_CHANNEL_ID)
        try:
            embed = discord.Embed(colour=discord.Colour.green())
            embed.set_author(name=member.name, icon_url=member.avatar_url)
            embed.add_field(name="Welcome" ,value=f"**Hey,{member.mention}! Welcome to {member.guild.name}\nI hope you enjoy your stay here!\nThanks for joining**", inline=False)
            embed.set_thumbnail(url=member.guild.icon_url)
            await channel.send(embed=embed)
        except Exception as e:
            raise e
    except Exception as e:
        raise e

bot.run(BOT_TOKEN)```
slate swan
#

lol

brisk zodiac
#

what is the error?

velvet tinsel
slate swan
brisk zodiac
# slate swan bruh?

Traceback (most recent call last):
File "main.py", line 7, in <module>
@bot.event
NameError: name 'bot' is not defined

slate swan
#

toatally not copy paste

boreal ravine
slate swan
junior verge
slate swan
placid skiff
#

What the hell is this?

velvet tinsel
slate swan
junior verge
slate swan
#

confirm

junior verge
#

Yep alright

slate swan
#

confirmed by sparky

junior verge
#

But thats weird since my other cogs are loaded

slate swan
#

very weird

velvet tinsel
#

Maybe I shouldn’t have left discord bots lmao wtf is this chat

slate swan
slate swan
#

🤔🤔

junior verge
slate swan
#

its prob with loading

velvet tinsel
junior verge
velvet tinsel
slate swan
junior verge
#

and how to fix that

slate swan
#

idk

#

never used that type of loading

velvet tinsel
#

Loading what

#

Cogs?

slate swan
#

yup

#

Wait

vale wing
slate swan
#

I found the issue

slate swan
#

pogchamp its bc of this

#

😶

boreal ravine
velvet tinsel
slate swan
slate swan
#

Command inside init

velvet tinsel
slate swan
#

tf

#

indents tf

boreal ravine
junior verge
#

Wait so what is the problem?

vale wing
#

!d disnake.ext.commands.Bot.load_extensions is cool btw

slate swan
unkempt canyonBOT
slate swan
#

i use that only

vale wing
#

But that's disnake only ig

junior verge
#

omg

slate swan
#

:D

slate swan
slate swan
vale wing
#

Yeah

boreal ravine
slate swan
#

simple and easy

final iron
slate swan
#

who cares

vale wing
#

Recursion supreme

slate swan
final iron
#

If you loop manually you can exclude certain files you don't want loaded

#

Can't do that with load_extensions unless you edit src

final iron
vale wing
#

Um you are supposed to provide string not the module

slate swan
#

pc laging like hell

junior verge
final iron
#

!d disnake.ext.commands.Bot.load_extensions

unkempt canyonBOT
final iron
#

You just provide a path to the folder

vale wing
#

What is the command that tells how to read traceback

junior verge
#

Can't you just help me instead

final iron
#

It's pretty clear

vale wing
#

Just read the traceback properly and you will be able to easily help yourself

junior verge
#

Yeah but how to fix it

spring flax
#

it would be a lot easier if you send your code first of all

vale wing
velvet compass
slim ibex
#

🤨

spring flax
#

i just have a list of extension strings and iterate through and load them

slim ibex
#

no organization of the project

slate swan
slim ibex
#

you can use Intents.all()

vale wing
#

Gotta disagree

slate swan
#

.

slim ibex
slate swan
spring flax
#

why do you keep putting .? What's it supposed to do?

vale wing
#

6 same statements with only one argument varying

spring flax
#

supposed to mean*

junior verge
#

!paste

boreal ravine
slim ibex
#

you can loop through the cwd (since there are no nested folders/subdirectories) to load the cogs

junior verge
bleak karma
#

does anyone here know how to end the code in pycharm? because the bot is still up even though i terminated it already

slate swan
#

end the code?

bleak karma
#

i did

slim ibex
bleak karma
slate swan
#

i just delete the terminal in vsc

junior verge
#

yeah same

spring flax
junior verge
spring flax
#

so why are you trying to remove it?

junior verge
vale wing
#

I usually organise the bot project like this

src | cogs
    cog1.py
    cog2.py
ext
    utils.py
    bot.py
res
    nice_image.png
    nice_image2.png
main.py
.env | encrypted token
bleak karma
vale wing
#

Yeah ofc it might differ from dev to dev but almost everyone stores cogs in a separated folder

slim ibex
spring flax
vale wing
slim ibex
#

it might take a little bit for the bot to go offline, from my experience

spring flax
#

look at what the list returns, before doing list.remove

bleak karma
junior verge
sullen pewter
#

When will prefixes be cancelled

vale wing
#

Cause in pycharm ctrl+c doesn't work for me as well but I only tried aiohttp servers there

vale wing
#

There's stop button however that works

slim ibex
#

^

bleak karma
vale wing
#

Online you mean even responding to commands?

slim ibex
#

btw if you just CLOSE the terminal (Ctrl+`), the bot won't go offline

spring flax
junior verge
#

My command works now but just my serverstats command shows up

bleak karma
slim ibex
#

you have to actually destroy the terminal or stop the bot instance

vale wing
#

And what IDE are you using?

spring flax
junior verge
bleak karma
vale wing
#

Okay and how do you stop your bot?

spring flax
#

just print it don't do anything else

junior verge
#

just print(cogs)

spring flax
#

yes

bleak karma
vale wing
#

Ok that should be a right way to stop it

bleak karma
#

if not idk

vale wing
#

Check the run tab if there's anything

bleak karma
#

even though i stopped it

junior verge
spring flax
#

error?

junior verge
#

None

vale wing
#

I remember several other users faced this issue but I don't remember the solution to it

spring flax
#

what is the command code you ran?

vale wing
#

If I would be using pycharm I would probably figure out why it happens but in this case I don't know how to help you sorry

junior verge
spring flax
#

huh?

bleak karma
vale wing
#

It is abnormal

bleak karma
#

will it affect anything

#

or

spring flax
#

also instead of async def help(self, ctx, cog="1"): why not async def help(self, ctx, cog : int = 1):

vale wing
#

Normally it would stay online for approximately 1-2 mins but not respond to commands and then just go offline

vale wing
junior verge
vale wing
#

Why you overriding builitin help lmao

junior verge
#

builtin is shit

vale wing
#

Check pins for the proper way of implementing help command or do

@commands.command(name="help")
async def _help(...):
    ...```
#

And yeah better check pins

shadow wraith
#

your better off subclassing it so you don't have to write all the shit

junior verge
#

Well why does it now just show my warn lol

slim ibex
#

!d discord.ext.commands.MinimalHelpCommand

unkempt canyonBOT
#

class discord.ext.commands.MinimalHelpCommand(*args, **kwargs)```
An implementation of a help command with minimal output.

This inherits from [`HelpCommand`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.HelpCommand "discord.ext.commands.HelpCommand").
junior verge
#

?

dense swallow
#

is there any efficient way for an help cmd with slash cmds?

maiden fable
#

I don't think there's a class for slash help command yet

vale wing
#

Or doing a simple command

dense swallow
#

hmm ok thanks

static beacon
#

cant you use

#

minimalhelpcommand and the other preset ones

#

in a slash command?

dense swallow
#

can we?

vale wing
#

It uses context so most likely it sends to channel

dense swallow
#

i tried commands.HelpCommand it didnt work

vale wing
#

Because it's not interaction based

#

Probably need to do some research in low-level stuff of the lib

#

On the message to command processing stage

static beacon
static beacon
vale wing
#

Slash commands are based on interactions, and the help command subclasses are based on simple message sending

static beacon
#

cant you reroute it

vale wing
#

Caught in different events

static beacon
#

whats more useful of having your whole bot basically invisible to anyone except for the people who use it

vale wing
static beacon
#

i dont get everyone making every command they have into a slash command

static beacon
vale wing
#

Ik

#

But I think you can't reroute help command processing without editing the library files which means creating own fork

static beacon
#

hm

#

im not too familiar with slash commands and what they're capable of

slate swan
static beacon
#

you arent going to have 3 year old children using your discord bot im positive if they could add it they know how to type right

tidal hawk
#

It's nice to see all commands pop up, instead of using help command for viewing the commands and then spell it carefully

#

And try to remember which argument is where

#

Also easier for dev, doesn't have to make error messages (for giving feedback, what went wrong etc)

junior verge
#

['Whois', 'Ping', 'Role', 'Warn', 'Avatar', 'Mention', 'ball', 'Moderation', 'Meme', 'EmojiInfo', 'Help', 'Serverstats']

#

Which are all my cogs but just 1 shows up on my help command

#

Now it just shows whois

#

It just gives a random cog

tidal hawk
#

'\n'.join(cogs)

junior verge
#

Instead of showing all

#

Where?

tidal hawk
#

Show me the code

junior verge
#

!pate

#

!paste

tidal hawk
#

So only 1 cog appears into neededCog list?

junior verge
#

Yeah

tidal hawk
#

Probably this part messes it up : x = i + (int(cog) - 1) * 4

junior verge
#

I think so

#

That should be it though

#

Got any idea

dense swallow
#

i made a class for the help command with select menus.. how do i call that in a slash command with disnake?

static beacon
#

disnake is weird

#

im a dpy guy but i could probably help you

#

idk how forks changed things

junior verge
dense swallow
#

so im having some confusions

static beacon
#

ik its a fork but like.. they just switched like 2 things around and called it theirs

boreal ravine
#

no?

static beacon
tidal hawk
boreal ravine
#

where did they say its theirs

static beacon
#

nvm thats nextcord

static beacon
#

nextcord is trying to make it seem like they arent a fork by changing EVERYTHING

dense swallow
#

v3

nimble plume
tidal hawk
junior verge
#

Nope

static beacon
final wagon
#

hello, can anybody pls help me my cog aint loading in heroku

slate swan
slate swan
final wagon
junior verge
final wagon
#

but not working in heroku

static beacon
maiden fable
#

Huh?

junior verge
#

Do you got a requirements.txt?

maiden fable
#

You can't define a module by seeing just a single commit... I'm not being biased here, but you should also look at the other features like faster releases bruv

slate swan
junior verge
static beacon
#

im talking about the file itself

slate swan
slate swan
maiden fable
#

And may I know why you are looking at only that thing? There are other plus points of the module too, to look at

junior verge
#

Pretty sure mine should work though just don't see the problem

slate swan
maiden fable
#

Yea

static beacon
#

breh

maiden fable
#

It's released

static beacon
#

v10 is released?

maiden fable
#

Yea...

slate swan
maiden fable
#

Bruh

static beacon
#

they dont work well with version numbers

maiden fable
slate swan
static beacon
tidal hawk
#
 for cog in neededCogs:
            commandList = ""
            for command in self.client.get_cog(cog).walk_commands():
                if command.hidden:
                    continue
            
                elif command.parent != None:
                    continue
#

Don't mind the weird indent (copy)

#

But you reset the string

#

Every iteration

slate swan
flat solstice
#

https://discord.com/developers/docs/resources/channel#embed-object-embed-limits
Does this mean that each embed (in the list of embeds that a msg can send) has a per embed limit of 6k chars or that the total char limit of each embed in the list combined must not exceed 6k chars

Additionally, the combined sum of characters in all title, description, field.name, field.value, footer.text, and author.name fields across all embeds attached to a message must not exceed 6000 characters. Violating any of these constraints will result in a Bad Request response.

static beacon
slate swan
#

but since it never got realeased, there;s the gap

#

v10 has been released recently

static beacon
flat solstice
static beacon
slate swan
flat solstice
unkempt canyonBOT
#

discord/http.py lines 274 to 275

class Route:
    BASE: ClassVar[str] = 'https://discord.com/api/v10'```
inner epoch
#

Hey how to know if a user entered the server? Like I wanna display a welcome message so if user enters how to know that he/she entered?

jaunty marsh
#

i second that^

static beacon
static beacon
#

both are events

inner epoch
static beacon
#

gl

static beacon
torn sail
#

They added support recently

static beacon
#

oh

#

i dont use slash commands much so idk

flat solstice
static beacon
static beacon
#

how new is it

boreal ravine
static beacon
flat solstice
#

they added support a weekish ago i think, maybe a bit longer

final iron
#

But how would I exclude certain files with load_extensions

#

Pretty sure you can't

quaint epoch
#

How would i filter audit logs entries that were moderation actions, like bans, kicks, mutes, messages etc with disnake.AuditLogActionCategory

final iron
#

!d disnake.AuditLogActionCategory

unkempt canyonBOT
#

class disnake.AuditLogActionCategory```
Represents the category that the [`AuditLogAction`](https://docs.disnake.dev/en/latest/api.html#disnake.AuditLogAction "disnake.AuditLogAction") belongs to.

This can be retrieved via [`AuditLogEntry.category`](https://docs.disnake.dev/en/latest/api.html#disnake.AuditLogEntry.category "disnake.AuditLogEntry.category").
naive pumice
#

Is discord. Py back?

#

They told no more updates....

slate swan
final iron
final iron
slate swan
static beacon
naive pumice
#

Y was there a sudden dip.?

#

I have lot to catch u ig

static beacon
flat solstice
# static beacon pre march break

yeah this is how I'm declaring my cog class (inheriting both Group and Cog isn't needed for everyone I'm just doing it so I don't need to declare a group later on, as I need that option later on) https://github.com/SnowyJaguar1034/Zupie/blob/fd409e115d56a4d34ec989c46b80be04686cf033/bot/cogs/users.py#L15 and then you add the cog the same way you used to https://github.com/SnowyJaguar1034/Zupie/blob/fd409e115d56a4d34ec989c46b80be04686cf033/bot/cogs/users.py#L112-L113

unkempt canyonBOT
#

bot/cogs/users.py line 15

class User_Cog(app_commands.Group, commands.Cog, name="user", description="Shows all user related commands, legacy and slash"):```
`bot/cogs/users.py` lines 112 to 113
```py
async def setup(bot):
    await bot.add_cog(User_Cog(bot), guild=Object(id=default_guild))```
torn sail
#

He didn’t like how discord was forcing slash commands

slate swan
slate swan
#

He was infuriated due to discord employees of not answering his question (they have also insulted him)

static beacon
#

then discord support ghosted me

slate swan
#

Oh

static beacon
#

what is one man gonna do about a multi million dollar company

slate swan
#

That's what they said?

slate swan
static beacon
midnight drum
#

anyone has discord custom help command dm me or paste it here please.

static beacon
#

i just asked why their staff were acting like toddlers

midnight drum
static beacon
#

here comes the code airplane!!! newwwwwwmmmmmm

#

🥄

final iron
#

That's not what this server is for

midnight drum
#

but i wanna add my own help command idk how

static beacon
midnight drum
#
class MyHelpCommand(commands.HelpCommand):
    async def command_callback(self, ctx, *,command=None):
        if command:
            await ctx.send(f"This is the help page for the command {command} ")
        else:
            await ctx.send("This is the front page for the bots help command")
bot.help_command = MyHelpCommand()```
#

just tell me where i should paste my own help

brisk zodiac
#
WELCOME_CHANNEL_ID = 955795195268567130

import discord
from discord.ext import commands
import os
from keep_alive import keep_alive

client = discord.Client()
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix = '!', intents=intents)

@client.event
async def on_ready():
    print("Logged in")

@client.event
async def on_member_join(member):
    try:
        channel = client.get_channel(WELCOME_CHANNEL_ID)
        try:
            embed = discord.Embed(colour=discord.Colour.green())
            embed.set_author(name=member.name, icon_url=member.avatar_url)
            embed.add_field(name="Welcome" ,value=f"**Hey,{member.mention}! Welcome to {member.guild.name}\nI hope you enjoy your stay here!\nThanks for joining**", inline=False)
            embed.set_thumbnail(url=member.guild.icon_url)
            await channel.send(embed=embed)
        except Exception as e:
            raise e
    except Exception as e:
        raise e

keep_alive()
client.run(os.getenv('BOT_TOKEN'))
``` how can i fix this it worked but when someone joined it didn't say anythiing
static beacon
brisk zodiac
#

oh ok

static beacon
brisk zodiac
#

okay

static beacon
#

and you can remove the field and have name and value as title and description

#

iin the main embed

#

also the member "icon" is actually member.avatar_url < 2.0.0 but if you are using 2.0.0 its member.display_avatar.url

#

and guild isnt used

#

its just member.name

#

also i see you're using replit. pro tip: dont.

flat solstice
slate swan
static beacon
#

its just easier

crimson nova
#

I have a json file like this:

{
    "ID": [int1, int2]
}

I have a guild_id. How can I check if guild_id matches one of the int in the json file?

static beacon
slate swan
marble rampart
#

hi

static beacon
#

hi

crimson nova
marble rampart
#

sure

#

one sec

crimson nova
#

Okay.

marble rampart
#

guild_id is a int right ?

crimson nova
#

Yep.

#

Compare guild_id as an interger and check if that guild_id is in the ID of the json file.

marble rampart
#
for _id in YourJsonObj["ID"]
  if _id == guild_id:
    # do stuff if they are the same
  else:
    # do stuff if they are not the same
static beacon
marble rampart
#

make sure to replace YourJsonObj with your json obj

static beacon
#

cant you also use [0] and [1] to get the first and the second?

slate swan
#

Hey I wanted to know that
If a user ran a command for e.g: ,knock-knock

And any user sent “who’s there?” The bot would respond with anything like “me” and much more
If this is possible please explain

crimson nova
quaint epoch
#

yello

slate swan
crimson nova
#

As for now, only 2 ints, but later on, I want to add more ints as well.

static beacon
#

please explain

crimson nova
#

So I should use for.

slate swan
#

I mean if user1 used a command ,knock-knock

And the bot sends any message I want and then
Let’s take the other user as user2 or anything
If he/she responds with “who’s there” then the bot should reply with “me” or anything like that
And after that the command should timeout

marble rampart
#
@bot.event
async def on_message(msg):
  if msg.content == "who there?"
    msg.channel.send("me")
marble rampart
#

or you can search for it in google

naive pumice
marble rampart
#

like how to wait for msg

marble rampart
static beacon
marble rampart
#

you can also use what @naive pumice did

static beacon
#

the user doesnt have to be the author. it can be anybody and you can check if the response fits the citeria. in this case "knock knock" and execute code. then if else just rerun the wait_for.

marble rampart
static beacon
#

or who's there

marble rampart
#

yeah i know

marble rampart
#

if msg.content == "who's there": wait for msg....

crimson nova
#

Above:

with open ("./test.json") as f:
    data = json.load(f)
    id = data['ID']
boreal ravine
crimson nova
#

json file:

{
    "ID": [38938246574374913, 859030372783751168]
}
static beacon
crimson nova
#

Bro, the json can be maximized later.

static beacon
#

based on your json file having an array

naive pumice
crimson nova
#

And actually, I use another lib.

#

And the method to get guild id is ctx.guild_id.

naive pumice
#

Oh ic

static beacon
#

ohh

static beacon
crimson nova
#

Just to make sure.

naive pumice
#

Try printing the ID before entering the condition...

static beacon
crimson nova
final iron
naive pumice
#

Ye

#

That u input

crimson nova
final iron
#

Why though

crimson nova
#

Because this is an interactions based bot.

#

And the structure for slash commands that dpy uses is pretty suck, in my opinion.

static beacon
crimson nova
#

Yeah, I know, but just my preference.

#

The interactions.py used to act as an extension for handling slash commands/components for dpy before the development got ceased. After that, the dev team decided to separate from an extension to a standalone lib.

static beacon
#

ah

naive pumice
#

?

crimson nova
naive pumice
#

🙃

slate swan
#

@crimson nova whats the issue? 😔

spring flax
#

why do people subclass bot? I want to write something about it and need some information on it

#

all I know is that it is done to add methods but are there any other applications or reasons?

vale wing
#

Basically to do other actions along with or instead of already made ones in superclass and for better code readability

#

Expand functionality

hushed galleon
#

ive been typehinting with my bot subclass for better ide autocompletion

vale wing
#

For example you could subclass it to implement a database inside

south jetty
#
    member_name, member_discriminator = member.split('#')
ValueError: not enough values to unpack (expected 2, got 1)```

```py
        banned_users = await ctx.guild.bans()
        member_name, member_discriminator = member.split('#')
        
        for ban_entry in banned_users:
            user = ban_entry.user
            
        if (user.name, user.discriminator) == (member_name, member_discriminator):
            await ctx.guild.unban(user)````
#

how can I make it so you can use their ids as well

vale wing
#

This is how I subclassed one of my bots, as you can see there are super init, checks addition and extension loading on initialization, override of start to create the database if it doesn't exist, override of close method to close the database connection as well, some database tools and events overwrites
https://github.com/BobuxBot/BobuxAdmin/blob/master/tools/bot.py

GitHub

Source code of BobuxAdmin bot from Bobux Bot Development server. - BobuxAdmin/bot.py at master · BobuxBot/BobuxAdmin

static beacon
#

im gonna scare the shit out of people with this

vale wing
#

Nah not really the discord token generation is epic

static beacon
#

get user creation, get raw number. base 64.

#

getid. base 64

proud rain
#

line 59, in get_prefix return prefixes[str(message.guild.id)] AttributeError: 'NoneType' object has no attribute 'id'

i get this error when im sending things to my bot - i have made a modmail system and this sends

Modmail
https://paste.pythondiscord.com/kojucuniwi

unkempt canyonBOT
#

Hey @proud rain!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

proud rain
#

someone who can help?

naive pumice
fresh iron
#

from discord.ext.commands import AutoShardedBot ImportError: cannot import name 'AutoShardedBot' from 'discord.ext.commands' (C:\Users\ramzi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\__init__.py) PS C:\Users\ramzi>

cold sonnet
#

and that for loops only saves the last user in the list

proud rain
#

line 59, in get_prefix return prefixes[str(message.guild.id)] AttributeError: 'NoneType' object has no attribute 'id'

i get this error when im sending things to my bot - i have made a modmail system and this sends

Modmail
https://paste.pythondiscord.com/kojucuniwi

Can someone pls help??

cold sonnet
#

u sent this in a dm

#

therefore message.guild is None

proud rain
#

so what to change?

cold sonnet
#

do some error handling

fresh iron
#

yeah

#

hi meh and ashely

cold sonnet
fresh iron
#

are you guys having a good day

cold sonnet
#

else like !

proud rain
fresh iron
#

i am just wondering what's this error
from discord.ext.commands import AutoShardedBot ImportError: cannot import name 'AutoShardedBot' from 'discord.ext.commands' (C:\Users\ramzi\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\__init__.py) PS C:\Users\ramzi>

cold sonnet
fresh iron
cold sonnet
#

and only then return that value

proud rain
#

if message.guild:
return

#

like this?

cold sonnet
#
    return prefixes[str(message.guild.id)]
else:
    return "!" ```
#

this makes the prefix ! in DMS

#

(ig)

#

don't scream at me if it don't work

slate swan
#

not required when you are using return

cold sonnet
#

you can remove it, yeah

#

for those bytes

proud rain
#

i think you gone me wrong, because when i type in dm to the bot this error comes, and i want to get rid of it

in get_prefix return prefixes[str(message.guild.id)] AttributeError: 'NoneType' object has no attribute 'id'

slate swan
#

and you could write it as

return prefixes[str(message.guild.id)] if message.guild else return "!"

this should work maybe

cold sonnet
#

exactly what I was talking about

cold sonnet
#

if it does the if first, then yeah

#

then I aswell learned something today

fresh iron
cold sonnet
#

!d discord.ext.commands.AutoShardedBot

unkempt canyonBOT
#

class discord.ext.commands.AutoShardedBot(command_prefix, help_command=<default-help-command>, description=None, **options)```
This is similar to [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") except that it is inherited from [`discord.AutoShardedClient`](https://discordpy.readthedocs.io/en/master/api.html#discord.AutoShardedClient "discord.AutoShardedClient") instead.
cold sonnet
#

hm

vale wing
#

@fresh iron what's your dpy version

slate swan
# proud rain i think you gone me wrong, because when i type in dm to the bot this error comes...

well, you do not have servers inside dms so thats why the message.guild returns None and has no attribute id, so thats what meh was talking about that if message.guild will check if the message was sent in a server or not, if it was then it would be to return the guild's desired prefix, and using a return statement, the function stops the execution of the function any further, and if message.guild returns None, the function should return a ! prefix

cold sonnet
#

😩

fresh iron
proud rain
cold sonnet
#

god

vale wing
#
import discord
print(discord.__version__)```
slate swan
unkempt canyonBOT
#

discord.__version__```
A string representation of the version. e.g. `'1.0.0rc1'`. This is based off of [**PEP 440**](https://www.python.org/dev/peps/pep-0440).
cold sonnet
#

just paste the line ashley sent

#

instead of the line that throws the error

proud rain
#

but i dont know which line or where i should paste it -_-

cold sonnet
#

replace the line that throws the error

proud rain
#

line 59, in get_prefix
return prefixes[str(message.guild.id)]
AttributeError: 'NoneType' object has no attribute 'id'

proud rain
#

okay

slate swan
vale wing
#

And in DMs there's no guild ofc lol

slate swan
#

I gave you a paragraph of explanation and you arent even gonna try

fresh iron
cold sonnet
#

noob

vale wing
#

It's more interesting to create own code isn't it

spring flax
#

You can make your own too

slate swan
fresh iron
#

not if you don't even know english

vale wing
#

Understandable

proud rain
#

sorry, im sorry if i wasted your time

spring flax
#

I've done that and it's better because you have control over everything

cold sonnet
#

yes

spring flax
#

Oh okay my bad

fresh iron
#

you can modify it

slate swan
#

just dont use modmail and contact users directly

vale wing
#

Tickets supremacy

slate swan
#

not fun

cold sonnet
#

and don't have to pay for features you can make too khmMEE6

fresh iron
slate swan
fresh iron
#

ashely

vale wing
#

None of bots premiums worth themselves

#

At least idk any

fresh iron
#

how are you ashely from discord

slate swan
slate swan
#

....?

cold sonnet
#

we can all make MEE6

spark fern
#

i dont have

cold sonnet
#

me not the dashboard but someone would make that

fresh iron
#

i paid for mee6 once and it's been premium for 2 years now

#

it's forever premium their payment system is broken

spark fern
fresh iron
#

did i do what

spark fern
#

its garbage

vale wing
#

I can't even integrate payment services cuz I live in russia 💀

fresh iron
#

objective

spark fern
#

The Russia is good the Putin is Bad

cold sonnet
#

y'all unlucky

fresh iron
#

Putin is good russia is bad

spark fern
velvet compass
#

You are all wildly off topic

fresh iron
#

nah ur opinion is invalid cause u have turkey flag as ur pfp

vale wing
#

Pretty sure politic discussions are against the rules as well

proud rain
#

is anyones changeprefix dont work?

fresh iron
#

ok

#

done with politics for today

spark fern
#

o sorry im quiting

cold sonnet
spark fern
#

bye

cold sonnet
#

u stalking

fresh iron
proud rain
#

is anyones changeprefix dont work?

velvet compass
cold sonnet
#

I see

#

that's nice

slate swan
vale wing
#

If you mean that

proud rain
vale wing
#

Show the code

proud rain
#

okay

fresh iron
#

yeah show the code sebaztian

slate swan
unkempt canyonBOT
proud rain
#
file_directory = os.path.dirname(os.path.realpath(__file__))


def get_prefix(Client, message):
    with open(file_directory + './databases/prefixes.json', 'r') as f:
        prefixes = json.load(f)

        return prefixes[str(message.guild.id)]

def get_prefix(Client, message):
    with open(file_directory + './databases/prefixes.json', 'r') as f:
        prefixes = json.load(f)

    if message.guild: #checks if the message was sent in a server or not
        return prefixes[str(message.guild.id)]
    return "." #returns a default prefix if the message was sent in dms

def get_prefix(Client, message):
    with open(file_directory + './databases/prefixes.json', 'r') as f:
        prefixes = json.load(f)

        return prefixes[str(message.guild.id)]


@Client.event
async def on_guild_remove(guild):
    with open(file_directory + './databases/prefixes.json', 'r') as f:
        prefixes = json.load(f)

    prefixes.pop(str(guild.id))

    with open(file_directory + './databases/prefixes.json', 'w') as f: 
        json.dump(prefixes, f, indent = 4)



@Client.command()
@has_permissions(manage_roles=True)
async def changeprefix(ctx, prefix):
    with open(file_directory + './datatases/prefixes.json', 'r') as f:
        prefixes = json.load(f)

    prefixes[str(ctx.guild.id)] = prefix

    with open(file_directory + './databases/prefixes.json', 'w') as f: 
        json.dump(prefixes, f, indent = 4)
    await ctx.send(f'`Serverens prefix er nu ændret til: {prefix}`' )```
cold sonnet
#

that's our Ashley

vale wing
#

Omg

#

JSON 😱

slate swan
cold sonnet
#

why do you have 2 get_prefix

#

3

proud rain
vale wing
#

Oh no

fresh iron
#

hmmm

proud rain
#

and it worked for a week ago

slate swan
#

./databases/prefixes.json the most controversial path I have seen today

fresh iron
#

it worked for a week?

#

are you sure you haven't changed anything

cold sonnet
#

3

proud rain
#

should i delete 2 of them

cold sonnet
slate swan
cold sonnet
#

they are both overwritten anyways

#

wait no

slate swan
#

anyways, bye, match started, goodluck meh and exenifix and 𝗡𝗮𝗺𝗲 kek

cold sonnet
#

the first and last one

fresh iron
#

sebastian finsterwalder

vale wing
#

@proud rain use a proper database, for example sqlite or postgres

proud rain
#

i deleted two of them now

cold sonnet
#

make sure to leave the correct one there

slate swan
proud rain
fresh iron
#

that's a terrible tutorial

vale wing
proud rain
#

ok

fresh iron
vale wing
#

Ok thx

proud rain
#

okay

#

but how can i see

fresh iron
ornate aspen
#

Is there any example code for local prefix caching for discord bot?

velvet compass
ornate aspen
#

Not entirely true, also storing api keys in json file is a bad idea

static beacon
proud rain
#

but how can i fix it?

vale wing
ornate aspen
vale wing
#

That's basic caching

ornate aspen
#

felt a bit... lacklustre if you will

#

more like alot of features missing

vale wing
#

Yeah the __main_cache right?

ornate aspen
#

I can set up pg NOTIFY to register changes or use hasura to make a webhook that registers remote changes

#

but too much work to do from scratch yert

south jetty
maiden fable
#

😔 GitHub is down

cold sonnet
velvet tinsel
maiden fable
#

Yea

velvet tinsel
#

Was working fine for me lmao

maiden fable
velvet tinsel
#

Oh well

velvet tinsel
#

What’s pyweek lmao

gaunt ice
#

jam

slate swan
#

no?

#

sql is a query language

slate swan
maiden fable
#

Lmao

slate swan
#

tf

#

your pfps wigglewiggle_pensive

maiden fable
#

😔

gaunt ice
gaunt ice
#

waitt hunter has the same

slate swan
gaunt ice
#

ima change before i become hunters clone

maiden fable
#

😔 Stop

gaunt ice
#

done

#

im not a weirdo anymore

maiden fable
#

Thanks

desert swift
#

Hey !
Trying to make a discord bot. I have a command named get.
Inside, i have a ```py
msg = await ctx.send("my message")

I'me trying to add 1️⃣, 2️⃣ and 3️⃣ to that message but couldn't find a way to send that reactions.
Can someone help me ?
maiden fable
#

!d discord.Message.add_reaction

unkempt canyonBOT
#

await add_reaction(emoji, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Adds a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.

Changed in version 2.0: `emoji` parameter is now positional-only.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
desert swift
#

yeah, but, as they are unicodes emojies, it doesn't works, do u know how to do ?

spring flax
#

!charinfo 1️⃣

unkempt canyonBOT
maiden fable
#

\1️⃣

#

For some reason my discord crashed

desert swift
#

yeah, i tryed x)

spring flax
spring flax
desert swift
spring flax
#

type !charinfo [emoji] in #bot-commands

#

[emoji] is a placeholder value for the emoji you want to get the character information of

maiden fable
#

Bruh for some reason discord is crashing repeatedly

desert swift
#

ok, ill try and say u if it doesn't works

hoary cargo
#

cursed be you tos and privacy policy for bots

velvet compass
#

Huh?

spring flax
desert swift
spring flax
#

send the full traceback

desert swift
#

no

#

joking

spring flax
#

uhmm

desert swift
#

just because i didn't put that ???

spring flax
#

yeah you missed an await

#

if you don't know where, send your code

maiden fable
#

😔 Thanks discord, not when I try to use the backslash button the app crashes

desert swift
#

thaaaaaaaanks it works !!!!

proud rain
#

Why is my buttons not sending?

spring flax
#

the code would help

civic path
#

anybody know how to actively import code from a seperate python script to the discord bot? im looking for active updates when i run a command but instead the bot will not start until the script its importing from is done (its while loop until i disable it) which completely defeats the purpose of active feedback :p

proud rain
#
@Client.command()
async def button(ctx):
    await ctx.send(
        "",
        components = [
            Button(style=ButtonStyle.red, label = 'test!') 
        ]
    )
    interaction = await Client.wait_for("button_click", check=lambda i: i.component.label.startswith(""))
    await interaction.respond(content="test")```

My buttons dont work?
#

someone who can help

maiden fable
#

which lib

proud rain
maiden fable
#

and for buttons?

proud rain
#

nextcord i think

left crater
#

huh

maiden fable
#

😔 I will leave it to Raven to help u

spring flax
left crater
proud rain
left crater
#

what version are you using

proud rain
#

how to see?

left crater
#

did you just do pip install discord?

spring flax
#

pip show discord.py in terminal

proud rain
#

1.7.3

left crater
#

you should probably upgrade

proud rain
#

how to

spring flax
#

if you want you can uninstall it and install again

proud rain
#

still dont fix

spring flax
left crater
#

pip install -U git+https://github.com/Rapptz/discord.py

#

@proud rain

proud rain
#

not working :(

left crater
#

what ide are you using?

spring flax
#

look at the example for buttons

modest plover
#

Hey uhh so this doesn't send the image, why?

    @animals.sub_command()
    async def cat(self, inter):
        async with aiohttp.ClientSession() as session:
            async with session.get(f"https://api.thecatapi.com/v1/images/search?api_key={cat_auth}") as resp:
                data = json.loads(await resp.text())
                catEmbed = disnake.Embed(
                    title = "Cat!"
                    ).set_image(
                        url = data[0]['url']
                    ).set_footer(
                        text = "Powered by The Cat API")
                await inter.response.send_message(embed = catEmbed)
#

No errors

maiden fable
#

can u print url?

velvet tinsel
#

Ok

rocky trench
#

what does pass_context do?

maiden fable
rocky trench
modest plover
maiden fable
#

Yea if its set to true then the ctx arg is passed else not

rocky trench
#

async def lol(ctx)

#

so its the same

modest plover
#

Yes I can

#

I get that but as a link

#

huh

maiden fable
#

hmm

modest plover
#

It fixed itself magically

maiden fable
#

Lmao

modest plover
#

I don't know how but it did

civic path
#

anybody know how to actively import code from a seperate python script to the discord bot? im looking for active updates when i run a command but instead the bot will not start until the script its importing from is done (its while loop until i disable it) which completely defeats the purpose of active feedback :p

spring flax
#

What do you mean?

civic path
#

so

#

basically im importing a few variables from a script running a while loop

#

every loop the variables increase by 1 so thats why i wanted an active variable

#

but the bot only ever goes online when the while loop is ended

#

aka the while x = y is no longer true

unkempt canyonBOT
#

Hey @candid veldt!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

candid veldt
#

I have a problem when I try to start the bot I get this error:
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.Moderation' raised an error: NameError: name 'tasks' is not defined
code: https://paste.pythondiscord.com/denegayife

gaunt ice
#

 from discord.ext import tasks

candid veldt
#

Next error:
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In guild_id: Value "Ellipsis" is not snowflake

maiden fable
#

remove ... and put in a proper ID

slate swan
#
value=discord.utils.format_dt(round(user.joined_at.timestamp()), "F"),```

```AttributeError: 'int' object has no attribute 'timestamp'```
not sure how to resolve it..
maiden fable
#

No need for timestamp()

slate swan
#

okay

#

nvm

maiden fable
#

😔 background sucks

candid veldt
# slate swan show the whole traceback

All traceback:
Traceback (most recent call last):
File "C:\Users(file name)\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "F:\test bot\cogs\Moderation.py", line 147, in on_ready
self.guild = await self.bot.fetch_guild(...) # You server id
File "C:\Users(file name)\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 1188, in fetch_guild
data = await self.http.get_guild(guild_id)
File "C:\Users(file name)\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In guild_id: Value "Ellipsis" is not snowflake.

maiden fable
#

I smell copied code

#

and oh well, fetch

left crater
#

its a tutorial i think

maiden fable
#

Hmm nah

candid veldt
maiden fable
#

I told u the issue ¯_(ツ)_/¯

dull terrace
#

What's the shortest string i could turn a guild id into while keeping every guild unique

slate swan
#

ellipsis isnt a snowflake

candid veldt
#

okay thanks

dull terrace
#

If a person from a guild wants to attack another they'll have to type an identifier

slate swan
#

how can i do slash (/) commands? Like probot, mee6 and more?

dull terrace
#

i think ill probably make it so they can only attack ones on the leaderboard so itll just be buttons

sick birch
dull terrace
wicked atlas
#

You can do slash commands in discord.py 2.0, you just need to install it from main

#

The d.py readme in github has instructions on how to do that

desert badger
#

How do i fix the Cannot write to closing transport thing?

south jetty
#

just want to confirm, is github working?

#

I am trying to host my bot, but it isn't working

wicked atlas
#

I mean, it looks like its up

#

Where are you trying to host your bot?

south jetty
#

heroku

uncut portal
#

that sounds like a plan for disaster

#

the best way I have found to host discord bot's cost effectively is to buy an rpi and run it on that

#

super low power and it's all you need

sick birch
sick birch
flat solstice
sick birch
#

Both work, before the setup function we did it within the main

#

But the setup hook makes it easier now

flat solstice
#

so both work but is the setup hook the more 'recommended' or more 'pythonic' way to do it? or does it completely not matter at all

sick birch
#

There's no method that's recommended or Pythonic

#

By that I mean it doesn't matter

#

But if you're an organized person you'd probably like the main function better

#

To have a defined starting point as the very last thing in your file instead of a hook somewhere within your code

flat solstice
#

okay I'll put it in main then (i'm not a very organized coder but I'm trying to be as organized as possible for tis project to make it scalable with the least amount of input from me as it grows. So now should I connect to the db from inside the async with self or not and from within the async with aiohttp.ClientSession() as session partpy async def main(self): # so here async with aiohttp.ClientSession() as session: # here async with self: # or here print( '------', 'main func', ) for extension in self.config.initial_extensions: try: await self.load_extension(extension) print(f"Loaded {extension.title()}") except Exception: print(f"\nFailed to Load Extension {extension}\n{traceback.format_exc()}\n") self.session = session await self.start(token)

junior verge
#

Anyone please

tardy atlas
#
@bot.command()
async def пред(ctx, member: discord.Member = None, *, reason = None):
    print(45)
    cursor.execute("""CREATE TABLE IF NOT EXISTS warning(guild BIGINT, userid BIGINT, warn INT, count INT, reasons VARCHAR);""")
    base.commit()
    print(1)

    if member is None:
        await ctx.send("Выберите участника")
        return
        
    if reason is None:
       cursor.execute('INSERT INTO warning(guild, userid, warn, count, reasons) VALUES(%s, %s, %s, %s, %s)', (ctx.guild.id,ctx.author.id,1,1,'Отсутствует'))
       base.commit()
       print(2222)
       cursor.execute('UPDATE warning SET warn = warn + 1 WHERE userid = %s AND guild = %s', (member.id, ctx.guild.id))
       base.commit()
       await ctx.send(f"**{member}** Выдал предупреждение {ctx.author.name} , причина ``Отсутствует``.")
    else:
       cursor.execute('INSERT INTO warning(guild, userid, warn, count, reasons) VALUES(%s, %s, %s, %s, %s)', (ctx.guild.id,ctx.author.id,1,1,reason))
       base.commit() 
       cursor.execute('UPDATE warning SET warn = warn + 1 WHERE userid = %s AND guild = %s', (member.id, ctx.guild.id))
       base.commit()
        await ctx.send(f"**{member}** Выдал предупреждение {ctx.author.name} , причина {reason}.")    

not working. Nothing output excepting 45 and 1, why?

south jetty
#
channel = await categ.create_text_channel(name=f"{interaction.user.name}-{}".format(ticket_number), overwrites=overwrites)```
I can't fix this. if I remove the f string `interaction.user.name` won't work but if i put the f string `{}` the error `empty expression not allowed` comes
maiden fable
quaint epoch
#

can you do ```py
@commands.command(description='this command is sus')
async def sus(sus_self, sus_context, sus_param):
print('sus')

maiden fable
#

sure

quaint epoch
#

and by that i mean, can you put a command description like that?

wicked atlas
maiden fable
#

sure

wicked atlas
#

!string

quaint epoch
#

nice

wicked atlas
#

!strings

unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

quaint epoch
wicked atlas
#

That was for the person i was replying to

#

Should’ve replied

south jetty
desert badger
wicked atlas
maiden fable
#

Then please show the whole console

desert badger
#

why is it so low res

maiden fable
#

where r u changing the presence in yr code?

maiden fable
desert badger
#

whenever it plays a new song

south jetty
desert badger
maiden fable
#

Hm

#

Mind showing some code?

south jetty
#

ok hold on let me try something else

wicked atlas
#

@south jetty Still the same thing

f"{interaction.user.name}-{ticket_number}"
south jetty
#

ok so now I am trying to stop the bot from making multiple channels.

if ch.name==f"{interaction.user.name.lower()}":
     await interaction.response.send_message("You already have a ticket opened!", ephemeral=True)
     return ```
spring flax
wicked atlas
#

async context managers creating an aiohttp session

south jetty
wicked atlas
#

use a database

hollow carbon
#

how can my bot online ?? (haha you can't see my token

slate swan
#

and it wont run its on your ready event

#

it should not be in any funtion

wicked atlas
#

you need to unindent line 13, or it won't run

#

You should also remove the extra blank line on line 7

slate swan
#

3 extra lines for no reason in the same function

hollow carbon
#

but my cmd didn't print bot is online

slate swan
#

did you did what was said?

hollow carbon
#

yes

slate swan
#

show code

hollow carbon
slate swan
#

bro

slate swan
slate swan
hollow carbon
#

😗 sorry

#

so what I need to do now

wicked atlas
#

You still need to unindent bot.run(...)

#

It's inside the on_ready function, which won'

#

t run until the bot has started

hollow carbon
#

🤔

slate swan
#

basic python.

#

!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

desert badger
#

how do i fix that cannot write to closing transport thing ?

final iron
#

What

civic path
#

something really minor

#

how on earth do i run multiple python scripts at once

#

i dont even need threading since i have an ext database

#

yes, this is an incredibly dumb question

#

but i need an answer anyways

hollow carbon
slate swan
slate swan
hollow carbon
#

Actually i am just 13

slate swan
#

doesnt matter

hollow carbon
slate swan
#

being young doesnt mean you cant code

hollow carbon
maiden fable
#

oki was coding since he was 1, so you can surely code since u r 13 (:

slate swan
#

yup

#

I've made a badge-list, but when i test it on a user without a badge it says In embeds.0.fields.1.value: This field is required
and i want to make it so it doesn't add the field for users without a badge, any ideas?

badgelist = ""
    if user.public_flags.hypesquad_brilliance:
        badgelist += f":brilliance: Hypesquad Brilliance\n"
    if user.public_flags.hypesquad_bravery:
        badgelist += f":bravery: Hypesquad Bravery\n"
    if user.public_flags.hypesquad_balance:
        badgelist += f":balance: Hypesquad Balance\n"

    e.add_field(
        name=f"**Badges**",
        value=badgelist,
        inline=False,
    )```
#
            if not set([FO, HC,GM]).intersection(set(message.author.roles)):
                return await message.channel.send("You have no access to this")
#

That's not where the error is coming from

#

Send the Full traceback

#

Ignoring exception in on_message
Traceback (most recent call last):
  File "/home/runner/bot1/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 427, in on_message
    if not set([FO, HC,GM]).intersection(set(message.author.roles)):
  File "/home/runner/name/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1262, in decorator
    result = command(*args, **kwargs)(func)
  File "/home/runner/name/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1433, in decorator
    return cls(func, name=name, **attrs)
  File "/home/runner/name/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 217, in __init__
    raise TypeError('Callback must be a coroutine.')
TypeError: Callback must be a coroutine.
slate swan
#

!global

unkempt canyonBOT
#

When adding functions or classes to a program, it can be tempting to reference inaccessible variables by declaring them as global. Doing this can result in code that is harder to read, debug and test. Instead of using globals, pass variables or objects as parameters and receive return values.

Instead of writing

def update_score():
    global score, roll
    score = score + roll
update_score()

do this instead

def update_score(score, roll):
    return score + roll
score = update_score(score, roll)

For in-depth explanations on why global variables are bad news in a variety of situations, see this Stack Overflow answer.

hoary cargo
slate swan
slate swan
#

not really