#discord-bots
1 messages · Page 8 of 1
I just made a bot..
it doesnt work lmao
Woah?
You are trying to get the owner?
And mention them?
get_owner = await ctx.guild.fetch_member(ctx.guild.owner_id) part one) this will get the owner id
get_owner.mention part 2 this will allow you to mention the owner
Now again, think about the positioning of the code.
mention the owner
How can I fix this?
💀
<@{ctx.guild.owner}>
like that py @bot.command() async def info(ctx): get_owner = await ctx.guild.fetch_member(ctx.guild.owner_id) get_owner.mention embed=discord.Embed (title=f""" **{ctx.guild.name} Info**""",description=f""" **Server ID** {ctx.guild.id} **Created On** {ctx.guild.created_at.strftime}("%b %d %Y") **Server Owner** <@{ctx.guild.owner}> **Member Count** {ctx.guild.member_count} **Channels** {len(ctx.guild.text_channels)} Text | {len(ctx.guild.voice_channels)} Voice **Region** {ctx.guild.region}""", color=000000) await ctx.message.reply(embed=embed)
Why write this much code when you can just do this
send full tb
File "c:\Users\vaibh\OneDrive\Desktop\Advay Python Projects\main\main.py", line 22, in <module>
asyncio.run(main())
File "C:\Users\vaibh\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\vaibh\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "c:\Users\vaibh\OneDrive\Desktop\Advay Python Projects\main\main.py", line 19, in main
[await bot.load_extension(f"cogs.{file[:-3]}") for file in os.listdir("cogs") if file.endswith(".py")]
File "c:\Users\vaibh\OneDrive\Desktop\Advay Python Projects\main\main.py", line 19, in <listcomp>
[await bot.load_extension(f"cogs.{file[:-3]}") for file in os.listdir("cogs") if file.endswith(".py")]
File "C:\Users\vaibh\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 991, in load_extension
spec = importlib.util.find_spec(name)
File "C:\Users\vaibh\AppData\Local\Programs\Python\Python310\lib\importlib\util.py", line 94, in find_spec
parent = __import__(parent_name, fromlist=['__path__'])
ModuleNotFoundError: No module named 'cogs'```
ಥ_ಥ
I don’t think you can use bold characters in title
Correct me if I’m wrong
just do ctx.guild.owner.mention ...?
no
why?
ctx.guild.owner returns a member object not an id. so you cannot mention the owner like that
the folder path is faulty, check it
💀
as established earlier, they don't have member intents. So they can't do it like that
Then use @ without <>
Member.mention ...?
I gave the full path but it showed same error
cool
ctx.guild.owner_id actually
wont work
mhm
owner.id if they are in 2.0..?
the owner_id property doesn't require member intents
wb this
sarthyyy 
Wish we could be smart as sarth
they can still use owner_id
nvm i removed the owner thing i wil fix it later
💀
but now it says something like Your ip:
Is it discord.utils again?
hi ash
I'm not even equivalent to a sloth, might as well forget about that level 😔
balls💀
yes but one thing can go wrong with this, one is that it could return None if the guild isn’t in cache by chance iirc
I used the full path to the file but it still showed the same error
you don't need to be, I'm quite pathetic
Oh
ever used tagscript?
what even is tagscript
balls
The tag thing in bots
I'd like to shoot the person who turns Guild intents off + if you really want that much code security use rus- uk
really informative

Guys?
You want me to explain what tag script it without knowing what / how to use it?
what's that, something like r Danny's tag command?
yup
yes.
.....
its not always an issue with intents. for some reason guilds just aren’t always in the cache for no fuckin reason. especially if you’re using AutoShardedClient
you can set permission overwrites for that role in the channel
who tf turns off the guild intent either way
welcome to #discord-bots
isn’t it enabled in Intents.default by default either way?
Is there a documentation i can read?
you dont?
@bot.command()
async def info(ctx):
embed=discord.Embed (title=f"""
**{ctx.guild.name} Info**""",description=f"""
**Server ID** {ctx.guild.id}
**Created On** {ctx.guild.created_at.strftime}("%b %d %Y")
**Member Count** {ctx.guild.member_count}
**Channels** {len(ctx.guild.text_channels)} Text |
{len(ctx.guild.voice_channels)} Voice
**Region** {ctx.guild.region}""", color=000000)
message = await ctx.message.reply(embed=embed)``` ```py
File "main.py", line 274
message = await ctx.message.reply(embed=embed)
^
IndentationError: unexpected indent```
I gave the full path but it showed the same error
Imagine using the code of red bot for a custom bot and being promoted to admin for that 💀
bruh
Not me ^
why would i smh. nearly half of the events in all of dpy utilize guilds + the guild intent smh
redbot?
Yup
well yeah ctx.guild would be None in that case, but since get_context prepares that and makes sure it's not None by get/fetching it
it’s some shitty open source bot people make custom cogs for
it’s mid
embed and message aren't on the same indentation level
And it’s being used for a 2.7k server
understand the sarcasm 😔
ik ik i was going off of it 
!d discord.abc.GuildChannel.set_permissions
await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sets the channel specific permission overwrites for a target in the channel.
The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role") that belongs to guild.
The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.
If the `overwrite` parameter is `None`, then the permission overwrites are deleted.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this...
I'm scarred
I mean, who even does that
Thanks
just because it’s used in a lot of servers doesnt mean it good necessarily. why do you think mee6 is still shit bro
I don’t even use mee6
y'all kids, I don't even host my bots
what.
stop using replit
this is the repl curse
I dont even make bots, argue.
Ye replit
no df
i already know that you’re using replit and replit gets your shit blocked.
type kill 1 in the shell and it'll fix itself probably
ill make a tutorial on how to make a simple bot
I use rust btw
or just stop fucking using replit smh
I guide others to the path i cannot pursue
it's under progress
well good luck with that error then and getting constant ratelimits!
balls
the exclamation mark makes the message a whole lot worse
so funny. im laughing my ass off because someone said “balls”. im laughing so hard rn omg
balls
any ideas boys ?
!indent
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
so i should go forward a tab or back a tab ?
you have a try: right there lota
like this?
no lmao, a tab but a tab of spaces
@slate swan what do i put after the target? What is for the channel viewing?
Channel. set_permission(role, ...)
if you want to use a try: statement you need to indent code inside it
although it'll break anyway because there's no except: statement
did you mean to use try?
Only that?
hi guys I am doing python app and I want to let discord show the activity of my app how to do that
open the docs it has an example
Oh yeah thanks
settings > activity > your app
Its only read message tho
honestly, i dont know python, i paid a guy to make me three bots and he ended up blocking me after i showed him errors in code .... so im having to fix it myself
I mean channel visibility
Please read rule 7 too.
lol
just delete try: and it'll be fine
no I want to do that automticly like other apps
you gotta set view_channel to False
Thanks!!!!
that's a single time process
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
what do you mean
ooofft
you need to do it only once .
oh well there's the except statement
use async with the functions
its algoods i mean best way to learn right ? being chucked into the deep end ahha
ok
discord bots is totally not the best way to learn py
or any programming language in general
I know python from 4 years and I always use it but I am new at discord.py
that's good you'll get an easy grip at it once you check out the docs
i mean i really want to get into python none the less but yeah i know what you mean, i guess ill try and take a course and pay someone to fix these bots
bro dont pay
your good man its not your job too 🙂
I learned java , python , c# , c/c++ , html , css , js in one year without paying
soo dont pay
hmmm i mean where would one go to learn python/java ?
^ there are pretty much free resources available
not in one year actualy but near that maybe 1 year and 4 months like that
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
@slate swan is is possible to set the view channel property to false to all users when i create a channel?
you can use udemy and youtube to learn and maybe someone of your friends that now he can help you
!d discord.Guild.create_text_channel
await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., default_auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel "discord.TextChannel") for the guild.
Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.
The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
Do i put channel_view there?
yes and stackoverflew for help
i find that youtube is too saturated with info ? idk tho i mean ill try youtube, i was gonna sign myself up to cs20 fo java
@commands.cooldown(1, 86400, commands.BucketType.user) how to make it into db, like if i restart bot it is not resetting for everyne
what exactly is channel_view? a permission overwrite?
ok good thing me too I started with youtube
note : if you learned 1 programming languege you will know some of the other like if you learned java you will know c/c++ and c#
you would have to use dynamic cooldowns and create your own cooldown system
!d discord.ext.commands.dynamic_cooldown
codegrepper is the badest thing everything is not working there 😂
I want to disable to view the created channel at default, how would i do that?
@fresh ferry note : start with python
!d discord.PermissionOverwrite
class discord.PermissionOverwrite(**kwargs)```
A type that is used to represent a channel specific permission.
Unlike a regular [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions"), the default value of a permission is equivalent to `None` and not `False`. Setting a value to `False` is **explicitly** denying that permission, while setting a value to `True` is **explicitly** allowing that permission.
The values supported by this are the same as [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions") with the added possibility of it being set to `None`.
x == y Checks if two overwrites are equal.
x != y Checks if two overwrites are not equal.
iter(x) Returns an iterator of `(perm, value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
you would have to pass in this object for that kwarg
i will 🙂
Yep got it
omg..
!d discord.ext.commands.dynamic_cooldown
@discord.ext.commands.dynamic_cooldown(cooldown, type)```
A decorator that adds a dynamic cooldown to a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
This differs from [`cooldown()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.cooldown "discord.ext.commands.cooldown") in that it takes a function that accepts a single parameter of type [`discord.Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") and must return a [`Cooldown`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Cooldown "discord.app_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://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/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.
New in version 2.0.
hey,how can i keep track of a certain command?
example : if i run a "1st command" >> !attack (prefix = !)
so the bot will ask me to choose between 3 commands like
!npc 1 , !npc 2, !npc 3 (choosing between 3 npc to attack)
but i want the user to be able to use one of these 3 commands only when he trigger the "1st command" (!attack)
can someone tell me how to do that? is there a specific method that i have to use?
@slate swan may u help me with @discord.ext.commands.dynamic_cooldown(1, 86400, commands.BucketType.user)
i cant catch what should i do with dynamic_cooldown
1 day cooldown?
Oh btw
If the user sends
.reminder 1h something
How can I make the bot respond in 1h rather than the user having to send seconds
i made myself like:
f"try again after {error.retry_after/3600:.0f} h"
Oh
I can’t just use it in a command where I want the bot to respond after 1h or the time the user sent
i even need help for myself, sorry..
@slate swan i have trouble figuring out what to put it overwrites = { }
I tried ctx.guild.PermissionOverwrite(view_channel=False)
But it says guild has no I forgor PermissionOverwrite
Please help
what library are you using?
2.0 dpy
For an icon_url in the footer of an embed, what is the recommended image size?
the order in which the decorator passed arguments is interaction then button
so your function signature should be
@..button(...)
async def ...(self, interaction, button):
@discord.ui.button(label="1",style=discord.ButtonStyle.gray,row=0)
async def one(self,button:discord.ui.Button,interaction:discord.Interaction):
self.expr += "1"
await interaction.message.edit(content=self.expr)
I did this
you have button, interaction, swap them
Ok
Then
Hello everyone. i actually want to build a bot.
the function of the bot would be -- there is website which posts daily quote at morning 8:30 AM. i want the bot to fetch that quote and the post it in the channel. how would i do it
https://type.fit/api/quotes
just pick quotes from this api and send it every morning
It was in the documentation
can u send a link?
i think it just needs to be an iterable like list or tuple, set only accepts hashable types
!d discord.PermissionOverwrite
class discord.PermissionOverwrite(**kwargs)```
A type that is used to represent a channel specific permission.
Unlike a regular [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions"), the default value of a permission is equivalent to `None` and not `False`. Setting a value to `False` is **explicitly** denying that permission, while setting a value to `True` is **explicitly** allowing that permission.
The values supported by this are the same as [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions") with the added possibility of it being set to `None`.
x == y Checks if two overwrites are equal.
x != y Checks if two overwrites are not equal.
iter(x) Returns an iterator of `(perm, value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
@paper sluice
where tho ?? im confused where to put it
it doesn't say that it needs to be in a set ....
Oh what
example :
async def command():
#your script
oh its already in the source ?
Its an error again
It says overwrite parameter needs a dict
Here is what i want to do: when i create a channel, I want all users to not be able to see it
indents issue
Go back 1 tab(4 backspaces)
At least i think so
can you resend the code ?
bro I need to go please faster
I have to work in something
@paper sluice ?
this is my first time im creating a discord bot. so i wanted to automate it every morning. would you guide me how would i create a discord bot. i know python but dont know where to start for discord bot
sorry bro I want to go byee
does somebody have panda's idiotic calculator
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
that and the discord.py doc
ty
Anyonw?
oh no ban pls
<@&831776746206265384>
Handled, thanks yall
boom banned 😄
No need to double tag
help everyone 😄
love you mans, thanks for all the hard work 🙂
brad 
poor joe 
https://paste.pythondiscord.com/ateguwujof
Guys i made this button
I want that it removes the last message and adds the new message with the same buttons
So how can I do that?
what did he send
free nitro for moderators
Pls help anyone
thanks, smarty 
well if he was banned, he cant rejoin once he gets his account back ;-;
msg = await ctx.send("first message")
await asyncio.sleep(42)
await msg.edit(content="yes", view=YourViewInstance())
I want to do that inside the button
dont care
why worry when you dont got to
what
just saying 💀
then send self 
send self -> send yourself, yes.
I confused
I have a C in my calculator command so i want when someone clicks it the calculator gets reset
ಥ╭╮ಥ
depends on your code on how you want and set it up
Hmmm?
https://paste.pythondiscord.com/quzasojuyu
Here is my code
skill issue
This, but it returns an error
skill issue
Line 24
wasnt replying to you but 'kay
ಥ_ಥ
overwrites shouldnt be in a dict
Oh lol
Hmmmm
Okay
Anyway i found my mistake in code
nice
I did a kid mistake
aren't you a kid too
damn
when i started with python i started with discord bots
totally more than three-fourth of the persons in this channel
How can I make that the author of the message can only use the button?
add a check
class MyView(ui.View):
def __init__(self, valid: typing.Union[discord.User, discord.Member]) -> None:
self.valid_user = valid
async def interaction_check(self, inter: discord.Interaction) -> bool:
return inter.author == valid
@bot.command()
#whatever
await ctx.send("...", view=MyView(ctx.author))
Do i need to add check in every button decorator?
@slate swan
interaction_check is triggered automatically whenever a button is clicked
Do i remove it?
remove the braces
Hi
read the error
Excpects a dict
sparky 
yes. thanku
😄 I'm inactive cuz my exams are going on
How would i add that •́ ‿ ,•̀
imagine
Reality
Going here
Tmrw math exam easy
show code
Hey ryuga ^_^
hi
im just becoming lazy lol
thats different
you just did overwrite = discord....its supposed to be a dict
Okay
Is there an example?
Oh k
I mean that do i need to put it at top of discord.ui.view class?
I mean on how it supposed to be a dict
Oh
Wait
Yep
How?
no?
"whenever a button is clicked", didnt refer to a specific button
!d discord.Guild.create_text_channel
await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., default_auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel "discord.TextChannel") for the guild.
Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.
The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
It expects a dict
Then why aren't you passing a dict 🤨
Lol saw that multiple times
change line 22 into:
overwrites = {
discord.PermissionOverwrite(read_messages=True)
}
i mean
Which ide btw
pydroid 3 i think
That's a set...
Oh well its in here
That's good , otherwise people just say I dont have pc I can't code
I cant even type properly on phone
imagine writing code
I can't imagine staring at a small screen for hours, it must be really bad for your eyes
Although I use light mode so maybe i shouldn't speak
do you know what a dict is?
how to delete 5 messages in the “channel” sent by the “bot”
TextChannel.purge has a check kwarg
Mhm
def check(msg: discord.Message):
return msg.author.id == client.user.id
await ctx.channel.purge(check=check, limit=...)
anyone knows how to track specific command?
lambda m: m.author == client.user
no.
Yes!!
I hate lambda for no reason
Whst do you mean by track?
You want to log whenever a certain command is used or something like that?
Finally me done with button calculator
example : if i run a "1st command" >> !attack (prefix = !)
so the bot will ask me to choose between 3 commands like
!npc 1 , !npc 2, !npc 3 (choosing between 3 npc to attack)
but i want the user to be able to use one of these 3 commands only when he trigger the "1st command" (!attack)
its something like if command 1 is True the other commands can run
You could use bot.wait_for... or you might need to implement a command handler suited to your case
i want to remove the "help" command that is already build in my bot and i dont know how so i used this py bot.remove_command('help') but it didnt work also i put this code at the top of my code how can i fix this
what is a command handler?
are you trying to make a custom help command?
something that parses user input and handles command invokation, like discord.ext.commands
no i already have one custom i just want to remove the one that i didnt build
i want to remove the command in the picture
when you're creating your Bot instance set help_command=None
where do i type this?
in the top of my code in the main.py file?
commands.Bot(help_command=None)
If i remeber correctly it was somekind of class
?
turn what to a dict?
The overwrites
you don't turn the overwrites to a dict, you use them in a dict
!d discord.Guild.create_text_channel
await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., default_auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel "discord.TextChannel") for the guild.
Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.
The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
there are examples here, please check
Okay
are you getting an error?
close, its a datatype that stores key-value pairs, so for your case you want the key to be an attribute of discord.Guild and value as a PermissionOverwrite
no i dont know where to type the code
I tried copy and pasting a code from the documentation and it got an error
I would recommend learning about dicts first
Yeee thanks
are you using discord.Client or commands.Bot?
@bot.command()
@paper sluice
ok, so when you do bot = commands.Bot(...) set help_command = None
ok so i put this at the top of my main.py code?
if that's where you're doing bot = commands.Bot(...) sure
oke
click on the link and go through the tutorial once, it shows exactly how dicts work
File "main.py", line 1
bot = commands.Bot(...) set help_command = None
^
SyntaxError: invalid syntax```
sorry im new to dev
!resources check these out
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Traceback (most recent call last):
File "main.py", line 1, in <module>
commands.Bot(help_command=None)
NameError: name 'commands' is not defined```
@vocal snow can u send me a link of how to use the command handler thing?
I meant that you'd have to implement your own command handler for a compicated usecase
😐 you didn't import anything
The easier option is to use bot.wait_for in your command to get user input
!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.10)"). 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.10)") 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.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
what do i need to import?
.
💀
then why did you have
bot = ...
at line 1 lmao
do this
bot = commands.Bot(yourstuffhere,help_command=None)
i didnt know where to type this code 💀
wdym (yourstuffhere)?
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.
it should go under the imported modules of course
yea but now i have this error py File "main.py", line 18, in <module> bot = commands.bot(help_command=None) TypeError: 'module' object is not callable
like the command_prefix
ok wait a min
it's commands.Bot(...) not commands.bot(...)
I would seriously recommend taking a python course, it will save you a shit ton of time
i dont want to sent my full code here sorry
File "main.py", line 17, in <module>
bot = commands.Bot(help_command=None)
TypeError: __init__() missing 1 required positional argument: 'command_prefix'```
bot = commands.Bot(command_prefix="!", intents=intents,case_insensitive = True)```
bot = commands.Bot(command_prefix="yourprefix",help_command=None)
examples/basic_bot.py line 16
bot = commands.Bot(command_prefix='?', description=description, intents=intents)```
import discord
from discord.ext import commands
from discord.ext.commands import bot
import asyncio
import datetime as dt
client = discord.Client()
import youtube_dl
import pafy
import datetime
import humanfriendly
import os
import praw
import random
intents= discord.Intents.default()
intents.members = True
reddit = praw.Reddit(client_id = "", client_secret = "", username = "", password = "", user_agent = "pythonpraw", check_for_async = False)
bot = commands.Bot(help_command=None)
bot = commands.Bot(command_prefix="!", intents=intents,case_insensitive = True)
wha-
i removed my client id and secret
flabbergasted rn
^
ok💀
from discord.ext.commands import bot
bot = commands.Bot(help_command=None)
bot = commands.Bot(command_prefix="!", intents=intents,case_insensitive = True)
💀 please learn basics of python before making a discord bot, its fairly advanced
ok so remove
bot = commands.Bot(help_command=None)
```py
then edit
```py
bot = commands.Bot(command_prefix="!",intents=intents,case_insensitive = True)
into this:
bot = commands.Bot(command_prefix="!",intents=intents,case_insensitive = True,help_command = None)
dont mind the py
you shouldn't spoon feed
thx for the secrets
😀
NOOOOO
How to fix "The application did not respond" error
are you getting any errors?
No but when I use the slash command, it says that
Not in terminal
probably there is some problem with your code, if you want you can send it
okk soo uhh i have a question,is there any other language you can use to make discord bots other than node.js and python
you can make it in any language
bot hosting site says i dont have proper perms for bot to operate to full capacity, yet on my discord dev portal iv given it admin controls and pretty much every perm their is ? im scratching my head in mass confusion
Is anyone having problems with slash commands?
I'm trying to make a slash command but it just doesn't assume it exists
but the funny part is that it takes over 3 others that I had created before
the discord API documentation lists some libraries in a few other languages, but technically any language that can do API requests is sufficient to interact with discord https://discord.com/developers/docs/topics/community-resources#libraries
okkk thx thx
bot hosting site?
wdym 🤔
Ok wow thats actually alot
What is the cause of "The application did not respond" and how do I fix it???
We don't help/condone the creation of music bots here.
It meant the bot you are currently making didn't respond in the given 5 seconds, Discord wants to receive a response.
So is that not something wrong with my code?
This is the case with slash command or any components like button, modals etc.
I have these two codes. The bot is just assuming that the 1st command exists and is not assuming that the 2nd command exists, when the two are exactly the same.
and I don't have any kind of error, that's the problem
Well yes and no, you can make code work and have that as response. Best is to handle the response and send something back.
How can I do that?
Did you add the second command? How do you register/sync the commands?
wdym?
A response can be a lot of things but usually a response is a message to the user.
pebblehosting , im getting missing permissions for my bot
pong, channel_message, deferred_channel_message, deferred_message_update, message_update, autocomplete_result, modal, these are all the responses.
You could also get a not responded if the code couldn't reach the response, aka an error.
the problem is that it doesn't give any error.
I'm not able to create other slash commands in any folder I put. It's not just that
Well like you said they should work, so it's likely a register/sync error.
So after the intended interaction is sent, but fails, would the response message use interaction or ctx?
can some one help me my giveaway bot is half working but he cant count down and cause of that no one is the winer 💀
interaction always
thanks
unless you use py-cord i think.
Not sure but I thought they still used ctx for everything.
Why count down at all just give it a datetime object.
iv given all my bots every permission that im capable of giving thats including admin, iv spent 2 days trying to fix this.... any help would be thankful ❤️
wait can i msg u
You have not provided the right scope, I assume you are trying to work with slash commands?
tbh i am really new and just making the bot fore my friends bday so i dont know a lot about coding
it uses "!" command
df im not creating a music bot lmao
import youtube_dl
Make sure the bot's top role is higher than whomever you're trying to ban
its higher then the owner with admin commands
yea i tried to create a music bot i saw it didnt work and i left import youtube_dl there
But is the top role of whoever you're banning the same as or higher than the bot's top role?
no all roles that im wanting to ban are way below the bots role
Also; you can't ban the server owner
i know but im using it to ban the role of said user and for some reason it'll remove anyones roles if it detects said banned words, its just not reacting the way it was months ago....
I recommend fixing all the previous errors first, work from top to bottom.
Oh wait you're removing roles not banning someone i misread
Although the reasons should be the same
funny thing, i paid someone to make the bot but they claim that there is no errors and shows me it working on their server but when i host it i have a moutain of errors, they do not want to help me fix this errors and pretty much chalked me so me not knowing any code im forced to fix them lol
Hmm 5 dollar gig on fiverr?
can some one help me my giveaway bot is not working idk why ```
from re import A
import discord
from discord.ext import commands
import datetime
import asyncio
import random
import time
#give away bot
TOKEN = "token"
bot = commands.Bot(command_prefix ="!")
@bot.command()
@commands.has_role("Owner")
async def giveaway(ctx, minute : int, prize: str):
await ctx.message.delete()
embed = discord.Embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)
end = datetime.datetime.now() + datetime.timedelta(seconds = minute*60)
embed.add_field(name = "ends at:", value = f"{end}")
embed.set_footer(text = f"end {minute} minutes from now!")
my_msg = await ctx.send(embed = embed)
await my_msg.add_reaction("🎉")
await asyncio.sleep(minute)
new_msg = await ctx.channel.fetch_message(my_msg.id)
users = await new_msg.reactions[0].users().flatten()
users.pop(users.index(bot.user))
winner = random.choice(users)
await ctx.send("congratulations! {winner.mention} you won {prize}!")
bot.run("token")```
nahh upwork but i did pay only like 20-30 usd for bot to be made
this is to stop racist comments being commit via a users custom status hence the banning of role
bot dont whana count down so he just like starts the giveaway but dont goes down to 0 and no one wins
How can I make my bot send message when i click button?
assert guild.me.top_role > role
``` can you add this before you call remove_roles and make sure it doesn't raise AssertionError?
(for @fresh ferry )
hey
bro
Have you worked with views yet?
i have a bot that delte racist comment if u want it
@bot.event
async def on_message(message):
await bot.process_commands(message)
if len(message.content) > 2:
id = str(message.author.id)
await asyncio.sleep(delay=random.randint(1,6))
data[id]['level'] += random.randint(1,5)
with open("values.json", "w") as f:
json.dump(data,f,indent=4)```
can somebody help me? i cant find where is the problem
would you mind if i post my source via your dms and we could go from there ? just that im yoloing this with no knowledge of anything code lol
im making source of my bot public once it works properly so im not too fussed sharing source
Don't worry about that, just add the line right above where you see bot.remove_roles
Ye
20-30 usd for a public sophisticated bot seems like a scam already, those aren't easy to create.
hi
@cloud dawn I understood the error
What have you got so far/ what library are you using?
can some one pls help me
but I still don't know how to solve
Dpy 2.0
I made a button calculator
Well me neither since I have no clue on how you register and sync the commands.
Oh so existing code? Where are you stuck?
I want to send a message on button click
I know about editing but forgot about sending
Well editing is also a response so you can just do x.send_message("Hey!")
Oh
Like this
await interection.send_message()
Yep, right above that line add assert member.guild.me.top_role > role
And how to send empherel messeg?
I really don't like this code, it's not really efficient.
await interaction.response.send_message("Psst, hey :wink:", ephemeral=True)
Yeah it's pretty poorly written
Thanks
honestly im split screening visual studio code and your message and i cant follow
his crappy gig made me want to learn python, which im going to but i heard java is better for discord idk tho
Aka if you were to put this bot public I'd suspect ratelimits, now I'm also wondering if it has autosharding or not.
JavaScript*
JavaScript are better in some aspects but Python has it's strengths as well.
JS is also much harder to learn/ jump into.
yesterday i had ratelimit issues i had to figure out how to fix that.... it took 9 hours and stackflow to help
Well yeah he basically putted a for loop on an api call. That's like spamming Discord messages for x amount of roles and expecting it to work.
See the await bot.remove_roles(role) line, put the assert line exactly above it
But then again it might be best to just scratch this code
Pretty hard for a starter plus he spend money on it.
That is true
yeah ima just yeet it all three sources... do you guys know anyone i can pay properly to rebuild my ideas... cause i need them asap for my server for moderation reasons :/
I got some spare time tonight
I don't like people being scammed 
i dont wanna burden you, but i dont mind the help if given
yeah i paid in usd and since covid thats 3 times my currency which what i paid i could have bought weeks worth of dinners 💀
Yeah np besides, I've been active here for the past 1.5 years so not like I have anything better to do.
(Not true but I like coding ok lol)
embed = discord.Embed(...)
embed.add_field(name = "foo", value = "Value", inline = True)
if #some condition:
#change the embed field value to "Value2"
How can I do this?
hey, hopefully ill be here just as long cause trying to fix these problems has sparked my interest in wanting to learn py
but shall i direct message you ??
Why not ```py
embed = discord.Embed(...)
if ???:
embed.add_field(name = "foo", value = "Value", inline = True)
else:
embed.add_field(name = "foo", value = "Value2", inline = True)
Sure.
Yes ok thanks maybe i will just stick with that
Or have a ternary
More complex
embed = discord.Embed(...)
embed.add_field(name="foo", value="Value" if ??? else "value2", inline=True)
@royal meteor If value is either None you could also use the or operator.
"Works for me"? Did you copy it?
yes
I recommend starting off easier then.
just found it and thougth why not just take it also in my bot but dont works fore me somhow
🙃
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.
i fixed it no error lemme try it if it works
Why the hell do you have so many useless imports (and even duplicated ones)
Like I highly doubt you'd ever need setuptools for a discord bot
to lazy to delte them tbh
i will make it later but it works so i dont really minde
Just run import optimization in your ide (depends which one you use)
And evaluating math expressions with eval() isn't a good idea unless the possible values in a string are strictly limited
You'd better use some math parser
thanks
!pypi strmath for example
How to fix this?
your bot did not respond to the interaction, there might be something wrong check the terminal for errors
You may defer the response if it's taking more than 3 seconds to respond for bot
await inter.response.defer() in most of libs afaik
Ok thanks
Would this go before or after the
await interaction.response.send_message()```
Before ofc
It basically sends "bot is thinking" message and when bot sends actual message, it removes "thinking" message
I still recieve the same message
Then check for errors in console as @paper sluice said
It may not necessarily be an error, something is taking more than 3 seconds. You should check to see what’s causing that. It’ll usually be something external, like an API or a database
Nothing appears in console other than what I printed myself
I'm not using any APIs or databases other than json files
Yeah read/write to JSON files may potentially be taking more than 3 seconds
How can I make it bypass the 3 seconds?
Defer the interaction before disk access, take as much time as you want, then send the actual response
!d discord.TextChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
oldest_first=True
So do I use
await interaction.response.defer(ephemeral = True, thinking = True)```
at the start of the command?
Right
No lol
I tried that but now the application is stuck on Bot is thinking ... and not giving any response
Can we see code?
You may just have some errors then
It is quite long
message = bot.get_channel(1000852468743282788).get_partial_message(1002254511336857672)
await message.edit(embed=stats)
Why bot edit delete message e
And how can i fix
i am trying to send a message in a specific channel and i used this
lb_channel = bot.get_channel(config["lb-channel-id"])
it is giving me None when i try to do
lb_channel.send(<some message>)
is the channel Id correct
@winter gull
you should also probably await until the bots cache is ready
alright i try awaiting
send your whole code
TypeError: object NoneType can't be used in 'await' expression
its a task
that's why
before you assign lb_channel add await client.wait_until_ready()
ow alright
you're probably getting the NoneType error because the channel isn't in the bot's cache yet, thus adding the await will wait until it is
alrr tysm
Did it work?
it workss
Nice 😄
yessss
Can you provide more code
how i can make a error handler only for on_cooldown
Idk
how i can return the CommandOnCooldown time to datetime?
You are on cooldown. Try again in 7199.07
you just used the default cooldown thing ?
commands stop working on my bot, is there a new update?
i got no error on the bot
yes
from datetime import datetime
datetime.fromtimestamp(SECONDSVAR).strftime("%A, %B %d, %Y %I:%M:%S")
I assume secondsvar is the seconds until cooldown is over
@commands.cooldown(1,7200,commands.BucketType.user)
you could also convert it to hours, minutes, seconds
datetime.timedelta(seconds=secondsvariable)
that arent any tutorials or videos that practise good practices, wont find any
just try some code out and ask for help here if you run into issues
you'll probably want to use a database though
Like mongodb
mongodb ew
Or any other database...
yes.
I like your asuna pfp
and I like you
I actually use json databases way to much
:pepeShy:
😄
omw to shoot u

I find it harder to use json-based databases for no reason lmao
I find it easier 😭
dictionaries suck, try relational DBs
or Google sheets 
csv database?
nah that's worse than json

@slate swan have you seen all of sao?
I've only seen embed builders like- https://autocode.com/tools/discord/embed-builder/
that ones for js though, this one is py- https://cog-creators.github.io/discord-embed-sandbox/
this one does it too- https://leovoel.github.io/embed-visualizer/
@whole sparrow
?
Oo I didnt ask for embed builders I meant that there was this website that showed how to make a discord.py bot really well but I completely forgot the URL
not that sadge
A learning guide for the discord.py bot framework written by members of our community.
can be this
@whole sparrow https://vcokltfre.dev this?
A tutorial to help you make better Discord bots.
could anyone help me (pretty new to discord bots) make a bot respond to multiple messages abt the same thing
for example a higher or lower game where the user inputs higher or lower mulitple times
the bot works fine but it keeps sending me a TimeoutError whenever the timeout hits 2.0 so i tried the code below to prevent that from happening but its not working any solution?
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="f")
#________________________
@bot.listen()
async def on_ready():
print("readyyyyyyyyyyyyyyy")
@bot.listen()
async def on_message(message):
if message.content.startswith('$greet'):
channel = message.channel
await channel.send('Say hello!')
def check(m):
return m.content == 'hello' and m.channel == channel
try:
msg = await bot.wait_for(
'message', check=check, timeout =2.0)
except TimeoutError:
print("there was an error") #this line is just testing not the actual code
await channel.send(f'Hello {msg.author}!')
bot.run(my_secret)
!d discord.Client.wait_for is your friend here
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.10)"). 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.10)") 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.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
btw thats part of my prblem above how to prevent the timeout error from happening?
timeout is in seconds, so you have to respond within 2 seconds
ye when i dont reply in 2 secs i want sth to happen
like the bot says "timeout " or sth
So put that within the except block
but it keeps giving me error in the console
What's the error in console?
raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError
Full traceback please
so if it was in the on_message() function i would pick a number between 1-100 and then use discord.client.wait_for to get a new message from the user
Ignoring exception in on_message
Traceback (most recent call last):
File "/home/runner/ddgtrhyrehr/venv/lib/python3.10/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 23, in on_message
msg = await bot.wait_for('message', check=check, timeout = 2.0)
File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/asyncio/tasks.py", line 501, in wait_for
raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError
Using a wait_for in an on message is kind of tricky, it's better to use it inside of a command
@silver reef in except
ok ill try that
welp the on_message() function is my safe space
i have no idea how to use anything else
Good time to learn then
bad idea
youtube here is trash
even just read the docs is better
guys how i can stop my bot from running
i know it's hard but try
Close the application that's running it
i just clicked the run button on vscode
so vscode?
Open the terminal, and you should be able to CTRL+C to terminate it
Ctrl + C in terminal
now its giving me another error :
Ignoring exception in on_message
Traceback (most recent call last):
File "main.py", line 23, in on_message
msg = await bot.wait_for('message', check=check, timeout = 2.0)
File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/asyncio/tasks.py", line 501, in wait_for
raise exceptions.TimeoutError()
asyncio.exceptions.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/runner/ddgtrhyrehr/venv/lib/python3.10/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 24, in on_message
except asyncio.TimeoutError:
NameError: name 'asyncio' is not defined
import asyncio
import asyncio
lol
oh ok xd
update my bot can say hello
Why i cant repear process in 10 sec on on_rady event
Im tried with
But its dont work
time.sleep(10)
? what dont work?
what's your code, what you expected, and what happened?
I puted
async def on_ready():
embed = discordEmbed(title...)
Message = bot get mess itd..
await message edit(embed=embed)
time.sleep(10)
And its didnt repeat event
of course it does not
it just does action when it starts up
and also there are a lot of syntax mistakes in this code
if it is the original one
why does the embed continues?
Yeye i know now ty im fixed
But i have problem with os
When u try to
gg = os.system("tps")
await ctx.send({gg})
Its dont work its send 256 but running process is 0
time.sleep is blocking, use asyncio.sleep instead
code..
its the normal code i used always but here
@client.command()
async def help(ctx):
embed = discord.Embed(title='simple degenerate bot', color=0x2c2f33)
embed.set_footer(text = f"Requested by {ctx.author.name}")
embed.add_field(name='Server', value='**`serverinfo`, `members`, `banner`, `icon`, `setbanner`, `seticon`**', inline=False)
embed.add_field(name='General', value='**`botinfo`, `userinfo`, `ping`, `ubanner`, `avatar`,**', inline=False)
embed.add_field(name='Moderation', value='**`ban`, `kick`, `unban`, `massunban`,`purge`, `nuke`**', inline=False)
await ctx.channel.send(embed=embed)
did they update it sorry im slow
i dont see 32ms..... here
me either
true here wait
@client.command()
async def ping(ctx):
embed = discord.Embed(color=0x2c2f33, description=f'**`{int(client.latency * 1000)}ms....`**')
embed.set_footer(text = f"Requested by {ctx.author.name}")
await ctx.send(embed=embed)```
what do you mean by 'embed continues'
look at the screenshot
like it's too long?
yeah
empty space
Looks like that's just default?
other bots dont do that
waht
hm
that's a link
but still embed
Any who know?
bruh, python bot makes all embeds this same length
but in every case it looks natural at least
I know what you mean, I'm pretty sure they embed differently on discord
<meta content="embed title" property=og:description>
Usually add embeds like that, in the html though
how do i use the info (message content etc) from a wait_for() function?
idk acc whats happening but all the embeds satrted looking longer
is that for all?
yeah
in wait_for() you give a check argument. which is a function, like wait_for('message', check=mycheck) and in a function you can use message object, like this:
def mycheck(message):
return message.author = 'imstupid'```
that's a check
and if you want a message that was sent, after that wait_for
that is message = await bot.wait_for(...)
and u use message as usual
@client.command()
async def test(ctx) -> None:
embed = discord.Embed()
embed.add_field(name="Test Name", value="Test Value")
await ctx.send(embed=embed)
idk if add fields are smaller than other embeds, you could try it though
Is there anything I could do to make a leaderboards like structure in embeds?
ty for help
here is an exemple :
@client.event
async def on_message(message):
if message.content.startswith('$greet'):
channel = message.channel
await channel.send('Say hello!')
def check(m):
return m.content == 'hello' and m.channel == channel
msg = await client.wait_for('message', check=check)
await channel.send(f'Hello {msg.author}!')
and some error like value in field is required occures
that was just psuedocode...
you have to add the value and name to the field obviously
*edited..
and then some error like title in Embed definition is required occu.. ok ok ill stop now
No it wouldn't
bruh
🗿
Hey, how can i send files from my db in a message? Storeing the proxy url
https://i.leaked-your.info/lC3fAcj8 norm i would do something like this when the user is imputting them, but tnow its from the db so idk how lol
I have a question
why do people screenshot something to upload on a website and copy paste the url here instead of screenshotting something and directly copy pasting here
from discord.ext import commands
bot = commands.Bot(command_prefix='/')
welcome_channel = ""
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
async def on_member_join(member):
if welcome_channel != "":
await bot.send_message(welcome_channel, "Welcome to the server, {}!".format(member.mention))
print("Welcome message sent to {}".format(welcome_channel))
@bot.command()
async def SetWelcome(ctx):
await ctx.reply('Set welcome channel to ' + ctx.message.channel.name)
welcome_channel = ctx.message.channel.id```
Events dont do anything
Saves storage
easyily find screen shots
It automaticly uploads it to the website
!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.
All i need to do is do control shift 4
take the ss
and it copys the url to my clipboard
you need to call @bot.event for every new function's related to an event (just add @bot.event before async def on_member_join)
and fix syntax
Syntax?
wait nvm
it was bugged on my screen
Oh yeah, it might look wierd, I'm used to c++
haven't done python in years
nah you're good
from discord.ext import commands
bot = commands.Bot(command_prefix='/')
welcome_channel = ""
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
@bot.event
async def on_member_join(member):
if welcome_channel != "":
await bot.send_message(welcome_channel, "Welcome to the server, {}!".format(member.mention))
print("Welcome message sent to {}".format(welcome_channel))
@bot.command()
async def SetWelcome(ctx):
await ctx.reply('Set welcome channel to ' + ctx.message.channel.name + "!\n")
welcome_channel = ctx.message.channel.id```
@slate swan could you tell me what's the problem with the thing?
I was guessing it's that welcome_channel needs a name instead of an Id but that would be dumb
bot.send_message? 💀
What version are you using
anyone how do I fix this for my bot
idfk, last time i used it was in 2019
or 20
i think i'm using discord 1.0? idk
Update it first.. there are already many breaking changes in api itself
anyone know how to wait for a message and use the content instead of getting the id, channel, author etc
I was using discord 1
what
?
!d discord.ext.commands.Bot.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.10)"). 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.10)") 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.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
Hey guys, how do i add description to my arguments in slash commands
Try reading the error. You know what's a KeyError?
bruv wtf is this shit
import discord
bot = discord.Bot()
@bot.slash_command()
async def hello(ctx, name: str = None):
name = name or ctx.author.name
await ctx.respond(f"Hello {name}!")
@bot.user_command(name="Say Hello")
async def hi(ctx, user):
await ctx.respond(f"{ctx.author.mention} says hello to {user.name}!")
bot.run("token")

im using msg = bot.wait_for("message", check=check, timeout = None) but when i print msg it just shows info such as id and author
no :{
msg.content?
This shit is terrible, who invented discord 2.0
You printed its class representation not the actual message
as in the variable name or the "message" part
To get the content just use the .content attribute
The one who invented Discord.py 1.0?
it was a joke, either way discord py 2.0 is weird
Well discord itself is much weird so cant expect any better
Nah
ty for the help
I suggest you read the docs before trying anything
its from the docs
the example of the docs
!e When you try to access a key from a dictionary and if it does not exist, you get a KeyError ```py
my_dict = {'foo': 1}
print(my_dict['bar'])
To suppress it, either use a try-except or use the `.get` method ```py
try:
print(my_dict['bar'])
except KeyError:
pass
# or
print(my_dict.get('bar'))
@slate swan :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | KeyError: 'bar'
official docs
🤦♂️ that's not discord 2.0
its discord2
Yea not the official one
Discord 2.0 isn't even on pypi
@surreal walrus Also that's some basic python you're expected to know if you're creating a discord bot. So prefer clearing your basic concepts first before jumping into advanced projects. Believe me it's more fun when you know what's actually going on
You need to install manually from GitHub
bruv
Send me a link to the repo
It's not stable yet. The PyPi one still offers 1.7.3 (latest stable version)
i found it
Thank u
That one hasn't been updated in an year
I used to do pythonb but stopped learning everything again and try to do this fun project Thanks for the Help
Yeah cause danny left the development in between and recently started maintaining it back..
Create a command named dc with test as one of it's subcommand
I can't be fucked to deal with this utterly dumb shit lmfao
im just gonna use js
Or use cobol 
Guys can someone help me code a set prefix command, multi guild, using txt
What issues are you having? Could you provide any code/tracebacks?
@client.command()
@commands.has_permissions(administrator = True)
async def set_prefix(ctx):
prefix = "!"
file = "prefix.txt"
if prefix == "!":
await ctx.send("Prefix set to !")
else:
await file.read("prefix")
``` i started but idk how to do it
Override the get_prefix command of your bot subclass, and return the appropriate prefix for that guild
Keep in mind this is called every message so you'll want to implement some sort of caching
Hello!!
I want to send a message in a specific channel which i am able to do with the get_channel attribute. And also edit the message which is also i am able to do with get_message method, i want something like when the bot runs it checks If the channel exists, if not it throws an error apart from that, when the message is sent i want to edit the message repetitive while getting the new data. I want opinions on this, one thing would be to use on_ready() command and do the same idrk what to do
There's no such thing as get_message
There is? I used it recently
Could I see it?
Like, bot.get_message(<Id>)
Yeah that's not a thing
Well it was before v1.0 but I doubt anyone uses that anymore as it's incredibly outdated
It is ig renamed to fetch_message
Not just renamed, the functionality is completely different
It makes an API request, instead of just getting from the cache
And I don't believe you need to fetch_message just to edit a message
Oh
You can use the message returned from the send()
msg = await bot.get_channel(...).send(...)
await msg.edit(...)
Use the returned message from send()?
Oh yes hmm
I'll think abt it, tysmm
Also uhh i was reading the docs and came across creat_guild() so i had a doubt, does it like create a guild? If so will the bot be the owner?
Right:
async def edit_message(message: discord.Message, content: str) -> None:
await message.edit(content=content)
@bot.command()
async def my_command(ctx: commands.Context) -> None:
message = await ctx.send("This message is about to be edited")
await asyncio.sleep(5) # wait 5 seconds
await edit_message(message, "This message has now been edited!")
yeeees tysm
Dm
is there any lib that converts strings like "12d 2h 4m" to a datetime object?
i am trying to make a timed mute command
What does this mean??
there are 2 commands with the same name
Okay ty
why always DMs?
its better off helping here and having multiple minds giving there own opinions and answers to the problem
and it gives the users more options on how to fix there problem
Because link is not enabled?
wut
Im rec tutorial on yt for prefixes
I dont know is eanble to send video because its ad
ah you mean a tutorial link, well its not really an ad if youre helping the person and yt ads are kinda bad and old ngl
Can anyone please give me a example on how to make a command that gives you a certain role??
like adds a role?
Yes.
API call to where?
You'd just call a method that makes a call?
When I run discord command
Who's api are you calling?
** **
🤏