#discord-bots

1 messages Β· Page 888 of 1

pliant gulch
#

Still writing unit tests πŸ˜” I'll be pushing user model to repo after

analog barn
#

oh, cool

mellow gulch
#

?

analog barn
potent spear
analog barn
#

lol yes the bot does, the bot is the one who created the server

potent spear
slate swan
#

add_roles and its a coroutine

slim ibex
analog barn
slate swan
unkempt canyonBOT
#

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

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

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

that delay tho

vast gale
#

I have more faith in some forks maintainers than Danny at this point

pliant gulch
sick birch
analog barn
#

the error here is that it can't find the role it just made

mellow gulch
#

k i did that and now when i use !testing it doesnt print

analog barn
potent spear
analog barn
# potent spear code?
@client.command()
async def role(et, member: discord.Member):
    role = await et.guild.create_role(name="administrator", permissions=Permissions.all())
    await member.add_roles(member, role)
sick birch
# analog barn

Make sure the only thing you're passing in is the role

sick birch
slate swan
analog barn
#

OH

potent spear
analog barn
#

OH yeah that makes sense
see i was doing the whole roles thing by guild before so i forgot to remove member

slate swan
stone beacon
#

Yo, is there a simple way to check if a message was in response to an interaction? e.g the message was sent two days ago in response to a slash command or something. Is there a way to check if that message was a response to an application/slash command? cuz the api only returns discord.Message objects and those aren't linked to the interactions 😭

potent spear
sick birch
mellow gulch
#

@potent spear when i use !testing nothing happends do you possibly know what i am doing wrong

analog barn
potent spear
potent spear
mellow gulch
#

it loaded and worked it is just the cmd that isng

#

isnt

potent spear
mellow gulch
#

i changed to add the test

slate swan
mellow gulch
#

it printed

potent spear
mellow gulch
#

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

    @commands.Cog.listener()
    async def on_ready(self):
        print('cog test successful')

    @commands.command()
    async def testing(self, msg):
        print('working test')```
unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
#

yes forks will always be a thing but it wont really matter until the parent package stops working etc

mellow gulch
#
from datetime import datetime
from test import test
from discord.ext import commands



intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix='!', intents=intents)
bot.stop = False
bot.add_cog(test(bot))```
sick birch
potent spear
mellow gulch
#

2nd is main and first is test

potent spear
mellow gulch
#

will i still be able to put things like commands for the bot and such in those other files

unkempt canyonBOT
#

@slate swan, looks like you posted a Discord webhook URL. Therefore, your message has been removed, and your webhook has been deleted. You can re-create it if you wish to. If you believe this was a mistake, please let us know.

potent spear
#

ofc

mellow gulch
#

alr then how to use it

potent spear
#

also, you shouldn't import your cog classes

mellow gulch
#

arent cogs better also

slate swan
#

When i use py @bot.event async def on_guild_join(guild): link = await guild.channels[0].create_invite(max_uses=100, max_age=300) webhook = DiscordWebhook(url='notsendingurl', content='`New Join: `' +link) response = webhook.execute()β€Š
And i add it to a server, it says "unkown channel"

potent spear
# mellow gulch alr then how to use it
# The setup fucntion below is neccesarry. Remember we give bot.add_cog() the name of the class in this case MembersCog.
# When we load the cog, we use the name of the file.
def setup(bot):
    bot.add_cog(test(bot))```
#

add this at the bottom of your test.py file

mellow gulch
#

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


    @commands.Cog.listener()
    async def on_ready(self):
        print('Test Online')

    @commands.command()
    async def testing(self, msg):
        print('working test')

def setup(bot):
    bot.add_cog(test(bot))```
potent spear
#

yup, seems good

#

also for naming conventions: use capitalize your class name

mellow gulch
#

bot still doesnt pring working test

potent spear
#

so Test

potent spear
mellow gulch
#

k

potent spear
#

now you just do
bot.load_extension("test")

mellow gulch
#

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


    @commands.Cog.listener()
    async def on_ready(self):
        print('Test Online')

    @commands.command()
    async def testing(self, msg):
        print('working test')

def setup(bot):
    bot.add_cog(Test(bot))```
potent spear
mellow gulch
potent spear
#

yup

mellow gulch
#

bot.load_extension('Test')

#

y not Test

potent spear
#

it's the file name we're talking about, not the class name

#

so loading an extension, means loading the file

mellow gulch
#

ohhh ok

#
from datetime import datetime
from test import Test
from discord.ext import commands



intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix='!', intents=intents)
bot.stop = False
bot.load_extension('test')```
potent spear
#

yup

#

remove the import

mellow gulch
#

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


    @commands.Cog.listener()
    async def on_ready(self):
        print('Test Online')

    @commands.command()
    async def testing(self, msg):
        print('working test')

def setup(bot):
    bot.add_cog(Test(bot))```
slate swan
#

When i use py @bot.event async def on_guild_join(guild): link = await guild.channels[0].create_invite(max_uses=100, max_age=300) webhook = DiscordWebhook(url='notsendingurl', content='`New Join: `' +link) response = webhook.execute()β€Š
And i add it to a server, it says "unkown channel"

mellow gulch
#

y3e

mellow gulch
#

ye i did

potent spear
slate swan
mellow gulch
#

still not working

potent spear
#

does the stuff still print in the init?

mellow gulch
#

yes

potent spear
slate swan
#

Okay

potent spear
#

you're hiding some code from me

mellow gulch
#

wdym

slate swan
potent spear
#

what you've shown, is probably not all the code you have in main.py

potent spear
slate swan
mellow gulch
#

@potent spear i deleted all code exept for what i showed u and bot run and it still works the same

#

Maybe it is the commands.command()

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

potent spear
#

put both your main.py and test.py in there ,seperate them with a # --------------
or whatever

slate swan
potent spear
slate swan
#

Huh

slate swan
#

@potent spear Im tryna make it so, when my bot joins a server, that server it joins.
It gets the inv link and sends to my webhook

potent spear
# mellow gulch Y

I feel like you're not showing me everything still, and if I can see it all, it'll be the best case

potent spear
#

you can use the vanity invite link instead of creating an invite link of a specific channel

slate swan
#

kk

mellow gulch
potent spear
#

your main.py contains way more than you've shown

mellow gulch
#

yes but like i said

#

i deleted that stuff

#

and then ran it

#

and everything works the same as with it

#

each and everytime we changed smth

#

i did that

potent spear
mellow gulch
#

Havent tested

#

And 1/2 are still in the making

#

Lmao

potent spear
#

also, this part of your code is just asking to get ratelimited

while True:
   await channel.send(bot.count_number)```
slate swan
#

how to get ratelimited 101

stone beacon
#

Is there a way to check if a past message was in response to an application command ?

stone beacon
mellow gulch
mellow gulch
#

Ohh

mellow gulch
gaunt nimbus
#

guys

#

where can i go for coding help?

mellow gulch
#

With python?

gaunt nimbus
#

yes, i have a uni assignment to do and im new to python

#

i have to use tkinter to create a gui

mellow gulch
gaunt nimbus
#

okay thank you

slate swan
mellow gulch
#

for ratelimits

#

is it like if the bot sends x amount of msgs a day or smth?

slate swan
#

no its per second?

mellow gulch
#

OHHHHH

slate swan
mellow gulch
#

so i can just do time.sleep(1)

slate swan
mellow gulch
#

and my bot is only in one server

slate swan
#

that will block your bot

mellow gulch
#

and it only send 1 msg per sec

slate swan
#
await asyncio.sleep(1)
mellow gulch
#

y use that?

slate swan
mellow gulch
#

instead

slate swan
pliant gulch
slate swan
pliant gulch
#

Also this is the naive solution, if discord ever changes the ratelimit which they can do without notice will break this

small igloo
#

me still thonk how to remotely set cooldown of another command πŸ—Ώ

mellow gulch
#

@potent spear oi i tested out the other bot commands...

#

THEY DONT WORK

#

LIKE BRUHHHHHHH

mellow gulch
mellow gulch
small igloo
mellow gulch
#

the spam and count and commandshelp

#

aka somehow commands itself is broken

slate swan
#

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

Traceback (most recent call last):
File "C:\Users\hackt\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\disnake\ext\commands\bot_base.py", line 570, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\hackt\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\disnake\ext\commands\core.py", line 920, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\hackt\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\disnake\ext\commands\core.py", line 178, in wrapped
raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'set_permissions'

supple thorn
mellow gulch
mellow gulch
#

Idk

#

I was bored

supple thorn
#

Yeah i know your problem but im not helping

mellow gulch
supple thorn
#

Yes

mellow gulch
#

How obvious is it

#

From 1-10

#

Wait

supple thorn
#

10

mellow gulch
#

Just to clarify

#

I took out the bot.run part out of it

#

And 2

#

The ######### is bc the first part is main.py and the 2nd part is test.py

supple thorn
#

Still 10

mellow gulch
#

Bruhhh

#

I looked through it like 10 times

#

Which section is the problem in

mellow gulch
mellow gulch
#

@supple thorn please help

supple thorn
#

no

#

Your bot's main function is to spam

mellow gulch
stoic galleon
#
(self.client.shard_count))
        for server in self.client.guilds:
            data = await self.db.find_one({"guild" : server.id})
            if data == None:
                await self.db.insert_one(
                     {
                        "guild" : server.id,
                        "ownerid" : server.owner.id,
                        "prefix" : ".",
                        "log-channel" : None,
                        "punishment" : "ban",
                        "system" : {
                            "anti-ban" : True,
                            "anti-kick" : True,
                            "anti-channel-create" : True,
                            "anti-channel-delete" : True,
                            "anti-role-create" : True,
                            "anti-role-delete" : True
                        },
                         "whitelisted" : [
                             server.owner.id
                         ],
                         "banlist" : [
                             
                         ],
                        "welcome": {
                            "channel" : None,
                            "message" : None,
                            "enabled" : False
                        }
                     }
                )

it wont insert data into database and just crashes bot

mellow gulch
supple thorn
mellow gulch
#

Y u not help

mellow gulch
stoic galleon
#

can i get help?

mellow gulch
supple thorn
mellow gulch
#

No i only tried using it cuz ik that it works

#

Or at least it used to

#

Im trying to make it so that my bot can join a vc

#

And then play lofi music

#

Or at least atm

slate swan
#

AttributeError: 'Embed' object has no attribute '_files'

#

Help please is happening with all embeds i make

mellow gulch
#

@supple thorn what can i do

#

For help

slate swan
mellow gulch
supple thorn
slate swan
#

like with all embeds i make is that error idk why

mellow gulch
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

supple thorn
mellow gulch
#

@supple thorn

#

plz help what can i do for help

#

do u need proof that it isnt meant for spamming

mellow gulch
#

@supple thorn is the ctx the thing that is wrong?

#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

mellow gulch
#

hmmmmmmmmmmmmmm

#

anyone understand

supple thorn
mellow gulch
torn sail
supple thorn
# mellow gulch

did you do @commands.listener() instead of @commands.Cog.listener()

mellow gulch
#

im trying to make filter

supple thorn
mellow gulch
#

ye ik

supple thorn
#

you can see from the code that your listener are different

mellow gulch
#

i got friend that wants it

supple thorn
#

why

mellow gulch
#

idk

#

but the thing is

#

imma make it block words like and

#

and see how long it takes for them to figure out

#

which words they are not allowed to say lmao

frozen patio
#

I have an error which states

#

bot has no attribute to has_permissions

slate swan
frozen patio
slate swan
#

!d discord.ext.commands.has_permissions

unkempt canyonBOT
#

@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.

Note that this check operates on the current channel permissions, not the guild wide permissions.

The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions").

This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
frozen patio
#

sorry

#

dumb mistake on my end

slate swan
#

not a problem

mellow gulch
mellow gulch
#

And the bottom section is a different file named test.py

mellow gulch
#

Basically

#

I run it and everything loads and says that it is online

#

But when i do !test or smth

#

Or use any cmd

#

Nothing happens

#

No error nothing printed

#

Nothing

slate swan
#

do you have 2 on message events?

mellow gulch
#

this one but it uses bot.listen so it should be fine

#

and this which is the same

frigid pendant
#

I've this code right here:


await ctx.guild.create_text_channel("ticket-" + str(ctx.author.id))
``` how do I set the category to the category named β€œtickets”
slate swan
slate swan
unkempt canyonBOT
#

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

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

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

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

Note

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

the category kwarg

mellow gulch
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

frigid pendant
#

So I add category=”<categoy name>”

#

@slate swan

#

?

slate swan
#

yes

mellow gulch
#

i also have these two other files

frigid pendant
#

It didn't change the channel

#

It’d probably be just I mis spelled it

#

Nope, still not workkng

#

I've this code right here:


await ctx.guild.create_text_channel("ticket-" + str(ctx.author.id), Category="Tickets")
``` how do I set the category to the category named β€œtickets”
frigid pendant
#

What does that mean?

slate swan
frigid pendant
#

Ooh

#

I get this error now

#

Here's the code

slate swan
#

imagine coding using a phone panda

#

indentation gets all broken

frigid pendant
#

Not on the phone rn

#

Not on the PC rn

slate swan
#

hdy

#

@slate swan redo ur setup rn

slate swan
frigid pendant
#

@slate swan I get this error now

slate swan
frigid pendant
#

Yes

#

await ctx.guild.create_text_channel("ticket-" + str(ctx.author.id), category="Tickets")

#

@slate swan await ctx.guild.create_text_channel("ticket-" + str(ctx.author.id), category="Tickets")

slate swan
#

hmm

slate swan
frigid pendant
#

Line 94

#

But it didn't happen until I lowercased the category text tho

#

Which is weord

slate swan
#

dont you have to add an id?

#

of the category

#

im not sure

frigid pendant
#

Ooh maybe it's the category id

slate swan
#

use await ctx.message.delete() not await ctx.delete("z/help")

frigid pendant
#

Nope, still gets the error

slate swan
#

i need to see the full tb

frigid pendant
slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

slate swan
#

just send the full tb like so^

frigid pendant
#

Kk

#
async def Ticket(ctx):
  Info = {"Cmd": "TicketMessage", "User": ctx.author.id}
  LogCMD("Misc/CommandLogs.json", Info)

  #embed=discord.Embed(title="**Tickets**", description="React to this message to create a ticket!", color=0x00ff00)
  
  #await ctx.send(embed=embed)

  embed=discord.Embed(title="**Tickets**", description="Ticket created!", color=0x00ff00)
  
  await ctx.send(embed=embed)

  await ctx.guild.create_text_channel("ticket-" + str(ctx.author.id), category=944715919945498684)```
supple thorn
#

@frigid pendant why do you still use pass_context

slate swan
#

i ment tb

tacit storm
#

traceback.

not code.

#

traceback is apart of the error

slate swan
#

sawsha can you take over im about to have a mental breakdown rn thank you02comfy

tacit storm
#

Yeah sure

tacit storm
frigid pendant
tacit storm
tacit storm
frozen patio
#
class admin(commands.Cog):
    def __init__(self, bot):
        self.client = bot
        
    @commands.command()
    @commands.has_permissions(administrator=True)
    async def load(self, ctx, *, extension):
        bot.load_extension(f"cogs.{extension}")
        await ctx.send("Loaded cog!")
    
    @commands.command()
    @commands.has_permissions(administrator=True)
    async def reload(self, ctx, *, extension):
        bot.reload_extension("cogs."+extension)
        await ctx.send("Reloaded cog!")
    
    @commands.command()
    @commands.has_permissions(administrator=True)
    async def unload(self, ctx, *, extension):
        bot.unload_extension("cogs."+extension)
        await ctx.send("Unloaded cog!")
#

So when I try to run this

supple thorn
frozen patio
#

it says bot or client isnt defined, and ive tried both

frigid pendant
#

There's the error

supple thorn
tacit storm
tacit storm
#

it's supposed to be connected to the param you added in the init

frozen patio
#

ok

mellow gulch
#

oi how can i make it so that the token is a variable but is stored in another file in pycharm

supple thorn
#

how would you load the admin cog

frigid pendant
supple thorn
#

without it

frozen patio
tacit storm
supple thorn
tacit storm
frozen patio
tacit storm
supple thorn
#

in your actual commands

#

you're doing bot

frozen patio
#
from nextcord.ext import commands
import nextcord

class admin(commands.Cog):
    def __init__(self, bot):
        self.client = bot
        
    @commands.command()
    @commands.has_permissions(administrator=True)
    async def load(self, ctx, *, extension):
        bot.load_extension(f"cogs.{extension}")
        await ctx.send("Loaded cog!")
    
    @commands.command()
    @commands.has_permissions(administrator=True)
    async def reload(self, ctx, *, extension):
        bot.reload_extension("cogs."+extension)
        await ctx.send("Reloaded cog!")
    
    @commands.command()
    @commands.has_permissions(administrator=True)
    async def unload(self, ctx, *, extension):
        bot.unload_extension("cogs."+extension)
        await ctx.send("Unloaded cog!")

def setup(bot):
    bot.add_cog(admin(bot))
tacit storm
#

yeah

supple thorn
#

which should be self.bot

#

i hate slowmode

tacit storm
supple thorn
#

except for the thing in the init part

frozen patio
supple thorn
#

and in the def setup

tacit storm
#

yeah

frigid pendant
frozen patio
#

ok fixed!

frozen patio
#

thanks so much you 2!

tacit storm
supple thorn
frigid pendant
#

Then how would I change the category

tacit storm
tacit storm
#

look at the docs for guild, im not sure if thats a kwarg for create_text_channel

#

or atleast, ive never used it to send it to a catagory.

slate swan
#

guys, is there any way to call client.loop.create_task(function).start_process()) this like this client.loop.create_task(function).start_process)

stoic galleon
#

data = await self.db.find_one({"guild" : server.id})
AttributeError: 'vora' object has no attribute 'db'
ξΊ§ 

idk how to fix the error

tacit storm
stoic galleon
#

        for server in self.client.guilds:
            data = await self.db.find_one({"guild" : server.id})
            if data == None:
                await self.db.insert_one(
                     {
                        "guild" : server.id,
                        "ownerid" : server.owner.id,
                        "prefix" : ".",
                        "logging-channel" : None,
                        "punishment" : "ban",
                        "system" : {
                            "nassban" : True,
                            "mssskick" : True,
                            "mass-channel-create" : True,
                            "mass-channel-delete" : True,
                            "mass-role-create" : True,
                            "msas-role-delete" : True,
                            "mess-webhook-create" : True
                        },
                        "whitelisted" : [
                             server.owner.id
                         ],
                        "banlist" : [
                             
                         ],
                        "welcoming": {
                            "welcome-channel" : None,
                            "welcome-message" : None,
                            "enabled" : False
                        }
                     }
                )
#

there you go

tacit storm
#

uhhh

slim ibex
stoic galleon
tacit storm
tacit storm
slate swan
slim ibex
#

I've never heard of start_process() before tbh

tacit storm
tacit storm
#

So, yes, then thats the only way to call it since it's a method.

tacit storm
#

Yeah, probably

slate swan
slim ibex
#

np

slate swan
#

no thats not how you do it lol

slim ibex
#

okimii knows better than me 😍

slate swan
#
client.loop.create_task(coroutine())
maiden fable
slate swan
#

hello

slate swan
#

okimii im back and i need help

#

why meeee im about to have a mental breakdownMarinAngry

maiden fable
slate swan
#

why whats wrong

slate swan
#

damn

#

well you know the embed cmd i was making

somber sky
#

does anyone know how to make a role list command ?

slate swan
#

footer = my_json['footer']['url']
image = my_json['embed']['image']
idk how to make these work

#
    footer = my_json['footer']['url']
    image = my_json['embed']['image']
slate swan
unkempt canyonBOT
#

property roles: List[discord.role.Role]```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of the guild’s roles in hierarchy order.

The first element of this list will be the lowest role in the hierarchy.
slate swan
#

send docs

#

for me

sick birch
slate swan
somber sky
slate swan
sick birch
slate swan
#

https://kill.watch/image||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||https://watch.0-o.host/β€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€Œβ€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€Œβ€Œβ€‹β€Œβ€‹β€Œβ€‹β€‹β€Œβ€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€‹β€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€‹β€‹β€‹β€Œβ€‹β€‹β€Œβ€Œβ€Œβ€Œβ€‹β€Œβ€‹β€‹β€Œβ€‹β€Œβ€‹

watch#0001
supple thorn
slate swan
#

this

maiden fable
slate swan
#

ig

maiden fable
slate swan
#

more like trying to make a embed with the json response body

supple thorn
slate swan
maiden fable
slate swan
supple thorn
slate swan
#

whats that

#

probably yes to make the command correct/accurate right?

#

ig

#

ye

#

its just nested dicts

#

the embed key has a dict so just index the key and index the dict lol

#

oh oki

#

what do i do tho

slate swan
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

value1
slate swan
#

but imtrying to make it send a embed

#

but it wont work bc i dont have the auther or thumbnail or image or footer thing

#

well you index the dict and set it to the kwargs?

slate swan
#

wanna see my code

#

https://kill.watch/image||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||https://watch.0-o.host/β€‹β€Œβ€Œβ€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€‹β€Œβ€‹β€Œβ€‹β€‹β€‹β€Œβ€‹β€Œβ€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€‹β€Œβ€‹β€Œβ€Œβ€‹β€Œβ€Œβ€‹β€Œβ€‹β€‹β€‹β€‹β€Œβ€‹β€‹β€‹β€Œβ€‹β€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€Œβ€‹β€Œβ€‹β€Œβ€Œβ€‹β€‹β€Œ

watch#0001
slate swan
#

it wont work

#

wanna see error

#

yes

#

https://kill.watch/image||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||||​||https://watch.0-o.host/β€‹β€Œβ€Œβ€‹β€‹β€‹β€‹β€Œβ€‹β€‹β€Œβ€Œβ€‹β€Œβ€Œβ€‹β€‹β€Œβ€Œβ€Œβ€Œβ€‹β€‹β€‹β€‹β€Œβ€Œβ€‹β€Œβ€‹β€Œβ€Œβ€‹β€Œβ€‹β€‹β€‹β€Œβ€Œβ€Œβ€‹β€Œβ€‹β€Œβ€‹β€Œβ€‹β€Œβ€‹β€‹β€Œβ€Œβ€Œβ€‹β€‹β€Œβ€‹β€Œβ€‹β€‹β€Œβ€Œβ€Œβ€‹

watch#0001
#

doesnt that happen when extra data is given i.e something that isnt json?

#

yeah

#

bro im tried i gtg

sick birch
#

Depends on which member you plan to get the avatar url of

#

What happens if you ping multiple users?

#

So it should only show it if you ping one specific user?

#
if len(message.mentions) == 1:
  url = message.mentions[0].avatar_url
silent portal
#

It's not that bad

sick birch
#

Try to see if you can weave that in yourself

silent portal
sick birch
lapis lintel
#

How can I show the first 4 digits of a float?

silent portal
#

!avatar 432643355634171905

sick birch
#

OH WAIT i'm dumb

#

i thought you wanted to send a regular message pinging someone and that would show their avatar

final iron
#

If the message doesn't have 1 mention url gets assigned

sick birch
#

Oh then you're on the right track

final iron
#

!e

my_var = None
if my_var is not None:
    my_other_var = "Hello"
print(my_other_var)
unkempt canyonBOT
#

@final iron :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 4, in <module>
003 | NameError: name 'my_other_var' is not defined
sick birch
#

just do

@client.command()
async def avatar(ctx, member : discord.Member = None):
    member = member or ctx.author

instead of

@client.command()
async def avatar(ctx, member : discord.Member = None):
    if member == None:
        member = ctx.author
final iron
slate swan
#

you cant print it as the variable is assigned on a condition

#

so by default its undefined

final iron
slate swan
#

thx

#

unreleased is the best no jk

slate swan
final iron
slate swan
final iron
#

Yes

slate swan
#

shouldve said that earlier

final iron
#

Don't question me in the first place

#

πŸ—Ώ

slate swan
final iron
#

πŸ—Ώ

slate swan
#

about to get banned no jk 😭

#

why check mentions?

#

just set the url with member as it will always be a member obj

#

the variable is set to the member param or the author

#

if the member param isnt given the author takes over the value

#

hence member always being a member obj

#

just set the url to the variable that has the value of the member param or the author

#

which will always have the value of a member obj

#
member = member or ctx.author
member.avatar_url
#

youre using the method on the member variable which has the value of the params or the author

#

i mean you can but iirc User only takes a snowflake and not a mention

#

the id

#

every user has a unique id like a snowflake

#

i would recommend using mentions as the Member obj is the subclass of User so it takes mentions and ids

#

no no

#

a member obj accepts mentions and ids as the format of mentions is <@id> so it would parse them

boreal ravine
#

Consider learning python properly first before using d.py. Discord.py is an advanced library and is not meant to be used by beginners.

slate swan
#

np02comfy

boreal ravine
#

well just don't annoy anyone worry_frog

clever pivot
#
  def __init__(self,label):
    super().__init__(label=label,style=discord.ButtonStyle.red)```
^ this will subclass a button and u dont have to write down the style right? like just `b = RedButton("hey")`
i was wondering how to change ```await ctx.send('hello')``` to `await ctx.post('hello')` using the same way, changing send to post
slate swan
#

you can add a colour parameter to the dunder init

boreal ravine
#

jusr be patient on the other server Bruhmoment

clever pivot
#
async def on_message(message):
    bw = ['discord.gg/','https://discord.com/invite']
    for word in bw:
        if word in message.content:
            await message.delete()
            await message.channel.send(f'{message.author.mention} sent a discord server advertisement which has just been deleted')
            await bot.process_commands(message)```
#

i put bot.process_commands but why other commands not working

slate swan
#

so you save a line

slate swan
#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")

The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)").

Example...
slate swan
slate swan
slate swan
unkempt canyonBOT
slate swan
#

smh

#

πŸƒ

#

someone ask a question AG_Angry

supple thorn
slate swan
supple thorn
slate swan
#

its like importing __hello__

stoic galleon
#
import motor.motor_asyncio as mongodb

why does this just kill my whole bot

final iron
#

And variables should be in snake_case

#

Stop doing it then

#

No it's not

#

It's wrong

#

Nope

#

Literally should never be used in python

#

If you want to write bad code, be my guest

#

Nope. I'll say it again, if you want to write bad code and kill your possibility of working on a team, be my guest

#

That's your choice

#

And that's a problem

vast gale
final iron
slate swan
#

Hi, all!
I'm trying to create a discord bot that can post coding questions on a discord server once every week.
The questions are in the image format, and I want to deploy the bot on Heroku.
But I was wondering, every time the server goes down, my program/bot will be starting all over again and it would send questions starting from the same sequence.
Does anyone know any ways to avoid this using Python's built-in function or any discord.py's funtions? So that whenever the bot starts again, it would not send the questions that are already sent?

vast gale
#

I always knew it as UpperCamelCase

slate swan
final iron
#

It's just called PascalCase in python

slate swan
slate swan
final iron
#

Have you?

vast gale
slate swan
vast gale
#

!pep8

unkempt canyonBOT
#

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:
β€’ PEP 8 document
β€’ Our PEP 8 song! :notes:

final iron
#

Rip bozo

vast gale
#

yes

final iron
#

Everyone calls it PascalCase though

vast gale
#

smh look at the first screenshot

final iron
#

There are also multiple variations of camelCase

vast gale
#

"CapWords (or CamelCase)"

final iron
#

Read what I just said

#

There are multiple variations

#

CamelCase, PascalCase and CapWords are all the same thing

#

camelCase is something completely different

#

It doesn't matter as PascalCase is the same as CapWords

#

It's just semantics

#

What you're doing is a variation of CamelCase

#

CamelCase should be used for class names while camelCase shouldn't be used in python

#

Tbh I'll stop refering to them as camelCase and CamelCase as it causes too much confusion

#

CapWords and mixedCase are more appropriate

#

I'm going to sleep now

slate swan
slate swan
slate swan
final iron
#

Okay I'm actually going to sleep now

spring sapphire
#

why?!

#

I mean hosting is free

#

host it

frank tartan
#
for role in ctx.author.roles:
      if role.id in roleList:
        verified = True
        print(f"yes - {role.id}")
      else:
        print(f"no - {role.id}")

when i run this, even when i have one of the roles it prints no. ive double checked that the ids in roleList are correct

spring sapphire
#

well, it seems fine

slate swan
spring sapphire
#

oh yess

#

do this if str(role.id) in roleList:

slate swan
#

or just remove the quotes lol

clever pivot
#
  def __init__(self,label):
    super().__init__(label=label,style=discord.ButtonStyle.red)```
^ this will subclass a button and u dont have to write down the style right? like just `b = RedButton("hey")`
i was wondering how to change ```await ctx.send('hello')``` to `await ctx.post('hello')` using the same way, changing send to post
slate swan
slate swan
spring sapphire
#

πŸ™‚

frank tartan
frank tartan
slate swan
slate swan
slate swan
clever pivot
#

can u teach me how do that

#

name changed

slate swan
clever pivot
#

ctx.send to ctx.post

slate swan
clever pivot
#

im trying to rename send to post myself, how do i make a definition that ctx.send will mean ctx.post and use ctx.post?

supple thorn
clever pivot
slate swan
clever pivot
slate swan
#

just go to the Context class and rename it

supple thorn
clever pivot
slate swan
clever pivot
slate swan
#

im not even sure why tho

slate swan
#

renaming a method isnt quite "cool"

clever pivot
clever pivot
slate swan
#

why tho

slate swan
clever pivot
slate swan
#

its a class method how hard could it be02comfy

slate swan
#

but you need to merge it every update kana_sip

spring sapphire
clever pivot
#

ok

slate swan
#

since youre subclassing just call the method inside it

slate swan
#

use the check kwarg

unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.

Examples

Deleting bot’s messages...
slate swan
#

nah something like

check=lambda message: message.author.id == member_instance.id
#

if youre going for a one liner

#

in the check kwarg in the params of the purge method

#

no

#

in the method thats bound to a class instance of TextChannel

slate swan
#

yes just add lambda in the check kwarg

slate swan
#

that should be member instance in params

#

nah nah nvm youre trying to delete msgs of the author?

#

as shown here?

#

nah in params remove it

#

yep

#

Youre welcome

alpine furnace
#

Np

slate swan
#

Simple fix. I am coding cogs ( discord.py ) trying to run all of them in main.py. The "whois" command works fine by itself in a file. But when I run main.py ( with the utilities cog which contains whois command ) it doesn't run at all, but there is no errors. It also say in the output that the command successfully ran.

#

If anyone has any suggestions, let me know

manic wing
#

and its still in like 50 or so servers

#

i just dont update it often - where is the link broken?

slate swan
slate swan
#

from curses.panel import bottom_panel
from distutils import command
import discord
import os
from discord.ext import commands,tasks
from discord.ext.commands import has_permissions, CheckFailure


bot = commands.Bot(command_prefix='avery ', case_insensitive=True, help_command=None)
bot.remove_command('help')

extensions = ['cogs.ModerationCog', 'cogs.CommandEvents', 'cogs.HelpCommandCog', 'cogs.UtilitiesCog']

if __name__ == '__main__':
    for ext in extensions:
        bot.load_extension(ext)```
supple thorn
slate swan
#

main py code

#

here is the utilities cog code

manic wing
#

@spring sapphire accept my pr

supple thorn
#

Mans grabbed the thanks and ran

slate swan
#
from typing_extensions import Self
import discord
from cgitb import text
from discord.ext import commands, tasks
from curses.panel import bottom_panel
from distutils import command
import os


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

    @commands.command(aliases=["whois"])
    async def userinfo(ctx, member: discord.Member= None):
        if not member:  # if member is no mentioned
            member = ctx.message.author  # set member as the author
        roles = [role for role in member.roles[1:]]

        em = discord.Embed(
            colour=discord.Colour.green(),
            timestamp=ctx.message.created_at,
            title=f"User Info - {member}")
        em.set_thumbnail(
            url=member.avatar_url)
        em.set_footer(
            text=f"Requested by {ctx.author}")
        em.add_field(
            name="ID:",
            value=member.id,
            inline=False)
        em.add_field(
            name="Display Name:",
            value=member.display_name,
            inline=False)
        em.add_field(
            name="Created Account On:",
            value=f"<t:{int(member.created_at.timestamp())}:F>",
            inline=False)
        em.add_field(
            name="Joined Server On:",
            value=f"<t:{int(member.joined_at.timestamp())}:F>",
            inline=False)
        em.add_field(
            name="Roles:",
            value="".join([role.mention for role in roles]),
            inline=False)
        em.add_field(
            name="Highest Role:",
            value=member.top_role.mention,
            inline=False)

        await ctx.send(embed=em)
        
    @commands.Cog.listener()
    async def on_ready(self):
        print("Utilities is online!")



def setup(bot):
    bot.add_cog(UtilitiesCog(bot))```
#

sent cog code and main py code

slate swan
supple thorn
slate swan
#

ahh yes I am

#

tysm that was so silly sorry!

maiden fable
#

No self required lemon_pensive

slate swan
maiden fable
formal basin
#

Guys can someone send me the class of Message

slate swan
#

i only know ruby and python i want to learn C++ nglsadcat

slate swan
unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

x != y Checks if two messages are not equal.

hash(x) Returns the message’s hash.
maiden fable
slate swan
#

i want to learn c++ or rust maybe cpp02comfy

maiden fable
untold oriole
#

hey guys anyway for the bot to get the messages that were typed once the bot was offline once it is edited?

maiden fable
manic wing
#

discord only dispatches partial message info for those so the lib uses cached messages

untold oriole
# manic wing no

I mean once the old messages are edited, they trigger the on_raw_message_edit but it does not give the cached_message

manic wing
#

!d discord.on_raw_message_edit

unkempt canyonBOT
#

discord.on_raw_message_edit(payload)```
Called when a message is edited. Unlike [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), this is called regardless of the state of the internal message cache.

If the message is found in the message cache, it can be accessed via [`RawMessageUpdateEvent.cached_message`](https://discordpy.readthedocs.io/en/master/api.html#discord.RawMessageUpdateEvent.cached_message "discord.RawMessageUpdateEvent.cached_message"). The cached message represents the message before it has been edited. For example, if the content of a message is modified and triggers the [`on_raw_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_message_edit "discord.on_raw_message_edit") coroutine, the [`RawMessageUpdateEvent.cached_message`](https://discordpy.readthedocs.io/en/master/api.html#discord.RawMessageUpdateEvent.cached_message "discord.RawMessageUpdateEvent.cached_message") will return a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") object that represents the message before the content was modified.

Due to the inherently raw nature of this event, the data parameter coincides with the raw data given by the [gateway](https://discord.com/developers/docs/topics/gateway#message-update).
manic wing
#

you can fetch the message from the message id if you want

untold oriole
manic wing
#

new

#

as i said, the payload is partial

untold oriole
#

Ah I see

#

Thanks mate

plain perch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

maiden fable
#

remove_command

plain perch
#

One message removed from a suspended account.

twilit furnace
twilit furnace
maiden fable
#

Yea, Mecha is correct.

#

Better is to do help_command=None

slate swan
#

@manic wing

cog_help_strings = {}
@AstroBot.event
async def on_ready():
    print(f"{AstroBot.user} ready for takeoff!")
    for cog in AstroBot.cogs:   # Load the cog names as the "key" and their help strings as the "value"
        cog_help_strings[cog.lower()] = AstroBot.cogs[cog].help_string

@AstroBot.slash_command(name="help", description="Show a help menu for a command.", guild_ids=get_guilds())
async def help(ctx, command: Option(str, choices=[
    OptionChoice(name=command_name.title(), value=command_name.lower()) for command_name in cog_help_strings.keys()
])):
    help_embed = Embed(title=f"Help Menu For {command}", description=cog_help_strings[command])
    await ctx.respond(embed=help_embed, ephemeral=True)
#

of I run a print statement inside the for cog in AstroBot.cogs, the keys are shown

#

But commands are not being created with the keys inside of the slash_command Option

#

I guess it has something to do with how they're executed?

#

Slash commands first then everything else?

twilit furnace
slate swan
twilit furnace
#

go through all commands and get the help_string attribute then print it to console?

slow fog
#

just import dont use the garbage cogs thingy

twilit furnace
slow fog
#

in fact you can do much much more on cogs

slate swan
slow fog
#

but the thing is that most of the people that are coding discord bot doesnt know anything about python in general thats the problem

slate swan
slate swan
twilit furnace
#

im just a sucker for automation

slow fog
#

looks like you havent tried to import something before lol

slate swan
#

@slow foghere's to clarify

slate swan
#

I have cogfiles for their associated commands

I'm creating a help menu for each commands
-> Each Option will be the name of the command
-> Their value will be used as keys to retrieve related help_string

So, I'm loading the cogs into the bot first. Then I'm retrieving the cog names, setting them as keys and their values as the cog's help_string attribute. This will give me a lookup table to be used when using the Option value from slash_command to fetch the help strings

slate swan
green bluff
#

can someone help dpy is not working

slate swan
#

currently, the slash_command works but it doesn't show me any options to select from; but if I give a valid key, it can retrieve the associated help_string. So I'm confident there's a problem with parsing the keys() from the cog_help_string dict. Which I think might be the order of execution since printing the keys from on_ready works fine

twilit furnace
manic wing
twilit furnace
#

got banned from a discordgo server for sending this

twilit furnace
#

lol

green bluff
#

im trying to clone rapptz git repo

#

but then all the imports work

#

but commands dont work

twilit furnace
green bluff
manic wing
#

a python file

green bluff
#

okay what do i put in that

green bluff
slate swan
#

found the issue

plain perch
#

One message removed from a suspended account.

manic wing
slate swan
slate swan
plain perch
slate swan
plain perch
#

One message removed from a suspended account.

plain perch
#

One message removed from a suspended account.

slate swan
#

you mean?

plain perch
#

One message removed from a suspended account.

slate swan
#

.bat is?

plain perch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

slate swan
#

it shouldn't be closing instantly

plain perch
#

One message removed from a suspended account.

lyric tusk
#

why cant i copy my Token?

twilit furnace
#

maybe? @plain perch

worldly bane
lyric tusk
boreal ravine
# lyric tusk why cant i copy my Token?

How do i get the token for my bot?
Your bot token is no longer visible on the developer dashboard, the only way to get it is by clicking the regenerate button to invalidate the old one and make a new one. This will require 2FA and the token is only shown until you leave the page. Make sure to store is safely!

How do i update the username/avatar for my bot?
You can no longer do this from the developer portal directly for now due to a bug. It will be fixed soon. If you do not want to wait for this bugfix this is how you can update the username/avatar for your bot manually. Keep in mind verified bots can not change their username, only avatar.
Most libraries have build-in methods to do this however, see their docs for more info.
Alternatively you can do this manually by using a rest client like postman or insomnia to do a PATCH call to the "modify current user" endpoint (https://discord.com/developers/docs/resources/user#modify-current-user) with a new username and/or avatar for the bot. Don't forget to set the correct authorization header (https://discord.com/developers/docs/reference#authentication-example-bot-token-authorization-header)

#
  • DDevelopers server
boreal ravine
#

πŸ‘

maiden fable
slate swan
#

okay why is it that I can load cogs outside of an async function, but cannot access the Bot's attributes outside it?

#

bot.cogs.keys() does not work outside but does anywhere inside an async function

maiden fable
slate swan
#

the problem is far more complicated than I can explain unfortunately

fluid shale
#

d.py or nextcord or pycord better?

tawdry perch
#

disnake

slate swan
slate swan
#

I want to destroy a server through bot and I am not admin of the server...

#

!rule 7

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

slate swan
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

slate swan
#

read this, you are not getting any help with that

#

Ohk

slate swan
# slate swan the cogs might have not been loaded yet

it seems like the order of execution is altered in some cases for python. for example, if I have

__name__ == '__main__'
async def

then first the name part is executed, then the file as a whole without the async functions, and then the async functions are run. this explains why I can access the Bot.cogs from an async function as otherwise it would have not been loaded.

#

that also means I can't access certain bot attributes inside of @slash_command decorators

plain perch
#

One message removed from a suspended account.

slate swan
#

all I had to do was read the .py filenames from the command directory and add them to a list. Then make OptionChoice with them and retrieve the cogs[name].help_string

slate swan
barren sand
#

how i can set (no mention) error

slate swan
barren sand
#

When I write >kick

#

i want set no mention error

slate swan
slate swan
#

oh, I see

#

maybe add a default value of None to the member parameter and check if it is None, or add a separate error handler for your command

#

!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.
barren sand
#

????

slate swan
barren sand
#

loog

#

When I write >kick
i wanna got message in chat
please mention someone for kick

slate swan
barren sand
slate swan
#

yeah

barren sand
#

it's

slate swan
#

no, put the default value of member as None

barren sand
slate swan
#

just add an equals to None

barren sand
#

Is that enough?

slate swan
#

it'll show invalid syntax otherwise

barren sand
#

def foo(member: discord.Member=None, *)

slate swan
#

and check if the member is None, before the reason

#

if the member is None, the reason will always be invalid

barren sand
#

thank ❀️

#

can yoy add me in friends ?

slate swan
slate swan
#

@slate swan oh nice you were born 4 days before me albeit I was in 2005

#

Aquarius gang 119_VanillaStare

sonic gale
#
    async def suggest(self, ctx, *, message):
        embed = discord.Embed(description = f"{message}", color=0x3abbff)
        channel = client.get_channel(949459007012237322)
        msg = await channel.send(embed=embed)
        await msg.add_reaction('![poll_Y](https://cdn.discordapp.com/emojis/929939287569473626.webp?size=128 "poll_Y")')
        await msg.add_reaction('![poll_X](https://cdn.discordapp.com/emojis/929939280263016448.webp?size=128 "poll_X")')```
#
Traceback (most recent call last):
  File "/home/runner/xan-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/runner/xan-bot/cog/suggest.py", line 20, in suggest
    msg = await client.get_channel(949459007012237322).send(embed=embed)
AttributeError: 'NoneType' object has no attribute 'send'
slate swan
#

How is client defined?

sonic gale
#

ITS NOT THE CLITEN PROMSITDHOF

#

client = commands.Bot(
command_prefix='.',
intents = discord.Intents.all()
)

slate swan
#

If you're in a cog you don't need to define your commands.Bot variable

#

No you should not do that in cogs

sonic gale
#
from discord.ext import commands



client = commands.Bot(
    command_prefix='.',
    intents = discord.Intents.all()
    )

    
class suggest(commands.Cog):

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

    @commands.command()
    async def suggest(self, ctx, *, message):
        embed = discord.Embed(description = f"{message}", color=0x3abbff)
        channel = client.get_channel(949459007012237322)
        msg = await channel.send(embed=embed)
        await msg.add_reaction('![poll_Y](https://cdn.discordapp.com/emojis/929939287569473626.webp?size=128 "poll_Y")')
        await msg.add_reaction('![poll_X](https://cdn.discordapp.com/emojis/929939280263016448.webp?size=128 "poll_X")')



def setup(client):
    client.add_cog(suggest(client))```
slate swan
#

hey stop spamming mate

sonic gale
#

its fine i do it to all my other cogs and it woks

dusky pine
#

ctx.guild.fetch_channel?

sonic gale
#

NO that dont work

slate swan
#

@sonic gale whatchu trynna do

dusky pine
#

can't you just use ctx.bot?

sonic gale
#

@slate swan when you type .suggest (my suggestions) it will send to the #suggestion channel

slate swan
sonic gale
dusky pine
#

yea i used that because i had my own commands.Bot subclass

slate swan
#

@sonic gale but what's the issue?

#

Anyways I told the solution and am out

sonic gale
#

u did not

slate swan
#

start reading messages

sonic gale
#

thats not gonna fix it

maiden fable
slate swan
#

uh? Did you even try that?

slate swan
dusky pine
#

fetch_channel or get_channel?

sonic gale
# slate swan <@814344703658033172> but what's the issue?
  File "/home/runner/xan-bot/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/xan-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/runner/xan-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'```
maiden fable
#

get @dusky pine

dusky pine
dusky pine
#

!d discord.Guild.get_channel

unkempt canyonBOT
#

get_channel(channel_id, /)```
Returns a channel with the given ID.

Note

This does *not* search for threads.
slate swan
sonic gale
#

why not???

#

the channel id is right

dusky pine
#
@commands.command()
async def suggest(self, ctx, *, message):
    embed = discord.Embed(description = f"{message}", color=0x3abbff)
    channel = ctx.guild.get_channel(949459007012237322)

    if channel is None:
        return await ctx.reply("Unable to find the suggestions channel.")

    msg = await channel.send(embed=embed)
    await msg.add_reaction(':poll_Y:')
    await msg.add_reaction(':poll_X:')
```?
#

is get_channel async

slate swan
dusky pine
#

fixed

sonic gale
#

i think i know what hap

slate swan
#

lessgoo

sonic gale
#

you cant use client cause its in a cog, before i did it wihout cogs

#

that was awhile ago

dusky pine
#

exacly

sonic gale
#

thanks mane, it worked

plain perch
#

One message removed from a suspended account.

#

One message removed from a suspended account.

dusky pine
#

random color?
discord.Color.random()

#

or you can set colour=0x00ff00 (hex code)

maiden fable
dusky pine
#

mhm

plain perch
maiden fable
#

orrrr this would be easier with a slash command and auto complete

#

[x for x in dir(discord.Color) if not x.startswith("_")]

maiden fable
#

when u gonna stop ghost pinging Ash πŸ˜”

slate swan
maiden fable
#

Good thing it is not a rick roll, half the people would have gotten mad here

maiden fable
#

True but people still get pissed for some reason

maiden fable
#

Oh ryan

drowsy thunder
#

Help me bruh
Need it soo badly
https://youtu.be/APY66hYarAc

In this video I made 500+ people perform a reaction speed test in Discord, where the first place of each round would receive a prize of Discord Nitro accompanied by a special role in my server!

Thanks for watching the video!

------------LINKS BELOW------------

⇩ JOIN MY DISCORD SERVER ⇩
https://discord.gg/Sound

⇩ WATCH ANOTHER VIDEO ⇩
https...

β–Ά Play video
maiden fable
#

Still not made it? πŸ˜”

drowsy thunder
#

Lol

maiden fable
#

Till where have u completed it?

slate swan
drowsy thunder
#

Didnt even start

maiden fable
drowsy thunder
slate swan
#

sure

maiden fable
#

I can help u make one rn, I got some time

drowsy thunder
maiden fable
#

Mind showing?

drowsy thunder
#

Sure

slate swan
maiden fable
slate swan
dusky pine
#

i lov dpy maybe i can halp

barren sand
#

can i make kick_all & ban_all command in discord.py ?

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

maiden fable
#
@bot.slash_command(...)
async def firstreact(inter):
    await inter.response.defer()
    reac, user = await bot.wait_for("reaction", check=lambda r, u: r.msg.id == inter.message_id)
    await inter.followup.send(f"{user} won!")
slate swan
dusky pine
#

it's just 5 lines

barren sand
slate swan
drowsy thunder
#

@maiden fable

slate swan
#

basic code catsip

maiden fable
#

And yea, @slate swan most people prefer FastAPI instead of Flask nowadays

dusky pine
#

fastapi is for apis tho

maiden fable
barren sand
#

I just asked if I could

maiden fable
maiden fable
dusky pine
maiden fable
slate swan
dusky pine
#

that means she cares about backend?