#discord-bots
1 messages · Page 909 of 1
But one person can create multiple invites
On the other hand one invite can only point to one channel so it's better to think of invites as associated with a channel rather than a member
A guild being at the max amount of invites, 1000, doesn't matter
What is the best way to listen to a VoiceChannel and do something when a member joins or leaves a specific voice channel?
Ideally, the behavior I would like is as follows:
Establish a channel and create an event listener for that channel in particular as a rather than a chain of similar cases like if channel_id==xyz in the body of a general method handling a voice state change over the whole channel, if there are many different channels that sounds like an awful way of handling individual channels
one idea I had was to create a channel object and somehow establish a listener pattern within it but not sure how to manage that, although that would certainly be a nice way of doing things if anyone has ideas on that?
looked at the following link:
https://discord.com/developers/docs/resources/voice#voice-state-object
I notice you get a dict with the channel id and all
so I can definitely process that
but I'd like to find means by which to do so efficiently - any ideas?
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
There's no native way. You'll need to compare the channel which they joined to the specific channel you want
ok so lets take this servers invite for example. discord.gg/python I think? I send this link to someone and they join. How would a bot know that I have invited them?
it wouldnt because you didnt make the invite
so how do invite trackers know?
by looking at which invite was used and who created that invite
if person A creates an invite and person B sends it to person C who joins with it, it's effectively person A who invited C
You would get all the invites from before that member joined. Compare that to all the invites after the member joined. One of those invites will be one more than it was before, that's how you know they joined using that invite
discord gives no good way of telling if an invite was used, other than invite count
But that isn’t very good either
!sm set #discord-bots 4s
✅ The slowmode delay for #discord-bots is now 4 seconds.
The only effective way of tracking invites is to go through an OAuth flow on a bot's website because then the bot gets explicit info
thanku
Say you have these invites:
X - 1 use
Y - 1 use
Z - 2 uses
now say a member joined, this is how the invites look like now:
X - 2 uses
Y - 1 use
Z - 2 uses
Now you know that the user joined using invite X
What is the length of invites
yes I know that. But if I want to reward someone for inviting 100 people, I wouldn't know who invited who
Like if let’s say I’m generating random invite codes how would I implement it
I would just know which invitation was used
I’m some cases you’d get wrong info with how this works as well though
Discord really frowns upon invite-for-reward servers, my advice would be to just not do that at all
pls help
I need to implement an algorithm to generate random discord invite codes
Could you explain a bit more about what you're trying to achieve :P
oh ok :/
thanks
You don't get to choose Discord invites so you'd have to let discord generate them for you
It’s a fiverr order I need to generate random discord invite codes
create random strings 8 characters long
I'm not sure I understand, you need to create random invalid discord invite codes for fiverr?
8 characters long Base64?
yeah
And they could be valid right
This sounds either useless or malicious, likely the latter, so I'm afraid out of an abundance of caution I won't be able to help
Ok I guess let me ask this order guy a bit more
and add latter to his nick is sqlinjections 😛
this raises type object is not iterable in the send
all_pages = []
for chunk in [all_snippets[i : i + 5] for i in range(0, len(all_snippets), 5)]:
page = disnake.Embed(title=f"Snippets [{len(all_snippets)}]", color = disnake.Color.blurple())
for snippet in chunk:
page.add_field(
name=snippet[0],
value=snippet[1][:117] + "..." if len(snippet[1]) > 120 else snippet[1])
page.set_footer(text="Use the buttons to flip pages.")
all_pages.append(page)
if len(all_pages) == 1:
all_embeds = all_pages[0]
else:
all_embeds = [embed for embed in all_pages]
await ctx.send(embed=all_embeds[0], view=Menu(all_embeds))
is there a way to group commands in nextcord?
Text or slash commands?
anyone got any examples of auto complete in action? I'm not really sure what the difference is between choices and auto complete as they seem rather similar
Here's an example someone made of how it could be used https://raw.githubusercontent.com/vcokltfre/autocomplete-calc-poc/master/example.mp4
text commands
if you're using cogs you should be able to use @commands.group() instead of @commands.command()
@slate swan, looks like you posted a Discord webhook URL. Therefore, your message has been removed, and your webhook has been deleted. You can re-create it if you wish to. If you believe this was a mistake, please let us know.
currently im using bot.getCommand("commandname").module
that's auto complete I take it? seems super laggy ngl
syntax?
It only sends the text after you stop typing for a while so that your app doesn't get spammed with requests
can I add a group name?
Ignoring exception in command role:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "D:\. InviteMnger\main.py", line 370, in role
web = DiscordWebhook(url="LINK HERE - Canary I Used",
NameError: name 'DiscordWebhook' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'DiscordWebhook' is not defined
You'll probably find this useful: https://nextcord.readthedocs.io/en/stable/ext/commands/api.html#nextcord.ext.commands.group
yeah makes sense
how do I get the group?
so the name of the group from the command?
how do I get that
I'm not sure what you mean
if a command is part of a group then its parent attribute will be the group
Is it possible to make the replit bot work 24/7?
set_footer(*, text=Embed.Empty, icon_url=Embed.Empty)```
Sets the footer for the embed content.
This function returns the class instance to allow for fluent-style chaining.
how can i unban a member? when i try member.unban(reason=None) return invoke error
you have to unban via a guild object since someone who is banned cannot be a member
!d discord.Guild.unban
await unban(user, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Unbans a user from the guild.
The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
you can pass a discord.Object() into the ban method in place of an actual user/member object
Ignoring exception in command role:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "D:\. InviteMnger\main.py", line 370, in role
web = DiscordWebhook(url="LINK HERE - Canary I Used",
NameError: name 'DiscordWebhook' is not defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'DiscordWebhook' is not defined
Any1 know ive tried
DiscordWebhook isn't a thing, you're probably looking for just Webhook
which you need to import from discord/nextcord/disnake/your library of choice
Can you join a server doing POST/api/v9/invites/{invite_code} ?!?!
no
bots can only join servers by being added by someone with permissions
k thanks
ey, im extremely new to python
so I have a list of cogs that my bot loads stored in a config.py file. I'm working on making commands to load/unload/reload cogs and felt that using the choices class made the most sense bc it could provide the user with a list of my cogs but I'm not sure which implementation of choices https://gist.github.com/Rapptz/c4324f17a80c94776832430007ad40e6#choices would be the best to use for my use case (keep in mind the cogs are stored in the list as "cogs.cog_name" so I'll need to do some string splitting to remove the "cogs." part from the lists strings
set_footer needs 1 argument but recieves 2?
Does anyone know who i have an error here?
if u selfbotting wich we dont support here
I know but client wants a bot that joins servers
yes u dont use " " @slate swan
dont work
url=f"{ngrok}/voice"
Bruh this guy has like $1000 USD budget and he wants a bot that joins server and DMs every member invite
What do I do
Decline?
@tame nymphleave this server or stop talking abotu it.
Ok
and clearly not a task for you anyway if u need to come here ask for help.
@vocal plover it is a thing btw i fixed it i imported the wrong thing
awesome :P
Is it possible to make the replit bot work 24/7?
it is possible (variety of methods can be found online) but if at all possible I'd highly recommend not using it since it is both underpowered and uses a few shared IP addresses across its hosts which means a hight chance of your bot being banned or ratelimited because of other people's badly behaving bots
yes, until it gets banned
!vps
yes but don't
What hosting to use?
@vocal plover
I have my own server that I put in a datacenter so I'm probably not the best role model here
, but I'd recommend looking at the free tiers of AWS, Google Cloud, and Azure, and possibly Linode
Ok
await coro(*args, **kwargs)
File "D:\Discord BOT\main.py", line 62, in on_message
await update_Data(USERDATA, message.author)
File "D:\Discord BOT\main.py", line 46, in update_Data
if not user.id in USERDATA:
ValueError: I/O operation on closed file.```
whats this
if that the full traceback? it looks like you've closed a file and then tried to read/write to it
if you used a context manager, it closes the file after exiting the scope of the manager
What like atom?
??
whats a context manager?
how do you open youtr file
idle python?
in code...
F5?
what do you write in code to open your file
it dosent open it
it just dumps and takes stuff into it and from it
yeah the file has to be opened to do shit with it...
how?

ares lol
🗿
how.
i assume you are new to python, then you might check resources 
what?
Hello, im new to python. Anyone know hy this is giving errors?
i installed the required stuff, the dev from github told me to
prolly not installed
you try to write data in a file. you need to open the file first, then write what you want and close the file. it's simple and logic as that.
and what are you doing with flask
i installed em all from cmd
restart vscode
how
do
i
open
the
file
already did
how
did
you
write
in
the
file?
Or tried, anyway
choose an interpreter again
if i install again, it just says requirement already satisfied
CTRL+SHIFT+P and type python, then select interpreter
user_data = json.load(USERDATA)```
that is a context manager
outside the scope of that statement, you can no longer so stuff with the file (although the variable isn't destroyed)
Traceback (most recent call last):
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\site-packages\disnake\client.py", line 531, in _run_event
await coro(*args, **kwargs)
File "D:\Discord BOT\main.py", line 63, in on_message
await update_Data(USERDATA, message.author)
File "D:\Discord BOT\main.py", line 47, in update_Data
USERDATA[user.id] = {}
TypeError: '_io.TextIOWrapper' object does not support item assignment```
Is ctx.author.edit a thing?
you named your variable user_data, USER_DATA is the file object
wym
USER_DATA is a file object created by open(), it is not the dictionary you created using the data from that file
so i do USER_DATA not user_data
That's what you're doing currently
you need to use user_data[user.id] = ... instead
Are you using slash commands?
Can this be used, to send api data to a json file?
wdym slash commands
i asked in a help channel but got nothing. how do i make a colour info command using pillow?
import disnake
from disnake.ext import commands
import PIL
class colours(commands.Cog):
"""A set of colour commands."""
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.slash_command()
async def colours(self, inter):
pass
@colours.sub_command()
async def hex(self, inter, bot, hex: str):
colourEmbed = disnake.Embed(
title = hex,
colour = f"")
json.dump(USERDATA, f)```
this can
I tried something like that before, but got data is not defined
/
oh yeah
bot uses that for commands
@commands.has_permissions(administrator=True)
async def nick(ctx, member: discord.Member = None, *, nick,):
if member == None:
await ctx.author.edit(nick=nick)
embed = discord.Embed(title="", description=f'**Name for {ctx.author.mention} has been changed!**', colour=0x992d22)
await ctx.send(embed=embed)
else:
await member.edit(nick=nick)
embed = discord.Embed(title="", description=f'**Name for {member.mention} has been changed!**', colour=0x992d22)
await ctx.send(embed=embed)```
**Why does this command only work if the user pings a other guy but if he doesnt ping someone it doesnt change his nick name?** it doesnt give me a error
Ok, what was the prob again?
the imports
they are giving me errors
I even did these installs pip install twilio pip3 install discord pip install -U discord-py-interactions
what is json docs
Does it say requirement already satisfied?
Api data, I want in a json file
Check All your code, you might have a copy somewhere
like its imported several places or
What’s twilio?
A service that lets you make automated texts or phone calls
my guy answered😂
What for?
No commands?
yeah there is commands, but twilio is for that stuff. U make a command, and trough twilio API, u can send SMS, make voice calls, TTS
etc.
twilio gives you your own private phone number
Sounds good, is it free/cheaper than 📱?
theres is a trial im using, but im not sure how limited it is
these imports are just pissing me off, dosent make any sense
Start # some off, see what happens 🤔
that just causes more errors in the code
Ok, forget I said it 🤣🙈
its like, the code know im using the library, but detetcs it as not installed
Type python main/bot.py in console, see what it says
File "C:\Users\frede\Desktop\OTP-Bot-main\bot.py", line 67
url=f{ngrok}'/voice',
^
SyntaxError: invalid syntax```
thats the error, no idea why its there
Which ide you using?
VS code
you forgot the opening quote/you have it at the wrong place
how to install python in replit with using command npm i ?
👍🏼
What’s npm i?
i have node.js already but my discord bot require python
can u maybe make a correct sample of how it should look. Im used to C#, and understand jack shit of this language.
It might of been to make something simpler first in 🐍 🤔
No its not like that. Its a bot i found from github, i just need to have up and running, not continue on it. It just have these erros which im stuck with
you should ask the person who made it
Ok. I was only to help. Can I look at the github pls?
👍🏼
who knows pymongo?
Can I take this looppy for entry in initial_extensions: cog = entry.strip('"').split('.')[1] Choice(name=cog.title(), value=entry), cogs.append(choice)and turn it into a concatenated(?) loop like thispy cogs = [cog.strip('"').split('.')[1] for cog in initial_extensions]and if so does someone mind telling me how bc I can't wrap my head around it
node.js is for javascript, you need a python repl for running a python bot
warning = cursor.execute('SELECT * FROM banwords WHERE userid = ?', (message.author.id,)).fetchone()
2022-03-15T20:51:22.447042+00:00 app[worker.1]: psycopg2.errors.SyntaxError: syntax error at end of input
2022-03-15T20:51:22.447042+00:00 app[worker.1]: LINE 1: SELECT * FROM banwords WHERE userid = ?
2022-03-15T20:51:22.447042+00:00 app[worker.1]: ^
postgresql
How to fix.
my brains telling it could be this, does that look at all right?py cogs = [Choice(name=cog.strip('"').split('.')[1].title(),value=cog) for cog in initial_extensions]
Traceback (most recent call last):
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "D:\TEST BOT\main.py", line 27, in on_message
user_data = json.load(USERDATA)
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 293, in load
return loads(fp.read(),
AttributeError: 'str' object has no attribute 'read'```
wtf does this mean
can you send the code for that `on_message event and if it's too long you can use hastebin
!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.
async def on_message(member):
with open('users.json') as f:
users = json.load(USERDATA)
async def add_experience(users, user, exp):
users[user.id]['experience'] + exp
print(exp)
I'm not massively familiar with using json files but isn't it users=json.load(f)
Someone correct me if I'm wrong
Traceback (most recent call last):
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "D:\TEST BOT\main.py", line 27, in on_message
users=f.load(USERDATA)
AttributeError: '_io.TextIOWrapper' object has no attribute 'load'```
nah
argument naming and dont use json as a db lol
its a test DB im changing it after
what about all the data?
yeah i just edited it, is it still wrong?
nah its correct
it gets put into a json file
not what i ment
!e
import discord
print(help(discord))
@honest vessel :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | ModuleNotFoundError: No module named 'discord'
🗿
Traceback (most recent call last): File "/home/runner/nitr0h/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped ret = await coro(*args, **kwargs) File "/home/runner/nitr0h/cogs/clean.py", line 12, in clear await ctx.reply("Got it. Clearing {} messages... 🧹".format(amount), delete_after=3) AttributeError: 'Clear' object has no attribute 'reply'
ah shit i wish this would work show that u can import lib n check help file aka "man in linux"
ok so
Can I take this looppy for entry in initial_extensions: cog = entry.strip('"').split('.')[1] Choice(name=cog.title(), value=entry), cogs.append(choice)and turn it into a concatenated(?) loop like thispy cogs = [cog.strip('"').split('.')[1] for cog in initial_extensions]and if so does someone mind telling me how bc I'm struggling to wrap my head around it but my brains telling it could be this,py cogs = [Choice(name=cog.strip('"').split('.')[1].title(),value=cog) for cog in initial_extensions]
@dusk karma
I used set_image for embed but some images still appear outside the embed
May the image size be the cause?
oh ok
are you adding any file or files into the send? I've never heard of file size causing images to not send as embeds
what are you trying to do, detect if 'discord.gg' is in a message's contents?
so what's the problem with it atm, producing any errors or just not firing? if your trying to pick up a mention remove the ! from the mention as it won't be detecting that as a proper mention
How?
elif client.mention in message.content:```try this
Bot.user
if client.user.mentioned_in(message.content):
which is idk why
oh I know, this also triggers on everyone pings
How would I get this to work py @client.event async def on_message(message): if message.channel.id == 942045216658051072: await message.add_reaction("🐒") . await message.add_reaction("😉") await client.process_commands(message)
Traceback (most recent call last):
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "D:\TEST BOT\main.py", line 46, in on_message
await update_Data(users, message.author)
NameError: name 'message' is not defined```
why is message not defined?
show your params
await update_Data(users, message.author)```
i can help with that dm pls
remove the period and the process coro should be outside of the if statement or use listen which you wouldnt need to process it
why bruh
i sent
your command params
isnt a command
the function params*
@bot.event
async def on_message(member):
change member to message so message will be the param of the function its basic oop
i can also help with that 👍
solve it
how can i edit a message with tasks.loop ?
@tasks.loop(seconds=5)
async def idk(ctx):
await ctx.message.edit(content="foo")
@bot.command()
async def test(ctx):
await ctx.send("hey")
idk.start()
that's my take
Anyone know why my clear message command wont work?
client = commands.Bot(command_prefix='?')
@client.command()
async def clear(ctx, amount=30):
await ctx.channel.purge(limit=amount+1)
tried that too but it didnt work
Traceback (most recent call last):
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "D:\TEST BOT\main.py", line 52, in on_message
await level_up(users, message.author, message.channel)
TypeError: level_up() missing 1 required positional argument: 'exp'```
As the error message says, you're missing an argument in the function being called, you need to provide a value to exp
!d discord.abc.Messageable.fetch_message
await fetch_message(id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
it has a value
Evidently not
You need to provide it as a function argument, setting it as a variable won't work
and why are you making it a tuple lol
wym tuple?
that's not a tuple, since it's just wrapped in parentheses as a single object without a comma the parentheses are ignored
they are, however, unnecessary
ah right i forgot python interprets parenthesis like that lol
How do I do this I was jus taught the variable
it's pretty confusing tbh, such a change in behaviour between almost identical source
your level_up() function should be called as level_up(exp)
Ty!
ikr it really does confuse sometimes lol
that way you're passing the value of exp into the function
its confusing but its handy and can be understood well sometimes
indeed
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | TypeError: unsupported operand type(s) for |: 'dict' and 'int'
!e print(({1: 2} | {1: 3})[1])
@slate swan :white_check_mark: Your eval job has completed with return code 0.
3
@slate swan :white_check_mark: Your eval job has completed with return code 0.
python for example
Traceback (most recent call last):
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "D:\TEST BOT\main.py", line 52, in on_message
await level_up(exp, users, message.author, message.channel)
File "D:\TEST BOT\main.py", line 46, in level_up
await message.send(channel, '{} has leveled up to {}' .format(user.mention, str(lvl_end)))
AttributeError: 'int' object has no attribute 'send'```
im so confused
message is an int
Yh it's ment to be
i get 403 forbidden, may i ask what permission it takes?
message should be a message obj
So I convert int to an str?
no
bro
I'm so dumb allow it 😭
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
message is an instance of the Message obj
yep ik but what discord permission is that (if u know which one it is)
async def on_message(message: Message) -> None:
with annotations
not sure what perms the endpoint requires tbh
aight
maybe it cant see the channel idk
Cannot edit a message authored by another user can't the bot edit its own messages
it can, maybe you tried to edit a message that wasnt the bots
why else would it raise the error then? im not sure why it would raise that error for any other reason
¯_(ツ)_/¯
@slate swan u need that helper role lmfao i always see u in this chat when asking for help
haha nah theres people who help more then me like andy or tyler or panda or hunter allot of people who deserve it more which also thought me
ctx.message.author.voice.voice_channel``` "VoiceState" object has no attribute 'voice_channel'. How to fix it?
well the VoiceState class doesnt have that attr hence why the error was raised
so what can I do that the bot joins my voice channel?
sorry i cant help much with that ive never gone to the voice category 
np
ah no
no need just make the class outside of it and then just use the class lol
if the author is not connected to a vc this will occur, ctx.message.author.voice would be None in that case, so just run a check
that would just raise a nontype error
which would say NoneType doesnt have such an attr
i was connected
wym
^
like of what
pardon?
outside from what?
of the cog
alrdy tried that but theres a few problems with my on message
show
raise discord.ClientException(f'Callback for {self.name} command is missing "ctx" parameter.')
discord.errors.ClientException: Callback for menu command is missing "ctx" parameter.
@client.event
async def on_message(message):
results = collection_prefix.find({"guild_id":message.guild.id})
for result in results:
pass
if result["prefix"] == "":
client.command_prefix = dprefix
await client.process_commands(message)
else:
client.command_prefix = result["prefix"]
await client.process_commands(message)
- its your menu command
- use a db and get_prefix
- just use listen and no need for the same 2 coros in the if statement just have it outside so it will always execute or just use listen as said lol
yeah im alrdy using a db
mongodb
!d discord.ext.commands.Bot.get_prefix
await get_prefix(message)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves the prefix the bot is listening to with the message as a context.
how can i get cooldown for a command? and then reset it. for example bucket.reset
btw im using cooldown Mapping with @commands.check
wdym
i created a custom cooldown
ah
and idk how to reset it inside the command
how are you setting the cooldown
hol on
lemmee show u wut it loosk like
class is_premium:
def __init__(self, rate, per, rate1, per1, guilds: list):
self.bucket_type = commands.BucketType.guild
self.cooldown = commands.CooldownMapping.from_cooldown(rate, per, self.bucket_type)
self.premium_cooldown = commands.CooldownMapping.from_cooldown(rate1, per1, self.bucket_type)
self.guilds = guilds
def __call__(self, inter: disnake.Interaction):
key = inter.guild_id
if key in self.guilds:
bucket = self.premium_cooldown.get_bucket(inter)
else:
bucket = self.cooldown.get_bucket(inter)
retry_after = bucket.update_rate_limit()
if retry_after:
raise commands.CommandOnCooldown(bucket, retry_after, self.bucket_type)
return True```
what exactly are you trying to do? get the commands cooldown and then reset it?
ye im trying to do that
If I declare a embed as py embed = discord.Embed(timestamp=datetime.datetime.now())can I then do py embed.title("A super cool title") embed.description("A cool description") embed.colour(discord.Colour.green())later on in the code without needing to set a new embed var
yeah you can
oh cool, didn't know that until recently when I saw another bot doing it, this is going to make making embeds so much quicker
well im not sure im not familiar with the methods of cooldown lol
yeah its just setting the classes kwargs on an instance of the class
me neither 

well
you wouldnt call it
its an str that you set, not call
embed.description: str = …
ah yeah thats right ^
okay thanks for the help
so this?py embed.title=("__Load Error__")or do I drop the ( )?
putting () around an str does nothing
only when you add a trailing comma does it tupilize
👍
Nobody needs help? Kinda dead here 
I need some help here.
help me with homework
i need some help with adding this, if you type a wrong word that isnt on the code list, my bot says invalid word please try again
I'd be glad to help
Code list?
Sure thing one second
For what kind of thing is it
if word not in word_list:
Yeah
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
!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.
:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1647467257:f> (9 minutes and 59 seconds) (reason: newlines rule: sent 160 newlines in 10s).
rip
!unmute 817437509607882752
:incoming_envelope: :ok_hand: pardoned infraction mute for @slate swan.
oh thanks
!paste Please use this @slate swan
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.
!d discord.ext.commands.cooldown
@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.
A command can only have a single cooldown.
what are you trying to do exactly?
wrong code mb
if you write senw, that isnt on in my code so my bot will say , Invalid please try again
- just check if the message is in a list
- use listen
could you explain a bit better
on message just check if the content of the message is in a list with an if statement and then just send "ok" and then use else to print "Invalid please try again"
could i get an example
if message.content.lower() in word_list:
await message.channel.send("ok")
else:
await message.channel.send("Invalid please try again")
something like this
wym with annotations
annotations by typehints and the return annotation
im so lost
name: str is a type hint which falls into annotations and () -> None is the return type annotation which just shows what the method will return
for registering your bot on top.gg how would you make sure your bot follows api rate limits
!pep 484
for more info on it^
dosent work
bro its an example.
Traceback (most recent call last):
File "D:\TEST BOT\main.py", line 25, in <module>
async def on_message(message: Message) -> str:
NameError: name 'Message' is not defined
well the class isnt defined simple.
so
just do message: discord.Message since you arent importing the class and are you sure that return type is correct?
i dont know
i legit have the same error i had at the start 🤣
Traceback (most recent call last):
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "D:\TEST BOT\main.py", line 52, in on_message
await level_up(exp, users, message.author, message.channel)
File "D:\TEST BOT\main.py", line 46, in level_up
await message.send(channel, '{} has leveled up to {}' .format(user.mention, lvl_end))
AttributeError: 'int' object has no attribute 'send'
^
^ look at the params it takes, a message obj
just makes no sense
its simple oop an int doesnt have that method
ENGLISH?
yes its in english
it isnt
its just terms lol
hello, i have a question how do i get the content of this message &enable hello world
its simple object oriented programming, an integer doesnt have that method
!d discord.Message.content
The actual contents of the message.
example?
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "D:\TEST BOT\main.py", line 50, in on_message
await update_Data(users, discord.Message.author)
File "D:\TEST BOT\main.py", line 31, in update_Data
if not user.id in users:
AttributeError: 'member_descriptor' object has no attribute 'id'```
??
is it on message?
well not really is in a command
AttributeError: 'member_descriptor' object has no attribute 'id'
thanks for telling me something ive read
!e print(["lol", "ok"].split("."))
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | AttributeError: 'list' object has no attribute 'split'
show params
dosent make sense to me
Have you learnt oop yet?
no
That's why it makes no sense
then you should learn some dpy is all about oop
This library is heavily based on oop
You split into a list, u can't split a list
example of an attr error!
&enable welcome {member.mention} to a server!
i ment the params of your function.
That's probably why. You'll get stuck at really simple problems if you don't know OOP. This library is not a beginner's library, it involves many advanced topics and OOP is one of them. You could save yourself a lot of headache by learning some OOP first before attempting discord bots with discord.py
What was OOP again?
object oriented programming
(self, ctx, arg)
trust robin he has helper role
I mean I started with dpy before learning python basics 😅
it would only take hello so make the arg a kwarg
Many did but that's not necessarily good
Here's a great video on OOP: https://www.youtube.com/watch?v=ZDa-Z5JzLYM
In this Python Object-Oriented Tutorial, we will begin our series by learning how to create and use classes within Python. Classes allow us to logically group our data and functions in a way that is easy to reuse and also easy to build upon if need be. Let's get started.
Python OOP 1 - Classes and Instances - https://youtu.be/ZDa-Z5JzLYM
Python...
I learnt them all after, biggest regret of my life that I skipped over them
COREY IS THE BEST
Basics are very important and with basics, it would've gone way faster
Been coding for 3 years now
corey is the best on tutorials no joke
1year
mine are pretty good too 
example?
Yeah and I still suck at some things
yeah they are but you dont do yt since 10months ago
same
self, ctx, *, arg
I keep meaning to do more and then ending up really depressed and don't want to do them 
Classes and subclasses is the things I don't get, like why do you use them
so much talent bro just go for it
ok thank you
i can relate
i dont get generics yet because im too lazy to read the long paragraph 
What are generics?🤣 also we should move to dm cuz we are in a help channel
you have been coding for 3 years and dont see the point of subclassing and classes?
Never used them
Ive been focused on library's like selenium web scraping and dpy
Traceback (most recent call last):
File "C:\Users\hustl\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "D:\TEST BOT\main.py", line 50, in on_message
await update_Data(users, discord.Message.author)
File "D:\TEST BOT\main.py", line 31, in update_Data
if not user.id in users:
AttributeError: 'member_descriptor' object has no attribute 'id'```
??
literally everything in python uses classes
do you use global instead?
I use classes for cogs
Ah yes. I do
Send code rq please
async def on_message(message: discord.Message) -> None:
with open('users.json') as f:
users=json.load(f)
async def update_Data(users, user):
if not user.id in users:
users[user.id] = {}
users[user.id]['experience'] = 0
users[user.id]['level'] = 1
async def add_experience(users, user, exp):
users[user.id]['experience'] + exp
async def level_up(message: discord.Message, users, user, exp):
experience = users[user.id]['experience']
lvl_start = users[user.id]['experience']
lvl_end = int(500)
if lvl_start < lvl_end:
await message.send(channel, '{} has leveled up to {}' .format(user.mention, lvl_end))
users[user.id]['level'] = lvl_end
with open('users.json') as f:
await update_Data(users, discord.Message.author)
await add_experience(users, discord.Message.author, exp)
await level_up(exp, users, discord.Message.author, discord.Message.channel) ```
remind me never to look at your code in my life 😳
Where do you define user?
its not defined
Show me a proper way of using classes instead😮💨
Then how do you not get ur error
all caeden thinks about is classes
because it dosent mention define
every single thing in python is a class
i mean classes are so good thoooo so i stand by him
If u didn't define it, what did u expect
x = "hi" is an object of class str
God
!e print(int)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
<class 'int'>
I see i see
bertie
its basic py
ty for not helping 
Now what should I replace 'global' with?

self
I don't see what you're trying to do
yw babe xx
I use self in cogs, no worries
wish i was him
async def init 
I'm trying to make it so when they type they get xp then after 500 xp they level up and it gets put into a .json database
That's not a database
I'm not gonna help with json
its a temp one
still not a db
its a temp one
a database is ment to store data unlike json
s it possible to use self in a deco? I have this deco in which I want to use selfpy @app_commands.choices(cogs=[Choice(name=cog.split('.')[1].title(),value=cog) for cog in self.bot.initial_extensions])
Unfortunately no you can't
ok so if i do mongo db instead you can help
damm that's annoying
i use sql
sql is sad
bro how
warning = cursor.execute('SELECT * FROM banwords WHERE userid = ?', (message.author.id,)).fetchone()
2022-03-15T20:51:22.447042+00:00 app[worker.1]: psycopg2.errors.SyntaxError: syntax error at end of input
2022-03-15T20:51:22.447042+00:00 app[worker.1]: LINE 1: SELECT * FROM banwords WHERE userid = ?
2022-03-15T20:51:22.447042+00:00 app[worker.1]: ^
postgresql
How to fix.
its old
!e ```py
from future import annotations
class :
def init(: , ): .=; .=
def pow(: , __): return .**__
print.call(___(2) ** 2)```
@manic wing :white_check_mark: Your eval job has completed with return code 0.
4
okay next question, is importing my bot var into a cog file a bad idea / bad practice (for use in a deco)py from main import bot
sick
the power of classes
Sql isn't hard, just learn query's
yup

its old.
why would you need to import it
you do know its a lan for queries right?
its old
shit posting rn
to use a property of my bot in a deco
still old
you really dont know what youre talking about lmfao
yes i dont have a pissing clue
being a pilot isn't hard. Just fly the plane
^^
Do you see the issue with that statement?
gta flash backs
I don't see what that has to do with my answer... if you know how to use query's in sqlite, u know how to control it
so is it a bad idea? I assume it's bad practice but will it have any knock on effects? would I avoid any potential knock on effects by just importing that the specific attribute I need from the bot var?
nah it wouldnt effect anything
What’s going on
i think he needs a value from a bot var from a cog
idk whats going on with you binds😳
That way
Code only nicks the author and ignores if a user was mentioned, i tried switching it to if member is None: did the same thing, please tell me what i did wrong
U did if member is true
I'm trying to use a bot var property in a deco, but deco's don't have self
Not if member is None
just do member = member or ctx.author
so no checking for it
nm
None & not None ≠ True & False
the heck is that
If member is None isn't the same as if member is False
Or am I wrong?
I tried to explain that, since he used if member
Yeah, I explained it bad again

warning = cursor.execute('SELECT * FROM banwords WHERE userid = ?', (message.author.id,)).fetchone()
2022-03-15T20:51:22.447042+00:00 app[worker.1]: psycopg2.errors.SyntaxError: syntax error at end of input
2022-03-15T20:51:22.447042+00:00 app[worker.1]: LINE 1: SELECT * FROM banwords WHERE userid = ?
2022-03-15T20:51:22.447042+00:00 app[worker.1]: ^
postgresql
How to fix?
._.
whats that
this is how you store a string into a variable in C
you can cause my friend does but hes off
bro what
?
i ment dpy 2.0
yes? main/2.0 of dpy?
psycopg2 wants you to do it that way
I guess?
oh
random question, is there a particular codeblock format that is good as displaying tracebacks?
do print(discord.__version__)
its like
int var
("%s",var)
lol
probably a default one
1.7.3
hey looking at the docs, pscyopg3 is out why dont u use that?
then no 1.7.3 doesnt have slash commands
how to update it?
you clone main
so copy and paste it?
Use %s btw
You could clone it, but it's a lot easier to pip install git+repo
https://github.com/Rapptz/discord.py its in the readme
okay
do you have a lit of them you can link me to, I also forget what they are bc the only ones I use are py and occasionally json
just like py codeblocks but just remove the py
oh okay, thought you meant a standard codeblock lang, not the literal default codeblock
where
discord supports most of the syntax higlighting shown in hightlight.js
so what do i type
python3 -m pip install git+repo_url_here
whats repo?
lol
allow it 😭
The github repo link
python3 -m pip install git+https://github.com/Rapptz/discord.py
so this?
Correct
After you install from here, you should probably uninstall your old version of discord.py
ERROR: Error [WinError 2] The system cannot find the file specified while executing command git clone -q https://github.com/Rapptz/discord.py 'C:\Users\hustl\AppData\Local\Temp\pip-req-build-abkpi19r'
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?
:l
can u not ping me
Uh... I am speaking english
Just install git, perhaps do a reboot to ensure it's on PATH
didnt mean to that
then run the command again
install git?
Yes
is that the command?
^
No
instal
Yes
install https://git-scm.com/
Yes...
thats the command?
Yes
well its funny how i downloaded it and it still didnt work
hi how can i get avatar url from bot? client.user.avatar_url doesnt work
If you're on 2.0 it's .avatar.url
I see, how does it "not work" by the way?
@client.event
async def on_message(message):
if message.channel.id == 942045216658051072:
await message.add_reaction(":monkey:953747076917887077")
await client.process_commands(message)``` can someone explain why this says unknown emoji? and whenever I try use other commands it doesn’t work ?
so how do i do a slash command now?
AttributeError: 'ClientUser' object has no attribute 'avatar_url'
this is the output
i have no idea why this doesnt work
type a \ and then put a emoji it will give you the full string
Yeah that's not right
!keka
just type \ and a emoji
then put that text on the message.add_reaction
Okay but how would I fix it from stopping my other cmds working
Your processing commands only when in channel corresponding to 942045216658051072. To make all commands work for all channels you'd un-indent await client.process_commands(message) by one level
no I want it so it only auto reacts in that channel however all my other commands stop working
why?
await client.process_commands(message)
Yh I do that and it does this look
Yea, I just told you how to fix it
It’s the default monkey emoji
HOW TO DO A SLASH COMMAND
just copy that and paste it to ur program
it does have an attribute av url tho
Okay but how would I fix my other commands because none of them are working
@client.event
async def on_message(message):
if message.channel.id == 942045216658051072:
await message.add_reaction(":monkey:")
await client.process_commands(message)
here
HOW TO DO A SLASH COMMAND
@slate swan
does this work
That's what I'm thinking
i think i now why my bot has a default pfp
I don't think that's the issue
Well idk bc out of nowhere I just got a big error saying discord has banned me from accessing their website on my host platform 🤨
yeah right it shouldnt be the issue
to many api calls?
HOW TO DO A SLASH COMMAND
it doesnt work for me too
What's your host platform?
HOW TO DO A SLASH COMMAND
Discord.py or what fork?
@client.command()
async def test(ctx):
await ctx.send(ctx.author.avatar_url)
just tried to see if it displays my av but it doesnt work
async def avatar(ctx, member: discord.member):
test = member.avatar_url
Same error?
Discord.py cause I dislike any other
it works with .url tho
There should be examples on the gist https://gist.github.com/Rapptz/c4324f17a80c94776832430007ad40e6
Didn't find any
Can you verify by printing discord.__version__?
is talk about pymongo allowed here?
sure
No?
a private thing
I'm finding plenty
Hm, people use replit which tends to do that alot. Just wanted to make sure you weren't on replit
I'm blind asf 🤦♀️
No 😂
im on 2.0.0b5
i think because of pycord
Why don't people make it via atom then host layer
game.creavite it’s basically a vps
Then it's .avatar.url
yeah
Kek
Earlier you said 1.7.3 so I thought something was really broken
lol i typed pip list and check my discord.py version and it said 1.7.3
Probably because you werent looking at the pycord version
yeah i forgot that i had pycord installed
can i have a link?
async def test(ctx):
author = ctx.message.author
pfp = author.avatar_url
embed = discord.Embed()
embed.set_image(url=pfp)
await ctx.send(embed=embed)
i think it only works on embeds
try this
warning = cursor.execute('SELECT * FROM banwords WHERE userid = %s', (message.author.id,)).fetchone()2022-03-16T23:08:46.605486+00:00 app[worker.1]: AttributeError: 'NoneType' object has no attribute 'fetchone'
postgresql
help me pls
alr fixed but ty
ok
avatar_url is an Asset object, you need to cast it to str to get the actual cdn url
this works fine ig?
\u001b[0;36mHi
🗿
\u001b[0;40m\u001b[1;32mThat's some cool formatted text right?
or
\u001b[1;40;32mThat's some cool formatted text right?
doesn't work anymore
u001b has to be the actual character
type this on the first line then it will work
oh
import os
os.system('cls')
[0;40m[1;32mThat's some cool formatted text right?
what this do
Low effort troll
it cleans the screen and debugs that problem
\u001b[1;32mThat's some cool formatted text right?
Again 
if that text is supposued to be with color or have a time stamp
then cls will work
Even the message you referenced talks about this
The \u001b is the unicode for ESCAPE/ESC, see http://www.unicode-symbol.com/u/001B.html. If you want to use it yourself without bots, then you need to copy paste the character from the website.
What's clearing the terminal supposed to do here? That isn't gonna fix anything
is the text suppoused to have color or some nice format?
anwser
It's an ANSI escape sequence...
Clearing the terminal is totally irrelevant to the current issue
They are using \u001b, not the ACTUAL unicode character
oh i thought you guys were talking about something else
In order to use ANSI escape sequence they need the REAL character
ok thanks
does this happen when you run the program or do you compile it to an exe?
i had the same issue it wasn't printing the fromated text cls fixed it
it was priting the exact same but with different characters
can i have a message handler inside main.py and also another message handler inside cogs?
Traceback (most recent call last):
File "C:\Users\nikit\PycharmProjects\dpamong\discord\ext\commands\core.py", line 182, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\nikit\PycharmProjects\dpamong\docs\commands.py", line 221, in channel
cursor.execute(sql , val)
sqlite3.OperationalError: near ",": syntax error
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\nikit\PycharmProjects\dpamong\discord\ext\commands\bot.py", line 1055, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\nikit\PycharmProjects\dpamong\discord\ext\commands\core.py", line 899, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\nikit\PycharmProjects\dpamong\discord\ext\commands\core.py", line 191, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: OperationalError: near ",": syntax error``` anyone know why this is happening
async def welcome(self, ctx):
await ctx.send("Setup welcome channel %welcome <channel>\n%welcome <welcome message>")
@welcome.command()
@commands.has_permissions(manage_messages=True)
async def channel(self, ctx, channel : discord.TextChannel):
db = sqlite3.connect("burber.db")
cursor = db.cursor()
cursor.execute(f"SELECT channel_id FROM main WHERE guild_id = {ctx.guild.id}")
res = cursor.fetchone()
if res is None:
sql = ("INSERT INTO main(guild_id, channel_id), VALUES(?,?)")
val = (ctx.guild.id, channel.id )
await ctx.send(f"Channel has been set to {channel.mention}")
elif res is not None:
sql = ("UPDATE main SET channel_id = ? WHERE guild_id = ?")
val = (channel.id, ctx.guild.id)
await ctx.send(f"Channel has been updated to {channel.mention}")
cursor.execute(sql , val)
db.commit()
cursor.close()
db.close()```i got it off a tutorial ik
or no pls don't copy tutorials
Nikit
?
i didn't know where to start
docs exist
you should do your queries on one line
db.execute("UPDATE main SET channel_id = ? WHERE guild_id = ?", (channel.id, ctx.guild.id,))
i dont think there's anything wrong with using variables
and the issue is that you added an extra space after sql before the comma
(thats what the traceback makes it seem like)
no there shouldnt be a comma there in the first place
clutters code up and takes more lines. its less readable imo
If you use a listener you can have as many as you want
it could be because sql is a tuple. not sure though
INSERT INTO main(guild_id, channel_id), VALUES(?,?) the comma after channel_id isnt part of the syntax
it still gives me an error
the sql is generally a string, not a tuple
the arguments passed to the placeholders is a tuple
oh didn't even see that one
its not actually a tuple, parentheses with no comma inside just acts the same as parentheses in order of operations
@left crater this is a syntax error
python interprets it like it wasnt their its just as said it just sets an order of each operation
good to know
you should be using an async lib for sqlite though
^
which one?
!pip asqlite
e.g. aiosqlite or asqlite
!e print({1: 2} | {1: 3}[1])
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | TypeError: unsupported operand type(s) for |: 'dict' and 'int'
!e print(({1: 2} | {1: 3})[1])
@slate swan :white_check_mark: Your eval job has completed with return code 0.
3
@slim ibex some examples^
👍
are you trying to reset all cooldowns the mapping has, or just one?
if its just one you should preferably use Command.reset_cooldown(ctx), where the command can also come from ctx.command
to reset the entire mapping you'd need to go through the _cache and call .reset() each Cooldown object
WHATS THE DOCSSSSSS
!d discord.TextChannel.send
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
the embed parameter is in there
like which part each parameter corresponds to?
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, 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.
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.
Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
My friend has mod and he can kick an admin, how do I fix that in python discord.py
what's your code?
make an ìf statement to check the user's guild perms (if they have permissions) the bot is going to pass it
i suppose get role id for the higher up roles and disallow the command to pass through if the person has a lower rank attempting to kick admin and whatnot.. or you can do it based on permissions i believe so
☝️
Idk how to use top_role
this
What do I write after the if
if member.guild_permissions.administrator: #it checks if the member has administrator permissions
await ctx.send("You cannot ban mod/admin")```
!d discord.Member.guild_permissions
property guild_permissions```
Returns the member’s guild permissions.
This only takes into consideration the guild permissions and not most of the implied permissions or any of the channel permission overwrites. For 100% accurate permission calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for").
This does take into consideration guild ownership and the administrator implication.
if user.top_role < ctx.author.top_role:
#ban
else:
#ignore
this can work if both has ban perms or so
thats a great one doe
ye
great representation 👍
note that those of equal roles arent normally able to ban each other
lemme fix that
i told them the same thing in #help-chili
is there a way to reset a mapping cooldown
@slate swan
i've been asking this question for like 2 days 
the problem is, it gives me an error
the traceback and the code being...?
'test' object has no attribute '_buckets'
that error looks like you made your own custom class?
ye :P
well then where's the cooldown mapping
in the custom cooldown 😏
custom buckets
basically wut i wanted to try is
yoy
class is_premium:
def __init__(self, rate, per, rate1, per1, guilds: list):
self.bucket_type = commands.BucketType.guild
self.cooldown = commands.CooldownMapping(commands.Cooldown(rate, per), self.bucket_type)
self.premium_cooldown = commands.CooldownMapping.from_cooldown(rate1, per1, self.bucket_type)
self.guilds = guilds
def __call__(self, inter: disnake.Interaction):
key = inter.guild_id
if key in self.guilds:
bucket = self.premium_cooldown.get_bucket(inter)
else:
bucket = self.cooldown.get_bucket(inter)
bucket.reset
retry_after = bucket.update_rate_limit()
if retry_after:
raise commands.CommandOnCooldown(bucket, retry_after, self.bucket_type)
return True``` i've tried `bucket.reset` to see if it reset the cooldown but
oh you're on disnake, that should have the dynamic_cooldown decorator forked from 2.0
!d disnake.ext.commands.dynamic_cooldown
@disnake.ext.commands.dynamic_cooldown(cooldown, type=BucketType.default)```
A decorator that adds a dynamic cooldown to a [`Command`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Command "disnake.ext.commands.Command")
This differs from [`cooldown()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.cooldown "disnake.ext.commands.cooldown") in that it takes a function that accepts a single parameter of type [`disnake.Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") and must return a [`Cooldown`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Cooldown "disnake.ext.commands.Cooldown") or `None`. If `None` is returned then that cooldown is effectively bypassed.
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.BucketType "disnake.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.CommandOnCooldown "disnake.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.disnake.ext.commands.on_command_error "disnake.disnake.ext.commands.on_command_error") and the local error handler.
A command can only have a single cooldown.
New in version 2.0.
you can return whatever Cooldown object you like based on the message
ion think i'll be able to make a special cooldown for special ppl with this?
thats exactly what dynamic_cooldown is for
Can someone explain why my change nick command doesn't change someones entire name if they put a space in it somewhere
@client.command(pass_content=True)
async def changenick(ctx, member: discord.Member, nick):
await member.edit(nick=nick)
await ctx.send(f'Nickname changed for{member.mention}')```
gimme an example
i"ve never used that
Btw can delete_message_days be set to other values than the built-in? ( None, 1 day, 7 days) like delete the messages from the past 3 days 
If this is for PUT/guilds/{guild.id}/bans/{user.id} yes, you can do 0-7
def length_cooldown(message):
"""The longer a message is, the longer the cooldown"""
return commands.Cooldown(
rate=1,
per=len(message.content)
)
@bot.command()
@commands.dynamic_cooldown(length_cooldown, discord.BucketType.member)
async def my_command(ctx):
...```
oh tnx 
userlvl = users[f'{ctx.author.id}']['level']
embed = discord.Embed(
description={
f'Your rank is:{userlvl}'
},
author={
'name':f'{ctx.author.name} Rank',
'icon_url':f'ctx.author.avatar_url'
},
footer={
'text':f'{experience}/500'
}
)```
whats wrong with this embed?
exactly for that
I could test it, but it would take like 28 days 
so..
'test' object has no attribute '_buckets' it gives dis error LMAO
command.Command.reset_cooldown(ctx) @hushed galleon
Can someone tell me what a guild is? (is it a server? channel? or something completely different?)
server
Thanks
class discord.Guild```
Represents a Discord guild.
This is referred to as a “server” in the official Discord UI.
x == y Checks if two guilds are equal.
x != y Checks if two guilds are not equal.
hash(x) Returns the guild’s hash.
str(x) Returns the guild’s name.
Why is my embed not working
did you delete/comment out your broken code? also you need the actual command object to call reset_cooldown on
HELLO
yes i deleted the comment, lemme try 
HELLO
Yeah just checked the github docs
I should check those more often, they quite useful
why is it all in dicts?
wym
Do they force specific days?
well some of your kwargs have dicts while some have sets
any discord guru here?
wdym?
If you want a discord account creator
Discord already does that
or do you mean what a discord token is composed of
He wants to automatically make discord accounts
He wants a bunch of alts
yeah of course
Maybe to sell or to use to raid a server
Quick question (hopefully). I have this command here, I want it to return if key or description is None. But instead it sends the first message (You must provide a key...) the proceeds to execute the second ctx.send() (You do not have permission...)
Anyone know the proper way to stop a command, like return would stop a function?
@commands.command(name='add-help')
async def add_help(self, ctx: commands.Context, key: str = None, *, description: str = None):
if not key == None or not description == None:
await ctx.send('You must provide a key and description when adding a help topic.\nUsage: `--add-help key description`')
return
await ctx.send('You do not have permission to create a new help topic.\nYour request will be forwarded to an administrator.')
return should be stopping the command as it is a function
that's what I though, but it doesn't work
🗿
something weird is up, cause it still works when it's not running xD
(my remote is off too)
Remote (cloud)
Discord wonky sometimes
Ah, I had a random python instance running in the background.
So it was duplicating my command (but one was outdated and only had one response so it looked like I explained)
Classic instance of asking for help 30 seconds before I figure it out.
🗿
It happens way more than you think. Reminds me of the time I was diagnosing an audio issue, unplugged my microphone but friend could still hear me. Figured out later it was my webcam mic.