#discord-bots
1 messages ยท Page 453 of 1
you could say InvalidArgument is thrown when the command can't be completed
yes
saying "can't be completed" is vague
I mean it cant really get more descriptive than that
Cant be completed cause of an error

what's more descriptive out of these two:
Forbidden โ You do not have permissions to edit the channel.
Forbidden โ The command cannot be completed.
no, it's thrown when the user hasn't got permissions
no? MissingPermissions is
which is entirely different to "the command can't be done"
that's thrown when the bot hasn't got permissions
No
bot != user
Forbidden โ You do not have permissions to edit the channel.

explain this
I guess forbidden is an umbrella exception
The command does not have a permission check so it cannot be the user, it has to be the bot.
Forbidden โ You do not have permissions to edit the channel.
show us your decorators
I don't think you understand.
@commands.command(name = "refresh", description = "refreshes the member and boost counts")
@commands.is_owner()
async def refresh(self, ctx):
guild = ctx.guild
members = guild.get_channel(884459371046768660)
boosts = guild.get_channel(749371688822767666)
await members.edit(name = f"Members: {guild.member_count}")
await boosts.edit(name = f"Boosts: {guild.premium_subscription_count}")
await ctx.send("updated stats")
Yeah it is the bot
what about the bot is it
So are you the owner of the bot?
I assumed they are
no i just have someone else's code in my editor
obviously i'm the owner
You'd be surprised how many people fork codes.
either way yes i am the owner
Does your bots integreation role have the perms it needs
integration role
Remove the ctx.send() and if the error still occurs it's the channel edit permission.
yeah, the role thats given to your bot when you invite it to a server
it has another role with sufficient permissions
give it admin and see what happens
what good will removing ctx.send do
Most of the time the permissions it has dont seem to work in my experience
Concealing the error, If you know what is causing the error fixing it will be a lot easier.
then it's edit
try/except won't really fix his issue since it will just throw forbidden again.
.
"something can't be done"
Not dpy's fault error code from discord is just an 404 code.
Well yeah, but theres obviously something else happening and its not being shown
I'm assuming members and boosts are getting defined correctly..
yes
you 100% sure?
i get my bot to send the tb to the ctx channel and for some reason it doesnt provide the full tb
Can you send what you got at least?
.
@reef trail @cloud dawn yes it is an issue with the bot's permissions
i've just compared it to a role with admin
Oh okay, it's the bot that doesn't have permissions it seems.
Who would have guessed
Buddy, you said you are using his code on your editor
You don't get the full traceback because you catch the error inside on_command_error then it leaves out the full tb
i was being sarcastic.

and even if that was the case, it wouldnt throw a forbidden error
does the bot have permissions to edit the channel you passed in for the ID? because that error seems to say the bot doesn't have permission
Best to take everything here with a grain or 10 million of salt
but we can't be sure even because you aren't getting the whole tb
Let's focus on the full traceback first imo 
okay that's guild, check channel permissions as well.
and also, by the way
that's how you get full tb
traceback scraping?
yeah. but he probably did was on command error await send error
He formatted his TB to be inside the discord text channel -> https://discordapp.com/channels/267624335836053506/343944376055103488/884477202698240000
He only got the error type.
yeah, because he probably just printed error
doing this should get you the full tb
ok i got it working
i mean i believe using it breaks companies ToS
or i may be wrong
idk lol
we just gave up and gave the bot perms :troll:
what alternative libraries are people using for discord.py
hikari, hata, edpy
lavalink breaks youtube ToS
and probably more
because rule 5

!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
generally any music library that has YT integration usually breaks ToS
Youtube official bot
and there's some decent logic behind it
lol
If youtube be making a discord bot be prepared to have an audio ad every 10 songs.

....that low? really i thought it was 2 ads a second .-.
wasnt it like 3 ads every 4 seconds
Honestly though if youtube would add a discord bot with youtube premium to allow premium users to use it in the VC that would be a better reason to buy it.
or did youtube change the ways
is there already a youtube bot
no
@commands.command(name = "refresh", description = "refreshes the member and boost counts")
@commands.has_permissions(manage_channels = True)
@commands.is_owner()
ok like i made a has permissions decorator but now i cant invoke the command even tho i have is_owner
help
Still gonna need the full Tb
it just says im missing manage channels
Any way to log errors in a .log file?
logging module
and i do that how?
I dunno
wow
if you really want, here it is
Ignoring exception in command refresh:
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/discord/ext/commands/bot.py" , line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/pi/.local/lib/python3.7/site-packages/discord/ext/commands/core.py ", line 855, in invoke
await self.prepare(ctx)
File "/home/pi/.local/lib/python3.7/site-packages/discord/ext/commands/core.py ", line 777, in prepare
if not await self.can_run(ctx):
File "/home/pi/.local/lib/python3.7/site-packages/discord/ext/commands/core.py ", line 1087, in can_run
return await discord.utils.async_all(predicate(ctx) for predicate in predica tes)
File "/home/pi/.local/lib/python3.7/site-packages/discord/utils.py", line 348, in async_all
for elem in gen:
File "/home/pi/.local/lib/python3.7/site-packages/discord/ext/commands/core.py ", line 1087, in <genexpr>
return await discord.utils.async_all(predicate(ctx) for predicate in predica tes)
File "/home/pi/.local/lib/python3.7/site-packages/discord/ext/commands/core.py ", line 1790, in predicate
raise MissingPermissions(missing)
discord.ext.commands.errors.MissingPermissions: You are missing Manage Channels
dont do that
!d discord.ext.commands.check_any
discord.ext.commands.check_any(*checks)```
A [`check()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if any of the checks passed will pass, i.e. using logical OR.
If all checks fail then [`CheckAnyFailure`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CheckAnyFailure "discord.ext.commands.CheckAnyFailure") is raised to signal the failure. It inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Note
The `predicate` attribute for this function **is** a coroutine.
New in version 1.3.
use this for the check
can i use that in conjunction with has_permissions as well?
or how can i add certain permissions
oh define my own function to assign perms i got it
em = discord.Embed(title='Hi there!', description='To setup the configuration, say start', color=color)
await ctx.send(embed=em)
await self.bot.wait_for('message', check=check, timeout=60)
embed = discord.Embed(title='Great!',description='What would you like to set the logging channel too, this will log all actions! Specify a channel!')
await ctx.send(embed=embed)
msg = await self.bot.wait_for('message',check=check2,timeout=60)
print(msg)
embed = discord.Embed(title=f'The logging channel was set to {msg}')
await ctx.send(embed=embed)
there is no error i just want it to print the id of the channel and its not
my bot was running on a linux server and everything was normal. then the bot suddenly shut down, i logged in to the server and try running the bot but i get this error, and i am confused, like why did it decide to not work now, and also i can't see anything wrong in this line.
any ideas why this happens?
check the lines above and below that one
send them here
help
What python version is this?
3
3 what?
3.9.5
Anyone
hm try ```py
print(cwd + '\n------')
ok
There is nothing wrong with it
Look at what I said
This is his full traceback
...
def has_manage_channels():
def predicate(ctx):
return ctx.guild is not None and True if manage_channels in ctx.author.guild_permissions
return commands.check(predicate)
...
@commands.command(name = "refresh", description = "refreshes the member and boost counts")
@commands.has_permissions(manage_channels = True)
@commands.check_any(commands.is_owner(), is_guild_owner(), has_manage_channels())
async def refresh(self, ctx):
...
Returns a SyntaxError for the has_manage_channels check function, I'm aware I haven't written it properly but i'm not sure how i should write it
Why don't you use @has_permission
.
Then use @commands.has_guild_permissions(**perms)
for that exact reason
if i use has_guild_permissions i can't use is_owner or it'll pass that i don't have permissions
what
void ping
?
Aren't you the bot owner?
yes
Then they'd both be true
but im making the command so only i or someone with the manage channel permissions can use it
or the guild owner
Then just pass in the manage_channels permission 
where do i pass it
inside the guild has permission decorator. And for the guild owner make a custom check
i' don't understand what you can't see here.
i can't use has_permissions because it conflicts with is_owner so i can't operate that command unless i have a permission given in has_permissions
?????????????????????????????????????
how do i pip install discord buttons?
pip install buttons
ok thx 
it's just buttons
discord.ext.buttons ^
yeah idk what that other guy is on.
there are too many buttons 
Decorator checks all have to be true idk what you want with is_owner
is_onwer is meant for the bot owner not the guild owner.
- rude
- buttons is a part of the discord_components package, which includes selections, button styles, etc
yeah i'm aware
Then why can't you use has_permissions
@commands.command()
@commands.has_permissions(**perms)
async def command():
#will work if anyone has permissions set in has_permissions
@commands.command()
@commands.has_permissions(**perms)
@commands.is_owner()
async def command():
#has_permissions overrides is_owner,
#so even if i am the bot's owner,
#the has_permissions check will come into function
i don't see why you aren't understanding
https://discordpy.readthedocs.io/en/latest/api.html#discord.Emoji.roles
I was wondering how to get this to work?
I tried doing stuff like
emoji = bot.get_emoji(id)
emoji.roles.append(role_id)
but uhhh I don't think that works lmao
has_permissions doesn't override anything
oh so you're telling me if i run the command and i'm missing a permission in has_permissions but i have is_owner then it will work
No i told you 10 minutes ago all checks have to be true
So why didn't you just tell me you want them to be optional.
i never said optional
so will this work then
@commands.command(name = "refresh", description = "refreshes the member and boost counts")
@commands.has_permissions(manage_channels = True)
@commands.check_any(commands.is_owner(), is_guild_owner())
i mean, if you're the bot owner that doesn't necessarily mean you have permissions
I'm not aware that i was trying to present that idea
I also don't get why you are checking for the permission because the owner would have admin perms anyways
checking for the bot owner.

confusion
Yeah i still don't really know what you want
Aside from the fact you want to screw with settings in other guilds 
em = discord.Embed(title='Hi there!', description='To setup the configuration, say start', color=color)
await ctx.send(embed=em)
await self.bot.wait_for('message', check=check, timeout=60)
embed = discord.Embed(title='Great!',description='What would you like to set the logging channel too, this will log all actions! Specify a channel!')
await ctx.send(embed=embed)
msg = await self.bot.wait_for('message',check=check2,timeout=60)
print(msg)
embed = discord.Embed(title=f'The logging channel was set to {msg}')
await ctx.send(embed=embed)
there is no error i just want it to print the id of the channel and its not
You asked this before we need more info
ID?
I want it when you send the channel mention it gets the id of it and prints it
do print msg.content
msg is a discord.Message object, you need to access content attribute of msg either via dotnotation or getattr. Then you have to the use TextChannelConverter to get the corresponding channel object
!d discord.ext.commands.TextChannelConverter
class discord.ext.commands.TextChannelConverter```
Converts to a [`TextChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.TextChannel "discord.TextChannel").
All lookups are via the local guild. If in a DM context, then the lookup is done by the global cache.
The lookup strategy is as follows (in order)...
Pass message content the convert method of an instance of this
Thanks Andy
Traceback (most recent call last):
File "C:\Users\USER\Desktop\ZENESIS DEVELOPEMENT\PYTHON\ZENESIS\CHAT FILTER\main.py", line 43, in <module>
bot.run(token)
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 719, in run
_cleanup_loop(loop)
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 95, in _cleanup_loop
loop.close()
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\asyncio\selector_events.py", line 89, in close
raise RuntimeError("Cannot close a running event loop")
RuntimeError: Cannot close a running event loop```
it worked with my vsc but not working with my spyder
yes
yeah then windows could be the issue here
but how and how can i fix this?
it happens when you stop the bot right?
maybe
maybe?
Or bot is already running
I had a bot running in the background once 
so how can i stop it
?
windows bad moment
i just tried to run the bot and this error occured
another error occured
If you run the bot and it does this error you didn't actually login correctly
send the full traceback
Seems like invalid tokens are passed I'm assuming?
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.pydis.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.
what's the best way to get a user's reply after sending a message?
!d discord.Client.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/stable/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
Hey @hoary gust!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
thats the whole thing?
yes
so you run the bot then that happens?
!d discord.Role.position
The position of the role. This number is usually positive. The bottom role has a position of 0.
why is this coming back as theres no attribute get_channel
I can't see how bot is defined here
ohhh
client
You named your client bot?
yes

idk it was client then someone told me to rename it to bot to make it easier
i dont think the name is the problem here anyways
@cloud dawn this is what im getting
What an horrible advice
Can i see your client/bot definition?
How is telling someone to name things correctly horrible advice?
Someone told him that client = commands.Bot()
Uh... seems like someone just told him to rename it to bot
its bot = commands.Bot() @cloud dawn
Now i'm confused
everything else works, dont think my bot definition is the probllem
what im trying to do here is when the command is used, to get the log channel id and send an embed there
Screencap shows its defined as commands.bot would seem like
Are you sure its commands.Bot not commands.bot?
Can you show your imports real quick
there is the issue
why import stuff from commands when you have ext.commands imported
what's different of loop.create_task and loop.run_until_complete
notice how its lowercase bot in this screencap
You should really clean up your imports
I see
yea ๐
This is by far not buried yet you are 1/3th of the way lol
i just moved everything into cog thats why my main file has unused inmports
tasks are meant to run indefinitely whitelists run until complete means it will wait for the code to finish. This is handy if you need information from a variable but it isn't yet defined because the other part of the code was faster.
They can also be combined.
Can you send your code that produces this error?
at least the single line where get_channel is called
Is Bot imported from discord.ext.commands?
get_channel should be called on a bot or guild instance
Did you perhaps me to do ```py
bot.get_channel(<id>)
And without the <>
says undefined if i do lowercase
Did you define your bot instance?
where is your bot = commands.Bot()
where is a good website to start learning how to code discord bots with python
in my main file
did not
yes it is
you need to use self then
self.get_channel?
self.bot.get_channel(id)
As long as you have taken bot as a parameter in __init__, like most cogs do
It's better to use bot when using commands.Bot
so do change it to self.bot = bot
is it possible to do .info megaman(or whatever character u want) and the bot will send an embed with the pic of the character I want
use an api or something
is there a video or website I can see to learn how to
Find an api that does that
alright I'll start searching ty
learn how to use apis
!d discord.Member.create_dm
await create_dm()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`DMChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.DMChannel "discord.DMChannel") with this user.
This should be rarely called, as this is done transparently for most people.
!d discord.User.create_dm
await create_dm()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`DMChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.DMChannel "discord.DMChannel") with this user.
This should be rarely called, as this is done transparently for most people.
Hello i'd like support
I'm making a discord bot and have an error and have no idea how to fix it
Send the code and error
It's a simple code but if I send the whole thing i'd be sending the token
So rrmove the the token from what you are sending?
guys how can i return something from on_ready ?
bro you are missing ```py
"
Please learn basic Python b4 approaching dpy
???
!resources can be a help for that.
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
@pearl inlet ur code makes no sense
just do 'We have logged in as {}.user'.format(client)
show code
discord.py is not for beginners :/
not that i'm gatekeeping or anything
you're just going to struggle
guyyyyyyyyyyyyyys how can i return something from on_ready
please help me bro
how can i return something from on_ready
?
somebody can help me ? :|
u dont. on_ready is just an event
!d discord.Client.get_guild
get_guild(id)```
Returns a guild with the given ID.
The guild name.
Traceback (most recent call last):
File "main.py", line 5, in <module>
import discord
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/__init__.py", line 23, in <module>
from .client import *
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 27, in <module>
import asyncio
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/asyncio/__init__.py", line 21, in <module>
from .base_events import *
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/asyncio/base_events.py", line 296
future = tasks.async(future, loop=self)
^
SyntaxError: invalid syntax
``` why?
give the context. What event?
ctx.channel is the channel where the command was used.
message.channel is the channel where the message was sent.
Both return a discord.TextChannel object.
!d discord.Webhook.channel
Command raised an exception: NotImplementedError: Derived classes need to implement this.
problem with rpl = await client.wait_for("message", timeout = 60.0), if it doesn't get an expected valid command, the prompt will just cancel completely
I could do it in a while loop but then the timer will reset any time you put in a new invalid feedback
example, I have it rn to where it will send a message then you react to the message with whatever reactions and then you type "done"
but if you type anything else, it'll just break itself
what are u waiting for
hold up gimme a sec
try:
rpl = await client.wait_for("message", timeout = 60.0)
if rpl.content.lower() == "done":
for i in list(client.cached_messages):
if i.id == rm:
print(i.reactions)
break
except asyncio.TimeoutError():
await cl.send("Prompt has been cancelled.")
but if the awaited reply is not "done", it will just break
Depending on cache size this could take ages to finish
trying to get it to wait for you to say done over multiple messages
I was thinking that, but im gonna change it
I'm gonna use the find command
@pliant gulch im having an i ssue now'
find(client.cached_messages, id = rm) I believe it would be
Looks better but it still iterates over
I don't think is a way to get past that tbh
Okay so better idea:
How can I better manage my bot's cache to where it'll only store like, the last 200 messages
class SetupCommand(commands.Cog):
def __init__(self,bot):
self.bot = bot
async def convert(self, ctx, argument):
raise NotImplementedError('Derived classes need to implement this.')
@commands.command()
@commands.has_permissions(administrator=True)
async def setup(self, ctx):
def check(message):
return message.author == ctx.author and message.content.lower() == "start"
def check2(message):
return message.author == ctx.message.author
try:
em = discord.Embed(title='Hi there!', description='To setup the configuration, say start', color=color)
await ctx.send(embed=em)
await self.bot.wait_for('message', check=check, timeout=60)
embed = discord.Embed(title='Great!',description='What would you like to set the logging channel too, this will log all actions! Specify a channel!')
await ctx.send(embed=embed)
msg = await self.bot.wait_for('message',check=check2,timeout=60)
msg2 = await self.convert(ctx,msg.content)
embed = discord.Embed(title=f'The logging channel was set to {msg2}')
await ctx.send(embed=embed)
except asyncio.TimeoutError:
await ctx.channel.send('Timeout, try again!')
Command raised an exception: NotImplementedError: Derived classes need to implement this.
Why are you adding a convert method to your cog?????
I told you earlier to just make an instance of TextChannelConverter and use the convert method of that
!d discord.ext.commands.TextChannelConverter.convert
await convert(ctx, argument)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The method to override to do conversion logic.
If an error is found while converting, it is recommended to raise a [`CommandError`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError") derived exception as it will properly propagate to the error handlers.
hi can somebody check why console returns client is not defined? i'm pretty sure i've defined it with
def __init__(self, client):
self.client = client
is it because client.latency needs to be commands.latency?
hmm not that
how long does this take to fix
self.client.latency
Where did you get this msg?
i was creating a channel
and got the msg
so im just using a vpn
so I can bypass lol
tenks
Maybe making a class? With some tables?
Hi!
hi
I want to make a function for easy embed building
embed = EmbedBuilder (
color = discord.Color.dark_gold(),
title = title,
description = description
).build()
return embed
await ctx.send(embedbuilder('',f'You can use this command again in {round(error.retry_after, 2)}s'))
but i get this result
<discord.embeds.Embed object at 0x000001DACC6244C0>
if i am correct you can't have a blank title
or something like that
self.client.latency
thanks! it worked!
Yw
Only applies for description
ah ok
replace client.latency to self.client.latency
What is discord.py v2.0?
It's the master version of dpy
It's dpy with a bit more features which should've been released somewhere in the near future if the development wouldn't have ceased
Ok
are you using replit..?
I basically replicated the dank memer hack command for fun but for some reason its sending channel information
I can send the code but essentially its sending the message then editing it then using asyncio.sleep and looping it
show
@commands.command()
async def hack(self, ctx, member: discord.Member):
msg = await ctx.send(f"Hacking {member.name} now...")
await ctx.send(msg)
await asyncio.sleep(1)
await msg.edit(content="[โ] Finding discord login... (2fa bypassed)")
await asyncio.sleep(1)
await msg.edit(content=f"[โ] Found:\n**Email**: `{random.choice(email_choices)}`\n**Password**: `{random.choice(password_choices)}`")
await asyncio.sleep(1)
await msg.edit(content="[โ] Fetching dms with closest friends (if there are any friends at all)")
await asyncio.sleep(1)
await msg.edit(content=f'[โ] Last DM: "{random.choice(dm_choices)}"')
await asyncio.sleep(1)
await msg.edit(content="[โ] Finding most common word...")
await asyncio.sleep(1)
await msg.edit(content=f'[โ] const mostCommon = "{random.choice(mostcommonword_choices)}"')
await asyncio.sleep(1)
await msg.edit(content=f'[โ] Injecting trojan virus into discriminator #{member.discriminator}')
await asyncio.sleep(1)
await msg.edit(content=f'[โ] Virus injected, emotes stolen')
await asyncio.sleep(1)
await msg.edit(content=f'[โ] Setting up Epic Store account...')
await asyncio.sleep(1)
await msg.edit(content=f'[โ] Hacking Epic Store account....')
await asyncio.sleep(1)
await msg.edit(content=f'[โ] Finding IP address')
await asyncio.sleep(1)
await msg.edit(content=f'[โ] IP address: 127.0.0.1:2994')
await asyncio.sleep(1)
await msg.edit(content=f'[โ] Selling data to the Government...')
await asyncio.sleep(1)
await msg.edit(content=f'[โ] Reporting account to discord for breaking TOS..')
await asyncio.sleep(1)
await msg.edit(content=f'[โ] Hacking medical records')
await asyncio.sleep(1)
await msg.edit(content=f"[โ] **IMPORTANT HEALTH UPDATE**: Subject's brain is {random.choice(healthupdate_choices)}")
await asyncio.sleep(1)
await msg.edit(content=f'Finished hacking {member.name}')
await ctx.send(f"The *totally* real and dangerous hack is complete")
It sends the first message then sends this <Message id=884578946367258675 channel=<TextChannel id=851801920695435277 name='general' position=1 nsfw=False news=False category_id=851801920695435275> type=<MessageType.default: 0> author=<Member id=868156490022789130 name='Epic bot' discriminator='8161' bot=True nick=None guild=<Guild id=851801920695435274 name='Test server' shard_id=None chunked=True member_count=4>> flags=<MessageFlags value=0>>
In Discord v.2.0, how do I get the users banner and send it as a link?
bannerURL = avamember.banner,url
await ctx.send(userAvatarUrl)
I will
actually, banner is only returned with fetch_user
How can i make the bot change the server icon
I saw something about that but I don't know how to ctx.send with fetch_user
!d discord.Client.fetch_user
await fetch_user(user_id)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`User`](https://discordpy.readthedocs.io/en/stable/api.html#discord.User "discord.User") based on their ID. This can only be used by bot accounts. You do not have to share any guilds with the user to get this information, however many operations do require that you do.
Note
This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client.get_user "discord.Client.get_user") instead.
How can i make the bot change the server icon
and then User.banner.url
!d discord.Guild.edit
await edit(*, reason=None, **fields)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the guild.
You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission to edit the guild.
Changed in version 1.4: The rules\_channel and public\_updates\_channel keyword-only parameters were added.
Is it possible for user banner command too?
you need to install discord.py from master branch
fetch_user is a method of Client/Bot
and you need an instance of User, fetch_user returns one
(also needs to be indented inside the command)
and user_id is not defined
yes
would that be user_Id?
wait
also put a cooldown on the command to prevent people from spamming it, fetch_user is an api call that could get you ratelimited if spammed or even banned
how do I make a cooldown?
!d discord.ext.commands.cooldown
discord.ext.commands.cooldown(rate, per, type=<BucketType.default: 0>)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/stable/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/stable/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.on_command_error "discord.on_command_error") and the local error handler.
A command can only have a single cooldown.
thanks lol but I realized
ok now it says int has no attribution to banner
indenting was fixed
@hasty iron
as i said banner is an attribute of User
you have to save the return value of fetch_user and use that
you clearly are a python beginner so i suggest you go back to learning basics
im a beginner at discord python
no, youโre a beginner at python as a whole
lmfao
Hoi
so with print(ctx.guild.members) how can I just print their ids?
I don't know how to do that but I do know you can loop through each member and print their ID.
for member in ctx.guild.members:
print(member.id)
you can do ids = [member.id for member in Guild.members]
Filter would be faster in this case wouldn't it
role = member.guild.get_role(853983786236377266)
await member.add_roles(role)
the role returns none altho I copied the id of the correct role from the server
@hasty iron Thanks for the help with the banner command lol. I will go and study the basics of python again. It now sends the banner and says if someone doesn't have a banner.
Found a fix to this, defining a separate function to handle total time elapsed while waiting through multiple responses
I guess i'll just dump all that into a list
the guild is incorrect ?
@vale pendant discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.member' has no attribute 'id'
do you have something along the lines of import discord.member in the import statements at the top of your code?
(@slate swan ^)
no thatโs good that you donโt
yeah donโt add it haha sorry poor phrasing
thatโs just what the error message read as to me
ids = []
for _ids in ctx.guild.members:
ids.append(member.id)```
oh actually i think i see the problem
oh?
um... is member member = ctx.guild.members?
no itโd be ids.append(_ids.id)
because _ids is a Member object
probably better to name it something like each_member
donโt name it just member because youโd override dpy
ohh that makes sense
actually i think dpy uses Member, not member, but probably still good to avoid just in case
your local variable member will not override anything in discord.py
naming a variable the same way as a class is pretty common if there isn't more context than the type
fair
how do i make a discord bot in colab?
what colab?
google colab
idt u can
what can you use to make discord bots
the discord api?
which is probably a language i cant understand?
What is the documentation for a user's accent color in discord.py v2.0
discovered the module called multiprocessing, can anyone tell me why this isn't printing anything:
from multiprocessing import Process
def func1():
while True:
print(1)
p1 = Process(target = func1)
p1.start()```
How can I make that, when a user has been kicked from the server, the bot send them md?
wdym
py or js
Direct message probably
yes, dm, md, private message, that's how it is said in Spanish
u should prolly send them a message before they get kicked
and use try except incase some have dms off
The color on the banner
O
thanks, but how do i make it respond to text command like /calloutuser?
Ok thanks
I know, but I thought that in English it was also said like this
que?
so it is not possible for the bot to do it automatically?
Not everyone can type perfectly 
nope
o :(
Well it could do it โautomaticallyโ you just canโt dm anyone who isnโt the same server as you
how is it done? 
Cant*
thank you anyway
he means dm
does anyone know anything about the API update? there are many things missing
#bot-commands
tysm lol my internet
@boreal ravine what's that?
is it possible to put timestamp in the footer?
!d discord.Embed.timestamp
The timestamp of the embed content. This could be a naive or aware datetime.
want the text to be small but also want the unix timestamp to be there
nono unix timestamp
aw okay ty
wtf
buttons are for discord.py 2.0a. unless ur using a different library
Use disnake instead. It has buttons inside the library. Discord Components is messing with the discord.py lib
ohk
does anyone know where to find a cookiecutter template for python discord bots?
What's the error?
embed red
It looks like they ended the discord.py project. Are there serious attempts to fork it and continue it?
!pypi disnake
dpy is still usable for now (until discord makes a breaking change or adds new features you want to use) and there are several forks but the dust hasnโt quite settled yetโ probably good to wait a month or so and see what the state of things is then
thanks for the heads up! have plans to make a discord bot for folks. shocking news
no worries! and dpy should keep functioning fine as-is for a fair number of months at least, although we never know
and yeah itโs kinda too bad but i understand where dpyโs maintainer is coming from
error?
let it be it got solved
kk
pls can u test my bot plis
no
no
no
:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1630988468:f> (9 minutes and 59 seconds) (reason: mentions rule: sent 6 mentions in 10s).
I just got pinged
Read.
Yea just saw
interactions_endpoint_url: The specified interactions endpoint url could not be verified
I have problem when i try to configure the endpoint for interactions event in discord. Does anyone face it , how can i fix this problem?
Most fail
But there are some you could consider switching to
hikari
You are not allowed to use that command here. Please use the #bot-commands channel instead.
1000493ns
How can i set custom activity status ( like listening, streaming etc ) in my discord bot?
!d discord.ext.commands.Bot.change_presence
await change_presence(*, activity=None, status=None, afk=False)```
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)
how can i return uptime for my bot?
!time
!d time
This module provides various time-related functions. For related functionality, see also the datetime and calendar modules.
Although this module is always available, not all functions are available on all platforms. Most of the functions defined in this module call platform C library functions with the same name. It may sometimes be helpful to consult the platform documentation, because the semantics of these functions varies among platforms.
An explanation of some terminology and conventions is in order.
โข The epoch is the point where the time starts, and is platform dependent. For Unix, the epoch is January 1, 1970, 00:00:00 (UTC). To find out what the epoch is on a given platform, look at time.gmtime(0).
Make a bot variable and set it to datetime.utcnow() when yr bot starts. That will be the uptime
!botvar this is how u make a botvar
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
let me read just a sec
what variable do i need to make
sorry i am noob
U can name or anything
guys
Hm?
Bro.... I have made one, but lemme tell you something.... It's not as easy as it seems. You gotta find an AI Module, then gotta find out how to train it and then add profanity filter and then add it to yr bot keeping in mind it doesn't block your bot. Then you gotta make a basic bot for the same
that's your tag isn't it?
(Everything else, Kylee gonna tell you cz he has more knowledge on this topic than me)
Mhm
No
!docstring this is mine 
A docstring is a string - always using triple quotes - that's placed at the top of files, classes and functions. A docstring should contain a clear explanation of what it's describing. You can also include descriptions of the subject's parameter(s) and what it returns, as shown below:
def greet(name: str, age: int) -> str:
"""
Return a string that greets the given person, using their name and age.
:param name: The name of the person to greet.
:param age: The age of the person to greet.
:return: The greeting.
"""
return f"Hello {name}, you are {age} years old!"
You can get the docstring by using the inspect.getdoc function, from the built-in inspect module, or by accessing the .__doc__ attribute. inspect.getdoc is often preferred, as it clears indents from the docstring.
For the last example, you can print it by doing this: print(inspect.getdoc(greet)).
For more details about what a docstring is and its usage, check out this guide by Real Python, or the official docstring specification.
yeahh i know....i need someone to copy paste the code
then
bot.time_to_return....
Cool
There goes my net, it was expected 
what is the difference between from discord.ext import commands and discord.ext.commands.Bot()
Does the second one work?
If yes, then no difference
Yes that works @maiden fable
Another question when using commands how do i run the bot? I was using client.run()
however someone suggested i use bot commands
since i was checking message content
yeah
commands.Bot inherits discord.Client
Just like u run it with message content
Thus you run it the same way
Ah, that thing. Yea
I feel like you are getting a stroke... Are you alright...? Using such a big path
Indeed
Alright thanks @maiden fable
big path?
Is there a reason why you manually load those cogs
i thought he was trying to see the difference between
from discord.ext import command
bot = commands.Bot()
and
import discord
bot = discord.ext.commands.Bot()
nah, the donation.py is still in progress
so i dont really want to load all of it
Ah, I thought u were using that path in ur project seriously and not just showing him

Why not use the os module but make a list of cogs which u don't wanna load, then check the list?
idk
If you do later I got a really clean way of doing it on my own bot 
A discord bot focused on clean code and utility. Using the discord.py library - 0x42/botbase.py at 6af6104be5ae9932123ebb59e432794ec6317531 ยท an-dyy/0x42
Alright so i am trying to figure out how to view the current channel name do y'all have a API reference i can checkout so i don't keep bothering you all i checked the discord.py docs and was confused when it came to the bot commands
i understand client() just not bot commands
and not ext.startswith("_") why tho?
oh the __init__.py
So it doesn't load the __init__.py and other files I want not to be loaded
For an example if I needed something like _help to stay unloaded
cool trick in that snippet is the async classmethod
makes the class in an async func so I don't need to do stupid asyncio stuff
How can i get a list of loaded and unloaded cogs?
!d discord.ext.commands.Bot.cogs
cogs```
A read-only mapping of cog name to cog.
Could someone help me with this
The channel name.
alright let me try that thanks @maiden fable
So it would be ctx.channel.name
why is this comming ?
its mine
Hmm, well u gotta uncheck the code grant check from discord dev portal. Open the portal, I will guide u
Go to the Bot section
ok
And there should be a check with the name code grant or something
(:
what happened XD
Nothing
one message got deleted
Idk
hey is there any more easy to read docs for bot commands than the discord.py documentation
I am trying to figure out how to access the message that called the bot command however i can't seem to find a answer i understand and @keen talon if you aren't going to help then shut up and don't answer a message i did not ask for your opinion i am here to get help not have someone try and act like they know everything
yeah i am used to client run event however i am trying to figure out bot commands @unique nexus
ok
u should use commands.Bot
I am now
again if you aren't going to bother reading the message don't respond

???
what? @boreal ravine
-.-
what do you want
Hey guys. Whats the benefits to using the discord.py (or its successors) vs just coding it myself?
Well, you have about 6 years of work already made for you
Why is it undefined?
I would say using a good fork of d.py would be good as it will save your time
BucketType
"T"
in line 5
Huh
I just copied it from my other files and the letters changed
thats weird
well thanks sherlock
!charinfo ๐
\U0001f3d3: TABLE TENNIS PADDLE AND BALL - ๐
Gotta figure out how to use this discord.py D:
yes that's the best out there
you want yt tutorial?
don't
sad
Send me one and if I get around to it I'll watch it ๐
Hey everyone i am back i am using cfx.message and before with message.content i could use split() however now i can not even when converting to a str does anyone have a suggestion how i can access a certain part of a bot command
read the docs first
.
elif(msg.content.lower().startswith('ban')):
if(not msg.author.id in devs and not msg.author.guild_permissions.view_audit_log):
return await noPerm(msg)
args = msg.content.split(' ')[1:]
if(len(args) < 1):
return await msg.channel.send(f'Usage: {prefix}ban <user> <reason>|none')
if(not args[0].startswith('<@') or not args[0].endswith('>')):
return await msg.channel.send(f'Usage: {prefix}ban <user> <reason>|none')
args[0] = args[0][2:-1]
if(args[0].startswith('!')):
args[0] = args[0][1:]
if(len(args) == 2 and args[1] == 'none'):
args[1] = ''
try:
memberToBan = await msg.guild.fetch_member(args[0])
await memberToBan.ban(reason=' '.join(args[1:]))
await msg.reply(embed=discord.Embed(title=f":white_check_mark: Banned {memberToBan.name}#{memberToBan.discriminator}!", color=0x00ff00), mention_author=False)
except discord.errors.HTTPException:
await msg.reply(embed=discord.Embed(title=":x: An error occurred.", color=0xff0000), mention_author=False)```
smth me and a friend made
maybe it can help
why not use a cmd deco.
is that an on message
!d discord.ext.commands
No documentation found for the requested symbol.
oh nvm
so an on message with if's and elif's
yess
thats bad
I'm making this now
ok
does anyone know a vscode extension with help in discord python?
like suggesting things
idk but vs code by default suggest/shows docstrings when you hover over any method or attr.
you see channel and purge are not even reached by vscode
await
yes
u didnt await it
still
await ctx.channel.purge(limit=amount)
not even reached
^
.channel.purge are white
wdyw
vscode says
so?
colors (pyflakes) dont matter except green and red
Ik
try it on your bot to see if it works ig
but I want something to suggest me things
Here the send is white too lmao
uh
also
the purge command works with 5 messages, how to make it purge much messages as I want?
@wispy sequoia yeah i had that working in my own version however someone suggested i move to bot commands
like #purge 50
and now with bot commands split does not work even when converting to a str
^^
Do
#purge 50
yeah uh on message commands gonna make spaghetti code
what do you mean @boreal ravine
i was using message.content however it was not clearing the text at the end and instead was just using the bot response as the message text
I mean that on message commands are messy and if you make normal commands you can set the command permissions like ```py
@commands.has_permissions(administrator=True)
Do you know how i could remove the content of the message on next run
the content?
can you share the code snippet
again , don't make commands using on_message event, lol
Hey @steel flower!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
o
I was not using commands for this one i was doing it almost like yours @reef shell lol
what @boreal ravine
what?
if I do #purge 50 this returns ['50'] (list), how to make it just 50
oh wrong person sorry @reef shell
can you tell me what's your goal so i can give you a better solution?
yes
@commands.command(aliases=['clear'], help='Purges (x) amount of messages.')
@commands.has_permissions(manage_messages=True)
async def purge(self, ctx, amount=2):
await ctx.channel.purge(limit=amount)
``` heres the command i use.
i got you confused with someone else and i would like to be able to check a Discord message at a specific part in the string and check it's length
o
those u dont have to change
how's it possible
what possible
like, isn't the amount set on 2?
@boreal ravine You going to answer the question you keep saying o
no thats the default amount if you do #purge it'll purge 2 and if you insert another amount like #purge 100 it'll purge the amount
oh wow
it's the default value
I didn't know that
when you don't pass the amount
You don't have to change things like those to commands
A filter is what your doing right? like dyno for example
alright do you know what could be wrong with my code and yeah @boreal ravine
ooo
@wispy sequoia
@bot.command(aliases = ['del', 'delete', 'clear'])
async def purge(ctx, amount : int = 5):
await ctx.channel.purge(limit = amount + 1)
await ctx.channel.send(f"Deleted {amount} messages!!", delete_after = 2)```
o
how to set the purge only on the bot
i just copied my code nvm
so if I do #purge it purges only itself messages?
no
no
it'll purge every1s message
latest messages in channel
^^^^
like rythm does
does anyone know how to help me or point me in the right way
what do u need
@wispy sequoia if you scroll up you will see i sent a piece of my bot that always returns the bots last message the next bot command and screws up the length check
ye that's a problem
as u can see
Idfk how to unlist
but u can try
anyone else
i already tried that
@client.command(pass_context=True)
async def play(ctx, url):
guild = ctx.message.guild
voice_client = guild.voice_client
player = await voice_client.create_ytdl_player(url)
players = [guild.id] = player
player.start()
@client.command(pass_context=True)
async def join(ctx):
if ctx.message.author.voice:
channel = ctx.message.author.voice.channel
await client.channel.connect()``` whats my dumb butt doing wrong now
@client.command()
async def ping(ctx):
await ctx.reply(f"\U0001f3d3 Pong! **{round(client.latency * 1000)}ms**", mention_author=False)
@client.command()
async def purge(ctx, amount=5):
await ctx.channel.purge(limit=amount)```
excuse me WHAT
what's that thing
bruh
also u seem to be the guy who knows how music bots work
u have to get rid of it
do uk what im doing wrong here?
I don't ๐
well frick
if u want to make a custom embed help command
how
anyone know how to yea yk
I'm learning and on yt is full of videos
learning or copying code from the videos lol
potato potaato
what's wrong with it
.remove_command("help")
meh id say its good to start with yt since its a bit hard togo through docs, once u get some basic knowledge u can start with docs
its better to learn basic python before making a bot first of all
well I do
ehh sure
Yt isn't the best way if u want to get started with dpy
bot = commands.Bot(command_prefix="m.", intents=intents)
token = os.environ['token']
status = cycle(['m.help', 'm.help'])
bot.remove_command("help")
Could someone help me with my bot
no
I have no idea whatโs wrong
Dude
we cant help if u dont tell us what u need help with
If you arenโt going to help shut up @brave ravine
Please be polite @brave ravine
lmao
@steel flower what do u need help with?
Nobody wants to hear a lowlife basement dwelling mamas boy talk
Calm down
If it scrapes YouTube, best of luck getting banned
its not gonna get banned since its not popular
<@&831776746206265384>
lots of things scrape youtube and arent banned
only reason why groovy and other popular bots are getting banned is because they made money of scraping youtube
Please i have multiple monitors a OpenSea query generator you ainโt nothing little boy this is just my first time with Discord bots @brave ravine also @maiden fable i am trying to check a bot command and check the length of a specific index of the code using splits however when the bot is ran again it gets the last bot comment not the users new command
what is that just await reply?
ye
dont tag me again thanks
Also it's against ToS
Donโt tag me again thanks @brave ravine
await ctx.reply("Sheesh", mention_author=False)
i didnt agree to them ๐








