#discord-bots
1 messages Β· Page 867 of 1
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
thats the default help command
It's Disnake, not dpy
i want to remove it
use the help_command kwarg in your bot constructor and set it to None
!d discord.ext.commands.Bot.help_command
The help command implementation to use. This can be dynamically set at runtime. To remove the help command pass None. For more information on implementing a help command, see Help Commands.
ok thanks
what i just gave lmao
outside of listeners?
in the bot constructor.
client = ....
in your bot variable/ class instance
yes
there?
yes
yes got it thx
variable naming and useless variableπΏ
lol
the bot is responding but its sending this
discord.ext.commands.errors.CommandNotFound: Command "help" is not found```
asynchronous synchronous multisinglethreaded python script to run a discord bot from mars
Pleasant goodnight to all
because its not found you have to make one
Goodnight
- 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
figured it out: ws is None, solution is waiting until connection
or over-engineering it like me 
- 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?
it'll probably break
have you tried it before it is a fork off of discord.py
nope
but if you wanna make slash commands in discord.py use slash_util
!pypi slash_util
A small script allowing the use of application commands with discord.py v2.0
thank you
π
return converter(argument)
ValueError: invalid literal for int() with base 10: '10s'
Which channel would i get regarding console of browser and image editing sutuff like tat
Infomation regarding*
can you answer my first question?
- 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
no access
what
you can't cast a string
um
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]
.
lol i didn't see that and there are 2 seprate questions in a message
and look again at number 1 here #discord-bots message
they already answered u in the dpy server...
^
right i read over thinking of the other
but thanks
any idea on the third question not in the dpy server?
embed.set_footer(text = f"Ends {mins} minutes from now!")
this doesnt show the timer
how to show timer?
code?
?
its saying that its line 511 but line 511 does not exist
that isnt exactly line 511
wdym?
dude
where have you written strip?
those are your files?
you must have made
are you using someone's command handler
?
?
send full traceback
u are probably looking at the wrong place
the line number is usually near the top
but client.py has over 1000 lines of code
os.getenv("TOKEN") is None
oh ok
Hmm
I want to convert this to python
how do I do it
this is actually for a football command in discord.py
And code?
can i ask pycord help here
yes but good luck getting a response π³
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```
im on mobile but have you done If with a capital I?
also go to #python-discussion
On mobile. Auto capitalising
Not a native way I believe unfortunately
π©
You could be looking for __setattr__() though
!e
class SomeClass:
def __setattr__(self, name, value):
print("changed")
instance = SomeClass()
instance.attribute = "some attribute"
@sick birch :white_check_mark: Your eval job has completed with return code 0.
changed
@property you can do some hack with this
Oh yeah, and setattr too
Hey @broken cave!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
If only python had a nice way like React.js has dependency tracking for useEffect() π
God freaking
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"ββ```
@dull terrace :white_check_mark: Your eval job has completed with return code 0.
001 | changed
002 | changed
My bot was hosted like 2 years ago, now the uptime robot hosting is good but the code isn't running. Heres the error https://paste.pythondiscord.com/xepopidiwe Can anyone help?
Replit?
yeah
Makes sense
how do I fix
Yeah it's server-side so not much you can do about it except not use replit
uptimerobot is great for keeping up a replit
Or just don't use replit at all
well its free
It's horrendous
if you dont want to pay for hosting then what else do you have?
AWS has a free tier
I hosted it 2 years before. now it doesn't work
So does Oracle last I heard
it was online yesterday
does it?
Replit has a shared IP system, other people can get on the same IP as you and get you blocked from cloudflare
oh shit
await channel.send(time.time())
sends "1646033596.4646752"
but i want it to send only "1646033596"
!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
@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
int() it
Is that apple's weird quotations
await channel.send(int(time.time()))
?
Exactly like so
hmmm
dunders
is there a dunder that runs when the class is made and not when-- that's __init_subclass__ thanks
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
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...
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
Time for u to contribute to CPython π
I'm good haha
Haha
do you have an on_message event?
Why these prefixes?
Hmm
You can just use commands.when_mentioned_or("prefix")
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
r is undefined
Anyone with discord codes they can share pls?
yes
wwhats wrong here i get unexpected indent error
Is there any way bot works on mention and with prefix
yes
With no prefix
wdym no prefix
The decorator is incomplete
Forget
Tell me that
i didn't get u
I swear this is possible with some random python tricks
Like, weβve all seen that runtime type checker
you need to put a method under @discord.ui.button() like ```py
@discord.ui.button(label="Hi")
async def button(self, button, inter):
...
got it thnx
that was just an example by the way
the response works but label doesnt change and it doesnt get disabled
You need to edit the message
How do I take an input for channel/role/user in 1 parameter and check which one it is?
dpy 1.7 ^
typehint the parameter to typing.Union[discord.abc.GuildChannel, discord.Role, discord.User]
@slate swan ^^
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?
cant really say "your JSON database" when json is used to format data and not store it
just use mongo db π€·ββοΈ
Hello, can someone help me with select menus?
json isn't a database
somewhy there's no select menu
is this python?
but i'm adding it correctly
its a file format
thats obvious
lisp that compiles to python (hylang)
btw it uses nextcord
i have no idea how that works lol
equals
@cord.group(
name="help",
description="...",
aliases=["h"],
invoke_without_command=True
)
async def help(self, ctx):
await ctx.reply(
embed=Embed(...),
view=HomeHelpView()
)
show the python code 
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]=
))
i know but
wait maybe i got why its empty
but?
as i said
For the discord bot developers here that are toooooooo lazy to learn relational databases
Json isn't a database
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
mongo db isn't a relational db
its a NoSQL db
omg fr π
π
Hi everyone!
!d dict.get
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").
Read the documentation
Oh
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)
Bet
Hello how can I contact the library aiohttp Open a web socket to discord to receive events?
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
why, when i subclass commands.Bot from pychord, it wants me to implement register_command abscractmethod
other forks i used dont do that
Cause pycord sucksssssss
IK
but i have to use it
working with a team and we voted
πΏ and the force u to use pycord?
we all use the same fork
πΏ
what is dis how to fix
E help
πΏ h e l p
bro don't flood, read the exception, it is sayin it clearly
ImportError: cannot import name 'AsyncWebhookAdapter' from 'discord'
idk
Do you know python?
ye, why
what does ImportError exception tells you when it raises?
no module named that smth?
yup
even the doc says that i must import that, but when i try it in action, the module gone, wtf
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
something went wrong when you installed discord.py
if this, how to fix (dont tell me re-install πΏ)
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?
wanna send a message use webhook :V
well, i alr import discord, but not for that AsyncWebhookAdapter
how to reinstall
Maybe you don't need that
pychord doesnt have support for select menus and buttons etc.
how do i do it right ik this is wrong
ight?
:happy_moyai: then.... what
Because probably you are trying to import a module which is already initialized in another module that you are using
!d commands.on_error
:moyai_confoos: no
No documentation found for the requested symbol.
lul
you need to check your imports, by opening the discord source code
its on_error
:moyai_surprised: wat
!d discord.on_error
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").
there we go πΏπ

essentially what is happening is like this:
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
circular import πΏ
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
seems like it atleast
yup it should be that
well, that's my first time import asyncWebhook thing, no way i use it in any of my files before so
yeah thatβs definitely a circular importπ
yes but what about discord.py? maybe AsyncWebhook is already imported in Webhook and that's the issue
you have to navigate through the error to know that
where the error πΏ
i mean to see through
maybe AsyncWebhook is already imported in Webhook
:moyai_big_eyes: w u t
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)
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
- get user object
- send that to the user DM ig
how do i use command groups in main file?
i mean where to import that async webhook thing, discord.Webhook.AsyncWebhookAdapter or what
πΏπ
you can't, you have to just import Webhook and then try to use AsyncWebhookAdapter, or you can only import AsyncWebhook
or you can modify the webhook folder inside discord.py to remove the circular import lol
and then try to use AsyncWebhookAdapter
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'AsyncWebhookAdapter' is not defined πΏ
da hec i cant (idk anything about that)
@bot.group()
async def git(ctx):
if ctx.invoked_subcommand is None:
await ctx.send('Invalid git command passed...')
@git.command()
async def push(ctx, remote: str, branch: str):
await ctx.send('Pushing to {} {}'.format(remote, branch))
Can i check the code?
uhhhhhhhh
all code?
the one that raises the error π
or you can only import AsyncWebhook
from discord import Webhook, AsyncWebhook
ImportError: cannot import name 'AsyncWebhook' from 'discord' (C:\Python310\lib\site-packages\discord_init_.py) oh wow
Bruh AsyncWebhook doesn't exists lol
@bot.command(
aliases=["say"]
)
async def repeat(ctx, text=None):
if text == None:
await ctx.send("where text")
else:
async with aiohttp.ClientSession() as session:
webhook = Webhook.from_url('no', adapter=AsyncWebhookAdapter(session))
await webhook.send(username=ctx.author.name, avatar_url=ctx.author.display_avatar, content=text)
πΏ
Why the fuck there is all those circular import lol
now what tf i must do? Webhook.AsyncWebhookAdapter ???
I don't know hahaha, you can try to contact one of the contributors of discord.py
πΏ what
do u mean owners or what
or you can try to use disnake
oh no, another fork appears :l
disnake doesn't have asyncwebhook but has the webhook class, maybe they fixed that issue
in fact as session disnake use aiohttp.ClientSession
can disnake work together with dpy πΏ
idk
with disnake you will not have this issue because aiohttp is an external package
so no way you will have a circular import
that's in what (module?) my bot written in πΏ
?
my bot use dpy bruh πΏ
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
wait :) as simple as that?
yup
OMFG ok ty
lol, np
did someone know how to download attached file on pycord?
so, discord.ext = disnake.ext? and all other things use discord?
fuck that, docs's here https://docs.disnake.dev/en/latest/index.html
k :V
:)) ok ty
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?
you will find that the docs too are pretty similar
I can't found nothing for that π
i hate u
from disnake import Webhook, asyncwebhook
ImportError: cannot import name 'asyncwebhook' from 'disnake' (C:\Python310\lib\site-packages\disnake_init_.py)
not sure you can. you could check audit logs but that will be challenging
i told you, you have to change the asyncwebhook thing hahaha
I think audit log is the better option
?????

Your session became an aiohttp.ClientSession object
so instead of AsyncWebhook you need to import aiohttp.ClientSession and create a session with that
import aiohttp.ClientSession ? wow, so confoozing
why is ctx.guild.owner returning None
nah not that much, check the docs and you will find how to do that
import aiohttp
import aiohttp.ClientSession
is that work like dis
you can import only clientsession, like doin this from aiohttp import ClientSession
and also what to do with that webhook thing πΏ
rip the server doesnt have any owner
https://docs.disnake.dev/en/latest/api.html?highlight=webhook#disnake.Webhook.from_url Check this, this is the webhook.from_url method
so, what to do with dis, is stil the same or no
πͺ¦ r i p
https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientSession this is clientsession class
Members intent
oh ok ty
!d aiohttp.ClientSession is also there (:
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.
doc command is against me today
already failed 4 times xD
xD
imagine using aiohttp 
Β―_(γ)_/Β―
man i was so getting to this that i was forgettin that i should do my work now xD
Lmao happens
finnally fking work, ty
Happy to help
Oh thanks
_now i have a question, how to make my bot create a webhook URL πΏ _
!d discord.Webhook.url
property url: str```
Returns the webhookβs url.
!d discord.TextChannel.create_webhook
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.
ok ty
is disnake also can πΏ
Yea
k ty
and now, how to make my bot access the webhook URL
you wont need it
wut
yeah you're creating the webhook, it cant have a link before you create it
πΏββ
nvm
webhook = await channel.create_webhook(...)
print(webhook.url)
await?
webhook = await TextChannel.create_webhook(name="Hunter uwu")
await webhook.send(content="hunter qt")```
Yea
oh ok, ty
await create_webhook(*, name, avatar=None, reason=None)``` is the star needed
That means it's a kwarg
See this ^^^
all the args after the star are kwargs*
Yea
oh ok, so i dont need it
TypeError: TextChannel.create_webhook() takes 1 positional argument but 2 positional arguments (and 2 keyword-only arguments) were given
now what
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)```
how can fetch a user's xbox name from their profile?
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^^^
U need to edit the message too
me?
how can i get the list of all the commands including the subcommands?
Yea
there is no other way?
Why r u creating another webhook tho
No
but wait
@maiden fable
!d discord.ext.commands.Bot.commands
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.
they edit it to the same message?

yeah but how can i check it it is a subcommand?
!d discord.ext.commands.Group.commands
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.
ow thanks π
U need to use try except
nope they done edit
How do you know?
Bro, u have to make an API call to let the API know that we are changing the button text
do I try above await member.edit?
!d disnake.ext.commands.Group.commands
property commands```
A unique set of commands without aliases that are registered.
Yea, or just check the member's permissions
hmm
saw it
@maiden fable its not same in disnake?
It is
then...
Then...?
@maiden fable why is it Any?
ThTs just type hinting
Idk tbh. I think it's the same code from dpy
hmm, lemme try
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
Command raised an exception: TypeError: 'property' object is not iterable
Oh mind showing the code?
sure
Oh wait
@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)}"
)
!d discord.ext.commands.Bot.walk_commands is there. U should use this
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
ow
Same in disnake
will try
!d disnake.ext.commands.Bot.walk_commands
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
thx π
You could count all the commands in all of your cogs.
totalcommands = 0
for cog in self.bot.cogs():
for command in cog.commands():
totalcommands + 1
for command in cog.Group.commands():
totalcommands + 1
for command in self.bot.commands if command.hidden:
totalcommands - 1
ow
?
ok*
thats unnecessary and badly written
thats like so slow
^^
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
total_cmds = len([command.name for command in self.bot.walk_commands() if not command.hidden])
``` is faster ig
Yup
idk if it will work, just made that rn 
the snake
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`.
!d disnake.Embed
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.
If a message has been deleted, can you still try to get it?
no
if you catch the deleted message, you can 100% have it returned back to you.
like, a payload such as the one you get from RawMessageDeleteEvent
Perhaps. .get_*() has to do with the cache, so it's possible that messages aren't instantly popped off the cache when they're deleted
Yeah
i was thinking the same thing, then thought, whats the likelihood of messages being removed from cache once deleted?
ive never really looked into that
Well shouldn't be hard to test out
what cache system does dpy even use?
During the raw message delete event you can try to .get_message() using the ID
well this would return the message instance, no?
Discord.py uses a deque cache for messages
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
https://vcokltfre.dev/ useful guide to get you started
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
Ok thanks ill have a look
only messages?
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
you've been ratelimited, classic replit
What should i do?
Get off replit
Ok
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
Thanks
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).
^ 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
Unfortunately, replit is the only thing on which I can learn Python on my phone.I don't have a computer
Yes, I agree with you.Coding on phone have different disadvantages
Yeah well unfortunately it's just replit and there's not much you can do but wait until you're not longer rate limited
Enter kill 1 in the shell
I have no idea
I think I've heard of that as a "fix" for this issue, although I'm not sure
but I heard that command changes your current IP to another one
preferably you would just get off replit and look for another host but that isn't really an option here
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)
Most likely repl.it spawns a new container for you
Perhaps thatβs what gives you the new IP
That would make sense
Mmm. How i can show bot ping?
add f before your ""
f"Hello! My ping is {bot.latency}"
well you should round because latency returns the time in microseconds i think
Round or int() it sure
should try this: round(bot.latency, 1)
Ok
mobile π
You seem to be using client, use that
Looks like you're still ratelimited
don't crosspost, you already got your answer in the other server
Sadly
stop saying 'it doesnt work", instead, show what you tried etc
you set up your error handler the wrong way most likely
Error
trying to install nextcord but got this error:
Could not find a version that satisfies the requirement nextcord....
im using python 3.8.6
I'm assuming it's that ratelimit you'll probably have to wait out
^
explain why nextcord
also, you probably didn't use the right version of pip when installing
/your python interpreter in your IDE is wrong
i used pip 2.11 or something for nextcord
pip install --upgrade pip
if possible
yeah
maybe even python3.8 -m pip install --upgrade pip
don't know if that works for nextcord i have python 3.9.5
or pip3.8 install nextcord 
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
lmao what
it's pretty similar but still has some major differences
"Pretty similar but major differences"
yeah
Doesn't go well together lol
but it's true lol
have a seperate nextcord folder ->
everything in the discord folder hasn't been updated since 5 months except the title in the init
Yo, anyone able to help me host my discord bot that doesn't shut off?
"Help you host it" how?
Suggest hosts?
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.
Well, do you have the code for it?
!d discord.ext.tasks.loop
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").
!d discord.ext.commands.Bot.change_presence with that
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.
thats not free
is there any consensus on the best discord bot lib fork to use?
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
+1
sadly, the big three seem to be nextcord, pycord, disnake
its a big leap to jump to one and there is little consensus yet which is dissapointing
everyone here uses disnake
disnake is much preferred to the other 3 forks, and you would probably get most help with it
That's probably one of the more liked ones of the three
noted, ya disnake is what im seeing the most of
Yeah, I agree on that too. @dim ruin was going to use disnake as well
and what most people seem to be settling on
cool, thats good enough for me. auditing their source they also seemed the msot solid
although the grounds are still shaky
File "C:\Users\sweti\Downloads\drive-download-20220228T165050Z-001\main.py", line 50, in <module>
bot.run(TOKEN)
Someone help me with this problem.
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
what problem?
you didnt actually show anything
File "C:\Users\sweti\Downloads\drive-download-20220228T165050Z-001\main.py", line 50, in <module>
bot.run(TOKEN)
Missed the most important part of that traceback
...
thats spectacularly unhelpful
what?
many different ways
Can you get the entire error?
please help me :p
although from assumption maybe it's a wrong token or an empty string
you also have not provided any context or supplemntary code to make helping you possible
π
?
i dont understand
you havent asked a good question, havent shown any code or showed us what you have so far. your question isnt really answerable
"these commands"? maybe you mean cogs?
provide more context and we can help. there are many different ways you COULD do this
i dont understand
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
i am still a beginner sorry
if you go to a mechanic and say "car broke" then walk out what do you think they will say?
oh ive tested the codes, they all work but when i put them in the cogs they dont
"what isa the problem"
what error do you receive when doing it with cogs?
well thats not good, but how do you expect us to help with stuff when youve told us nothing about it?
let me see again
ill give you a hint, post screenshots or copy paste your code
me?
until you do that this isnt a useful conversation
both of yo
ok
you have also not shown anything useful π
that tells us nothing
that isn't the full traceback
dont crop it
get the entire error
take a full screen screensyhot
just info dump the whole screen, we know what we ar elookign for
there we go
now if you had posted that in your original message in this channel we would be way further rn lol
yeee
for future reference lead with that next time
okk
I can barely notice it but seems you haven't enabled privileged intents
!intents do u have anything that looks like this in your code?
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.
i have @quick gust
make sure to enable them in the Developer Portal aswell
read this
screenshot plz
take one of your entire screen do not crop it
Has anyone created a discord bot that purges specific channels at a specific time automatically? I am stuck here and looking for some assistance
You might wanna check out the discord.ext.tasks extension
cogs structure and main file structure are entirely different
Hm I can't do it for free?
I tried but it seems to block the rest of the commands when it is running
how are asynchronous loops blocking code 
I have other commands like /train, /gtg, so when i run the bot with auto purger segment on. These commands dont work
probably some other code blockin them, tasks are async
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
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())
I am confused π
use tasks 
ext.tasks
!d discord.ext.tasks.loop
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").
yeah mb, second time same mistake
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()
!paste
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.
discord.Client 
tasks are very simple
caeden help pliz
with what
this person smh, me gonna go play
https://github.com/DisnakeDev/disnake/blob/master/disnake/ext/tasks/__init__.py#L140 if they read this all their problems will go away
disnake/ext/tasks/__init__.py line 140
async def _loop(self, *args: Any, **kwargs: Any) -> None:```
why while loops in task tho
for loops are so easy to make
for i in range(β) works with python 3.10
what 
nods convincingly

!e
for i in range(β):
print(i)
@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)
he lies
!e print.__call__(__import__('os'))
@manic wing :white_check_mark: Your eval job has completed with return code 0.
<module 'os' from '/usr/local/lib/python3.10/os.py'>
damn its 3.10
caeden lies 
nitro isnt free

slowly walks away
Yeah hi can someone help me host my bot 24/7
Use a VPS/read pins
Imagine if infinity worked with Python
refer to this - #discord-bots message
I don't think people would let you host your bot on their VPS since they're paying for it, they'll probably make you split the bill
Never :)
Yeah I am broke
AWS has a free tier, but if you want some of their more powerful machines such as the t3.small it's not that expensive
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
My bot has no purpose other than aesthetics
I think my ec2 instances come out to be ~30/month excluding other services like domains and S3 storage unit
Rip ;-;
If anyone tryna let me run my bot from them lmk
Okay ig
I'll slide u 1 pizza crust per month
Consider dockerizing your code so it's easy for people to host it for you
Man I am silly and stupid so people get really frustrated at me because I don't understand it
I am the same π
calling yourself silly and stupid is just lowering your self-esteem 
You do know everyone knows their reality, right?
hate to be that guy, but we're not counsellors, please stay on topic
yeah lol
facts π
Very true
Ye so if someone wants a pizza crust shipped to them and can host my bot or something dm me
That would be nasty
dms u but without a VPS
I will vacuum seal it
what
Meh, my bot itself is being hosted by a friend, don't expect anything from me
Get me that friend
I do have an EC2 instance running π
do you think pizza is gonna get us?
No thanks
robin stop im literally going to go psycho
@distant sparrow where do u live tho like what country
Why lol
literally 1 out of 3 times i go into discord-bots you're mentioned aws
Ukraine
thats not even a joke
smh see the edited msg
I like aws ok
no time to joke
leave me alone βΉοΈ
?
your bad, not my problem
That's not a joke
Do NOT make those kind of jokes here. Maintain the peace. Period
thats not a joke
π shipping charges hella expensive from Ukraine to India
what if he lives there... tf?
Why is my nationality a joke now?

Meh okay stop the bully
I dont think they are

You want a picture from my apartment lol?
same, i mean, nobody would be-
No I believe you
Not a joke, just I never talked with someone from Ukraine recently since u know why, so thought u were joking
Oh lol yes I am Ukranian

yes, only 40 million people who live there that clearly must not exist according you
stage 2, good luck

!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
.topic
Suggest more topics here!
lots of minimods here
i dont particularly want to get perm banned
That is known as spamming useless commands here
again
didn't target u, just telling him the truth about this channel
hunter can we veer back on topic
i think tasks is redundant
VOICE. RECEIVING.
guys stop arguing if u think Im offended Im not so its fine
why π₯Ί
never said you did, you always do 
disnake/ext/tasks/__init__.py line 140
async def _loop(self, *args: Any, **kwargs: Any) -> None:```
@final iron
Okay okay it ain't my intention to target u, sorry for that
!zen
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!
guild_prefixes[str(ctx.guild.id)][str(ctx.author.id)] = prefix will this work to add the prefix?
not as simple as for a newbie like me
sure
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
this wont work when I use it
@maiden fable how can i get the prefix from that?
Huh?
like
its to make a music bot, I use the command, and it says not in a VC
Music commands do be against ToS
what ToS?
Terms of Service
many bots are music bots
guild_prefixes.get([str(ctx.guild.id)][str(ctx.author.id)]):
@maiden fable is this the right way to pull the prefix from it?
youtube's
what is guild_prefixes? a dict?
yes
bot can play music not only from youtube
so use spotify
Ah yes that should work
alr
Against ToS
I tried to send a snipe command, but it only works when i delete a message that was sent after the bot starts up
isnt their music highly encrypted which makes it unable to stream audio 
is it because it needs to be in it's cache?
spotify_dl
im not sure
against tos? ofc
Against ToS
tos
yes
s.m.h.
You cannot download music from a legal site lol
yes
don't matter, same ToS rejection
i know
I know, I was just answering your question lol
alright π¦
So yea, in short you cannot stream music without paying millions to the creators as royalty, so might just drop the idea
imagine spending money on a discord bot used by 10 servers 
That too millions lmao

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
how come my snipe command only snipes messages that were sent and deleted after my bot starts up
That is what should happen
because the bot only starts to track messages when it comes online
Since the cache refreshes everytime yr bot restarts
!d discord.on_raw_message_delete
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.
is there any option to not refresh the cache after every restart
.......?
i was showing the alternative to just cached messages?
With how discord.py works no, not unless you do major monkey patching
.....?
You didn't understand me lol
not really unless you fuck with the internals
mess with the internals not really unless you are planning to make your own wrapper
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
U both do know that it is known as monkey patching, as andy said, right? (cc @manic wing)
I dont, I barely read any message of andy's
you do know i am aware but dont really care? (bcc @maiden fable )
No I didn't
Now u do lmao
is this better hunter
you can stop doing the ....
not really, idk if you're trying to push info in my brain without me knowing 
Bro, the cache which is stored in the RAM is gonna refresh anyway when the bot restarts
I am lmao. I am just saying that editing the internals to suit our personal needs is known as monkey patching
?
Nvm I give up
read my message
preferably with code
yep
read the error again, hunter
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)
try printing guild_prefixes[str(guild)]
where
!d discord.on_raw_reaction_add is what u need
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.
anywhere, we are just debugging the code

Don't
Copy
It
Off
GitHub
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
o
thats the same error with no new information
Mind printing the whole dict?
is empty
Why are you doing .get([])?
bro calm down
im quite calm thanks
i saw smth look
AAAAAAAAAAAH YES
.
Ah remove the []
no it's just the name of the key in string form
so without []
!e
x = {
"hello": "world"
}
print(x.get("hello"))
@sick birch :white_check_mark: Your eval job has completed with return code 0.
world
guild_prefixes.get(str(guild), str(author))
just like so
that's good?
Why the comma? It only takes one argument
guild_prefixes.get(str(guild), str(author)) is this good?
guild_prefixes.get(str(guild))[str(author)]
Watch Youtube videos π
That's just as bad
so this?
it takes two or more, the second one is the catch argument
Sure
!e
x = {
"hello": "world"
}
print(x.get("e", 1))
@manic wing :white_check_mark: Your eval job has completed with return code 0.
1
guild_prefixes.get(str(guild)).get(str(author))
so which one bruh
Both work
Just start by creating a command, then when command is used, the bot creates a channel with perms etc...
being painful already
Nevermind, use that then
and keep testing
So if it doesn't find a guild prefix, it'll default to username#discrim instead, is that what you want?
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 = "."
if [str(ctx.guild.id)][str(ctx.author.id)] ??
why are you indexing an str with an str
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
will that work tho?
like ye it should get the guild id and author id in the command error
no this is like really messed up lol
@sick birch
start using .get() instead of using []
like?
right now you have a list and you're trying to subscript that list using a string
theres no point using .get instead if you dont have the fallback arg
You can avoid try/except hell
robin how can i fix this bruh
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
if [str(ctx.guild.id)][str(ctx.author.id)] like what's this supposed to be
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
that's like doing [1, 2, 3, 4]["string"]
all you need to do is
if str(guild.id) in guild_prefixes:
...
no bro is something different here
i need guild id + author id + prefix
like a self prefix but for guild .. not global
str(guild) returns the guild name you are aware of that?
it doesn't
and str(author) returns authorName#discrim
oh did you change the variable names
ah yeah
yes
naming conventions are not the best but i guess that's ok
damn u the bird do be cute
i DO use this, but it still only works after the bot starts up
@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
you cant wait like 3 seconds for the bot to turn on?


