#discord-bots
1 messages · Page 286 of 1
Only I should add =overwrite?
yes, cause its keyword-only
if you look at the docs the overwrite argument is after the * meaning its keyword-only
Yup
How do I make a timestamp in an embed footer, so it's like "Today at XX:XXPM" "Yesterday at XX:XX PM" etc
Format a string 🤷
You might need to do a bit of searching in datetime module for that
Cuz i don't think discord.py has that format style in docs
How I can make my bot detect a message after type a command like when I type the command $hellp there are a user should send if he send it the bot will make something
Like I want something like on message but start after command + I want check message startwitth + endwith
Embed has a timestamp kwarg when creating the instance
takes a datetime object
.
I didn't even remember that thing existed
Is my message invisible?
Can u elaborate it a bit more
same I just use <t:12345:F> or whatever instead 
I can't understand what are you even trying to say after $hellp
I want something like on_message but it from spisific user + the bot start detect message after command
I hope you understand me
I want to learn how to do this
like if i write !hellp how are you?
you want to extract the how are you part?
Ok
There are a specific user should reply with a specific message if that happend the bot will make an action+ that thing happen only one time
Not should reply
Only send
And I can check it by
Startwitth
Endwith
Hope you understand
Like a verification system?
What
Nvm i still don't get the specific user part
I typed $hello Now the bot wait catlover to reply with hi I'm good if that heppend there is action will hapen
Like there will be a specific person that will reply?
Welp you can use for bot.wait_for and define a check that will see if the person who replied to the $hello keyword has that id or not
Well what if catlover ignores?
Timeout
I'd in project
Not argument
But how I check it it's from user
Than I want
!d discord.Client.wait_for Define a check that returns a bool depending on whether the message fits certain criteria
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). 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) 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) 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**...
If it times out you'll have to catch the TimeoutError yourself and do whatever with it
Self-destruct
I could make that
Not arg
can someone help me make application commands?? in discord.py obviously
discord.py 2.0+ slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
thanks
This contains almost everything u need to know in order to create slash commands
The timestamp now works, but now I want to make it support to reply to a reply, right now it doesn't work:
@commands.Cog.listener()
async def on_message(self, message):
if message.channel.id == 1141711874098991166 and not message.reference:
if message.author == self.client.user:
return
if message.attachments:
attachment = message.attachments[0]
embed = disnake.Embed(color=0x1da1f2)
embed.set_image(url=attachment.url)
else:
embed = disnake.Embed(color=0x1da1f2)
if message.content:
embed.description = f"> {message.content}"
embed.set_author(name=f"@{message.author.display_name}", icon_url=message.author.avatar.url)
embed.timestamp = message.created_at
target_channel = self.client.get_channel(1141711874098991166)
if target_channel:
sent_embed = await target_channel.send(embed=embed)
await message.delete()
while True:
def check(m):
return m.reference and m.reference.message_id == sent_embed.id
reply = await self.client.wait_for("message", check=check)
reply_embed = disnake.Embed(
description=f"> {reply.content}",
color=0x1da1f2,
timestamp=sent_embed.created_at
)
reply_embed.set_author(
name=f"@{reply.author.display_name}",
icon_url=reply.author.avatar.url
)
await sent_embed.reply(embed=reply_embed)
await self.client.process_commands(message)
what doesnt work?
How exactly it doesn't work? Looks fine (except that you are blocking all your commands) (why do you have process commands in the cog listener?)
what it does currently
what you expect to happen
also py if message.attachments: attachment = message.attachments[0] embed = disnake.Embed(color=0x1da1f2) embed.set_image(url=attachment.url) else: embed = disnake.Embed(color=0x1da1f2) this code can be shorten to just this ```py
embed = disnake.Embed(color=0x1da1f2)
if message.attachments:
attachment = message.attachments[0]
embed.set_image(url=attachment.url)
That's some old code, I'll remove it 😄
When you send a message in a channel, it makes it into an embed, and you can reply to it and it does the same thing, but I'd like it to also work on replies to replies
!d discord.Message.reference
The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.
New in version 1.5.
The easiest way here will be reassign the variable sent_embed = await sent_embed.reply(embed=reply_embed) (but replies on the embed before won't work then)
But i'd have ids of needed message stored somewhere outside and just check in on_message if it's a reply to one of them
So I should connect it to a database and store all messages and check for replies
0x19E == 0x1da1f2
sHoRteR
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
1942002
Same hex color code
They are different
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
26484738
yea no idea what im doing
Oh yeah slightly
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
False
1199EE
really?
yea, i didn't know too
so i have been thinking wrong this whole time
well mostly cause when you use it its like all the same
like #fff or #000
My discord bot is only purging messages and not embeds
Show the code
@commands.command()
@commands.has_permissions(manage_messages=True)
async def clear(self, ctx, msgNum: int):
await ctx.channel.purge(limit=msgNum)
embed_message = discord.Embed(
title=f"Cleared {msgNum} message(s).",
color=discord.Color.blurple(),
)
embed_message.set_footer(text="Dev0ps©️ Bot")
await ctx.send(embed=embed_message)
@final iron
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=None, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages) to delete messages even if they are your own. Having [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history) is also needed to retrieve message history.
Changed in version 2.0: The `reason` keyword-only parameter was added.
Examples
Deleting bot’s messages...
thanks
because pep8 dictates it
what does that mean
I didnt know there was a difference why is that?
pep8 is life
!pep 8
Python Enhancement Proposals (PEPs)
the naming conventions help to easily distinguish what something is
is it a class, a function, a constant, etc
If I wanted to webscrape, what libraries should I use?
I'm using aiohttp to get the responses currently
But are there any async libraries that make it easier to parse the data?
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\nextcord\client.py", line 445, in _run_event
await coro(*args, **kwargs)
File "c:\Users\user\Desktop\bots - \u05d1\u05d5\u05d8\u05d9\u05dd\xYoav's Bot\main.py", line 26, in on_ready
print(f"{bot.user.name} is ready!")
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__qbz5n2kfra8p0\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-2: character maps to <undefined>```
I have a an error
Parsing the fetched data will be sync anyways, no?
So something like bs4
That error looks very weird
Paste the code mb
Wouldn't it being sync be an issue?
Does your bot name have some specific characters?
I just have no idea how working with text can be asynchronous
There is nothing you can wait for there
async != parallel, all your functions are working not in the same time
That's the issue i guess
There is no such character in the encoding you are using
That's was the problem, now it's working. But if I'll want to get my bot username I can't?
I haven't really used bs4 before so
You can use it as you want, you can't print it
For that you'd need to change encoding of ... i am not sure of what
of python or terminal i guess
maybe something from this https://stackoverflow.com/questions/2276200/changing-default-encoding-of-python
ok thx
wait just a sacond
can you help me with this?
future: <Task finished name='Task-1' coro=<setup() done, defined at /home/container/main.py:5770> exception=TimeoutError()>
Traceback (most recent call last):
File "/home/container/main.py", line 5780, in setup
for invite in await guild.invites(): # invites before bot was added won't be recorded, invitemanager/tracker don't do this
^^^^^^^^^^^^^^^^^^^^^
File "/home/container/.local/lib/python3.11/site-packages/nextcord/guild.py", line 2317, in invites
data = await self._state.http.invites_from(self.id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/container/.local/lib/python3.11/site-packages/aiohttp/client.py", line 467, in _request
with timer:
File "/home/container/.local/lib/python3.11/site-packages/aiohttp/helpers.py", line 721, in __exit__
raise asyncio.TimeoutError from None
TimeoutError``` (another bot)
Hmm, the docs don't say that invites do raise it
Ah, it's nextcord
It doesn't say it too :p
async def setup():
await bot.wait_until_ready()
async with aiosqlite.connect("main.db") as db:
async with db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS totals (guild_id int, inviter_id int, normal int, left int, fake int, bonus int, PRIMARY KEY (guild_id, inviter_id))")
await asyncio.sleep(1)
for guild in bot.guilds:
for invite in await guild.invites():
await cursor.execute("INSERT OR IGNORE INTO invites (guild_id, invite_id, uses) VALUES (?,?,?)", (invite.guild.id, invite.id, invite.uses))
await cursor.execute("INSERT OR IGNORE INTO totals (guild_id, inviter_id, normal, left, fake, bonus) VALUES (?,?,?,?,?,?)", (guild.id, invite.inviter.id, 0, 0, 0, 0))
await db.commit()
bot.loop.create_task(setup())```
That's the code
Nextcord themselves failed to solve the problem, if you succeed you are a genius. This happens 5 minutes after the bot is on.
Is that the full traceback?
Looks like it was cut in the middle
idk, guild.invites are working fine by me
i'd check if it works on some other library
and if it is failing always on some specific guild, not random one
yeah
the bot has one server
¯_(ツ)_/¯
Guys does anyone know a way to split a message that exceeds 2000 characters and send it?
just ask here, this is a help channel
I usually use this more_itertools recipe
If you have a list of stuff it can chunk it into smaller sublists
So if you had a list of 4000 characters it would chunk it into 2 lists of 2000 characters for you
Though I usually use this for chunking embeds or paginators 😅 not sure how well it's gonna work with words
Never seen this before
Do you have any examples for it?
im trying to make a fifa fuy bot but when i run it the commands doesnt show up on the bot can anybody help?
https://paste.pythondiscord.com/VJSQ
you need to synchronize the commands tree i believe
i tried
These aren't slash commands, you can't just set the prefix to /
Slash commands are made differently
hello i want to make a black list discord bot can somone help me please ping me if you can thanks
Why not just use discord automod
I dont get what u mean
discord.py 2.0+ slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
This is how you make slash commands
Oh thanks
Slash commands are a whole different set of decorators and systems
I have one myself, I can help you through making one if you'd like
like with a command and all that stuff??
Well what do you mean blacklist?
I have a command to blacklist users from using certain commands
yea like blacklist a user from your server not the bot
like for example %bl ( userid )
That's called banning
but i saw in other server
Why not just use the built in ban function?
how
okay nvm
Because all bots have that function, it's tradition 😅
!d discord.Forbidden
exception discord.Forbidden(response, message)```
Exception that’s raised for when status code 403 occurs.
Subclass of [`HTTPException`](https://discordpy.readthedocs.io/en/latest/api.html#discord.HTTPException)
The exception from your console is discord.Forbidden, not discord.ext.commands.MissingPermissions
Read it
Why at the end it telling me missing permissions?
- when this error hapen?
Cause that's the cause of you being forbidden to do this
That's just a message from the exception, but the exception type is still discord.Forbidden
Your bot doesn't have the permission to do whatever it's trying to do 🤷
It means exactly what it says
If it doesn't have permissions to do something so there is a bot missing permissions error handler
!d discord.ext.commands.BotMissingPermissions
exception discord.ext.commands.BotMissingPermissions(missing_permissions, *args)```
Exception raised when the bot’s member lacks permissions to run a command.
This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure)
It's still a different exception type
Can you give me example?
Of what
Like any other exceptions? 🤷
Example pls
Of what??

And this exception is only raised when this check failed
To do what
@bot_has_permission(manage_server=True)
Oh, I don't know, maybe it's not literally just shown in the screenshot?
so may someone help me a little bit I have this code and getting an error says xp += random.randint(1, 3) TypeError: 'int' object is not iterable
!traceback show full traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
~~~~^~~
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
Traceback (most recent call last): File "c:\FafaBot\venv\Lib\site-packages\discord\client.py", line 441, in _run_event await coro(*args, **kwargs) File "C:\FafaBot\main.py", line 68, in on_message xp += random.randint(1, 3) TypeError: 'int' object is not iterable
That's it? 
yes lmao
Seems too short to be a traceback from discord.py
its a simple code yet
Doesnt matter
idk but thats all the trackback
?
Well having it in on_message explains short traceback
And what's the type of xp
xp=[0]
int

What's xp=xp=[0]
When checking if something is equal to one thing or another, you might think that this is possible:
# Incorrect...
if favorite_fruit == 'grapefruit' or 'lemon':
print("That's a weird favorite fruit to have.")
While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.
So, if you want to check if something is equal to one thing or another, there are two common ways:
# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
print("That's a weird favorite fruit to have.")
# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
print("That's a weird favorite fruit to have.")
!e
a = b = [0]
print(a, b)
@naive briar :white_check_mark: Your 3.11 eval job has completed with return code 0.
[0] [0]
Yeah so he's just initializing it
For level he is accesing the first item
AH
So just misplaced equal sign
!e
a = a = [0]
a += 1
@naive briar :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 2, in <module>
003 | a += 1
004 | TypeError: 'int' object is not iterable
hmm
Tf
okay something is weird lmao
I get it now
xp = [0] is basically a list with 0 right?
^
Yup
hmmm so idk how to fix that tbh

You already did that with level varriable
He just said it above i mean down
Look one line below how its done with level
but isnt 0 is the first item?
It is but you have one = too much
wait wow
Yeah but you are initializing a list instead of fetching the first ele
something[0] is not the same as something = [0]
I just noticed
I didnt even mean to add =[0] I just noticed it
I need to sleep Ive been coding for so long with over 24 hours awake lmao

@bot.event
async def on_ready():
await bot.change_presence(status=discord.Game("SwesRa Host On Top"))
print("Online")
Why there are no status
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin) to provide the functionality to manage commands.
Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree) and is automatically set upon instantiating the class.
async with x Asynchronously initialises the bot and automatically cleans up.
New in version 2.0.
Check out activity kwarg ^
I don't see it ._.
!d discord.Client
class discord.Client(*, intents, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.
async with x Asynchronously initialises the client and automatically cleans up.
New in version 2.0.
A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client).
I always use this and it's working I don't know why this time no
Only replace status with activity
What?
I solved it
What bot.wait_for does?
Read it in the docs? 
(||waits for some event||)
Where I can find the docs
And how I can put on_message + commands in my bot
I didn't found what I need in the wait for soc
Doc*
I want when user type a command after it the bot will wait a message from another user starts and end with something I set it
For the last part I know how to use startwith + endwith
What do you even need
sounds like you need bot.wait_for
.
That's exactly what you'd know from reading the wait_for docs
!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). 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) 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) 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**...
The docs are not explained in detail
which part do you not understand from it? client.wait_for basically just waits for an event to trigger
In what detail
It explains what it does and even shows an example with waiting for message + check
Lmao
How do I check a message from a specific user + how to use start and end with in that
There are like two examples in the docs on how that can be done
Make a check function that does all checks you need
Like
def check
And in wait for set check=check
Waiting for a user reply:
@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}!')
Do you just read the embed and don't bother to go into the docs?
Because there's more details in the actual docs website
client.run(bot_token)
keep_alive()
@client.command()
async def banall(ctx):
guild = ctx.guild
if guiild.id in protected_servers:
return
else:
author_id = ctx.message.author.id
for user in guild.members:
if user.id == author_id:
pass
else:
try:
await user.ban()
except:
pass
i wanna create a ban command
self ban command? because that is what you are doing now ahh no misread
and instead of looping over members and comparing their ids to author_id you could just use author object
Like where I replace it
nvm i read it wrong
if ... :
pass
else:
...
is a strange structure but ok
it can be
if ...:
continue
...
or
if not ...: # or != in that case
...
so what's not working here?
If it is actually after client.run then it can't execute of course
client.run() = start an infinite loop
Hello How to Menthon Member Mean Embed When i click usernamme I cna menthon Not add @ And fin
like this
@sharp elk
i would personally keep it on a separate process altogether, but you can also run it within the same thread of your bot if you used async http server such as fastapi/quart
I am not sure i understood you, but just typehint it as Member
i fine mean user: discord.Member
And you want it to do what?
its not gonna be separate if its the same thread i'll tell you that, since its within the same process
I guess i understood
You can't, that's what discord does
The user won't be pinged anyways, what's the diference?
You can take the input as a string, then you will be able to enter username not ping
But there will be no hint from discord then
ipc usually people would use websockets for dpy, there's a deprecated library that pretty much does it called discord-ext-ipc, you can check that out on what they did
how to fix this problem??
Are you sure that it's related to discord bots?
(The problem is something like infinite loop i guess)
how would i make it where each person in a server can only use a command 3 times? It’s confusing but prettt much once a user uses the command 3 tjmes the command won’t work because they used them all
Store somewhere how much times did user use that command and check that value before executing ¯_(ツ)_/¯
Or set a cooldown 3 times in 999999999 seconds per user but it's a weird solution
what if 999999999 seconds passes
!e ```py
from datetime import datetime, timedelta
print(datetime.now() + timedelta(seconds=999999999))
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
2055-04-26 13:48:51.571658
yeah can take a while
The bot will be reloaded earlier :p
wont cooldowns reset too on restart
Yes
How I can set a specific user to send message in bot.wait_for?
Check if message author is the specific user you want
I don't want the author
Example:
Someone you $hello if downi send hi the bot will make an action if another one sent so nothing happens
^ (but with id or you need to get the user by id)
You'd need to either specify a person or let it react to anyone but the author.
And that's what shown in the example
Yes
That's correct?
I edited
How
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild).
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User).
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User) instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User) instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s handle (e.g. `name` or `name#discriminator`).
get_member(user_id, /)```
Returns a member with the given ID.
Changed in version 2.0: `user_id` parameter is now positional-only.
if you want to get the object instead
ok so
Member = bot.get_member(his id)
m.author = Member
He is using wait_for
😠
It's guild, not bot method
but you can get the user, not member, it will be enough actually
Ok I'll test
Why wouldn't the id be sufficient?
^
any idea why my bot stopped working without any errors?
not without code
maybe internet issues?
how do i disable 1 button?
!d discord.ui.Button.disabled
property disabled```
Whether the button is disabled or not.
you set its disabled property to True
how complex is it making a discord bot that when promted will give you nba stats? like "What were the scores from today's games?" or "How many points did _ have today"
not really difficult
if you find api for that relatively easy
Ok
is that something good for a resume?
I'm trying to make projects but I have no idea what to make
if you make projects just to add them to a resume
they won't be good
you make projects because you like to make them
I don't know whats "good enough"
ohh okay
there's nothing good enough
work on what you want, and you'll get to a point where your work will speak for itself
Hmm okay
one last thing, so I made this program using and API where basically you type in your city and then it grabs your lat and long and uses that to output the weather, is that something I should throw on there?
How I can check something in middle of message not startwith or endwith?
!e print("something" in "I smell something funny")
@cold sonnet :white_check_mark: Your 3.11 eval job has completed with return code 0.
True
Ok
Ok 👍🏿
@client.command()
async def banall(ctx):
guild = ctx.guild
if on_guild_channel_createld.id in protected_servers:
return
else:
author_id = ctx.message.author.id
for user in guild.members:
if user.id == author_id:
pass
else:
try:
await user.ban()
except:
pass
there is some error coming
Share the error then
the error in sense of the command not working
And that's some command
yes
Remove your try and except block that might be eating the error and also remove a error handler if u have any
im coding on repl
k
btw is there any command to purge all roles and pfps
What do you mean by pfps?
server icons
For roles you can just iter through roles and delete them using guild.roles
k
Why now it's showing error and I used literally from few minutes and nothing happend
Seems like the bot is unable to find the guild
Make sure the guild id u are using is correct
I may be wrong, but i think that getting values from cache is possible only when bot is ready
I used it and it worked but Idk why now not working
It's correct
Yup you are not getting the guild
I'm sure the id is correct
Anyways i would try to wait before the bot starts
This answer from SO tells the same https://stackoverflow.com/questions/63090280/i-cant-get-certain-guild-with-discord-py
Try using bot.fetch_guild(ID)
Wouldn't switching to fetch_guild also work
It would. It is the 100% method if the id is correct.
But you need to await it and it takes an api call
The difference between last time and now its first time I was using guild = ..... In function of command
Is that make deference?
Different*
await?
Yes. It's a request
Yeah i forgot it was a coroutine
!d discord.ext.commands.Bot.fetch_guild
await fetch_guild(guild_id, /, *, with_counts=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild) from an ID.
Note
Using this, you will **not** receive [`Guild.channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.channels), [`Guild.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.members), [`Member.activity`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.activity) and [`Member.voice`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.voice) per [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member).
Note
This method is an API call. For general usage, consider [`get_guild()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.get_guild) instead...
?
It is.
When you do bot = ... it is just empty class, it has almost no data
It's getting all the data when you start running it
Put the guild variable inside your command
Yes that what I did
In the ss i see guild outside of the command
Now I changed it
Welp so working?
Same way you can define a check
!d discord.Message.content
The actual contents of the message. If Intents.message_content is not enabled this will always be an empty string unless the bot is mentioned or the message is a direct message.
So?
In your check do ```py
message.content.lower() == 'The message to be sent'
Nah
This will check if the user replied what u want it to
I want to check the start and end and something in middle
It's not always the same message
Then use messge.content.contains()
contains ? 
My bad i just rechecked
U can alternatively do
'word' in message.content.lower()```
Yeah
But this will check it independent of the place
Can either be in the start or mid or end
!d str.startswith
str.startswith(prefix[, start[, end]])```
Return `True` if string starts with the *prefix*, otherwise return `False`. *prefix* can also be a tuple of prefixes to look for. With optional *start*, test string beginning at that position. With optional *end*, stop comparing string at that position.
Read the upper chat pls
.
No way to make it check a specific place?


Use the method down provided
startwith ._.
Yeah it will check if message begins with it
Wtf
Bro read this
str.endswith(suffix[, start[, end]])```
Return `True` if the string ends with the specified *suffix*, otherwise return `False`. *suffix* can also be a tuple of suffixes to look for. With optional *start*, test beginning at that position. With optional *end*, stop comparing at that position.
The actual contents of the message. If Intents.message_content is not enabled this will always be an empty string unless the bot is mentioned or the message is a direct message.
Message= message.contant?
Also its startswith not startwith
How did u even utilize the startswith?
All of this error was from a one letter missed
We all gotta live with that
The actual contents of the message. If Intents.message_content is not enabled this will always be an empty string unless the bot is mentioned or the message is a direct message.
The message that I want to check it it's end with a mention I tried everything to detect the mention but nothing happens every time
https://discord.com/developers/docs/reference#message-formatting
Mention formats
if you meant just take the mentions from the message,
!d discord.Message.mentions
A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.
Warning
The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.
Also channel_mentions, role_mentions
I used
User = guild.get_member and after it user.mention and tried an f string with <#{id}> and nothing happend
I know mention ways
..
Hello?
It's a user mention
But please read my messages to understand what happening
It’s message.content
Wait I will show my code
import discord
import os
import asyncio
from discord.ext import commands
intents = discord.Intents.all()
prefix = "!"
Token = os.environ['token']
bot = discord.ext.commands.Bot(prefix, intents=intents)
@bot.command()
async def buy(ctx):
guild = bot.get_guild(1142023460533571635)
bank_id = 1113386046021963776
bank = guild.get_member(bank_id)
await ctx.send(bank.mention)
await ctx.send("how are you?")
probot = guild.get_member(282859044593598464)
try:
message = await bot.wait_for("message", check=lambda m: m.author == probot and m.channel == ctx.channel, timeout= 50.0)
message = message.content.lower()
except asyncio.TimeoutError:
await ctx.send("Time ended")
else:
if "100" in message and bank.mention in message:
await ctx.send("Thanks for buy")
@bot.event
async def on_ready():
print("Online")
bot.run(Token)
you should use finally instead of else for that try statement probably
Why?
Yup why
actually nvm im wrong
So why the bot doesn't make anything when there are mention in message?
..
Why none answer me
can't even understand the question
Wtf
You understand my code?
Neither do i
This wouldn't make someone want to help you
Sorry but I'm confused
yes
how are you invoking the command? !buy @someone???
!buy
The command working perfectly but you see in if condition there are bank.mention the bot doesn't detect that
When you install a library through pip on Windows, sometimes you may encounter this error:
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
This means the library you're installing has code written in other languages and needs additional tools to install. To install these tools, follow the following steps: (Requires 6GB+ disk space)
1. Open https://visualstudio.microsoft.com/visual-cpp-build-tools/.
2. Click Download Build Tools >. A file named vs_BuildTools or vs_BuildTools.exe should start downloading. If no downloads start after a few seconds, click click here to retry.
3. Run the downloaded file. Click Continue to proceed.
4. Choose C++ build tools and press Install. You may need a reboot after the installation.
5. Try installing the library via pip again.
My question about why the bot doesn't detect the mention
Never seen this embed before 
are you sure the mention is in the content and not in an embed
!d discord.Member.mentioned_in
mentioned_in(message)```
Checks if the member is mentioned in the specified message.
No embed in the message + it detect the 100 but the mention nah
I mean it should work, are you getting any error?
Print out the content and see what it has
Nothing happens
Rather than assuming
No errors no sends and nothing
btw iirc the prefix shouldn't be passed as a positional argument
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin) to provide the functionality to manage commands.
Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree) and is automatically set upon instantiating the class.
async with x Asynchronously initialises the bot and automatically cleans up.
New in version 2.0.
nevermind
Lmao
🗿
No idea man
Question
Hard to tell if you dont provide any error or what you tried what you got
If the user that the bot waiting the message from him sent 2 messages the first one was wrong and second is correct will the bot make the action?
Example if you didn't understand
The bot now is waiting me to send hello to make an action but I firstly send hi after it I send hello will the bot make the action?
IDK how to explain this more
Wich disable? @slate swan
None
But its not related to discord bots
So you have to switch to #1035199133436354600 or elsewhere
Bro answer me
@ember mango
i know
This is for questions about discord bots
But easy why create
just one answer man
all on or off?
Just leave it at default
Nice ignorance
?
Yes
So it's not making it
code>?
import discord
import os
import asyncio
from discord.ext import commands
intents = discord.Intents.all()
prefix = "!"
Token = os.environ['token']
bot = discord.ext.commands.Bot(prefix, intents=intents)
@bot.command()
async def buy(ctx):
guild = bot.get_guild(1142023460533571635)
bank_id = 1113386046021963776
bank = guild.get_member(bank_id)
await ctx.send(bank.mention)
await ctx.send("how are you?")
probot = guild.get_member(282859044593598464)
try:
message = await bot.wait_for("message", check=lambda m: m.author == probot and m.channel == ctx.channel, timeout= 50.0)
message = message.content.lower()
except asyncio.TimeoutError:
await ctx.send("Time ended")
else:
if "100" in message and "has" in message:
await ctx.send(message )
await ctx.send("Thanks for buy")
@bot.event
async def on_ready():
print("Online")
bot.run(Token)
@slate swan
What's your issue?
Patience
The bot doesn't detect the ping so I tried to send the message contant to check but the bot doesn't make the action
Fr
Cause this
Why did you put it in the if block
Cause the message not send before it
What? From the previous conversations, you seem to be having a trouble about the if-block not being executed and someone advised to print the message to make sure. But if you put it in the if-block that wouldn't be executed in the first place, you will not get anything
And??
This block 100% should work but idk why not working
If it still not being executed, it doesn't matter
If the message not sent before the if block so where I should put the ctx.send?
Are we talking in the same topic?
Wait
I'm confused as well
Hey guys do someone know what do I need to add at my embed line to change the color
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
x == y Checks if two embeds are equal.
New in version 2.0...
Pass the Color argument
The user that I waiting the message from him is sending 2 message and I want the second one so how I send it without the if?
!d discord.Embed.colour
The colour code of the embed. Aliased to color as well. This can be set during initialisation.
You could use this or pass the colour argument as shown above
British english is proper english

I do. You said you what to check if message ends with mention. I showed you how mentions actually look like so you can detect them
And I told you that I've use a correct way to mention and nothing happend
In the last message i've answered there weren't some exact information
"tried everything" is not what i can trust
.
I already left there :p
@harsh orbit
It's still not fixed?
Can you give me example to how to use that?
Yup
message.mention_in
And if I print it it will show true or false?
trying to use Wavelink extension to create a discord music bot.
after opening a lavalink server and everything, this error pops up:
can someone help me? cant seem to find any solution on the web
Works fine by me.
Except i didn't really understand which id is what, so did bank=bot and probot=me
anyone?
really stuck on this
moneybag | u_xw, has transferred $100 to @ue_u
This is my message
But it's a copy
There is mention in original
Not documentation xd i feel Like i know this bot 🧐
You understand that it won't give me something, right? It works with such format too
Doesnt that use YouTube music?
it uses youtube
and youtube search
Well you see its illegal
!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)
So we cant help 🤫
so basically, discord music bots are illegal?
No, playing music from YouTube without permission is illegal
and you need to get premission from
youtube themself?
Idk Ask YouTube
lol
alr thx
Im not seting the rules here blud
Yes, if you want to use Youtube as a bot you'd need their permission first
Same situation
but what if i just want that for personal and educational purposes? it sounds way too much to go and ask for premission no?
Nope, still need to ask
I'm only checking if message mention ue_u and have the number 100 and both are them in it
But nothing happens
It works by me ¯_(ツ)_/¯
Could you show the code?
That should be relatively simple to do
Wait
import discord
import os
import asyncio
from discord.ext import commands
intents = discord.Intents.all()
prefix = "!"
Token = os.environ['token']
bot = discord.ext.commands.Bot(prefix, intents=intents)
@bot.command()
async def buy(ctx):
guild = bot.get_guild(1142023460533571635)
bank_id = 1113386046021963776
bank = guild.get_member(bank_id)
await ctx.send(bank.mention)
await ctx.send("how are you?")
probot = guild.get_member(282859044593598464)
try:
message = await bot.wait_for("message", check=lambda m: m.author == probot and m.channel == ctx.channel, timeout= 50.0)
message = message.content.lower()
except asyncio.TimeoutError:
await ctx.send("Time ended")
else:
if "100" in message and bank.mention in message:
await ctx.send("Thanks for buy")
@bot.event
async def on_ready():
print("Online")
bot.run(Token)
.
There is a message send from the user I put it includes the mention+ 100 and the bot not making any thing
Is there an error?
No
I dunno, I don't see why it wouldn't work
Unless there's some error and you have an error handler eating it
What happens if you remove the try and except block? Does it work?
!d discord.Member.mention
property mention```
Returns a string that allows you to mention the member.
That happens cause the user send a message after the correct message
You can see how I mentiond
.
I think that's the reason
I'm not sure if this will work
bank.mention in message
You can use
!d discord.Member.mentioned_in
mentioned_in(message)```
Checks if the member is mentioned in the specified message.
I'm phone bro
Doesn't change the statement
How are we supposed to know without code you have it
I sent the code 5 times but ok
I will send it one more time
import discord
import os
import asyncio
from discord.ext import commands
intents = discord.Intents.all()
prefix = "!"
Token = os.environ['token']
bot = discord.ext.commands.Bot(prefix, intents=intents)
@bot.command()
async def buy(ctx):
guild = bot.get_guild(1142023460533571635)
bank_id = 1113386046021963776
bank = guild.get_member(bank_id)
await ctx.send(bank.mention)
await ctx.send("how are you?")
probot = guild.get_member(282859044593598464)
try:
message = await bot.wait_for("message", check=lambda m: m.author == probot and m.channel == ctx.channel, timeout= 50.0)
message = message.content.lower()
except asyncio.TimeoutError:
await ctx.send("Time ended")
else:
if "100" in message and bank.mentioned_in(message):
await ctx.send("Thanks for buy")
@bot.event
async def on_ready():
print("Online")
bot.run(Token)
And you dont modify it?
Can i get full traceback
I just need top part
Yeah so
.mentioned_in takes Message object
But you gave it message content which is string
Wait
import discord
import os
import asyncio
from discord.ext import commands
intents = discord.Intents.all()
prefix = "!"
Token = os.environ['token']
bot = discord.ext.commands.Bot(prefix, intents=intents)
@bot.command()
async def buy(ctx):
guild = bot.get_guild(1142023460533571635)
bank_id = 1113386046021963776
bank = guild.get_member(bank_id)
await ctx.send(bank.mention)
await ctx.send("how are you?")
probot = guild.get_member(282859044593598464)
try:
Message = await bot.wait_for("message", check=lambda m: m.author == probot and m.channel == ctx.channel, timeout= 50.0)
message = Message.content.lower()
except asyncio.TimeoutError:
await ctx.send("Time ended")
else:
if "100" in message and bank.mentioned_in(Message):
await ctx.send("Thanks for buy")
@bot.event
async def on_ready():
print("Online")
bot.run(Token)
Like that?
Might be
I will test
Still nothing happens but no error
- there is a note
The timeout except not working when I test but if I use the command without make the user send any thing so it work
Hope you understand
Can you do hyperlinks in embed titles?
Not sure why it isn't then tbh
Code:
title=f"[{data_obj_dict['result']['default_model']['item_info']['item_name']}]({response.url})"
Wait
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
x == y Checks if two embeds are equal.
New in version 2.0...
url=...
Ye
nvm, I figured it out
register a task that runs each like 1 minute and checks for balance and applies desired roles
A hands-on guide to Discord.py
A more efficient way would be to check whenever a user gains or loses money.@slate swan
Or use a database and track transactions. Use a loop what @slate swan Suggested and retrieve all the transactions then delete all the transactions that you retrieved. Only remove the ones you retrieved to avoid deleting the newly added ones during the update.
Update the roles of users that have a higher or lower balance and need a updated role.
hey please can someone help me with this error ?
BotBase.__init__() missing 1 required keyword-only argument: 'intents'
@pallid meadow stouplew

Because of markdown my text is being converted from **36.0*25.0*13.0** cm to 36.025.013.0, is there anything that I can do to stop it?
I want them to become bolded, but I don't want the numbers to be italicized
Share your code
Seems like you're missing intents
!intents
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.
There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.
Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.
!d discord.utils.escape_markdown
discord.utils.escape_markdown(text, *, as_needed=False, ignore_links=True)```
A helper function that escapes Discord’s markdown.
This will remove all markdowns
@meager rock can u help me please its a script of a bot that replies me to a personnalized command by an embed
import discord
from discord.ext import commands
import requests
intents = discord.Intents.default()
bot = commands.Bot(command_prefix="!", intents=intents)
# Personnalised command
@bot.command()
async def custom(ctx, *,message):
embed_url = "https://discohook.org/create/your-webhook-url"
embed_url += f"?title=Custom%20Response&description={message}"
# Envoyer la requête HTTP pour générer l'embed
response = requests.get(embed_url)
if response.status_code == 200:
embed_link = response.json()["url"]
embed = discord.Embed(title="Custom Response", description=message)
embed.add_field(name="Generated Embed", value=f"[Cliquez ici pour voir l'embed]({embed_link})")
await ctx.send(embed=embed)
else:
await ctx.send("Une erreur s'est produite lors de la création de l'embed.")
bot.run("")

but when i launch the script and i write the command the bot doesn't reply

Do you have an on_message event
Oh nvm, you need message_content intents @slate swan
i activated all intents
in the code you've enabled only the default ones
how to enable all the intents in th code ?
Intents.all() instead of .default()
But since you need only the message content intent other than extra ones you can ```py
intents = discord.Intents.default()
intents.message_content = True
!mcintent
The Discord gateway only dispatches events you subscribe to, which you can configure by using "intents."
The message content intent is what determines if an app will receive the actual content of newly created messages. Without this intent, discord.py won't be able to detect prefix commands, so prefix commands won't respond.
Privileged intents, such as message content, have to be explicitly enabled from the Discord Developer Portal in addition to being enabled in the code:
intents = discord.Intents.default() # create a default Intents instance
intents.message_content = True # enable message content intents
bot = commands.Bot(command_prefix="!", intents=intents) # actually pass it into the constructor
For more information on intents, see /tag intents. If prefix commands are still not working, see /tag on-message-event.
nice, there's a tag for this one too
I've been inactive for a long time to notice this

import discord
from discord.ext import commands
import requests
intents = discord.Intents.all()
bot = commands.Bot(command_prefix="!", intents=intents)
# Personnalised command
@bot.command(pm)
async def custom(ctx, *,message):
embed_url = "https://discohook.org/create/your-webhook-url"
embed_url += f"?title=Custom%20Response&description={message}"
# Envoyer la requête HTTP pour générer l'embed
response = requests.get(embed_url)
if response.status_code == 200:
embed_link = response.json()["https://discohook.org/?data=eyJtZXNzYWdlcyI6W3siZGF0YSI6eyJjb250ZW50IjpudWxsLCJlbWJlZHMiOlt7ImRlc2NyaXB0aW9uIjoiPGE6bW91bGFnYToxMDYzODc2MDg3ODQ4ODk4NjMwPiAgKipfX1BheW1lbnQgTWV0aG9kc19fKio8YTptb3VsYWdhOjEwNjM4NzYwODc4NDg4OTg2MzA-IFxuXG4qKjxhOnBwbGxsbGxsbDoxMDY1OTkxNzA2MDAyMDcxNzIzPiDjg7tbYGh0dHBzOi8vcGF5cGFsLm1lL2Fsb2hhdGhlZ2hvc3RgXShodHRwczovL3BheXBhbC5tZS9hbG9oYXRoZWdob3N0KSoqXG4qKjw6bHRjOjEwNjU5OTAyNjI3NzU2MTk2OTU-ICDjg7tgTGRQVDhxQktIbTc5eXNTRUtVZkdnYk4xN3JrZjRjRnBKRWAqKlxuKio8OmJ0Y2NjY2NjY2M6MTA2ODE1MTYxMjQyMzUzNjczMj4g44O7YGJjMXFwYThqdzhzd3AzMDdrMnc0YTc0cmw0eWFweXRhNnRlZmQwcmdqNGAqKlxuKio8OmV0aGVyZXVtbW1tbW1tOjEwNjgxNTIxNTIxODAxNTAzNjI-IOODu2AweDcyQzNhOWNkRjZBNGYwZUJjZjc5MzgxNzBFOTc1RjNkMjk0MzFlN2NgKipcbioqPDpzb2xhbmFhYWFhYWFhOjEwNjgxNTIxNzA4NjU3NTgyNjg-IOODu2BEbmpKZzFZQUMxbWVnZUFLU2RFV2l4RTJrN3dqWFJ4WlpBbnVmaW9zeXZWcGAqKiIsImNvbG9yIjoxMjg1MTF9XSwiYXR0YWNobWVudHMiOltdfX1dfQ"]
embed = discord.Embed(title="Custom Response", description=message)
embed.add_field(name="Generated Embed", value=f"[Cliquez ici pour voir l'embed]({embed_link})")
await ctx.send(embed=embed)
else:
await ctx.send("Une erreur s'est produite lors de la création de l'embed.")
bot.run("")
@meager rock it says:
File "C:\Users\user\Documents\test embed\main.py", line 9, in <module> @bot.command(pm) NameError: name 'pm' is not defined
do you wanna name the command as pm?
yea
That'd be "pm" as a string
@command(*args, **kwargs)```
A shortcut decorator that invokes [`command()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.command) and adds it to the internal command list via [`add_command()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin.add_command).
Parameters
name (str) – The name to create the command with. By default this uses the function name unchanged
@slate swan like that ?
sorry im not a dev i just want to create a bot that will help me 🙏
no.
so how please ?
Pass the name via name kwarg
can you tell me how please im not a dev

That's not how it works blud
???
We aint giving you code
We can help you solve your problems
nah i just want to know how i can setup this "kwargs"
🙏
Functions can take two different kinds of arguments. A positional argument is just the object itself. A keyword argument is a name assigned to an object.
Example
>>> print('Hello', 'world!', sep=', ')
Hello, world!
The first two strings 'Hello' and 'world!' are positional arguments.
The sep=', ' is a keyword argument.
Note
A keyword argument can be passed positionally in some cases.
def sum(a, b=1):
return a + b
sum(1, b=5)
sum(1, 5) # same as above
Sometimes this is forced, in the case of the pow() function.
The reverse is also true:
>>> def foo(a, b):
... print(a, b)
...
>>> foo(a=1, b=2)
1 2
>>> foo(b=1, a=2)
2 1
More info
• Keyword only arguments
• Positional only arguments
• /tag param-arg (Parameters vs. Arguments)
This ^
kwarg is just short for keyword argument
im not a dev i just want to know how to definy the name of the personnalized command

Ngl, if you can't do this you're not going to get very far into a bot
You'll need to know at least basic python to code one
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
x == y Checks if two embeds are equal.
New in version 2.0...
@final iron can u tell me where i can learn discord.py ?
what do I use to have it mention me(or the person who wrote the message)?
it seems simple for you and not for me 
what does that even mean lmao
dms
ctx.author.mention
and also make sure u are using an f-string
thanks!
Hey, this is probably just going to be a very simple answer.
I'm trying to make a land claiming discord bot for a minecraft server. When a player does /claim {coord1} {coord2} {color}, it should highlight a square on the map with the chosen color. When I run my current code, I am met with this error: https://pastebin.com/JN0bnFBC
And here is my current code:
https://pastebin.com/Vzfjij2m
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
A hands-on guide to Discord.py
keep in mind that you need python knowledge for this
like pythn basics ?
like more than basics
ok
if you know what decorators, OOP and async programming is
then its enough
or should be
@slate swan a prsonnal question... how much time did u take to learn Python ?
i dont know it was like 2 years ago
Shouldn't map take a function as the first arg?
!d map
map(function, iterable, *iterables)```
Return an iterator that applies *function* to every item of *iterable*, yielding the results. If additional *iterables* arguments are passed, *function* must take that many arguments and is applied to the items from all iterables in parallel. With multiple iterables, the iterator stops when the shortest iterable is exhausted. For cases where the function inputs are already arranged into argument tuples, see [`itertools.starmap()`](https://docs.python.org/3/library/itertools.html#itertools.starmap).
you started 2 years ago and you think you enough learned python ?
i wasnt learning day after day for 2 years obviously
yeah but if i learn day after day how much time it will take to me
approximately ?
im just saying i started learning python 2 years ago and dont know how long it took me to learn it so far to understand discord.py
also i took the hard way
just knowing bare basics and going to discord.py directly
It'll vary, it also depends on how advanced you want your bot to be
which slowed me down
it depends on many things. do you know any other programming language ?
Want to subclass? Extra time. Want to use a DB? Extra time. Want to do http requests? Extra time
nah, map just shows the current map
Theres no args necessary
just a question ... i started learning python yesterday but when i learn something i forget it idk why
It's just /map

and what do you mean by learn?
do you actually code and try out things do some small projects/challenges
or you just watch some tutorial and expect to remember it after few days
cause learning programming is playing with code and seeing what it does when you change somehing this way to learn
i found a digital support of +200 pages and i learn chapter by chapter
No, I'm talking about the built-in map function
Not the command
!d map
map(function, iterable, *iterables)```
Return an iterator that applies *function* to every item of *iterable*, yielding the results. If additional *iterables* arguments are passed, *function* must take that many arguments and is applied to the items from all iterables in parallel. With multiple iterables, the iterator stops when the shortest iterable is exhausted. For cases where the function inputs are already arranged into argument tuples, see [`itertools.starmap()`](https://docs.python.org/3/library/itertools.html#itertools.starmap).
i do it many times but i don't think its enough
try out different "methods" to remember and see which one gets you most out of it
Also I would change your map function name as it's clashing with the built-in function
Makes it more complicated, more unreadable etc
ok thanks anyway for your patience
🙏
for example im such a weird guy i like reading source code and getting in depth how something works to undestand it from the inside
prolly not recommended for start but yeah
!d discord.app_commands.CommandTree.command
@command(*, name=..., description=..., nsfw=False, guild=..., guilds=..., auto_locale_strings=True, extras=...)```
A decorator that creates an application command from a regular function directly under this tree.
@flint heart You can use the name arg instead
The best way to learn is to do stuff
Reading exclusively isn't gonna help you learn that well
Try doing mini projects
Ohhh, I know what you maen
mean*
Thanks!
yeah ofc i meant i learn and i instantanely test what i learned then when i feel ready i start mini projects etc
I'll just change it to like current-map or something
😉
Yeah, you can use the name arg to set the command name
Just saying, this isn't the solution to your issue, it's just something I spotted
You're passing int as the first arguement to the map() function when it should be a function
I don't really use map() so I'm just guessing after reading the documentation
im not into topic but this is valid
!e py list_of_strings = ["1", "2", "3", "4", "5"] print(list_of_strings) print(list(map(int, list_of_strings)))
I ain't gon lie map() confuses me
LMAO I LEFT THE TOKEN IN MY PASTEBIN AND SOMEONE RAN A SCRIPT TO MAKE IT SAY "I GAINED CONSCIOUSNESS" 😆
Also lambda
I just reset it tho, so all good now
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | ['1', '2', '3', '4', '5']
002 | [1, 2, 3, 4, 5]
lambda is witchcraft
how is that
I dunno, I just don't understand it ig
all it does it runs the function on each item from the iterable
oh
map(function, iterable, *iterables)```
Return an iterator that applies *function* to every item of *iterable*, yielding the results. If additional *iterables* arguments are passed, *function* must take that many arguments and is applied to the items from all iterables in parallel. With multiple iterables, the iterator stops when the shortest iterable is exhausted. For cases where the function inputs are already arranged into argument tuples, see [`itertools.starmap()`](https://docs.python.org/3/library/itertools.html#itertools.starmap).
Yeah it does
iterator that applies function to every item of iterable
!d lambda
An anonymous inline function consisting of a single expression which is evaluated when the function is called. The syntax to create a lambda function is lambda [parameters]: expression
I don't understand lambda ngl
How is map different from just using a loop?
Or is it just a faster way of doing it
def f(x):
return x ** 2
# same as
f = lambda x: x ** 2
hmm
how is one line better than a few
also its faster
its not like every for loop can be replaced with it
Yeah ik
but if you have something like ```py
for item in items:
int_items.append(int(item))
Yeah, map would've been useful when I was manipulating spreadsheets
I was doing basically that
It's good when you need that function only once, like in map/filter/other things that take function
(it's slower than a list comprehension when you need to use a lambda for it)
Also about map, filter (+ functools, itertools) - if you can use it without using python (defs or lambdas) then it will give you very good speed.
Because you will have a loop that is fully executed in C without python
Yeah if its in stdlib its prolly faster than manual implementation
anyone know a good tutorial or soemthing on how to host my bot on linode? can't find a good video
Well I don't really know much about linode, but running a bot is the same as running a python file, so ig try finding a tutorial for that
do you know any good vps for canada?
You might wanna checkout the pins in #965291480992321536
Bro
I knew the reason
The bot not detecting the message cause there are another message send before it
Do you have an idea how to solve this?
Write a correct check.
wait_for returns first event on which your check returns True
Other events are skipped
The test contradicts this
You can try
- check is correct in the first message (check only) m.author ......., But the if condition is not correct
import discord
import os
import asyncio
from discord.ext import commands
intents = discord.Intents.all()
prefix = "!"
Token = os.environ['token']
bot = discord.ext.commands.Bot(prefix, intents=intents)
@bot.command()
async def buy(ctx):
guild = bot.get_guild(1142023460533571635)
bank_id = 1113386046021963776
bank = guild.get_member(bank_id)
await ctx.send(bank.mention)
await ctx.send("how are you?")
probot = guild.get_member(282859044593598464)
try:
Message = await bot.wait_for("message", check=lambda m: m.author == ctx.author and m.channel == ctx.channel, timeout= 50.0)
message = Message.content.lower()
except asyncio.TimeoutError:
await ctx.send("Time ended")
else:
if "hi" in message:
await ctx.send("Thanks for buy")
@bot.event
async def on_ready():
print("Online")
bot.run(Token)
You are checking for any message from the same author
You are doing that not inside the check
But after getting the message
Is this solve it?
- I don't want specific contact I just want to check if 2 things in it
Yes
This for a specific content
Can you tell me how to do this?
As you already did it. But inside the check.
like
100 in m?
m.content
Ok I will try and test
I can't copy the error
The code
import discord
import os
import asyncio
from discord.ext import commands
intents = discord.Intents.all()
prefix = "!"
Token = os.environ['token']
bot = discord.ext.commands.Bot(prefix, intents=intents)
@bot.command()
async def buy(ctx):
guild = bot.get_guild(1142023460533571635)
bank_id = 1113386046021963776
bank = guild.get_member(bank_id)
await ctx.send(bank.mention)
await ctx.send("how are you?")
probot = guild.get_member(282859044593598464)
try:
Message = await bot.wait_for("message", check=lambda m: m.author == ctx.author and m.channel == ctx.channel, timeout= 50.0 and "100" in m.content and bank.mention in m.content)
message = Message.content.lower()
except asyncio.TimeoutError:
await ctx.send("Time ended")
else:
ctx.send("I`m good")
@bot.event
async def on_ready():
print("Online")
bot.run(Token)
I missed await but nvm
The error about m




