#discord-bots

1 messages Β· Page 867 of 1

sick birch
#

It's imperative that you reset your bot's token

#

As fast as you can

green veldt
#

i have done that

#

when i used my play command of music, i think it left after that

#

its still there in my main server

#

​```No Category:
giveaway
gstart
help Shows this message
reroll

Type $help command for more info on a command.
You can also type $help category for more info on a category.```
why does it show this when i do $help

slate swan
modest plover
#

It's Disnake, not dpy

green veldt
slate swan
#

!d discord.ext.commands.Bot.help_command

unkempt canyonBOT
green veldt
#

ok thanks

slate swan
#

yw

slate swan
green veldt
#

outside of listeners?

slate swan
green veldt
#

client = ....

slate swan
#

in your bot variable/ class instance

slate swan
slate swan
green veldt
#

there?

slate swan
#

yes

green veldt
slate swan
green veldt
#

lol

#

the bot is responding but its sending this

discord.ext.commands.errors.CommandNotFound: Command "help" is not found```
stone beacon
#

asynchronous synchronous multisinglethreaded python script to run a discord bot from mars

#

Pleasant goodnight to all

slate swan
echo wasp
#
  1. I have a question how would i make this command check if there are more people reacted then just it self if not send a message saying not enough reactions to determine a winner? code: https://paste.pythondiscord.com/zujewocefe
vast gale
#

figured it out: ws is None, solution is waiting until connection

#

or over-engineering it like me mmlol

echo wasp
#
  1. I have another question can i keep using discord.py for the non slash commands stuff then use diskord for slash commands or will the libraries intervein and break?
echo wasp
boreal ravine
#

but if you wanna make slash commands in discord.py use slash_util

#

!pypi slash_util

unkempt canyonBOT
echo wasp
#

thank you

boreal ravine
#

πŸ‘

green veldt
#

return converter(argument)
ValueError: invalid literal for int() with base 10: '10s'

light violet
#

Which channel would i get regarding console of browser and image editing sutuff like tat

#

Infomation regarding*

echo wasp
#
  1. and my third question is i have 4 different questions the 4th question is if it is required gw or not can i have it send a message after it posts it in the other channel? if so how i tried and failed
green veldt
#

def convert(time):
pos = ["s", "m", "h", "d"]

timeDict = {"s": 1, "m": 60, "h": 3600, "d": 3600*24}

unit = time[-1]

if unit not in pos:
return -1

try:
val = int(time[:-1])
except:
return -2

return val * timeDict[unit]

light violet
#

.

echo wasp
quick gust
echo wasp
#

but thanks

#

any idea on the third question not in the dpy server?

green veldt
#

embed.set_footer(text = f"Ends {mins} minutes from now!")
this doesnt show the timer
how to show timer?

cosmic agate
#

AttributeError: 'NoneType' object has no attribute 'strip'

#

help

green veldt
#

code?

cosmic agate
#

?

green veldt
#

give code

#

part of the code where error is occuring

cosmic agate
#

its saying that its line 511 but line 511 does not exist

green veldt
#

that isnt exactly line 511

cosmic agate
#

wdym?

green veldt
#

dude

cosmic agate
#

i went through files and saw something named client.py

green veldt
#

where have you written strip?

green veldt
#

you must have made

cosmic agate
#

i made my code in replit

green veldt
#

are you using someone's command handler

cosmic agate
#

downloaded it

#

and used it on vscode

#

hmmm

green veldt
#

?

cosmic agate
#

?

quick gust
#

u are probably looking at the wrong place

#

the line number is usually near the top

cosmic agate
quick gust
#

not the code

#

the error traceback

cosmic agate
#

ok sir

#

@quick gust

visual island
#

os.getenv("TOKEN") is None

cosmic agate
#

oh ok

maiden fable
#

Hmm

broken cave
#

I want to convert this to python

#

how do I do it

#

this is actually for a football command in discord.py

maiden fable
#

And code?

slate swan
#

can i ask pycord help here

manic wing
dull terrace
#

How do you trigger functions when a class variable is changed? I.e.

class butt:
    def __init__(self, big, small, smells):
        self.big = big
        self.small = small
        self.smells = smells
    If self.big or self.small changes:
        print('changed')

test = butt(True, True, True)
### changed is printed

test.small = False
### changed is printed```
manic wing
dull terrace
#

On mobile. Auto capitalising

sick birch
dull terrace
#

πŸ’©

sick birch
#

You could be looking for __setattr__() though

#

!e

class SomeClass:
  def __setattr__(self, name, value):
    print("changed")
instance = SomeClass()
instance.attribute = "some attribute"
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

changed
alpine furnace
#

Oh yeah, and setattr too

unkempt canyonBOT
#

Hey @broken cave!

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

sick birch
#

If only python had a nice way like React.js has dependency tracking for useEffect() πŸ™

dull terrace
#

God freaking

sick birch
#

You're forgetting the underscores

#

setattr takes underscores as well

dull terrace
#

Copy and pasting on mobile

#

!e

class SomeClass:
    def __init__(self, att):
        self.att = att
    def __setattr__(self, name, value):
        print("changed")
instance = SomeClass('test')
instance.att = "test2"β€Šβ€Š```
unkempt canyonBOT
#

@dull terrace :white_check_mark: Your eval job has completed with return code 0.

001 | changed
002 | changed
broken cave
broken cave
#

yeah

sick birch
#

Makes sense

broken cave
#

how do I fix

sick birch
#

Yeah it's server-side so not much you can do about it except not use replit

slate swan
#

uptimerobot is great for keeping up a replit

sick birch
#

Or just don't use replit at all

slate swan
#

well its free

sick birch
#

It's horrendous

slate swan
#

if you dont want to pay for hosting then what else do you have?

sick birch
#

AWS has a free tier

broken cave
sick birch
#

So does Oracle last I heard

broken cave
#

it was online yesterday

slate swan
sick birch
broken cave
#

oh shit

stray carbon
#
await channel.send(time.time())

sends "1646033596.4646752"
but i want it to send only "1646033596"

dull terrace
#

!e

class SomeClass:
    def __init__(self, att, att2):
        self.att = att
        self.att2 = att2
    def __setattr__(self, name, value):
        if name == 'att2':
            print("att2 changed")
        elif name == 'att':
            print('att changed')
instance = SomeClass('test', 102)
instance.att = "test2"β€Šβ€Š
instance.att2 = 123
unkempt canyonBOT
#

@dull terrace :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 11
002 |     instance.att = "test2"β€Šβ€Š
003 |                           ^
004 | SyntaxError: invalid non-printable character U+200A
sick birch
#

Is that apple's weird quotations

stray carbon
#
await channel.send(int(time.time()))

?

sick birch
#

Exactly like so

vast gale
#

hmmm

#

dunders

#

is there a dunder that runs when the class is made and not when-- that's __init_subclass__ thanks

stray carbon
#
esnipe_message_author = {}
esnipe_message_content = {}
esnipe_author_avatar = {}
message_edited_at = {}

@client.event
async def on_message_edit(message):
     esnipe_message_author[message.channel.id] = message.author
     esnipe_message_content[message.channel.id] = message.content
     esnipe_author_avatar[message.channel.id] = message.author.avatar_url
     message_edited_at[message.channel.id] = int(time.time())

Ignoring exception in on_message_edit
Traceback (most recent call last):
File "C:\Users\Akai\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
TypeError: on_message_edit() takes 1 positional argument but 2 were given

vast gale
#

before, after

#

!d disnake.on_message_edit

unkempt canyonBOT
#

disnake.on_message_edit(before, after)```
Called when a [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") receives an update event. If the message is not found in the internal message cache, then these events will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.

If this occurs increase the [`max_messages`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") parameter or use the [`on_raw_message_edit()`](https://docs.disnake.dev/en/latest/api.html#disnake.on_raw_message_edit "disnake.on_raw_message_edit") event instead.

The following non-exhaustive cases trigger this event...
stray carbon
#

oh

#

do i put message_before, message_after

#
client = commands.Bot(command_prefix=["sugari  ","sugari","@crisp ferry","@crisp ferry ","@crisp ferry ","@crisp ferry"], help_command=commands.MinimalHelpCommand())

bot not responding,aint got any traceback as well

maiden fable
sick birch
#

I'm good haha

maiden fable
#

Haha

boreal ravine
stray carbon
#

yes

#

i fixed it

maiden fable
#

Hmm

slate swan
#

You can just use commands.when_mentioned_or("prefix")

unique lichen
#
  async with aiohttp.ClientSession() as session:
    async with session.get(url) as r1:
     openimg = open(str(os.path.join(path,'someimage')),'wb')
     openimg.write(r.content)
     openimg.close()
     api_url = 'something'
image_file_descriptor = open('someimage', 'rb')
files = {'image': image_file_descriptor}
     async with aiohttp.ClientSession() as session:
       async with 
``` its getting errors . pls note someimage is img.png and url is a actual url
code is going to be used later in a discord bot
slate swan
#

r is undefined

narrow sleet
#

Anyone with discord codes they can share pls?

wanton veldt
slate swan
#

wwhats wrong here i get unexpected indent error

jade garden
#

Is there any way bot works on mention and with prefix

jade garden
boreal ravine
#

wdym no prefix

boreal ravine
jade garden
jade garden
slate swan
alpine furnace
#

Like, we’ve all seen that runtime type checker

boreal ravine
# slate swan i didn't get u

you need to put a method under @discord.ui.button() like ```py
@discord.ui.button(label="Hi")
async def button(self, button, inter):
...

slate swan
#

got it thnx

boreal ravine
#

that was just an example by the way

slate swan
#

the response works but label doesnt change and it doesnt get disabled

hoary cargo
slate swan
#

How do I take an input for channel/role/user in 1 parameter and check which one it is?

#

dpy 1.7 ^

visual island
#

typehint the parameter to typing.Union[discord.abc.GuildChannel, discord.Role, discord.User]

#

@slate swan ^^

iron sorrel
#

Hiiiiiiiiiiiiiii
not really a help-needed question,
more like a how-can-I-help-you question.

For the discord bot developers here that are toooooooo lazy to learn relational databases, what would you like your JSON database to be able to do?

slate swan
#

cant really say "your JSON database" when json is used to format data and not store it

red sundial
mellow barn
#

Hello, can someone help me with select menus?

red sundial
#

json isn't a database

mellow barn
red sundial
mellow barn
slate swan
mellow barn
#

btw it uses nextcord

red sundial
#

i have no idea how that works lol

mellow barn
visual island
mellow barn
# mellow barn but i'm adding it correctly
class HomeHelpView(View):
  def __init__(self, *, timeout=180):
    super().__init__(timeout=timeout)
    self.add_item(Select(
      placeholder="...",
      options=[SelectOption(...) for name, option in ace.modules]=
    ))
iron sorrel
mellow barn
#

wait maybe i got why its empty

red sundial
iron sorrel
#

as i said

#
For the discord bot developers here that are toooooooo lazy to learn relational databases
placid skiff
#

There is no need to use a ORM database for discord bots, considering that almost all discord object matches the abstract class Snowflake you can use a normal database and take as primary key the ID of the object you are interested to

red sundial
#

its a NoSQL db

dry kelp
#

@sick birch wtf

iron sorrel
slim ibex
#

πŸ’€

final iron
#

See the issue?

humble drum
#

Hi everyone!

dry kelp
#

Oh

#

Still no

final iron
#

!d dict.get

unkempt canyonBOT
#

get(key[, default])```
Return the value for *key* if *key* is in the dictionary, else *default*. If *default* is not given, it defaults to `None`, so that this method never raises a [`KeyError`](https://docs.python.org/3/library/exceptions.html#KeyError "KeyError").
final iron
#

Read the documentation

dry kelp
#

Oh

stiff nexus
#
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/slash_util/cog.py", line 28, in command_error_wrapper
    return await func(*args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/slash_util/core.py", line 345, in invoke
    await self.func(self.cog, context, *params.values())
  File "/home/runner/cogs/slash.py", line 65, in quote
    await ctx.send(f' {message.clean_content or utily.nothing}\n- {message.author}',files=w)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/slash_util/context.py", line 95, in send
    await self.response.send_message(content or None, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/slash_util/_patch.py", line 164, in send_message
    payload = handle_message_parameters(
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/slash_util/_patch.py", line 110, in handle_message_parameters
    'value': file.fp,
AttributeError: 'Attachment' object has no attribute 'fp'

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/slash_util/cog.py", line 75, in _internal_interaction_handler
    await command_error_wrapper(command.invoke, ctx, **params)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/slash_util/cog.py", line 32, in command_error_wrapper
    raise commands.CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Attachment' object has no attribute 'fp'
    @slash_util.message_command(name="Quote",description="Quotes your message!")
    async def quote(self, ctx: slash_util.Context, message: discord.Message):
        w=[]
        for attachments in message.attachments:
          w.append(attachments)
        await ctx.send(f' {message.clean_content or utily.nothing}\n- {message.author}',files=w)
dry kelp
#

Bet

cyan tree
#

Hello how can I contact the library aiohttp Open a web socket to discord to receive events?

small igloo
#

from discord import Webhook, RequestsWebhookAdapter
ImportError: cannot import name 'RequestsWebhookAdapter' πŸ—Ώ

i also try
from discord import Webhook, AsyncWebhookAdapter
but
ImportError: cannot import name 'AsyncWebhookAdapter' from 'discord' holy crap

cedar stream
#

why, when i subclass commands.Bot from pychord, it wants me to implement register_command abscractmethod

#

other forks i used dont do that

final iron
cedar stream
#

but i have to use it

#

working with a team and we voted

small igloo
cedar stream
small igloo
#

πŸ—Ώ

placid skiff
#

bro don't flood, read the exception, it is sayin it clearly

small igloo
placid skiff
#

Do you know python?

small igloo
placid skiff
#

what does ImportError exception tells you when it raises?

small igloo
placid skiff
#

yup

small igloo
# placid skiff yup

even the doc says that i must import that, but when i try it in action, the module gone, wtf

placid skiff
#

so the reason could be two:
The version of discord.py that you are using has not that class yet or something went wrong when you installed discord.py

small igloo
placid skiff
#

could be but you need to do other checks before, there is the possibility that you are trying to import a module which is already imported

#

why are you using AsyncWebhookAdapter?

small igloo
small igloo
placid skiff
#

Maybe you don't need that

cedar stream
#

pychord doesnt have support for select menus and buttons etc.

frozen elk
#

how do i do it right ik this is wrong

small igloo
placid skiff
#

Because probably you are trying to import a module which is already initialized in another module that you are using

cedar stream
unkempt canyonBOT
#
Nuh-uh.

No documentation found for the requested symbol.

small igloo
#

lul

placid skiff
#

you need to check your imports, by opening the discord source code

cedar stream
#

its on_error

small igloo
visual island
#

!d discord.on_error

unkempt canyonBOT
#

discord.on_error(event, *args, **kwargs)```
Usually when an event raises an uncaught exception, a traceback is printed to stderr and the exception is ignored. If you want to change this behaviour and handle the exception for whatever reason yourself, this event can be overridden. Which, when done, will suppress the default action of printing the traceback.

The information of the exception raised and the exception itself can be retrieved with a standard call to [`sys.exc_info()`](https://docs.python.org/3/library/sys.html#sys.exc_info "(in Python v3.9)").

If you want exception to propagate out of the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") class you can define an `on_error` handler consisting of a single empty [raise statement](https://docs.python.org/3/reference/simple_stmts.html#raise "(in Python v3.9)"). Exceptions raised by `on_error` will not be handled in any way by [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
small igloo
visual island
placid skiff
# small igloo there we go πŸ—ΏπŸ‘

essentially what is happening is like this:

main.py

import file1, file2
#stuffs here

file1:

from file3 import package_1

file3:

import file1

this will rise an error on file3 telling that you can't import file1

slim ibex
#

circular import πŸ—Ώ

placid skiff
#

somewhere in your code this is happening, you can try to run a debug where you import AsyncWebhook and followup the code untill you find the issue

slim ibex
#

seems like it atleast

placid skiff
#

yup it should be that

small igloo
slim ibex
#

yeah that’s definitely a circular importπŸ’€

placid skiff
#

you have to navigate through the error to know that

small igloo
small igloo
small igloo
placid skiff
small igloo
# placid skiff Yup, that's the evidence

where is it, also

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'AsyncWebhookAdapter' is not defined (when i remove that)

placid skiff
#

in discord.py webhook is a folder which contains three python file, one init file which imports the two other files and an async.py file and a sync.py file

small igloo
#
  1. get user object
  2. send that to the user DM ig
spring flax
#

how do i use command groups in main file?

small igloo
#

πŸ—ΏπŸ‘

placid skiff
#

or you can modify the webhook folder inside discord.py to remove the circular import lol

small igloo
small igloo
cold sonnet
small igloo
placid skiff
#

the one that raises the error πŸ˜†

small igloo
placid skiff
#

Bruh AsyncWebhook doesn't exists lol

small igloo
placid skiff
#

just import Webhook and modify your code to work with it

#

Oh wait it exists

small igloo
#

πŸ—Ώ

placid skiff
#

Why the fuck there is all those circular import lol

small igloo
placid skiff
#

I don't know hahaha, you can try to contact one of the contributors of discord.py

small igloo
placid skiff
#

or you can try to use disnake

small igloo
placid skiff
#

disnake doesn't have asyncwebhook but has the webhook class, maybe they fixed that issue

#

in fact as session disnake use aiohttp.ClientSession

small igloo
placid skiff
#

No lol

#

Why you want to use dpy? xD

small igloo
placid skiff
#

with disnake you will not have this issue because aiohttp is an external package

#

so no way you will have a circular import

small igloo
placid skiff
#

?

small igloo
placid skiff
#

disnake is a fork, you have only to change the discord namespace into disnake

#

and it will work without any issue

#

you have only to change this thing of asyncwebhook

small igloo
placid skiff
#

yup

small igloo
placid skiff
#

lol, np

brave flint
#

did someone know how to download attached file on pycord?

small igloo
placid skiff
small igloo
gleaming torrent
#

Hello. So I am trying to make a log for when people delete their messages. on_message_delete. But how do I make it get the user that deleted the message?

placid skiff
#

you will find that the docs too are pretty similar

placid skiff
small igloo
slim ibex
placid skiff
gleaming torrent
gleaming torrent
placid skiff
#

so instead of AsyncWebhook you need to import aiohttp.ClientSession and create a session with that

small igloo
leaden jasper
#

why is ctx.guild.owner returning None

placid skiff
#

nah not that much, check the docs and you will find how to do that

small igloo
placid skiff
#

you can import only clientsession, like doin this from aiohttp import ClientSession

small igloo
slate swan
small igloo
small igloo
placid skiff
maiden fable
maiden fable
unkempt canyonBOT
#
class aiohttp.ClientSession(base_url=None, *, connector=None, cookies=None, headers=None, skip_auto_headers=None, auth=None, json_serialize=json.dumps, ...)```
The class for creating client sessions and making requests.
placid skiff
#

already failed 4 times xD

maiden fable
#

xD

slate swan
#

imagine using aiohttp zulal

maiden fable
#

Β―_(ツ)_/Β―

placid skiff
#

man i was so getting to this that i was forgettin that i should do my work now xD

maiden fable
#

Lmao happens

placid skiff
#

Happy to help

leaden jasper
small igloo
unkempt canyonBOT
maiden fable
#

!d discord.TextChannel.create_webhook

unkempt canyonBOT
#

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

Creates a webhook for this channel.

Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.

Changed in version 1.1: Added the `reason` keyword-only parameter.
small igloo
small igloo
maiden fable
#

Yea

small igloo
#

k ty

small igloo
slate swan
small igloo
slate swan
#

yeah you're creating the webhook, it cant have a link before you create it

slate swan
#

nvm

maiden fable
slate swan
#
webhook = await TextChannel.create_webhook(name="Hunter uwu")
await webhook.send(content="hunter qt")```
maiden fable
small igloo
small igloo
# maiden fable Yea
await create_webhook(*, name, avatar=None, reason=None)``` is the star needed
maiden fable
#

That means it's a kwarg

slate swan
#

all the args after the star are kwargs*

maiden fable
#

Yea

small igloo
#

oh ok, so i dont need it

small igloo
maiden fable
#

Code

small igloo
# maiden fable Code
@bot.command(
    aliases=["say"]
)
async def repeat(ctx, text=None):
    if text == None:
        await ctx.send("where text")
    else:
        s = await ctx.channel.create_webhook(name="Salcash RPG Webhook", avatar=None, reason=None)
        async with aiohttp.ClientSession() as session:
            webhook = Webhook.from_url(s.url, session=session)
            await webhook.send(username=ctx.author.name, avatar_url=ctx.author.display_avatar, content=text)```
honest shoal
#

how can fetch a user's xbox name from their profile?

stiff nexus
#
class quote(discord.ui.View):
    def __init__(self, user):
        super().__init__(timeout=None)
        self.user = user
      
    @discord.ui.button(style=discord.ButtonStyle.gray, custom_id="quote_name")
    async def quote_name(self, button: discord.ui.Button, interaction: discord.Interaction):
        self.label=f"Message by {self.user}"
``` how do i set the label?? this is not working^^^
maiden fable
#

U need to edit the message too

stiff nexus
opaque tiger
#

how can i get the list of all the commands including the subcommands?

maiden fable
stiff nexus
#

there is no other way?

maiden fable
maiden fable
stiff nexus
#

but wait

stiff nexus
#

mee6 does not edit the message

#

how does they get it

maiden fable
unkempt canyonBOT
#

property commands: Set[discord.ext.commands.core.Command[discord.ext.commands.core.CogT, Any, Any]]```
A unique set of commands without aliases that are registered.
opaque tiger
maiden fable
opaque tiger
maiden fable
#

!d discord.ext.commands.Group.commands

unkempt canyonBOT
#

property commands: Set[discord.ext.commands.core.Command[discord.ext.commands.core.CogT, Any, Any]]```
A unique set of commands without aliases that are registered.
opaque tiger
maiden fable
#

U need to use try except

stiff nexus
maiden fable
#

Bro, u have to make an API call to let the API know that we are changing the button text

radiant rampart
opaque tiger
#

!d disnake.ext.commands.Group.commands

unkempt canyonBOT
maiden fable
opaque tiger
#

hmm

stiff nexus
maiden fable
#

.....?

#

Well, idrk then. According to me, u need to make an API Call

opaque tiger
maiden fable
#

It is

opaque tiger
maiden fable
#

Then...?

opaque tiger
#

@maiden fable why is it Any?

maiden fable
#

ThTs just type hinting

opaque tiger
#

its not correctly type hinted?

maiden fable
#

Idk tbh. I think it's the same code from dpy

opaque tiger
maiden fable
#

Try adding debug prints

#

Adding print statement to every other line and seeing which one is being called, to check what code is working and what's not

opaque tiger
maiden fable
#

Oh mind showing the code?

opaque tiger
maiden fable
#

Oh wait

opaque tiger
# maiden fable Oh mind showing the code?
    @commands.command(description="Displays the total number of Commands")
    @commands.cooldown(rate=1, per=5, type=commands.BucketType.user)
    async def total_commands(self, ctx: commands.Context):
        available_commands = [
            command for command in self.bot.commands if not command.hidden
        ] + [command for command in commands.Group.commands]
        hidden_commands = [command for command in self.bot.commands if command.hidden]

        await ctx.reply(
            f"Available Commands: {len(available_commands)}\nHidden Commands: {len(hidden_commands)}"
        )
maiden fable
#

!d discord.ext.commands.Bot.walk_commands is there. U should use this

unkempt canyonBOT
#

for ... in walk_commands()```
An iterator that recursively walks through all commands and subcommands.

Changed in version 1.4: Duplicates due to aliases are no longer returned
opaque tiger
maiden fable
#

Same in disnake

maiden fable
#

!d disnake.ext.commands.Bot.walk_commands

unkempt canyonBOT
#

for ... in walk_commands()```
An iterator that recursively walks through all commands and subcommands.

Changed in version 1.4: Duplicates due to aliases are no longer returned
opaque tiger
silk kelp
silk kelp
#

?

opaque tiger
slate swan
#

thats like so slow

stone beacon
#

^^

#

You'd get away with just setting a class var that stores the number of commands in your cog 🀣

#

But that isn't dynamic enuf now is it

slate swan
#
total_cmds = len([command.name for command in self.bot.walk_commands() if not command.hidden])
``` is faster ig
stone beacon
#

Yup

slate swan
#

idk if it will work, just made that rn kek

boreal ravine
#

the snake

quaint epoch
#

nvm

#

!d disnake.Message.reply

unkempt canyonBOT
#

await reply(content=None, *, fail_if_not_exists=True, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

A shortcut method to [`abc.Messageable.send()`](https://docs.disnake.dev/en/latest/api.html#disnake.abc.Messageable.send "disnake.abc.Messageable.send") to reply to the [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message").

New in version 1.6.

Changed in version 2.3: Added `fail_if_not_exists` keyword argument. Defaults to `True`.
quaint epoch
#

!d disnake.Embed

unkempt canyonBOT
#

class disnake.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.

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

bool(b) Returns whether the embed has any data set.

New in version 2.0.

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

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
quaint epoch
#

If a message has been deleted, can you still try to get it?

quick gust
#

no

patent lark
#

well.

#

yes.

quick gust
#

u can try

#

but it will return None

patent lark
#

if you catch the deleted message, you can 100% have it returned back to you.

quick gust
#

try to get it
Figured they were talking about geting

#

would that work aswell?

quaint epoch
#

like, a payload such as the one you get from RawMessageDeleteEvent

sick birch
quick gust
#

Yeah

patent lark
#

ive never really looked into that

sick birch
#

Well shouldn't be hard to test out

slate swan
#

what cache system does dpy even use?

sick birch
#

During the raw message delete event you can try to .get_message() using the ID

patent lark
#

well this would return the message instance, no?

pliant gulch
quaint epoch
#

where could we run .get_message()

#

because disnake.Guild doesn't have it

sullen garnet
#

Hi i would like to try and make a discord bot. Could anyonr give me any pointers to how i would start this e.g programme, how we would make the user

sick birch
sullen garnet
#

Ok thanks ill have a look

slate swan
pliant gulch
#

Messages are deque because they pop left after the amount goes past the limit, the rest of the objects use a regular mapping as the cache

slate swan
#

ic

#

What is that?

quick gust
#

you've been ratelimited, classic replit

slate swan
#

What should i do?

sick birch
slate swan
#

Ok

sick birch
#

I hate to be blunt but it's just replit

#

It's one of the worst "hosts" there is, if you can even consider it that

slate swan
wispy spade
#

To actually explain what's happening, basically, you got ratelimited. Your IP sent too many requests to Discord and as such you're getting that error. The problem with repl.it is that your IP is shared with other users, so if another user triggers a ratelimit, all people using that IP will also receive that ratelimit (since it's the same IP).

sick birch
#

^ its also possible for malicious users to get your account in trouble

#

since they will more than likely have the same IP as you

#

If you were to use something like AWS, they provide you with your own subnet & elastic IP that only you have access to

slate swan
sick birch
#

Oh that's unfortunate

#

Coding on a phone is just not ideal, I'm sure you agree

slate swan
sick birch
#

Yeah well unfortunately it's just replit and there's not much you can do but wait until you're not longer rate limited

boreal ravine
sick birch
#

Uhm

#

isn't that usually the root process?

boreal ravine
#

I have no idea

wispy spade
#

I think I've heard of that as a "fix" for this issue, although I'm not sure

boreal ravine
#

but I heard that command changes your current IP to another one

wispy spade
#

preferably you would just get off replit and look for another host but that isn't really an option here

sick birch
#

I don't know, assuming replit servers run some version of linux, 1 is usually the root process PID

#

Killing that is not a good idea

#

(trust me i tried it once)

pliant gulch
#

Most likely repl.it spawns a new container for you

#

Perhaps that’s what gives you the new IP

sick birch
#

That would make sense

slate swan
#

Mmm. How i can show bot ping?

sick birch
#
f"Hello! My ping is {bot.latency}"
placid skiff
#

well you should round because latency returns the time in microseconds i think

sick birch
#

Round or int() it sure

slate swan
placid skiff
#

should try this: round(bot.latency, 1)

slate swan
potent spear
#

mobile πŸ‘€

wispy spade
sick birch
potent spear
#

don't crosspost, you already got your answer in the other server

slate swan
potent spear
#

stop saying 'it doesnt work", instead, show what you tried etc

#

you set up your error handler the wrong way most likely

slate swan
stray carbon
#

trying to install nextcord but got this error:
Could not find a version that satisfies the requirement nextcord....
im using python 3.8.6

wispy spade
cold sonnet
#

also, you probably didn't use the right version of pip when installing

#

/your python interpreter in your IDE is wrong

red nest
#

i used pip 2.11 or something for nextcord

cold sonnet
#

pip install --upgrade pip
if possible

red nest
#

yeah

cold sonnet
#

maybe even python3.8 -m pip install --upgrade pip

red nest
cold sonnet
#

or pip3.8 install nextcord thonk

#

try pip3.8 install disnake

#

I still don't see a reason for anyone to use nextcord

#

nextcord is just dpy

#

they still even use the same namespace

quick gust
red nest
#

it's pretty similar but still has some major differences

spring flax
#

"Pretty similar but major differences"

red nest
#

yeah

spring flax
#

Doesn't go well together lol

red nest
#

but it's true lol

quick gust
#

everything in the discord folder hasn't been updated since 5 months except the title in the init

distant sparrow
#

Yo, anyone able to help me host my discord bot that doesn't shut off?

sick birch
#

Suggest hosts?

distant sparrow
#

However possible really man. I have 0 experience coding except for lua and I just need to get my discord bot online. I'd then like to have the status switch around every 15 seconds.

sick birch
#

Well, do you have the code for it?

slate swan
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
slate swan
#

!d discord.ext.commands.Bot.change_presence with that

unkempt canyonBOT
#

await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Changes the client’s presence.

Example

```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
```   Changed in version 2.0: Removed the `afk` keyword-only parameter.
hollow tide
#

is there any consensus on the best discord bot lib fork to use?

sick birch
#

No

#

There are popular ones but no singluar "best" one

#

Now other people might tell you their fork is the best fork but that only proves the point, it's subjective and people will tell you the best fork is the one that they use

full lily
#

+1

hollow tide
#

its a big leap to jump to one and there is little consensus yet which is dissapointing

manic wing
#

everyone here uses disnake

#

disnake is much preferred to the other 3 forks, and you would probably get most help with it

wispy spade
#

That's probably one of the more liked ones of the three

hollow tide
#

noted, ya disnake is what im seeing the most of

sick birch
#

Yeah, I agree on that too. @dim ruin was going to use disnake as well

wispy spade
hollow tide
#

cool, thats good enough for me. auditing their source they also seemed the msot solid

wispy spade
kind cargo
#

File "C:\Users\sweti\Downloads\drive-download-20220228T165050Z-001\main.py", line 50, in <module>
bot.run(TOKEN)
Someone help me with this problem.

coarse anvil
#

so uhh does anyone know how to make these commands i put in folders make them work and not have to put them in main.py, im still learning python!! :D

hollow tide
#

you didnt actually show anything

kind cargo
# hollow tide what problem?

File "C:\Users\sweti\Downloads\drive-download-20220228T165050Z-001\main.py", line 50, in <module>
bot.run(TOKEN)

wispy spade
#

Missed the most important part of that traceback

hollow tide
#

thats spectacularly unhelpful

kind cargo
#

what?

wispy spade
#

Can you get the entire error?

hollow tide
#

you posted that an error happened

coarse anvil
wispy spade
hollow tide
#

πŸ‘

hollow tide
#

you havent asked a good question, havent shown any code or showed us what you have so far. your question isnt really answerable

wispy spade
#

"these commands"? maybe you mean cogs?

hollow tide
#

provide more context and we can help. there are many different ways you COULD do this

kind cargo
sick birch
#

You posted the fact that python told you there was an error at this point, but we don't know what the actual error is

coarse anvil
hollow tide
coarse anvil
kind cargo
#

"what isa the problem"

wispy spade
hollow tide
coarse anvil
hollow tide
#

ill give you a hint, post screenshots or copy paste your code

kind cargo
#

me?

hollow tide
#

until you do that this isnt a useful conversation

hollow tide
kind cargo
hollow tide
#

you have also not shown anything useful 😁

wispy spade
#

that tells us nothing

quick gust
#

that isn't the full traceback

hollow tide
#

dont crop it

wispy spade
hollow tide
#

take a full screen screensyhot

#

just info dump the whole screen, we know what we ar elookign for

kind cargo
hollow tide
#

there we go

#

now if you had posted that in your original message in this channel we would be way further rn lol

kind cargo
#

yeee

hollow tide
#

for future reference lead with that next time

kind cargo
#

okk

wispy spade
#

I can barely notice it but seems you haven't enabled privileged intents

quick gust
# kind cargo

!intents do u have anything that looks like this in your code?

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

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

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

kind cargo
#

i have @quick gust

quick gust
#

make sure to enable them in the Developer Portal aswell

quick gust
hollow tide
#

take one of your entire screen do not crop it

rancid escarp
#

Has anyone created a discord bot that purges specific channels at a specific time automatically? I am stuck here and looking for some assistance

sick birch
slate swan
distant sparrow
rancid escarp
slate swan
rancid escarp
slate swan
rancid escarp
#

I thought and i executed all the tasks one by one.They all executed fine, the moment i add the auto execute segment, the blocking starts

slate swan
rancid escarp
# slate swan can you show the task code if you by any chance have it?

I dont have the exact code since i have rewritten it so many time πŸ˜… but i tried to follow the below approach:

import datetime
async def function():

schedule_time = datetime.datetime(2020, 10, 3, 11, 58, 00, 000000)#(year, month, day, hour, minute, second, microsecond)
await client.wait_until_ready()

while not client.is_closed():
   now = datetime.datetime.now()
   if schedule_time  <= now:
       #JOB
       #add one day to schedule_time to repeat on next day
       schedule_time+= datetime.timedelta(days=1)
   await asyncio.sleep(20)

client.loop.create_task(function())

cold sonnet
#

this ain't a task

#

I mean yeah well nvm

rancid escarp
#

I am confused πŸ˜…

cold sonnet
#

ext.tasks

slate swan
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
slate swan
rancid escarp
#

class AutoPurge(discord.Client):
def init(self, *args, **kwargs):
super().init(*args, **kwargs)

    # an attribute we can access from our task
    self.counter = 0

    # start the task to run in the background
    self.my_background_task.start()

async def on_ready(self):
    print(f'Logged in as {self.user} (ID: {self.user.id})')
    print('------')

@tasks.loop(seconds=60) # task runs every 60 seconds
async def my_background_task(self):
    now = datetime.now()

    current_time = now.strftime("%H:%M:%S")
    print("Current Time =", current_time)
    run = True
    while run == True:
        while(current_time >= '02:20:00' and current_time <='02:21:00'):  # check if matches with the desired time
            print('sending message')
            channel_id=(944555898779611174,944555898779611175,944555899173888040,944555899459092512,944555899459092513,944555899459092514,944555899459092515,944555899459092516,944555899459092517,944555899459092518,944555899727544350,944555899727544351,944555899727544352,944555899727544353,944555899727544355,944555899727544356,944555899727544357,944555899727544358,944555899727544359,944555899903680562,944555899903680563,944555899903680564,944555899903680565)
            ch_count=0
            while ch_count<len(channel_id):
                print("Testing for auto purge")
                channel = self.get_channel(channel_id[ch_count])
                await channel.send("/clean")
                ch_count=ch_count+1
                if ch_count==22:
                    channel = self.get_channel(944555898297262083)
                    await channel.send("War Channels auto purged successfully")
            run == False

@my_background_task.before_loop
async def before_my_task(self):
    await self.wait_until_ready() # wait until the bot logs in

client = AutoPurge()

slate swan
#

!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.

rancid escarp
#

This is what i am using right now

#

@slate swan

slate swan
#

discord.Client WTFStare

manic wing
#

tasks are very simple

slate swan
#

caeden help pliz

manic wing
#

with what

slate swan
manic wing
unkempt canyonBOT
#

disnake/ext/tasks/__init__.py line 140

async def _loop(self, *args: Any, **kwargs: Any) -> None:```
cold sonnet
#

for loops are so easy to make

manic wing
#

for i in range(∞) works with python 3.10

manic wing
#

nods convincingly

slate swan
sick birch
unkempt canyonBOT
#

@sick birch :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     for i in range(∞):
003 |                    ^
004 | SyntaxError: invalid character '∞' (U+221E)
sick birch
#

he lies

manic wing
#

!e print.__call__(__import__('os'))

unkempt canyonBOT
#

@manic wing :white_check_mark: Your eval job has completed with return code 0.

<module 'os' from '/usr/local/lib/python3.10/os.py'>
manic wing
#

damn its 3.10

slate swan
#

caeden lies KEKWlaugh

manic wing
#

ash stop using free nitro

#

its embarrasing cringe

slate swan
slate swan
manic wing
#

slowly walks away

distant sparrow
#

Yeah hi can someone help me host my bot 24/7

boreal ravine
maiden fable
#

Imagine if infinity worked with Python

sick birch
boreal ravine
sick birch
maiden fable
#

Well what most of the hosts do is, rent a VPS for like 6 USD a month or smth (maximum 10) and just sell it to a person like 500 MB RAM for 2 USD or smth. This way, they earn profits since they cover the VPS costs by 5-6 people and the rest is all profit

distant sparrow
sick birch
#

I think my ec2 instances come out to be ~30/month excluding other services like domains and S3 storage unit

maiden fable
distant sparrow
#

If anyone tryna let me run my bot from them lmk

maiden fable
#

Okay ig

distant sparrow
#

I'll slide u 1 pizza crust per month

sick birch
distant sparrow
#

Man I am silly and stupid so people get really frustrated at me because I don't understand it

maiden fable
#

I am the same πŸ‘€

slate swan
#

calling yourself silly and stupid is just lowering your self-esteem sadcat

distant sparrow
#

It's already at its lowest

#

Lol

maiden fable
manic wing
#

hate to be that guy, but we're not counsellors, please stay on topic

distant sparrow
#

Very true

#

Ye so if someone wants a pizza crust shipped to them and can host my bot or something dm me

sick birch
#

That would be nasty

distant sparrow
#

I will vacuum seal it

manic wing
#

what

maiden fable
#

Meh, my bot itself is being hosted by a friend, don't expect anything from me

distant sparrow
#

Get me that friend

sick birch
#

I do have an EC2 instance running πŸ‘€

slate swan
maiden fable
manic wing
#

robin stop im literally going to go psycho

maiden fable
#

@distant sparrow where do u live tho like what country

sick birch
manic wing
#

literally 1 out of 3 times i go into discord-bots you're mentioned aws

manic wing
#

thats not even a joke

maiden fable
maiden fable
sick birch
#

leave me alone ☹️

distant sparrow
#

?

slate swan
distant sparrow
#

That's not a joke

slate swan
distant sparrow
#

thats not a joke

maiden fable
manic wing
distant sparrow
#

Why is my nationality a joke now?

slate swan
maiden fable
sick birch
slate swan
distant sparrow
#

You want a picture from my apartment lol?

slate swan
sick birch
maiden fable
distant sparrow
#

Oh lol yes I am Ukranian

slate swan
manic wing
cold sonnet
manic wing
#

!ot

unkempt canyonBOT
#

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

manic wing
#

.topic

lament depotBOT
#
**What feature would you like to see added to the library? What feature in the library do you think is redundant?**

Suggest more topics here!

distant sparrow
#

Holy fuck

#

That's a lot of moderation

cold sonnet
#

lots of minimods here

manic wing
#

i dont particularly want to get perm banned

maiden fable
slate swan
maiden fable
manic wing
#

hunter can we veer back on topic

manic wing
cold sonnet
distant sparrow
#

guys stop arguing if u think Im offended Im not so its fine

maiden fable
slate swan
unkempt canyonBOT
#

disnake/ext/tasks/__init__.py line 140

async def _loop(self, *args: Any, **kwargs: Any) -> None:```
manic wing
#

its too simple

#

simple = bad

dry kelp
#

@final iron

maiden fable
manic wing
#

!zen

unkempt canyonBOT
#
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

dry kelp
#

guild_prefixes[str(ctx.guild.id)][str(ctx.author.id)] = prefix will this work to add the prefix?

maiden fable
cold sonnet
unkempt canyonBOT
dry kelp
#

like creating a str of guild id + author id

#

then prefix

frozen patio
#

this wont work when I use it

dry kelp
#

@maiden fable how can i get the prefix from that?

dry kelp
#

like

frozen patio
#

its to make a music bot, I use the command, and it says not in a VC

maiden fable
frozen patio
maiden fable
frozen patio
#

many bots are music bots

dry kelp
#

guild_prefixes.get([str(ctx.guild.id)][str(ctx.author.id)]):

#

@maiden fable is this the right way to pull the prefix from it?

slate swan
maiden fable
dry kelp
#

yes

buoyant quail
#

bot can play music not only from youtube

frozen patio
maiden fable
dry kelp
#

alr

maiden fable
quaint epoch
#

I tried to send a snipe command, but it only works when i delete a message that was sent after the bot starts up

slate swan
quaint epoch
#

is it because it needs to be in it's cache?

slate swan
maiden fable
quaint epoch
quick gust
slate swan
maiden fable
quick gust
cold sonnet
quick gust
slate swan
#

don't make a music bot, dump the idea

#

I dont see an option

frozen patio
#

alright 😦

maiden fable
# slate swan i know

So yea, in short you cannot stream music without paying millions to the creators as royalty, so might just drop the idea

slate swan
slate swan
maiden fable
#

Reasons Spotify doesn't allow downloading music on the free plan. The company has to pay royalty to the singers to make the music available to everyone

quaint epoch
#

how come my snipe command only snipes messages that were sent and deleted after my bot starts up

slate swan
maiden fable
#

Since the cache refreshes everytime yr bot restarts

manic wing
#

!d discord.on_raw_message_delete

unkempt canyonBOT
#

discord.on_raw_message_delete(payload)```
Called when a message is deleted. Unlike [`on_message_delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_delete "discord.on_message_delete"), this is called regardless of the message being in the internal message cache or not.

If the message is found in the message cache, it can be accessed via [`RawMessageDeleteEvent.cached_message`](https://discordpy.readthedocs.io/en/master/api.html#discord.RawMessageDeleteEvent.cached_message "discord.RawMessageDeleteEvent.cached_message")

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
quaint epoch
maiden fable
manic wing
pliant gulch
maiden fable
#

You didn't understand me lol

manic wing
slate swan
manic wing
# manic wing !d discord.on_raw_message_delete

this is what you can use in order to get all deleted messages, whether or not they are cached - this might be useful if you turn your bot off a lot, however it can cost a lot of api calls

maiden fable
slate swan
manic wing
#

you do know i am aware but dont really care? (bcc @maiden fable )

maiden fable
#

No I didn't

maiden fable
manic wing
#

you can stop doing the ....

slate swan
maiden fable
maiden fable
maiden fable
#

Nvm I give up

manic wing
#

read my message

dry kelp
#

@maiden fable

manic wing
#

preferably with code

maiden fable
dry kelp
#

yep

manic wing
dry kelp
#
async def get_prefix(bot, message):
    author = message.author.id
    guild = message.guild.id
    prefixes = [".", bot.user.mention]

    with open(prefix_path, "r")as f:
        guild_prefixes = json.load(f)
        guild_prefix = guild_prefixes.get(str(guild))
        if guild_prefix:
            prefixes.append(guild_prefix)

    with open(self_prefix_path, "r")as f:
        self_prefixes = json.load(f)
        self_prefix = self_prefixes.get(str(author))
        if self_prefix:
            prefixes.append(self_prefix)

    with open(guild_prefix_path, "r")as f:
        guild_prefixes = json.load(f)
        guild_prefix = guild_prefixes.get([str(guild)][str(author)])
        if guild_prefix:
            prefixes.append(guild_prefix)

    return commands.when_mentioned_or(*prefixes)(bot, message)
maiden fable
#

try printing guild_prefixes[str(guild)]

dry kelp
#

where

maiden fable
#

!d discord.on_raw_reaction_add is what u need

unkempt canyonBOT
#

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

This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
maiden fable
dry kelp
cold sonnet
slate swan
maiden fable
#

Don't
Copy
It
Off
GitHub

dry kelp
#

wait lemme put it after the if

#

but is going to return none anyways

maiden fable
# dry kelp

that means there ain't a prefix set for that guild

dry kelp
#

cuz the guild is not added that's why automatically it should get . if is none

#

exactly bro like why am i getting the str error

maiden fable
#

o

dry kelp
#

like fuck am i doing wrong

manic wing
#

thats the same error with no new information

maiden fable
dry kelp
#

is empty

maiden fable
manic wing
#

im quite calm thanks

dry kelp
maiden fable
dry kelp
maiden fable
sick birch
#

no it's just the name of the key in string form

dry kelp
#

so without []

sick birch
#

!e

x = {
  "hello": "world"
}
print(x.get("hello"))
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

world
dry kelp
#

guild_prefixes.get(str(guild), str(author))

sick birch
#

just like so

dry kelp
#

that's good?

sick birch
#

Why the comma? It only takes one argument

dry kelp
#

guild_prefixes.get(str(guild), str(author)) is this good?

maiden fable
#

guild_prefixes.get(str(guild))[str(author)]

tidal hawk
#

Watch Youtube videos πŸ˜†

sick birch
dry kelp
manic wing
maiden fable
manic wing
#

!e
x = {
"hello": "world"
}
print(x.get("e", 1))

unkempt canyonBOT
#

@manic wing :white_check_mark: Your eval job has completed with return code 0.

1
sick birch
dry kelp
#

so which one bruh

maiden fable
#

Both work

tidal hawk
#

Just start by creating a command, then when command is used, the bot creates a channel with perms etc...

dry kelp
#

being painful already

sick birch
#

Nevermind, use that then

sick birch
#

So if it doesn't find a guild prefix, it'll default to username#discrim instead, is that what you want?

dry kelp
#
    with open(prefix_path, "r")as f:
        guild_prefixes = json.load(f)

        if [str(ctx.guild.id)][str(ctx.author.id)] in guild)prefixes:
            p = guild_prefixes.get(str(ctx.guild.id))[str(ctx.author.id)]
        else:
            p = "."
#

will this work?.. wait i made a error

#
    with open(prefix_path, "r")as f:
        guild_prefixes = json.load(f)

        if [str(ctx.guild.id)][str(ctx.author.id)] in guild_prefixes:
            p = guild_prefixes.get(str(ctx.guild.id))[str(ctx.author.id)]
        else:
            p = "."
sick birch
#

if [str(ctx.guild.id)][str(ctx.author.id)] ??

manic wing
sick birch
#

this is the problem with json

#

it's notoriously difficult to work with data

#

if you used a database you could do this in 5 lines and move on

dry kelp
#

will that work tho?

#

like ye it should get the guild id and author id in the command error

sick birch
dry kelp
#

@sick birch

sick birch
#

start using .get() instead of using []

dry kelp
#

like?

sick birch
#

right now you have a list and you're trying to subscript that list using a string

manic wing
sick birch
#

You can avoid try/except hell

dry kelp
#

robin how can i fix this bruh

sick birch
#

You're gonna wanna think about how to structure your code first or it's gonna end up looking like spghetti code and nobody will know how to fix it

dry kelp
#

i mean it looks fine to me

#

i just have issues loading the prefix lol

sick birch
#

if [str(ctx.guild.id)][str(ctx.author.id)] like what's this supposed to be

dry kelp
#
    with open(guild_prefix_path, "r")as f:
        guild_prefixes = json.load(f)
        guild_prefix = guild_prefixes.get(str(guild))[str(author)]
        if guild_prefix:
            prefixes.append(guild_prefix)
#

getting the guild id and author id

sick birch
#

that's like doing [1, 2, 3, 4]["string"]

#

all you need to do is

if str(guild.id) in guild_prefixes:
  ...
dry kelp
#

no bro is something different here

#

i need guild id + author id + prefix

#

like a self prefix but for guild .. not global

sick birch
dry kelp
#

it doesn't

sick birch
#

and str(author) returns authorName#discrim

dry kelp
#

please check the define

#

it doesn't do that

sick birch
#

oh did you change the variable names

dry kelp
sick birch
#

ah yeah

dry kelp
#

yes

sick birch
#

naming conventions are not the best but i guess that's ok

maiden fable
dry kelp
#

fr

#

please cuz is being a pain in the ass this shit a_sobs

#

i just can't im brain dead

quaint epoch
slate swan
unkempt canyonBOT
#

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

001 | <string>:1: SyntaxWarning: 'NoneType' object is not subscriptable; perhaps you missed a comma?
002 | Traceback (most recent call last):
003 |   File "<string>", line 1, in <module>
004 | TypeError: 'NoneType' object is not subscriptable
manic wing