#discord-bots
1 messages · Page 434 of 1
You mean to get it from the other bot? I don't think you can if reference is none 
i have a bot that blacklists bot commands from specific roles/users on specific channels. it worked perfectly until the slash commands that for some reason has reference=None
is there anymore a way to externally know who used the bot command to which the bot (dynobot in this case) replied to?
you cant get that info, i believe
though discord has plans on their api docs repo to improve command permissions for server owners, so it shouldnt be an issue that much longer
!d discord.Permissions
class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.
The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.
Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.update "discord.Permissions.update").
yuh nvm I figured it out
create_channel can take permissions kwarg. You can for example do:
await ctx.guild.create_channel(permissions=discord.Permissions(send_messages=False, read_messages=True))
I had to do .attach_files()
Ah, alright.
good to know. though, it should be possible to know the user who used the slash command. maybe the api is just lacking
oh yeah that should be accesible i agree
but im fairly sure its an api limitation yeah
Need some help
how can i make the name of a channel being created be different each time?
example
support#0001 and support#0002
Keep track of the count
If you have a SQL database use a Sequence
btw, what kind of apis you make
?
i need ideas while learning FastAPI
Is there any search module on python? Like i want to automatically search the username of the user that leaves the server (if there is any message send by specific user and the user has left the server then ban the user)
I would appreciate if there's anyone give me an example code ig?
Do you mean searching for something on google?
On discord
Why isn't the channel deleted when I press the second button?
If you mean search for messages sent by a specific user then you can use the discord.TextChannel.history. It can take a check kwarg.
Sesrch the matching message
!d discord.TextChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/stable/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
Ah
I'm new to this and trying to make automatic Freeloader detect commands so..
I'll try my best ig
Is that dislash.py?
yea
You have the second on_click inside the first on_click.
!d discord.on_member_remove
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
Alr ty
No problem.
I changed tabs but didn't work either
This doesn't work either
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.
Yo @visual island, the package I was talking about has been released on pypi. It's still WiP as application commands are been coded. They should be ready in a few days!)
!pypi disnake
A python wrapper for Discord API forked from discord.py.
1_button works but 2_button doesn't, right?
EQ said it's still under development.
yea
Do you get any errors?
Indeed, read the whole message haha
WiP --> Work in Progress
In cmd no, but in discord itself yes
Ah, gotcha.
What's the error?
Communication error
I never heard of that. Can you show me a screenshot?
Try printing inter.channel.
Doesn't output anything in cmd
Hello can Someone help me by a Python discord bot the bot should do if a person comes in a channel that the bot a sound plays pls help and dm me
Print above the emb2 =.
Pls help
Is there a way I can check if a commands cooldown is finished?
please help mee
Anyway, nothing
how can a bot play music
Any output?
Lemme get it
!d discord.ext.commands.Command.is_on_cooldown
What does it mean?
is_on_cooldown(ctx)```
Checks whether the command is currently on cooldown.
Returns a bool?
Ok
Did it print anything?
no
Then most likely the event does not get triggered at all.
Most likely
Try making it on_click() and check for the button's id inside the function.
so?
Don't pass anything just @on_click() then print the custom_id.
Maybe with edpy
@on_click()
async def on_con_button(inter):
print(inter.custom_id)
i see
Yups
This is when you press 1 button
hoi
What is the code to start a Discord Bot?
Hmm, maybe make it @on_click.from_user(ctx.author)?
Hi!
hey!
run token?
inter.component.custom_id? I didn't do this in a while so I'm just looking at the docs.
Hi
hi
Lol
lol 
async def review(ctx, sterren=None, prompt=None):
if sterren is None:
return await ctx.send("!review <1/5> <feedback>")
if prompt is None:
return await ctx.send("!review <1/5> <feedback>")
await ctx.channel.send("Hartelijk dank voor je feedback! Mocht er iets mis zijn kan je altijd contact op nemen!")
prompt = ctx.message.content
embed = discord.Embed(title="Feedback / Review", description="", color=discord.Color.blue())
embed.add_field(name="Sterren:", value=sterren, inline=False)
embed.add_field(name="Opmerking:", value=prompt, inline=False)
embed.set_footer(text=f"Uitgevoerd door {ctx.author}")
channel = bot.get_channel(881094340087283722)
await channel.send(embed=embed)```
The channel in which I wrote the report command was deleted
!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.
someone knows how do i open a file package in replit?
Was this what's supposed to happen?
I want the prompt variable to be the value of after the sterren variable, but currently It outputs as prompt: !review sterren prompt
U want to monkeypatch or something?
you should ask them in their server
they have one?
Ah yea. ThTs monkeypatching
so yap
No, the channel should have been deleted when I click on the delete button
Monkeypatching means editing the package files locally @slate swan
thx
As the other person said, ask in the discord server plz. Idk
ok thx
is it possible to have a subcommand and a normal command with the same name?
No
Just print the inter.component.custom_id to check if it prints the custom_id of the button clicked. Then you can move on and do your own checks to see which button got clicked.
99%, nope
okay, thanks
No problem.
!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.
Incidentally, you do not know how to do so that you do not have to display a message when you click on the button
ERROR:
FileNotFoundError: [WinError 3] The system cannot find the path specified: './cogs'```
> **CODE:**
```py
@client.command()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')
@client.command()
async def unload(ctx, extension):
client.unload_extension(f'cogs.{extension}')
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')
Can someone pleasee tell me what's wrong with the code?
You don't have a folder named cogs.
Ah yes, one second. It should be os.listdir(r"cogs"), not os.listdir('./cogs').
Strange, still doesn't work
The same error

@client.command()
async def unload(ctx, extension):
client.unload_extension(f'cogs.{extension}')
for filename in os.listdir(r"cogs"):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')```
let me try :)
Sure
Anyone found any good dpy forks?
Somebody can help please?
@dapper cobalt Where can i learn development?
With context commands and slash commands included (in a few days)
Google.
!resources if you want to learn Python specifically.
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
@maiden fable isin't there a single module to just make a simple webpage nothing more just one page
!pypi flask ?
@clever pelican
Asking for frontend@maiden fable
Yes?
Ah idk. U gotta use HTML
Not a single module in python to make a webpage lol
Yes
@client.command()
async def unload(ctx, extension):
client.unload_extension(f'cogs.{extension}')
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')
try this
Same error?
You need to put ffmpeg executable to the working directory I am pretty sure
How to avoid sending a message after each button click
how to mention
Mention what?
Let me try
user.mention
the user
If it is possible, show your code please
Still same error
bot.get_user(id)

admin_normal = guild.get_role(749603000208719872)
msg_id = 881867819912953886
if payload.message_id == msg_id:
if str(payload.emoji) == ':soyfonSoporte:':
overwrites = {
guild.default_role: discord.PermissionOverwrite(view_channel=False),
payload.member: discord.PermissionOverwrite(view_channel=True),
admin_normal: discord.PermissionOverwrite(view_channel=True)
}
canal_soporte = await guild.create_text_channel(f'soporte-#{member.id}', overwrites=overwrites)
embed_soporte = discord.Embed(title='Ticket de Soporte', description='Informanos de tu problema y pronto te responderemos.', color=0xb522ba)
await canal_soporte.send('')
@clever pelican could you show your files hierarchy?
can anyone tell me how to send a message to user, if the user does not have a role for that command
i have done this
@bot.command(hidden=True)
@commands.has_role('ServerBotMaintainer')
try:
code here
except discord.ext.commands.errors.MissingRole:
def norole(msg):
await msg.send('You do not have the role to run this command')
does not work
Yes
How to notify mods when a channel has been created
@floral crypt you can either get mention like this: @vale wing or f'{user.mention}' but you will need to define user like I showed before
Okay
Why did you put a function to there?
so that i can send message
cause when i will do msg.send
msg would be needed to be defined
@clever pelican sorry if I am asking again, but what error did it give when you tried running this code?
I don't really understand
Message does not have send attribute afaik
You can use ctx.send or channel.send
TypeError: on_member_join() missing 1 required positional argument: 'member'
on_member_join(member): ...
in short
what is want is when the user does not have that role
my idle console gives me the error discord.ext.commands.errors.MissingRole
i want to tell that user tell that he/she does not have that role
File "d:\Just... go away\Discord_bots\Droog-bot\main.py", line 27, in <module>
for filename in os.listdir('./cogs'):
FileNotFoundError: [WinError 3] The system cannot find the path specified: './cogs'```
This is not the code I meant
how to double line on fstring?
i downloaded it but still this is coming
I need the error from os.listdir('cogs')
Have you put it to the working directory?
I came across something wired in python today
can someone explain me why python dose this
!e
list1 = [[0]*5]*5
list1[3][3] = 1
print(list1)
@loud crane :white_check_mark: Your eval job has completed with return code 0.
[[0, 0, 0, 1, 0], [0, 0, 0, 1, 0], [0, 0, 0, 1, 0], [0, 0, 0, 1, 0], [0, 0, 0, 1, 0]]
what do u mean?
i was expecting 1 only at 3,3
File "d:\Just... go away\Discord_bots\Droog-bot\main.py", line 27, in <module>
for filename in os.listdir('./cogs'):``` You mean that?
f'Some string \
other part of string'```
Or just use multiline
```f'''Some string
Other part of string'''```
@ashen notch
nobody uses this channel for what it is....
ffmpeg is supposed to be a file which you can download I am pretty sure
The module is not what you need
??
No, you are listing wrong dir, try just os.listdir('cogs')
isnt it \n
you have to make an error handler
\n is new string, \ is ignoring new string in code
o
if the check returns False, that code won't process there
they are the same
If that's what you meant
try cogs/
can you send your code please ?
No, still doesn't work
Same error
f'some long \
string'```
Will result into ```some long string```
And
```py
f'some long \n string'```
will result into
```some long
string```
@bot.command()
@commands.has_role('ServerBotMaintainer')
async def test(ctx):
#code here
@test.error
async def test_error(ctx, error):
if isinstance(error, discord.SomeError):
#code here
@slate swan
this is how you handle a checkfailure
oo i'll try it ty
It is not code related, you download ffmpeg executable (it will be named ffmpeg) from https://ffmpeg.org and copy it to your bot folder
I am not sure if that's right way but it works for me this way and I have been told this several times
@clever pelican wait, I will try to create similar code to yours and run it
Ok
which directory shud i put it in?
@clever pelican are you running your code from main.py folder or from upper layer?
from main.py
To the directory your bot is in
it worked ty
Together with main bot file
nice, you're welcome
async def review(ctx, sterren=None, prompt=None):
if sterren is None:
return await ctx.send("!review <1/5> <feedback>")
if prompt is None:
return await ctx.send("!review <1/5> <feedback>")
await ctx.channel.send("Hartelijk dank voor je feedback! Mocht er iets mis zijn kan je altijd contact op nemen!")
embed = discord.Embed(title="Feedback / Review", description="", color=discord.Color.blue())
embed.add_field(name="Sterren:", value=sterren, inline=False)
embed.add_field(name="Opmerking:", value=prompt, inline=False)
embed.set_footer(text=f"Uitgevoerd door {ctx.author}")
channel = bot.get_channel(881094340087283722)
await channel.send(embed=embed)```
I want the prompt(variable) to be all messages after the sterren variable but It currently outputs only one word.
(Sterren means stars and prompt Is my basic solution for feedback btw)
But currently Its like !review 5 Test testcc
and It only outputs Test
you use a star for that
async def command(ctx, stuff, *, stuff2)
stuff2 will return everything that was passed in after stuff in a string
however, by using the star like this:
async def command(ctx, stuff, *stuff2)
stuff2 will return everything that was passed in after stuff in a list
@clever pelican this is what I made, extensions loading alright worked
With that I get no output nor error
, case_insensitive=True
``` some says that it causes performance loss
?
like ? i dont get it
show the code
!codeblock
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.
how to make a button independent for each person, I have a problem that when someone presses the button no one else can do it until the other person finishes the cycle
async def review(ctx, sterren=None, *, msg2=None):
if sterren is None:
return await ctx.send("!review <1/5> <feedback>")
if msg2 is None:
prompt="Geen feedback gegeven"
if sterren == "1":
await ctx.channel.send("Hartelijk dank voor je feedback! We vinden het jammer dat je niet tevreden bent! Je mag altijd contact opnemen met support .")
embed = discord.Embed(title="Feedback / Review", description="", color=discord.Color.blue())
embed.add_field(name="Sterren:", value=":star:", inline=False)
embed.add_field(name="Opmerking:", value=msg2, inline=False)
embed.set_footer(text=f"Uitgevoerd door {ctx.author}")
channel = bot.get_channel(881094340087283722)
await channel.send(embed=embed)
return
if sterren == "2":
await ctx.channel.send("Hartelijk dank voor je opmerking! Toch is ier iets mis? Als er iets mis is met product of je niet tevreden bent kan je contact opnemen!")
embed = discord.Embed(title="Feedback / Review", description="", color=discord.Color.blue())
embed.add_field(name="Sterren:", value=":star: :star:", inline=False)
embed.add_field(name="Opmerking:", value=msg2, inline=False)
embed.set_footer(text=f"Uitgevoerd door {ctx.author}")
channel = bot.get_channel(881094340087283722)
await channel.send(embed=embed)
return
if sterren == "3":
await ctx.channel.send("Hartelijk dank voor je feedback! Het is nog niet perfect, maar alsnog bedankt!")
embed = discord.Embed(title="Feedback / Review", description="", color=discord.Color.blue())
embed.add_field(name="Sterren:", value=":star: :star: :star", inline=False)
embed.add_field(name="Opmerking:", value=msg2, inline=False)
embed.set_footer(text=f"Uitgevoerd door {ctx.author}")
channel = bot.get_channel(881094340087283722)
await channel.send(embed=embed)
return
if sterren == "4":
await ctx.channel.send("Hartelijk dank voor je feedback! We zijn blij dat je tevreden bent!")
embed = discord.Embed(title="Feedback / Review", description="", color=discord.Color.blue())
embed.add_field(name="Sterren:", value=":star: :star: :star: :star:", inline=False)
embed.add_field(name="Opmerking:", value=msg2, inline=False)
embed.set_footer(text=f"Uitgevoerd door {ctx.author}")
channel = bot.get_channel(881094340087283722)
await channel.send(embed=embed)
return
if sterren == "4":
await ctx.channel.send("Hartelijk dank voor je feedback! We zijn blij dat je helemaal tevreden bent!")
embed = discord.Embed(title="Feedback / Review", description="", color=discord.Color.blue())
embed.add_field(name="Sterren:", value=":star: :star: :star: :star :star:", inline=False)
embed.add_field(name="Opmerking:", value=msg2, inline=False)
embed.set_footer(text=f"Uitgevoerd door {ctx.author}")
channel = bot.get_channel(881094340087283722)
await channel.send(embed=embed)```
Performance loss maybe by running .lower() lmao, I am not sure how commands processing works
Can i dm yyou please?
Sure
oh heck
does it even cause any issue ??
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.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.
im experimenting with a module that implements drop down menus into dpy, i am stuck on a problem that is i need to append to a list a changing amount of times but its not a string or an integer i need to append something else as shown belowpy msg = await ctx.send( "**Tickets!**", components=[ Select( placeholder="Select A Ticket!", options=[ SelectOption(label="a", value="a"), SelectOption(label="b", value="b"), ], custom_id="select1", ) ], ) as you can see, i need to append SelectOption(label="a", value="a"), anyway i can do it with a for loop?
No of course
no output?
alr
Yeah thats what I though thoo lol
how to make a button independent for each person?, I have a problem that when someone presses the button no one else can do it until the other person finishes the cycle
too*
When does discord.py, 2.0 release?
dpy is getting discontinued :)
?
do you have an eh?
Python noob
Dpy Isnt getting updated no more
its no longer gonna be a thing
Eh, lol. Please tell me what that is 😂
Ok
I ask these because I would've wanted you to disable it

I'm new to discord.py, so should I try to learn discord.js instead?
can anyone tell what feature i can add to my bot (no music please idk how to do it)
But normally it would, the last variable would like put the left overs In the last one\
idk i use py and its pretty good
Dpy doesnt support slash commands lol
Discord wants all verified bots running on only slash commands
In like 2 months estimated
but for example:
djs has voice receiving
oh
that sucks
April 2022*

I've won, but at what cost
how to make a button independent for each person?, I have a problem that when someone presses the button no one else can do it until the other person finishes the cycle
No, if you only need slash commands, consider just running over HTTP
I am also making one haha
Ofc with a friend
That's fine. U can always contribute to the library I am making (:
I am also contributing. The community is friendly asf
Surprisingly, nope
It's a WiP
That's what I'mma use
Disnake will take over probably.
https://paste.pythondiscord.com/upagujosob.py
Does anyone know why this code gets no output nor error?
And how do i get msg2 to get all left overs In the command so like If the text is !review 5 Test and double test.
Sterren would get 5
and msg2 would get test and double test
Disnake is made by the developer of dislash.py.
Nope, I am maintaining that only
!pypi dislash.py
Nope. He said it will have the same syntax.
EQ is going to save us, lmao.
He already updated the logo and the name.
Disnake? What's that?
!pypi disnake the new discord.py
A python wrapper for Discord API forked from discord.py.
It's gonna be so good.
Is it just API or API and websocket?
A proper library
When will it release?
That doesn’t answer the question
Probably in a few more days.
It has released, just too unstable till context commands drop
That library covers the whole API
Does it have all the features like JavaScript?
It also has some advanced features like guild.humans to make yr life easier
It has features of discord.py and dislash.py combined!
!pypi dislash.py
So no websocket
Except voice receive, it has everything
Hey @lone flume!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
!past
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.
It uses asyncio
Is it hard to learn?
No. It has the same syntax as dpy for commands!
Your not library maintainer are you?
Oh, so its the same? Just with more features?
I am a contributer and I will be helping the owner maintain the library to the fullest.
Indeed
Errr ok
does adding return after the command helps ?
No
It won't change anything since the command will automatically return after being executed.
alr
The owner is working hard to implement buttons, slash commands and context commands. They should be ready in a few days. After that, u will be able to use them (tho they will be in alpha/beta)
If I am assigning my client via a class, how do I set my prefix?
(Please ping me, I am not always at my computer.)
Cool
If everything goes well, they should be live within this week (as EQUENOS is the only person working on them and I am working on extra/advanced features)
Are you making it?
U can't
!d discord.ext.commands.Bot use this for command prefix
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
I am helping him maintain the library, yes
Cool
Rip
How to install it?
pip install disnake
U shouldn't. Please wait for slash commands, buttons and context commands. They should be up within this week ;)

Okay
weak
Or if your bot is nothing but call and response, switch over to HTTP Interactions
i want to every time when sogs plays the bot will send "now playing + the song"
but with this script he send it every time , olsu when the song just added to the q and he dosent play right now.
someone knows what to do?
If u want, I can invite u to the support server so that u can have a close look at the development
Yes please
Hm?
At least the dev isn't waiting for dpy 2.0 like every other person so that they won't have to implement slash commands and stuff themselves haha
i think you mean week
Ah
My bad :c
Yea
U gotta get a different channel every time
for channel in guild.text_channels:
. . . .
!pypi anvil
@client.command()
async def update(ctx, *, title, msg):
embed = discord.Embed(title=f"**{title}**", description=f"{msg}", color = 0xFFFF00)
await ctx.send(embed=embed)
await asyncio.sleep(0.1)
await ctx.message.delete()
can someone help me with this?, i dont know how i can separate the title from the msg
For some reason, it does not respond to the command, if you make an error handler, if the person is not an administrator
https://paste.ofcode.org/eJg9An67GnQfD58Mgxwpiy
can smone find out the error
no error shown
line 28 - 90
but uhh the healthbar doesnt work smtimes
My favorite about dpy situation is ignoring Danny talk about gateway problem and pretending lack of slash interactions is the issue
?
@client.command()
async def update(ctx, *, title, msg):
embed = discord.Embed(title=f"**{title}**", description=f"{msg}", color = 0xFFFF00)
await ctx.send(embed=embed)
await asyncio.sleep(0.1)
await ctx.message.delete()
can someone help me with this?, i dont know how i can separate the title from the msg
someone?
- hey I am making a discord bot and my bot has a mute command in which I am getting the unmute time with the help of now() + time delay how to find its unmute time like do I have to loop through the database every min
Help
you need to do unmute using task loop??
I don't think 0 < p2health <= 13.37 is valid in python
ah yes discord.py substitue
@client.command()
async def update(ctx, *, title, msg):
embed = discord.Embed(title=f"**{title}**", description=f"{msg}", color = 0xFFFF00)
await ctx.send(embed=embed)
await asyncio.sleep(0.1)
await ctx.message.delete()
can someone help me with this?, i dont know how i can separate the title from the msg
!pypi disnake
A python wrapper for Discord API forked from discord.py.
you can't by this method afaik, since different arguments are identified using space in between, and using the * there will take everything and won't separate it by spaces, so there is basically no way for the function to differentiate between more than one argument after the star thingy, what I do is just pass one argument after that and using some string splitting get two arguments out of it inside the function, like using | in between the sentence.
all the arguments are being passed in as the title
What I do is add a client.wait_for and get the other required arguments
do you mean that you want it to look like this?
message here
<embed here>
in one message?
if so, then you can do this
@client.command()
async def update(ctx, title, *, msg):
embed = discord.Embed(description=str(msg), color = 0xFFFF00)
await ctx.send(f"**{title}**", embed=embed)
await asyncio.sleep(0.1)
await ctx.message.delete()
why?
how will python know what to put for the msg arg then?
just do this
@client.command()
async def update(ctx, title : str, msg : str):
embed = discord.Embed(title=title, description=msg, color = 0xFFFF00)
await ctx.send(f"**{title}**", embed=embed)
Usage (saying that the command prefix is ?:
?update "put your title here" "put your description here"```
this is to have more than one word for the title and description both
oh yeah didn't see that mistake
Haven't been completely on board but ppl say that discord is going to mandate slash commands, is that the case?
right now i have slow.txt in no folder i was thinking to adding it in a folder.. what will be the changes in opening it ??
Oh damn, do you happen to have the detailed article? would be interested to see their TOS
you would have to specify the folder name then slow.txt e.g folder/slow.txt. apart from that, no changes
alr thanks
this isn't official but the main developer of discord.py wrote this https://gist.github.com/Rapptz/4a2f62751b9600a31a0d3c78100287f1
ty
It also seems likely that slash commands move to over HTTP only
No it doesnt
Where do you guys get the info from? I haven't been able to keep up
What doesn’t?
Since a lot of bots will still need the gateway it makes no sense to remove interactions from it
anyone able to tell me why cmds wont work? i have the await client.process_commands(message) line ```py
@client.event
async def on_message(message):
if message.author.bot:
return
if 'modded' in message.content.lower():
await message.channel.send('This is blah blah blah')
return
await client.process_commands(message)```
Why continue to have two paths when one works well enough?
heyo, needed help making threads that work with discord py. . .
something like running ffmpeg while handling real time output (waiting to capture errors or success + file paths) and my bots completely frozen 
(well, like ffmpeg, running esrgan upscaler -- takes a while to run for some images)
because it works crap for a lot of people
In what way?
Not everyone has even close to the knowledge required to set stuff up well over HTTP
That seems like not their problem
I'm not gonna argue with you if you make this sort of stupid point
"Its not their problem" is never a good argument
would recommend switching over to the rewrite way of making bots welp
hmm
Except running slash commands over HTTP instead of transmitting them over gateway is alot less expensive for Discord
not if you already have a gateway connection open
because even if your bot doesn't have on_message intent, WebSocket is more expensive then just HTTP calls
since you have to bi directional open connection that must be pinged and tracked
wait, whats going to happen to word filters then?
If your bot has legit need for getting messages, your fine, HOWEVER, all commands you issue to bot per Discord must come over slash commands in the future
;-; welp,
Obviously, if your bot is small, you can keep doing it over just normal messages since you can have message intent but I expect that to become more restrictive in the future regardless of bot size
Hey, I'm kinda new, can someone teach me how to use cogs
So if your bot is simple call and response, I would switch to slash commands and while doing it, I'd consider looking to do it over HTTP instead of WebSocket because I could see a world where Slash Commands are only available over HTTP
its kinda like subscribing events. . .
at the bottom somewhere just add cogs to all the classes? where all the classes use commands.cog. . .
how do i make it in different py files
and load it
i guess mines all in one file . . . i dunno
suppose i want to make logger(member events like join, leave, edit) message events like(edit and delete)

For loop, file path and using discord.py's load function inside the init of the constructor.
so that can be in one py file and import it to main file, i heard cogs is the way to do it, can someone explain how to do ti

welp, i dunno, guess i wanted to use cogs back then without understanding them, so i just added it
there were also several stackoverflow questions about that
oh okay
If you just use the docs and read it, at some point you don't even need the docs anymore since you already know what you will need 
is there anyway in the doecs that can help me with this?
You can still ask questions if you don't know what i mean, since i'm pretty sure you still don't get it.
You can switch to "latest" inside the docs version default is "stable".
literally everyone has the same code there
with that for loop
I don't, cuz I'm stupid and I don't wanna complicate it too far
This is my cog loading part ```py
for extension in c.BOT_EXTENSIONS:
try:
print(extension)
bot.load_extension(extension)
except Exception as e:
print(e)
uh
https://youtu.be/vQw8cFfZPx0
i dont understand why this person defined 2 commands for loading and unloading when he made the for loop
In this video, we learn about cogs and how to implement them in a discord bot.
If you have any suggestions for future videos, leave it in the comments below.
GITHUB: https://github.com/Rapptz/discord.py
DOCUMENTATION: https://discordpy.readthedocs.io/en/latest/
OFFICIAL DISCORD.PY SERVER: https://discord.gg/r3sSKJJ
JOIN MY HELP SERVER: https:...
they check over all files in a folder
That is imo pretty bad practice.
Hello, can someone help me on the subject of cogs? everything works, but I wanted to know how I can add subdirectories and read all the files in those folders
You can do this with basic bots but if you are going to include more advanced options like __init__ & __main__ it also tries to load those extensions.
anyone know what my problem is? i also have import random and from random import choice ```py
@client.event
async def on_message(message):
if message.author.bot:
return
if 'modded' in message.content.lower():
random = ["vkjsjbv", "eeee", "lololol"]
await message.channel.send(f"{random.choice(random)}")
await client.process_commands(message)this is my errorIgnoring exception in on_message
Traceback (most recent call last):
File "C:\Users\jamie\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\jamie\OneDrive\Documents\BreadProject\main.py", line 64, in on_message
await message.channel.send(f"{random.choice(random)}")
AttributeError: 'list' object has no attribute 'choice'```
is it possible to set the about me page of a bot?
random.choice...
You can't just "read" them, you need to assign a path. Using os.listdir() to loop over a folder is not good.
Inside the developers portal on the discord site.
thx
@waxen tangle name variable something else
ooooh
then what would it be like?

<-- just relized he is python ceo/owner
Python confuses the name of your "random" variable with the "random" module. Change the name of the variable to "random_list" for example, and try again.
@fleet oracle c.BOT_EXTENSIONS will be something like this ```py
BOT_EXTENSIONS: list = [
'cogs.fun.coin_toss',
'subfolder.subfoler.file_name'
]
Got it thanks! what way can i do it tho so it responds randomly and not everytime, i have thrown some empty lists in and it works but i do get erros in terminal
What kind of errors?
I'd choose a random number between 1-10
for example, if the random number is 8, it sends something
then it's 1/10 chance it sends something

import random
...
@bot.command()
async def random_send(ctx):
number = random.randint(1, 10)
if number == 1:
await ctx.send("Something")
elif number == 2:
await ctx.send("Something")
...
How can I send ephemeral messages with my discord bot?
I don't even know what "ephemeral" means lol
ephemeral:
"lasting for a very short time"
somt like this ```py
@client.event
async def on_message(message):
if message.author.bot:
return
llll = random.randint(1,10)
if 'modded' in message.content.lower():
llll = random.randint(1,10)
if llll == 8:
await message.channel.send('This is the 2019 modded war modpack')
else:
pass
those message that use the bots to respond you slash commands
I translated it to hungarian
There is a kwarg in send() named delete_after in seconds.
it was like:
the lifetime of a certain bug
little do I know, that bug lives for 2 weeks

My language translated it to "quick"
uh why you assigning a random number to it twice
but yeah
extra randomness
should I pin it for u?
lol
ty
Just saw a comment under this video 
I'll ask Scragly to pin it later when he is on.
I think praw's client id and secret are not meant to be leaked*
I don't think this is our stuff
No idea but that i do know is that you need to reset your client secret.
oh wait nvm
Worst you can do is get him banned from the api
Also the issue is praw.reddit is a module not an object, but idk what is correct
😂
Well it's not a crime but it's a bit rude.
what does module not callable mean anyways?
import random
random()
well how do i fix it?
dont call it
im preety new to python sorry 
Yeah you prob need to use a function inside reddit
oh
the id of the author is equal to a role object?
if ctx.author.id == discord.Role
in your code
Not yet but in python 3.10 there is going to be a match/case system that cleans this up. Also you can't take control of the owners role but people lower than that cannot "add upper role than you have" anyways so that's a bit extra extra.
Scragly said in the pin he won't be pinning the gist (if that's what you're referring to)
Why not? Yes i am.
I'm sure he has his reasons
I understand i won't ask it. Thanks for replying.
For now yes, but like i've said the "You can't control the owner role" and people lower than that cannot even use it. Only owners can so that's imo a bit much.
When 3.10 is released you can implement it. You can also experiment with it now over at #878694948810137621 the bot has python 3.10 beta.
i dont understand 
praw.Reddit
so i should import praw.reddit?
Noooo, look into it you will get it :)
Syntax is indeed a bit off but when the IDE assigns the colors it will be doable.
Also the fact that match/case will be way faster than elif's.

Also the fact that match/case will be way faster than elif's.
they are?
im dumb
thanks thanks
Yes i asked when the event was going on. I asked the PEP author and he told me it was. I also checked it using timeit.

Guys I want to store one embed and whenever a command is executed then my bot will send that embed but what should I use to store that 1 embed
does anybody know how to open a file with a varible because when i a sign it to a variable it opens by itself so i want it to only open with a variable for my discord bot
This sound like an pretty easy solution if you are using OOP, and since discord.py kinda forces you to use OOP it will be pretty doable.
I mean I want to store that embed until I change it
And the time could be 1 min or 1 day or even a month maybe
Yes that is exactly what i mean. You can use the class his own instance to save the variable using self.
f = open("path/of/the/file") it opens by itself how can i open the file only when f is printed
@cloud dawn is it possible to change that embed using command
now how to fix this
I don't think i understand could you give an example?
Yes it is possible although as i'm following now it sounds like you want to make a command that creates an embed an that you can recall every time using another command.
if message.content.startswith(~message):
message.channel.send(f)
f = open("path/of/the/file")
for word in f:
pyautogui.typewrite(word)
pyautogui.press("enter")
it just opens by itself
Mostly we us with open
or
So what should I use to store that embed
!pypi aiofiles
so i have to use with
with open("path/of/the/file", "r+") as f:
if message.content.startswith(~message):
message.channel.send(f)
for word in f:
pyautogui.typewrite(word)
pyautogui.press("enter")
This will also automatically close the file once the code is finished.
oh ok thank you
Also to send the file's content you need to do f.read()
f is not defined
@cloud dawn
and doing for word in f works too
Edited thanks.
Anyone?
? I don't know what you are expecting since i told you how you can do this.
Depends on where this code is
How can i link my bot to my website?
Like a dashboard?
Nope to send informations
What kind of info?
for word in f:
ValueError: I/O operation on closed file.
what does that mean it closed to fast
@cloud dawn can u gimme a example what u tried to say
Send strings for exemple or files (like .txt or even .mp4)
I can't really see a problem either. How are you using this?
Well for strings you can use a database or if you want to do it more complicated but more optimized is to use IPC routes. And for files, if the strings relate to the file then check the dir otherwise you can make a task that checks for files on the webserver.
I was thinking about making an api
Not really since this will more likely be around 70/150 lines to write and i got to go in about 20 min
That is also valid. There are a lot of methods.
@cloud dawn any docs for this or any stackoverflow link?
Do you have sources for other methods?
Anything will be fine
If the website as an api your bot can send requests to the api
@hoary gust @dim wing , Not really since this combines multiple skills. For both it is combining different sources with each other i'm speaking from experience and how i would tackle this problem.
You can search on the web and maby someone has done this already but 50/50 of the times the thing you have in your own head is unique.
ig thats what you wanted
For Cursed Wolf i would recommend looking into OOP programming since that allows you to use variables and save them over multiple functions (commands).
And for Baptiste i'd do something that you are most comfortable doing with. Going with an API is more work than just checking the file and using a DB but using an API or IPC routes is significantly faster.
Are jsons fast?
What? JSON is a format
yeah idk i just want to share informations between my bot and "my website"
Javascript object notation
jsons is pretty slow and is mostly used to save settings/config or save file for small programs.
If your website has an api your bot can send information to it
@cloud dawn OOPS ARE FAST?
OOP is a class instance
I want to share data between my bot and my future website to learn some concepts so actually i don't know anything about API, DB or IPC routes lol but i gather informations before starting this fun project
This is the best tutorial on YT for OOP -> https://www.youtube.com/watch?v=ZDa-Z5JzLYM&list=PL-osiE80TeTsqhIuOqKhwlXsIBIdSeYtc&ab_channel=CoreySchafer
In this Python Object-Oriented Tutorial, we will begin our series by learning how to create and use classes within Python. Classes allow us to logically group our data and functions in a way that is easy to reuse and also easy to build upon if need be. Let's get started.
Python OOP 1 - Classes and Instances - https://youtu.be/ZDa-Z5JzLYM
Python...
and thx for you help ^^
@dim wing I would like to know about that too cause I am also learnin about api route etc
Yeah i think it's very interesting and fun (i hope so) concepts
You can use frameworks like FastAPI, quart or django to make api's
okay i'll see that 👍
Personally if you are starting to get into coding as a beginner i would recommend starting with a database for now. But if you want more of a challenge API is 2nd most difficult and IPC routes is the most difficult but it does allow for direct communication with your website and your bot.
OOP is the concept that everything is an object, like in python everything is an object
I dont want to confuse you but classes and functions are also objects
Okay i think i'll try those 3
IPC routes are the hardest?
Yes.
Amd what do u mean by db, I mean what u want to say
Database
And*
Since you need to code in 3 different files and connect them by also using 2 programs at the same time and linking them.
I know that I mean what is the use of db
Storing data.
Ok I got it
@cloud dawn I ultimately wanted to say what is the use of it in IPC and ROUTING else I know what db and it's work is
You shouldnt use a db if you are going to store pictures
So to pass files, IPC routes are the best?
@lament mesa I don't think it's even possible
Store img to base64 then decode it 
What but how using base64
lmfao cursed method since loading 2mb of text is way more intesive than loading a 2mb image xD

I have also seen people storing the bytes of the file
2mb in a DB is alot that is like 50k user data.
Store a file as a file.
Bye bud
It was more that that takes 45 min lol
Unfortunately i do have to go :/
There will prob be someone here to help!
Thanks, if not i will be same time here tomorrow again.
it's okay
create_instant_invite
@cloud dawn so basically in this code i don't get why hels made the load and unload commands when he's got a for loop to load the files
this is a command? or event
why do you need to get the channels?
for channel in ctx.guild.channels:
await channel.set_permissions..
keep in mind ratelimits too btw
full traceback?
is this 2.0
dpy v2
then i guess use_slash_commands=False is not valid because it does not have that yet
No lastest has use_slash_commands as well
!d discord.Permissions.use_slash_commands
Returns True if a user can use slash commands.
New in version 1.7.
why do we use @commands.Cog.listener() instead of @bot.event in cogs
Hi I need help
@commands.has_any_role("(👑) Owner","(⌛️) Administrator","(🎧) Manager","(🔧) Developer")
async def balance(ctx, user: discord.Member=None):
if not user:
user = ctx.author
await open_account(user)
users = await get_bank_data()
user = user
wallet_amount = users[str(user.id)]["wallet"]
bank_amount = users[str(user.id)]["bank"]
total_amount = bank_amount + wallet_amount
embed = discord.Embed(title= f"{user}'s Balance", color = discord.Colour.blurple())
embed.add_field(name = "Wallet :money_with_wings:", value=f"{wallet_amount:,}", inline= False)
embed.add_field(name = "Bank :bank:", value=f"{bank_amount:,}", inline= False)
embed.add_field(name = "Total Balance :moneybag:", value=f"{total_amount:,}", inline= False)
await ctx.send(embed=embed)
def moneypurge(money):
money = str(money)
nmoney = ""
if money.endswith("000000000000000"):
nmoney = money[:-15] + "Q"
elif money.endswith("000000000000"):
nmoney = money[:-12] + "T"
elif money.endswith("000000000"):
nmoney = money[:-9] + "B"
elif money.endswith("000000"):
nmoney = money[:-6] + "M"
elif money.endswith("000"):
nmoney = money[:-3] + "K"
else:
nmoney = money```
/balance is my command but I made this deg moneypurge how can I add this behind my numbers in /balance?
Take a look at the documentation for set_permissions it has examples of what to pass
!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/stable/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/stable/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/stable/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/stable/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` permission to use this...
Yes
Ignoring exception in command mute:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/container/bot.py", line 109, in mute
await member.add_roles(mutedRole)
File "/home/container/.local/lib/python3.9/site-packages/discord/member.py", line 777, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'
async def unmute(ctx, member: discord.Member):
mutedRole = discord.utils.get(ctx.guild.roles, name="Muted")
await member.remove_roles(mutedRole)
await member.send(f" U bent geunmute van: {ctx.guild.name}")
embed = discord.Embed(title="Unmute :speaker: ", description=f" Ik heb {member.mention} geunmute",colour=discord.Colour.light_gray())
await ctx.send(embed=embed)
@bot.command()
async def mute(ctx, member: discord.Member):
mutedRole = discord.utils.get(ctx.guild.roles, name="Muted")
await member.add_roles(mutedRole)
await member.send(f" U bent gemute in: {ctx.guild.name}")
embed = discord.Embed(title="Mute :muite: ", description=f" Ik heb {member.mention} gemute",colour=discord.Colour.light_gray())
await ctx.send(embed=embed)```
hi guys... i want to make an auto moderation bot, the "banned" words are stored in a json file (the bot is for only one server), now here i am a bit confused. is this the right way to check if any message has one of these words?
@commands.Cog.listener()
async def on_message(self, message):
data = utils.jjson.read_json("words")
if message.author.bot:
return
if any(word in message.content for word in data['blacklistedWords']) and not message.content.startswith(self.client.defaultPrefix):
if message.author.bot or message.author.id == self.client.owner_id:
return
await message.delete()
await message.channel.send(f"{message.author.mention} you can't send this here")
await self.client.process_commands(message)
why is PyCharm doing this?
put try and except statement
also this is how i add a word to the json file
@commands.command(description="Add a word to blacklist", aliases=['aw'], usage='<word>')
@commands.has_guild_permissions(administrator=True)
async def addWord(self, ctx, *, word:str = None):
data = utils.jjson.read_json("words")
if word is None:
return await ctx.send("Please specify a word to blacklist.")
if word in data['blacklistedWords']:
return await ctx.send(f"`{word}` is already blacklisted.")
utils.jjson.write_json(data, "words")
await ctx.send(f"Added {word} to blacklist")
Read the file into memory once
When the bot starts and when you add a new word
Rather than every time there's a message
is there a way to save all of the messages in a channel (as in like modmail) with a .txt file?
i need help
i want a song to download to a folder, but it doesnt even when i try to make it download to the folder
queue_path_2 = "/home/pi/asbeta/Queue
subprocess.call(f"youtube-dl --extract-audio --audio-format mp3 -o {queue_path_2}" + (str("song")) + ".mp3 " + f'"ytsearch:{url}"', shell=True)
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
don't curse antiswear man
How can I fix this error?
TypeError: argument of type 'NoneType' is not iterable```
Anyone?
File "/home/container/bot.py", line 101, in mute
await bot.add_roles(member, role)
AttributeError: 'Bot' object has no attribute 'add_roles'
How do I then add a role?
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
topic is None. Check if the topic is not None, if it's not then iterate through it
I set the topic channel to Bypassed though.
Oh okay
It is possible it's checking any other channel too, so having some check is good
Okay
Uh.. It's for User319183

@bot.command()
async def hello(ctx):
"""Says world"""
author = ctx.message.author
print(str(author) + " used ?hello")
await ctx.send("world")
if not author in usedhello:
usedhello[str(author)] = 1 else:
usedhello[str(author)] += 1
await ctx.send(str(author)+" used ?hello "+str(usedhello[str(author)])+" times!")
Last line always prints "(username) used ?hello 1 Times how to fix
How do I get 22.58
copy paste it
make the bot type it
omg
like in my code
how do I get 22.58
using split and indextaion
AttributeError: 'NoneType' object has no attribute 'mention'
embed.description = f"**Sunucu Ad**: {guild.name}\n**Sunucu ID**: {guild.id}\n**Sunucu Kurucusu**: {guild.owner.mention} ({guild.owner_id})\n**Üye Sayısı**: {guild.member_count}"```
@client.command()
@commands.has_permissions(kick_members=True)
async def warn(ctx, member: discord.Member, *, arg):
logsChannel = client.get_channel(809483574398812160)
user = member.mention
embed = discord.Embed(title="Warning issued: ", color=0xf40000)
embed.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
embed.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
embed.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
embed2 = discord.Embed(title="Warning issued: ", color=0xf40000)
embed2.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
embed2.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
embed2.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
await logsChannel.send(embed=embed2)
await member.send(f'You have been warned in {server_name} for **{arg}**!')
message = await ctx.send(embed=embed)
await message.add_reaction('☑️')```
says arg is a required argument thats missing
ok and?
what do i do
learn python before using a hard lib
help pls
ok? you expect us to help without you knowing any python?
IK PYTHON
ill help
ty
send problem
i did
hm, guild without a owner?
make the arg argument optional
maybe
try doing arg = None and add a statement if arg == None arg = None
where
ok lets see
Where you define warn then add the if statement under async def
:**
Can i make a command inside on_raw_add_reaction?
How do I make a command that will do something by deafult when no arg is passed
and will do something else when 1 arg is passed
Whats the difference between Client.Command and Client.Event
it doesnt work @stark flicker
Give the arg a default value
@client.command()
@commands.has_permissions(kick_members=True)
async def warn(ctx, member: discord.Member, *, arg):
logsChannel = client.get_channel(809483574398812160)
user = member.mention
embed = discord.Embed(title="Warning issued: ", color=0xf40000)
embed.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
embed.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
embed.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
embed2 = discord.Embed(title="Warning issued: ", color=0xf40000)
embed2.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
embed2.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
embed2.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
await logsChannel.send(embed=embed2)
await member.send(f'You have been warned in {server_name} for **{arg}**!')
message = await ctx.send(embed=embed)
await message.add_reaction('☑️')```
says arg is a missing requirement
U didn't change ur code
i did
In ur arg param put arg = None
@client.command()
@commands.has_permissions(kick_members=True)
async def warn(ctx, member: discord.Member, *, arg):
if arg == None:
arg = None
logsChannel = client.get_channel
(809483574398812160)
user = member.mention
embed = discord.Embed(title="Warning issued: ", color=0xf40000)
embed.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
embed.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
embed.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
embed2 = discord.Embed(title="Warning issued: ", color=0xf40000)
embed2.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
embed2.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
embed2.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
await logsChannel.send(embed=embed2)
await member.send(f'You have been warned in {server_name} for **{arg}**!')
message = await ctx.send(embed=embed)
await message.add_reaction('☑️')```
Hey sorry to bother the topic you're in right now, but can someone help me? My code isnt working to the basics, client command isnt working and nobody knows why
Do u have client.event with on_message?
yes!
Do u have the process_commands at the end of it?
no : s
!d discord.ext.commands.Bot.process_commands
await process_commands(message)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
This function processes the commands that have been registered to the bot and other groups. Without this coroutine, none of the commands will be triggered.
By default, this coroutine is called inside the [`on_message()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_message "discord.on_message") event. If you choose to override the [`on_message()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_message "discord.on_message") event, then you should invoke this coroutine as well.
This is built using other low level tools, and is equivalent to a call to [`get_context()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") followed by a call to [`invoke()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
This also checks if the message’s author is a bot and doesn’t call [`get_context()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") or [`invoke()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") if so.
it isnt working
What's not working
Hello, i want to send a validation message with a reaction in DM
My function:
@bot.command()
async def dm(ctx):
msg = await ctx.author.send("Bonjour et bienvenue dans notre entreprise!")
await msg.add_reaction(":white_check_mark:")
def check(reaction, user):
reaction.message.id == msg.id
reaction, user = await bot.wait_for("reaction_add", check=check)
print("test")
await ctx.author.send("Thanks")```
And it don't work
@client.command()
@commands.has_permissions(kick_members=True)
async def warn(ctx, member: discord.Member, *, arg = None):
if arg == None:
arg = None
logsChannel = client.get_channel
(809483574398812160)
user = member.mention
embed = discord.Embed(title="Warning issued: ", color=0xf40000)
embed.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
embed.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
embed.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
embed2 = discord.Embed(title="Warning issued: ", color=0xf40000)
embed2.add_field(name="Warning: ", value=f'Reason: {arg}', inline=False)
embed2.add_field(name="User warned: ", value=f'{member.mention}', inline=False)
embed2.add_field(name="Warned by: ", value=f'{ctx.author}', inline=False)
await logsChannel.send(embed=embed2)
await member.send(f'You have been warned in {server_name} for **{arg}**!')
message = await ctx.send(embed=embed)
await message.add_reaction('☑️')```
What's the issue now
AttributeError: 'function' object has no attribute 'send'```
I believe it's reaction.message_id @slate swan
Send the full error
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'function' object has no attribute 'send'```
Hey. How can I cancel other methods that are on await
Is that really the full error?
I want a command, that blocks every new message if the mode is enabled
can someone help out
yes
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'function' object has no attribute 'send'
172.18.0.1 - - [30/Aug/2021 20:26:03] "HEAD / HTTP/1.1" 200 -
Ignoring exception in command warn:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 1036, in warn
await logsChannel.send(embed=embed2)
AttributeError: 'function' object has no attribute 'send'```
sorry this is
I also have an error when putting the await process commands
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\simao\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "d:\Documentos\code\main.py", line 18, in on_ready
await process_commands(message)
NameError: name 'process_commands' is not defined
Could you elaborate
await bot.process_commands(message)
Or client instead of bot, depending on what you have
Kraots can u solve my problem
which what ?
what is the problem ?
It should work, idk why it's giving error
I want a command like !stop
and if its enabled I want any other command that is written in the time the mode is enabled to be blocked
In your check, change reaction.message.id to reaction.message_id
now it says message isnt defined
await logsChannel.send(embed=embed2)
AttributeError: 'function' object has no attribute 'send'```
thanks, let's try
Use a bot check and store the value in the database, use if/else statements and if the value is True then return else pass
what did you put as your message param for on_message
It's not that
Do you have a func that's named logsChannel
i might've confused on message with ready
OH
is there a way to set cooldown to a button?
???
I said on_message not on_ready
use asyncio.sleep
Yes it was good how you did it first, my bad 😅
yes im sorry
still learning, on the youtube tutorials they just do this and won't really explain
but it didn't work 😭
yea no
wdym
can you give me a tip on where to learn it?
You need to return the check (return reaction.message.id == msg.id)
ha year, ok
nice!
might as well ask already
does it explain how to make the bot join the channels?
no
thanks, now it work
Np
it tells you the basics of making a discord bot
ill check it out now, thanks!
that would throw quite a lot of errors...
my bot was working with events just fine
but yeah im coming back because
its already not replying to the hello world
wouldn't it reply to !hello
yes, that
ok
if i run it just with that line of code
it replies
but my code is probably already very twisted, ill start over
you could just delete the name parameter
and name your function hello
keep it simple
so just client.command()
i see, ill keep following this tutorial to get the hang of it
if you want your command to have multiple names
and I saw you put something in on_ready
well- don't do that
a print is enough
I have no clue what it does honestly, i tried following those yt vids and got way to overwhelmed
so when on_ready just print that its on
on_ready triggers once the bot is ready for commands and stuff
but it happens multiple times
and randomly
so with loading cogs in on_ready, you will get an error like everyday that you already have loaded them
and I'm not sure you have cogs

yeah, that's enough
im starting over, so i don't have anything and open to everything
i think it works regardless
it works, just cleared it rn
some IDEs throw error cuz of that space
!e ```py
print ("h")
@hasty iron :white_check_mark: Your eval job has completed with return code 0.
h
how do you guys send code like that?
!code


