#discord-bots
1 messages ยท Page 143 of 1
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.")
???
if 'praying' or 'pray' in message.content:
...
is interpreted to be
if ('praying') or ('pray' in message.content):
...
which is interpreted to be
if True or ?:
...
where ? is True or false. Whatever it is, it's always true

Though you could just do if pray in message.content because pray is in praying
if message.content in (..., ...) would be the best solution
!e print("pray" in "praying for you")
@sick birch :white_check_mark: Your 3.11 eval job has completed with return code 0.
True
to check multiple contents
Doesn't work if you want to just compare words
Hey @sharp nest!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
hmmm
If you want to compare if one of multiple words is in a message:
words_list = ["hello", "world", "word", "other", ...]
if any(word in message.content for word in words_list):
...
cocacolastic
bump
do i have to add that if message.author
etc. etc.
Or better yet, extract into function:
import typing as t
def has_word(words: t.Sequence[str], sentence: str) -> bool:
return any(word in sentence for word in words)
yes
ahhh
Yeah you still need the if message.author == client.user: return as the first thing inside the function
i feel so dumb rn lol
can anyone host my bot
Not a good idea
Depends how much power it consumes
its just a simple bot i need to run 1 slash command
pretty sure u can stop running it once i do the slash command
Just run it on your PC?
https://paste.pythondiscord.com/obuwehuwir
how can I make the message go to the channel with id 1046124838772813954
cant
having 2 many problems
also why ask "depends" if ur just going to tell me to do it myself
I thought you would host it long-term
dO i SeE rObIn AbUsInG FlExInG rEaCtIoN pErMiSsIoNs ๐
Host != Run
cause hosting a bot is something that you should do yourself?
uhhh ..?
just fix those problems and run the py file
how's that hard
dont recall asking
You want to run the bot, not host it for the long time from what I understood
...?? what
if i ask anyone for a favor and u dont want to do the favor why type
yea i just need a one time run
That's easily done on any machine
client.run('yourtoken')
What problems do you have
and then click this thing
Ignoring exception in on_connect
Traceback (most recent call last):
File "/home/runner/QuixoticConfusedModem/venv/lib/python3.8/site-packages/discord/client.py", line 377, in _run_event
await coro(*args, **kwargs)
File "/home/runner/QuixoticConfusedModem/venv/lib/python3.8/site-packages/discord/bot.py", line 1164, in on_connect
await self.sync_commands()
File "/home/runner/QuixoticConfusedModem/venv/lib/python3.8/site-packages/discord/bot.py", line 738, in sync_commands
app_cmds = await self.register_commands(
File "/home/runner/QuixoticConfusedModem/venv/lib/python3.8/site-packages/discord/bot.py", line 531, in register_commands
prefetched_commands = await self._bot.http.get_guild_commands(
File "/home/runner/QuixoticConfusedModem/venv/lib/python3.8/site-packages/discord/http.py", line 366, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In guild_id: Value "Ellipsis" is not snowflake.
This example requires the 'members' privileged intent to use the Member converter.
import discord
intents = discord.Intents.default()
intents.members = True
bot = discord.Bot(
debug_guilds=[...],
description="An example to showcase how to extract info about users.",
intents=intents,
)
@bot.slash_command(name="userinfo", description="Gets info about a user.")
async def info(ctx: discord.ApplicationContext, user: discord.Member = None):
user = (
user or ctx.author
) # If no user is provided it'll use the author of the message
embed = discord.Embed(
fields=[
discord.EmbedField(name="ID", value=str(user.id), inline=False), # User ID
discord.EmbedField(
name="Created",
value=discord.utils.format_dt(user.created_at, "F"),
inline=False,
), # When the user's account was created
],
)
embed.set_author(name=user.name)
embed.set_thumbnail(url=user.display_avatar.url)
if user.colour.value: # If user has a role with a color
embed.colour = user.colour
if isinstance(user, discord.User): # Checks if the user in the server
embed.set_footer(text="This user is not in this server.")
else: # We end up here if the user is a discord.Member object
embed.add_field(
name="Joined",
value=discord.utils.format_dt(user.joined_at, "F"),
inline=False,
) # When the user joined the server
await ctx.respond(embeds=[embed]) # Sends the embed
debug_guilds=[...] you need to put actual server IDs to there or remove this kwarg at all
yeah
at set would be faster
wdym
bot = discord.Bot(
debug_guilds=[yourServersID],
description="An example to showcase how to extract info about users.",
intents=intents,
)
or make sure elipissisiis is an actual INT
if you wanna get your server's id you just need to right click on the icon and click the button that says copy id @turbid shale
!e
print(type(...))
@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.
<class 'ellipsis'>
https://paste.pythondiscord.com/obuwehuwir
how can I make the message go to the channel with id 1046124838772813954?
pls help me
get the channel and channel.send
i have my id where do i put it in the code
now you have to go to the debug_guilds=[...]
and you delete those "..." and paste the ID
Ellipsis is ...
That's a meaningful construction in python
Gotta love tutorials
Can anyone tell me if we are allowed to track amount of online users on servers and their statuses (online/idle/dnd/offline)
why won't we allowed to do so?
I heard somewhere that it's not
you definitely cna
there's literally an event for it lol
Well many bots make graph of yr status, so I am betting on u can
K good
And... if some day u get an error saying Discord banned your bot from accessing their API or a DM from Discord, you know that its not allowed
"Certified Nurse Assistant"? ๐ง
LMAO
Well I googled it
Next, designate your official server for your app (for example, your App Support Server, App Community Server or App Development Server).
how do i do this?
huh
Only google gives those kinda full forms so I understood lol
are u trying to get the badge lmao
ye
literally anyone can get it so i might as well try
๐
how do i do that i dont see anything on the bot
its not with the bot lol
where is it
u need to enable community in one of your servers
Wish discord made "verified bot developer" badge so it's deserved
Wait what server badge are we talking about?
i did
they never will make another limited badge like so.
its been mentioned by them multiple times
i already enabled
Is this one limited?
nope
Well why would the verified bot developer badge be limited
Just give it to all people who have verified bots ๐
bro
and would cause issues
does aznyone see my messages
with ppl spamming bots with fake servers
They have a protection against that
its trash lmfao
bro
If you read an article about bot verification
What's so trash about it
duyde does no one see my msgs
No sorry we are having an argument conversation
Lmao its already hard to get yr bot verified by making sure it isn't in any bot farms/ghost servers how harder do u want it to be?
a civil argument debate
wgere do i go to make my bot my support
it is not hard lol. i see ppl farm shit all the time and get verified
Well yea, but then due to them genuine bots either get delayed verification or are denied verification (has happened with me)
bro try to google for once.
https://discord.com/developers/active-developer
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
what did u get denied for
I should probably verify my antispam bot but I am too lazy ๐ฅฑ
this api doesnt tell me how to set up a support, and i already tried google didnt see anything
i applied once, and got verified within a day lmao. i got lucky with timing
- i didnt ask u
Inorganic growth
It took me a month
Took my other bot like 3 months
Lmao it was literally a day before their winter holidays start that my bot got verified
sheesh
i already told you. enable community in one of your servers then go to that link and click the drop down and select the server u enabled commuinty
the link u sent is the one to apply for the badge
is that not what you are doing????????????????
i need to apply my bot for a support server
Lmao
you choose the support server from that page itself, just enable community for the server that you are planning to choose
and theres no link for that on any of their sites
he dont listen
Maybe sarth will be able to explain in a better way lmao
and don't be lazy enough to not reload your page after enabling community on discord
im asking how do i setup my server support for my bot
u dont have any bots with slash commands
no link to that page has been sent
yes i do
not with a global slash command
then u need to wait for them to register
maybe the slash command has the guild_ids kwarg set
or that
how do i make it global
remove that kwarg
show ur cmd
@turbid shale does your bot has application commands or normal commands
well app commands or tree commands or how you call them
This example requires the 'members' privileged intent to use the Member converter.
import discord
intents = discord.Intents.default()
intents.members = True
bot = discord.Bot(
debug_guilds=[1046119225170874499],
description="An example to showcase how to extract info about users.",
intents=intents,
)
@bot.slash_command(name="userinfo", description="Gets info about a user.")
async def info(ctx: discord.ApplicationContext, user: discord.Member = None):
user = (
user or ctx.author
) # If no user is provided it'll use the author of the message
embed = discord.Embed(
fields=[
discord.EmbedField(name="ID", value=str(user.id), inline=False), # User ID
discord.EmbedField(
name="Created",
value=discord.utils.format_dt(user.created_at, "F"),
inline=False,
), # When the user's account was created
],
)
embed.set_author(name=user.name)
embed.set_thumbnail(url=user.display_avatar.url)
if user.colour.value: # If user has a role with a color
embed.colour = user.colour
if isinstance(user, discord.User): # Checks if the user in the server
embed.set_footer(text="This user is not in this server.")
else: # We end up here if the user is a discord.Member object
embed.add_field(
name="Joined",
value=discord.utils.format_dt(user.joined_at, "F"),
inline=False,
) # When the user joined the server
await ctx.respond(embeds=[embed]) # Sends the embed
what is debug_guilds? literally nothing in docs ab that lol
oh pycord
so yeah remove debug_guilds because that makes ur cmds NOT global
ฯ๐
if i remove that itll still run correctLy?
yup
Traceback (most recent call last):
File "main.py", line 11, in <module>
@bot.slash_command(name="userinfo", description="Gets info about a user.")
NameError: name 'bot' is not defined
removed it and got an error
bro i said remove debug_guilds
i did it and nothing on this page https://discord.com/developers/active-developer
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
u literally remove the entire bot definition lol
hence why bot isn't defined
and if u fixed it then u just need to wait a couple mins then refresh the page
ok
How do two optional arguments works?
Idea:
` - command arg1 Optional[arg2] Optional[arg3]
- command arg1 arg3
- command arg1 arg2 arg3`
I cant figure out how i can allow arg3 being passed without using it as arg2 
wdym
when i do the kick command in a slash command = raise TypeError(f'parameter {parameter.name!r} is missing a type annotation in callback {func.qualname!r}')
TypeError: parameter 'reason' is missing a type annotation in callback 'kick'
๎บง
what does this mean
lmfao wtf. can u show code?
can you explain better
tried the easiest lol
@client.tree.command(name="kick", description="Kicks a member")
async def kick(interaction: discord.Interaction, member: discord.Member, *, reason=None):
await interaction.member.kick(reason=reason)
thats the kick command lol
u set to none
ah
I figured it out
what do i set that to
if none dont supply a reason for the kick
alr
if none .kick()
else .kick(reason=reason)
Add a type hint to reason argument
Why
interaction didnt have .member inside of the thing
wait
permissions arent working wth
@commands.has_permissions(kick_members=True)
How do i add that to my line of code
does it go under async or like
No... That stays before async
oh alr
@stuff
@commands.has_permissions(kick_members=True)
async def test():
yuh
wym
BUTTONS ARE NOT APPCMDINTERACTIONS
Oh
sent old ones... yes changed that
i know.. but the things the guy from disnake didn't make me understand
im the guy from disnake bro lmao
we weren't talking about the same things.. the callback u sent me was not what i wanted
original_message() does not exist because u never sent a message using the button
read docs
This is why im using self.message
hfaksdjfhgkjwsrtghjksndfbasdf
Also this worked like 2-3 weeks ago
so i suppose changes happened to disnake when it comes about this
no way that worked
im telling you it did
no it did not you never sent a response for clicking the button so there is no way an original_response/message exist
@slate swan
i didn't change the code since then and it always worked.. i've noticed this recently
i've seen that already
but i thought it's because of the response.. that's why i came up with defer
async def callback(self, interaction: disnake.MessageInteraction):
message = interaction.message
this u told me
why do u think i have self.message in the def
holy bro. it is an example showing u how to properly get the message attached to the button
i told you.. the way i was doing it worked that's why im so confused and i can't understand
not possible.
^^
idk why u dont just read docs
when u click the button.
you are trying to edit the message right?
Ok i understood that but this is confusing me
well yes it edits the button as disabled
yes
so you need to use interaction.message
because original_message is used for fetching the RESPONSE message
which you have yet to send a RESPONSE message so it does not exist
yup
Hey @slate swan
I made a slash poll command but it got a little problem can you help me to fix it?
sup
im getting the same error?? But i changed the code
1 sec lemme run docker again
u never changed it lol
look at ur error
Bro im not that dumb rn ik how to save the code
you are dumb
Yes that's why im confused ๐คฃ
So I made this poll command
impossible
Buy when I use it this happen
want me to sharescreen rn?
your error is smarter than u
All the unchoosed options show as None but I don't want it to show how can I do it? @slate swan
Yes I wanna do that but idk how
So how to make if option is none don't add to embed here
@slate swan
no idea i aint that smart
for idx, option in enumerate(options) if option not None i giess idk
.
@slate swan
why u keep deleting code bruh i dont have photographic memory
try
for emoji in numbers[:len(options)]:
for option in options:
if option != None:
aawait message.add_reaction(emoji)
i am certain there is prob a better way but i aint that advanced lmao
Anyone know what @application_checks.has_permissions(manage_messages=True) is but for cogs?
I haven't coded in months, when my bit is ratelimited what do I send in the console, kill 1?
*bot
It didn't worked all happend that it started to put reactions slowly but still 10 @slate swan
for emoji in numbers[:len(options)]:
for option in options:
if option != None:
await message.add_reaction(emoji)
he had 2 a on await
Yes I made only 1 a
what the error?
is that the hole code or just one part of it?
if your bot is getting ratelimited you're probably doing something wrong or abusing discord on purpose
No it just has a lot of code running 24/7
Part of it
ok
Nothing's wrong or against tos, my bot has been around for a long time, never been abusing anything, just running 8 cog files and a ton of code in main.py all the time
@merry sail
Do you use nextcord or dpy?
replit?
If u r good on slash commands I can show you full code if you can help me tho @errant coral
there's so many things that can cause rate limits when used improperly i don't even know where to begin
Yeah, just downloaded the app today and found it was offline lol
Well, thats why lol
nextcord or dpy? I code /commands so im oket at it
Why
ok i use nextcord but i can ask a person who knows it and he will probobly aswere fast
Which better nextcord or discord.py?
Depends
i would say discord.py is hareder and nextcord ez
Oh
what
i used to code dpy but not now
Is there a free alternative? I'm kinda broke so yeah...
Good ones? Nope
Depend on what
Bro I coded discord.py when it wasn't being developed
hey im trying to make a drop down menu and i keep getting AttributeError: 'Interaction' object has no attribute 'disabled', dont know what i did wrong been doing this for the past 10 minutes
class selectm(View):
@discord.ui.select(
placeholder = "Select Category",
options = [
discord.SelectOption(label="Utility", value = "1", description = "Utility Commands", emoji="")
]
)
async def select_callback(self, select, interaction: discord.Interaction):
select.disabled = True
if select.values[0] == "1":
await interaction.response.edit_message(embed=discord.Embed(
description = "hi"
))
@bot.command()
async def help(ctx):
view = selectm()
await ctx.reply(mention_author=False, embed=discord.Embed(
title = "Enemy Help Menu",
description = "a rich discord bot designed at your needs.",
color = color
).add_field(
name = "Need Help?",
value = "use the dropdown menu below to view all the commands."
).set_footer(
text = "20 commands"
), view=view)```
Preference
ok
Nope there's always a catch or drawback if it claims to be free
But if pro on dpy and pro on nextcord who can make better bot?
select is an interaction object and interaction is a select menu, you would need to switch the arguments around in your parameters
the one that are the fastes of coding
ah i just realized that, thanks!
Lmao
The person who doesnt use either would be a "pro"
or the one that use nextcord if they are same speed.
not sure
i think its less code for a nextcord command
What do you suggest doing now then? I've always enjoyed coding bots but I don't have money to spend on a code editor
Fr lol
code editor like vs code?
What do you mean
Anyway r u good on slash commands at dpy? @primal token so u can fix my problem
You dont need to spend money on a code editor, just a VPS, you can maybe look on student accounts etc
Visual studio code*
Ye
I personally dont use dpy
VPS? What's that
Visual studio is free if that what you looking for
Yall going to make me use nextcord now lol
A virtual private server
you want a start up file?
I dont use nextcord either lol
I host my bot off of my own device lol
disnake best
Same issue from earlier?
Wow
Is it on mobile?
No I fixed it
he needs to remove reactions if option is none
both
Debatable
@ember nest can you paste your code
i tried but i aint that advanced.
@sick birch
Can you tell me where to download it?
lmao
ill send dm
Now only 2 options but 10 reactions
send your code
fields = [("Options", "\n".join([f"{numbers[idx]} {option}" for idx, option in enumerate(options) if option != None]), False),
("Instructions", "React to cast a vote!", False)]
for name, value, inline in fields:
embed.add_field(name=name, value=value, inline=inline)
message = await channel.send(embed=embed)
for emoji in numbers[:len(options)]:
await message.add_reaction(emoji)
Here
I'd argue buttons are usually superior to reactions for this type of thing
or a select menu
I am not that professional yet
Lmao
So how to make the reactions add same as the options that not None ? @sick birch
Where do you define options
Uh lemme send full code again then lol
Yes please
So loop through each option in options using enumerate, and add that number to the reactions from numbers
Yeah
I'd also probably filter options so you can use it in both your list comp and here
filtered_options = filter(lambda x: x is not None, options)
...
fields = [for idx, option in enumerate(filtered_options)]
And the later on
for i, option in enumerate(filtered_options):
await message.add_reaction(numbers[i])
just a thought of course not 100% sure if it'll work
Lemme try
You could probably just do ```py
filter(lambda x: x, options)
Reactions didn't even add @sick birch
Nice, ghostping
fair enough
but being explicit can't hurt here
Sorry it's enumerate(filtered_options): ... the 2nd time
Tbh theres a lot more overhead with filter here, you could really just do ```py
for idx, item in enumerate(options):
if item is None:
continue
fields.apend(...)
And did you mean to make an empty list here? ```py
fields = [for idx, option in enumerate(filtered_options)]
Actually, wouldn't this be a SyntaxError
Yall got me confused fr xD
@sick birch
@pliant gulch help please?
Bruh I got confused and yall gone lol
what's this supposed to do?
Add reaction (numbers) to the same len(options) is not None
so if I've got 6 options, it should add 6 reactions from numbers 1-6?
Yes
There is 10 options 2 is required and other 8 in None
option1: str, option2: str, option3: str = None, 3, 4, 5, ........
And numbers is 1๏ธโฃ 2๏ธโฃ 3๏ธโฃ etc
Emojes
why're you using filter?
To get the options that is not None
can't you just directly check that in your list comp?
oh, no, nvm
is it sending the message? any errors?
Did that but didn't work too
Hello, I'm trying to authorize my bot (app) but it's not working. I click on authorize, but it does nothing (it doesn't come to the list of authorized bots), it just redirects me to the web. (ping me if you know what it might be)
not sure if this is related to dpy. I am trying to run an asynchronous function outside by using asyncio but I am getting event loop errors. Is there a way to do this through dpy? only needs to be run once
what exactly are you trying to do, there might be simpler ways
well
res = asyncio.get_event_loop().run_until_complete(config.dbQuery("SELECT name, filename FROM badgelist"))```
hopefully that explains it
it runs inside my __init__ function
the db query is an asynchronous function cos of the library btw
just use the setup_hook
!d discord.Client.setup_hook
await setup_hook()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A coroutine to be called to setup the bot, by default this is blank.
To perform asynchronous setup after the bot is logged in but before it has connected to the Websocket, overwrite this coroutine.
This is only called once, in [`login()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.login "discord.Client.login"), and will be called before any events are dispatched, making it a better solution than doing such setup in the [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready") event.
Warning
Since this is called *before* the websocket connection is made therefore anything that waits for the websocket will deadlock, this includes things like [`wait_for()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_for "discord.Client.wait_for") and [`wait_until_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_until_ready "discord.Client.wait_until_ready")...
this coro is triggered before the bot runs, only once in runtime
this will be ran while the bot is running tho
no, before it is running
sorry can you give me a use case, im a little confused
.
i worked around this by nesting my asyncio loop with nest-asyncio library
show some code
or is this discord related?
by adding the bot
discord related
try clearing your browser cache
I try it in app discord and my friend try it too
Most likely the wrong settings.
Don't know what you are doing.
just app that get their name
You can send images, could you show what permissions and scopes you selected?
only identify
Isn't there a 24-hour limit?
But you also need bot for a bot application.
and copy the link
wait a minute
I can't read 25% of the error.
oh
Yes I have
I just created bot then I add random redirect then create url with identify and it dont work.
What doesn't work? And what do you expect it to do?
bot is not added to the list of authorized bots in settings
As in
How are you handling the redirect?
I must?
I put random domain like https://discord.com
That won't work.
Can you show me explain?
Well you need to use Oauth to handle the payload.
Why would you want identify if you aren't going to use it anyways?
Im only trying something new to make
Nice, someone else is also making a bot with the ability to spam. I have a question for you - do you have some sort of โ!deactivateโ command coded into your bot to stop the spamming? I donโt want my bot to spam forever, but Iโm struggling to code a counter feature for it.
We aren't helping with this for obvious reasons.
Lol, completely understandable. Though, if those were my intentions, Iโm not exactly sure why Iโd be trying to code a command to stop the spamming ๐
Are you having the same issue with recursive calling?
If I'm right I think this is just another case of on_message calling itself - nothing malicious
Robin.. so innocent still..
just tryna look on the positive side
Lmaoo
Even I was trying to make a raid bot, the while loop has a huge delay on it. It isnโt a constant spam, the bot spits out like 4 messages and then pauses for 5 seconds.
LMAO
that's due to rate limits
Put in place for exactly that reason
For sure, I'd make the most overengineered raid bot there is.
rate limits your mortal enemy
More like detect activity of staff in the discord and then taking rate limit into account and strike when there is little to no staff.
Iterate over guild id's and invite urls.
It'd be a massacre.
devious indeed
๐คจ ๐ธ

I did made an alt for Discord really quick to join a server and to my surprise if you join 4/6 servers in 10 minutes or so I already needed to verify a phone number since it thought I was self botting.
Funny, my bot acts like me for some odd reason
not really a lot of servers per 10 minutes
one could easily stumble upon that just joining a few new servers
print(โHello Worldโ)
funny quotes
found the mobile user
๐๐ญ๐ญ๐๐ญ๐๐๐๐ค
@sick birch Remember the time we had like 3/4 people a week asking how to set a mobile status for the bot using raw requests lol
And i found where you live https://www.google.com/maps/place/Ohio,+USA/@40.3633984,-82.6692525,7z/data=!3m1!4b1!4m5!3m4!1s0x8836e97ab54d8ec1:0xe5cd64399c9fd916!8m2!3d40.4172871!4d-82.907123
i'm in your walls robin
what goin on in ohio
๐ญ
You know you've seen it all when instead of grimacing when looking at raid bot you instead look at all the places you could make it more efficient
My country fits 2 times in Ohio
๐
Then you know you are a true coder.
swag like ohio
Deflects with free healthcare
๐ฆ
inb4 monkey patching discord.py's ratelimit with a semaphore system so you can send 5 messages all together at once without getting ratelimited
possible btw, tested when writing my discord API wrapper
@sick birch
Although deleting messages is funky
I normally just stop the running the code cause I don't always expect for it to spam
@pliant gulch please help bro
Format your answer question before pinging.
filtered_options = filter(lambda x: x, options)
fields = [("Options", "\n".join([f"{numbers[idx]} {option}" for idx, option in enumerate(filtered_options)]), False),
("Instructions", "React to cast a vote!", False)]
for name, value, inline in fields:
embed.add_field(name=name, value=value, inline=inline)
message = await channel.send(embed=embed)
for i, option in enumerate(filtered_options):
await message.add_reaction(numbers[i])
The reactions are not showing
Why don't just use buttons and put the text in the buttons.
Evolution ๐ค
Wait if I hosted my bot to an online server, which would run it constantly (so it stays online). If I had sys.exit() in my code, and all the conditions were met to execute that, would it technically not even work? Because the code would just rerun and the bot would come back online
I don't know how to and 10 buttons would be a mess
There is up to 10 options
Select menu with submit button is pretty clean.
Not unless you have a process manager to handle that for you
Not when it's dynamic
Idk how to do that though
I never watched a video or learned how to make buttons
That's why I am using reactions
Same.
May be the reason I suck at coding.
;-;
Robin is good with raw reaction payload.
He helped me once and provided bunch of code too.
I just want to fix my code thats it's not showing reaction
"discord.py" raw payloads
And I will be done with this command
try print("Filtered options:", *filtered_options)
See what it prints out
Make sure it's not conditional or affected by any control flow
Move the print outside of any if statements
wait nvm
that's odd it should at least print "filtered options"
Unless whatever hosting provider you're using is consuming stdout for whatever reason
what
sorry brain dont work
When does it ever
I didn't understand that too
facts
๐ฆฆ
Bruh I don't know why I came to slash command this commad was working well as prefix command lmao
anyway so you don't know how to fix it? @sick birch
hi
Well I would but your app or whatever you're using seems to be eating up stdout
Might want to see if you can get that fixed
Can u just take the command edit or whatever you do to make it work in any look and I'll try to learn more about it later? Lmao
I just need this command be done before tomorrow
To use on my server
what's the problem here, are you getting an error?
Nah but reactions are not adding on my poll command
Nah it was working well before as prefix command
It's unicode already
.
- numbers showed on options
Dude it's been like 3-4 hours I am on this channel and none can fix it I give up I going to sleep lmao
how can someone help you if you delete all the code
I kept sending the code for 3-4 hours none helped tho
Just nevermind bro I'm going to sleep good night
gn
If anyone is good at discord bots can they dm me need small project done $โฌ$
!rule 6 9
6. Do not post unapproved advertising.
9. Do not offer or ask for paid work of any kind.
gimme 15kโฌ
How do I find ppl
Is it possible to program a discord bot that converts youtube urls into mp3s?
Possible? Yes
However it would violate Youtube's terms of service
when using discordpy, the Message.add_reaction(...) method appears to be hanging forever?? Any help?
code? traceback?
ctx.send is a coroutine
nope
there is no output after this
after adding this print statement:
the reactions passed are these:
what is embed anyway?
hey guys
Embed doesn't have an add_reaction method
the message probably does
embed is a type of message, not the message itself (is what I would think the issue is)
ah sorry I then set embed to the value return from ctx.send
and i believe after that embed should have an add_reaction method
anybody know how you can set a server for a discord bot so that you can make a developer channel?
im having trouble setting a support server in the dev portal because i cant figure out how
you should iterate through reactions.values, not just reactions, otherwise you're iterating through its keys
are you trying to get the active dev badge?
uh
"version" is missing a comma
thank you frustrating that i couldnt catch that for a while....
what is that
what
when did they add this thing
weird that no exception was raised ๐ค you might want to check error handlers if you've got one
oh, idk what you mean then
i just want to make a dev channel for a bot im working on
idk how that works, sorry
yeah i think i overlooked it because of that and just thought the method was hanging due to rate limiting or something. thanks for the help!
!rule 1 2
1. Follow the Python Discord Code of Conduct.
2. Follow the Discord Community Guidelines and Terms Of Service.
noice
uhhhh
about this, i think it's because i have to import settings
but what i did was doing from python_settings import settings
right?
if that's the case then how do i import settings, cause i dont know what's the library that i would have to download
nvm i fixed
im using railway.app
just make a github repo and link it
got a credit card/debit card?
yea oracle cloud has insane free tier
That's what I use
i can't have a cc yet sadly
Is there a way to pass the message itself into a view? I've got a tricky situation and I can't quite figure it out. A person sends a message (message) then the bot reacts await botchannel.send('I like pie', view=view(message))
This works to pass the original person's message into the view to pull stuff like guild and channels and whatnot. But I want to edit that message that's sent with botchannel.send with a new view. I've tried a few different things but can't get it to work
view = View()
msg = await send()
view.message = msg
That's just a thing by default? I can just view.message.edit(view=self) after disabling buttons?
you could just interaction.response.edit_message as well
It's not a response to an interaction though. The interaction is a message, which there's no response to because the message is sent in a different channel
then this yeah
Alright I'll give that a try. Thanks
no, it doesn't really have to be message, it can really be anything https://discordpy.readthedocs.io/en/stable/faq.html#how-can-i-disable-all-items-on-timeout
you're basically just setting an attribute
depends on what you want it to be lol
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
@bot.event
async def status_task():
while True:
await bot.change_presence(activity=discord.Game(name=f"mit {len(bot.users)} membern | /help"))
await asyncio.sleep(30)
It does count only 0 member/s ...
Want my bot to count all members in all guilds.
cant find the error bc I dont get one xd
Does it update after running for a while?
You may not have member intents enabled
u mean intents.member=True? or in dev
Both
did it
intents = discord.Intents.default() do I need to put the intents members in here ? bc I got it under it ๐
I do have :/
Both
Is it enabled in your developer portal?
Yes it is
Also do you have a custom event you're dispatching?
do I need intents.all() or .default() ?
I don't remember status_task to be a discord.py event
Change it to all and make sure you have all 3 toggles flipped in dev portal
Yeah but are you calling status_task manually or dispatching a custom event?
Can I see where you're dispatching the event?
I dont get the question.
Like it's not a regular event so discord.py won't call it for you
So you must be calling it yourself somehow, I'm just wondering how you're doing that
it works now I just had to change Intents.default to .all
can I make this invisible so no one sees it ? I want a anonymous text
You want ephemeral=True for a message only that person can see? Or are you asking about just sending a message instead of a response
wait Ill show everything
thats what it looks like and I want the "SyntaxAki....." to not be shown
Ah then you just want to defer first and then send as regular message
!d discord.InteractionResponse.defer
await defer(*, ephemeral=False, thinking=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Defers the interaction response.
This is typically used when the interaction is acknowledged and a secondary action will be done later.
This is only supported with the following interaction types...
Or send an ephemeral message to avoid error followed by an interaction.channel.send
I do a lot of stuff across channels so I always prefer ephemeral stuff lol
Ik what u mean but I dont get where to put it in the code
What code do you have so far?
@bot.slash_command(name="beichten")
async def beichten(interaction: discord.Interaction, beichte: str):
embed = discord.Embed(title=f" :mute: Beichte")
embed.add_field(name=f"Beichte von {interaction.user}", value=beichte)
await interaction.response.send_message(embed=embed)
await defer(*, ephemeral=False, thinking=False)```
do not think I get smth atm its 4.27 am here rn
Everything is good but the last line
You also need to flip the order
huh
Actually I take it back it wasn't good lol
First you should await interaction.defer()
Then you can send it like usual from interaction.channel.send
Lots of fun new stuff like slash commands buttons and modals
Ic.... so the "await interaction.defer()" need to be infront of the embed sh
Just needs to be before the interaction.channel.send()
@bot.slash_command(name="beichten")
async def beichten(interaction: discord.Interaction, beichte: str):
embed = discord.Embed(title=f" :mute: Beichte")
embed.add_field(name=f"Beichte von {interaction.user}", value=beichte)
await interaction.defer()
await interaction.channel.send(embed=embed)
So like that?
bc it doesnt work. No errors :]
need to eat some.
Does the bot say thinking in discord?
Yes then it doesnt replyโฆ
Thinking for a while then doesnโt reply
Do defer(thinking = False)
I'm not familiar with reading lines from a file, I'm sure someone here is
use aiofiles and do readlines then use a for loop to make embeds add the lines in the desc if the content is huge split it up between multiple embeds
google yo best friend and youtube
<insert hi Asher gif here>
Nice
when i try start my bot come this message
Maybe (ephemeral = False, thinking = false)? You need to get rid of the thinking
await interaction.defer(ephemeral = False, thinking = false) u mean like that?
Yea but False, not false
this one-
Alright I give on the deferred message. Haven't done enough with it myself. Try this. Comment out that line and put in a await interaction.response.send('test', ephemeral = True) and see if that at least sends the embed under it how you want it to
it does send on my old method too...
I just want to get rid of who used the command.
It should be a anonymous command thats my prob
I dont want others to see who used the command
@sick birch sorry for the tag, do u maybe know why?
Show me what your code looks like now then. If it shows who used it then you have an interaction.response somewhere
@bot.slash_command(name="beichten")
async def beichten(interaction: discord.Interaction, beichte: str):
embed = discord.Embed(title=f" :mute: Beichte")
embed.add_field(name=f"Beichte von {interaction.user}", value=beichte)
await interaction.defer(ephemeral = False, thinking = False)
await interaction.channel.send(embed=embed)
why you defering for a simple command that sends a message
you can simply use interaction.response.send_message
He doesn't want it to show the person who used the command
my bot canยดt start i have a error code but idk why
I just said what I want.
the defer response will still show who used the command, kinda against the cause?

set ephemeral to True in there
and take the thinking = false out there?
yep
an easier workaround will simply be ```py
await interaction.response.send_message("your message has been posted!", ephemeral=True)
await interaction.channel.send(...)
Should only be in an ephemeral message though which you can dismiss
solves all your issues
ahhhh
Deferring is weird. I don't like that lol
gimme a sec
same, but Discordโข๏ธ
bro ur the best, haha thank you ๐
This is what I tried recommending. I like this more better
my bot canยดt start i have a error code but idk why has someone a idea
thinking (bool) โ Indicates whether the deferred type should be InteractionResponseType.deferred_channel_message instead of the default InteractionResponseType.deferred_message_update if both are valid. In UI terms, this is represented as if the bot is thinking of a response. It is your responsibility to eventually send a followup message via Interaction.followup to make this thinking state go away. Application commands (AKA Slash commands) cannot use InteractionResponseType.deferred_message_update.
But yeah it looks like it's solved
Are you using discord.py or pycord?
it is , thank you anyway hahah. Sorry for the mention again.
pycord
that's not discord.py
you're probably following some forks tutorial
No worries. I'm in and out of a bunch of help channels - didn't quite catch the mention. My apologies :P
uninstall discord.py / any other lib that uses discord namespace
and then install py-cord
pip list to see if you have discord.py and pycord installed at the same time
Its alright, u doing good : D
i uninstall discord.py i had only this
is bot a commands.Bot there, or discord.Bot?
commands.Bot
it should be discord.Bot
you have multiple versions of python installed
be specific to the version that has py-cord installed while running the code
i had 3.9 uninstalled and 3.10 installed
type python in terminal and press tab, you'll know
python --version too
how did u have it unistalled
over microsoft store
u created a venv? or working on global
i created a new venv
python -V basically shows tue version registered with python namespace
the tab will list all commands starting with python including all other versions too 
ahh you didn't activate it as your environment then
?
activate venv and install packages there
!venv the command, and stop ?
Virtual environments are isolated Python environments, which make it easier to keep your system clean and manage dependencies. By default, when activated, only libraries and scripts installed in the virtual environment are accessible, preventing cross-project dependency conflicts, and allowing easy isolation of requirements.
To create a new virtual environment, you can use the standard library venv module: python3 -m venv .venv (replace python3 with python or py on Windows)
Then, to activate the new virtual environment:
Windows (PowerShell): .venv\Scripts\Activate.ps1
or (Command Prompt): .venv\Scripts\activate.bat
MacOS / Linux (Bash): source .venv/bin/activate
Packages can then be installed to the virtual environment using pip, as normal.
For more information, take a read of the documentation. If you run code through your editor, check its documentation on how to make it use your virtual environment. For example, see the VSCode or PyCharm docs.
Tools such as poetry and pipenv can manage the creation of virtual environments as well as project dependencies, making packaging and installing your project easier.
Note: When using PowerShell in Windows, you may need to change the execution policy first. This is only required once per user:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
I didnยดt understand this ๐
Do I have to do this in the folder where the bot is inside or it doesn't matter
you do that wherever your venv is located
i try this is doesnยดt work ๐
Does anyone know how im getting this error? Please helpppp
just how the fu im so fkin g confused
how do I make it where the link part has to start with "https://"
What do you mean exactly?
so the "link" part is a message variable, so I want it to only go through if the link starts with https://
you could just use an if statement
if 'https://' in link:
# do something
if it is in the link it'll return True
if it's not in the link it'll return False
i want to create a task that changes the bots status between multiple pre programmed ones after a set amount of time. how exactly would i go about that
excuse me if I look dumb, im pretty new to coding. I'm trying to make it where if it doesnt have the link it will delete the message and say "your link is not valid" but it isnt deleting the message, how can I fix that
can you copy and paste that command here
@slash.slash(description='Start a pickup')
@commands.has_any_role('Captain')
async def pickups(ctx, host: discord.Member, type: discord.Message, link: discord.Message):
channel = bot.get_channel(1046308765609230396)
await channel.msg.send(f'**Link:**`{link}`\n**Type:** `{type}`\n**Host:** {host.mention}`{host}`\n\n <@&1044437889599156264>')
if 'https://' in link:
await channel.msg.send()
else:
await channel.msg.delete()
await ctx.send('Your link is not valid.')```
Hello, i have a question. I'm new in this thing. How to make slash command?
Second message in the pins
Thanks
What library is this
what that mean, im new lol
@slash.slash(description='Start a pickup')
@commands.has_any_role('Captain')
async def pickups(ctx, host: discord.Member, type: discord.Message, link: discord.Message):
if 'https://' in link: # it's in the link, so send the rest of the message
channel = bot.get_channel(1046308765609230396)
await channel.msg.send(f'**Link:**`{link}`\n**Type:** `{type}`\n**Host:** {host.mention}`{host}`\n\n <@&1044437889599156264>')
else: # https:// was not in link
await ctx.send('Your link is not valid.')
something like that I'd say
the first part work, it says your link isnt valid when it doesnt have https:// but when it does have it it just has an error
What error.
onjobject has no attribute to 'msg'
It's just channel.send
Yeah
I fixed it, i tried that it errored
i just did await ctx.channel.send and it worked
Question do anyone know what the permission code is but when i code in cogs? ( i use nextcord)
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send(f"{round(error.retry_after, 2)} seconds left")
@slash.slash(description='Start a pickup')
@commands.has_any_role('Captain')
@commands.cooldown(1, 600, commands.BucketType.user)
async def pickups(ctx, host: discord.Member, type: discord.Message, link: discord.Message):
if 'https://' in link: # it's in the link, so send the rest of the message
channel = bot.get_channel(1046308765609230396)
await ctx.channel.send(f'**Link:** {link}\n**Type:** `{type}`\n**Host:** {host.mention} `{host}`\n\n <@&1044437889599156264>')
else: # https:// was not in link
await ctx.send('Your link is not valid.',hidden=True)```
sorry to bother, just wanna ask do you know why this doesn't work? The cooldown message doesn't send, the command works though its just the cooldown
the cooldown works, it just doesn't send the message saying theres one
What's it supposed to send?
its supposed to send the cooldown time
oh, don't make it an event, instead use command_name.error
so for example, @mighty ledgeckups.error
Uhmm guys? anyone have ideas
why cant i install app commands
no problem ๐
don't recommend using repl for hosting..
what should i use then
I think you have some name clashing going on or something
or library incompatibility
In terminal type pip list and give me a pic of it
!e
from asyncio import run
async def main():
await () # ๐คท
if __name__ == "__main__":
run(main())
@naive briar :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 9, in <module>
003 | File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
004 | return runner.run(main)
005 | ^^^^^^^^^^^^^^^^
006 | File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
007 | return self._loop.run_until_complete(task)
008 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
009 | File "/usr/local/lib/python3.11/asyncio/base_events.py", line 650, in run_until_complete
010 | return future.result()
011 | ^^^^^^^^^^^^^^^
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/kewewuyoco.txt?noredirect
Is there a way to get the emoji string of the numbers on Discord? like 1๏ธโฃ 2๏ธโฃ etc.
I try \:one: but it doesn't work unlike \:smile: and others.
Unicode
U+0031 doesn't work. I am trying to use it with add_reaction()
1๏ธโฃ
HOWWW
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
It's ` then another one for a 1 line code block.
It's possible on mobile but im on phone right now. Can you just send them from 2 to 9?
ohhh nevermind thanks! I found a website for that.
https://unicode.org/emoji/charts/full-emoji-list.html
1๏ธโฃ
how to edit the bot answer from a slash command
await inter.response.send_message("Connecting to ssh...")
await inter.response.edit_message(":white_check_mark: Connected !")
tried like that but i dont think thats how it works
Use Interaction.original_response to get the Message and then use Message.edit
!d discord.Interaction.original_response
await original_response()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Fetches the original interaction response message associated with the interaction.
If the interaction response was a newly created message (i.e. through [`InteractionResponse.send_message()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.send_message "discord.InteractionResponse.send_message") or [`InteractionResponse.defer()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.defer "discord.InteractionResponse.defer"), where `thinking` is `True`) then this returns the message that was sent using that response. Otherwise, this returns the message that triggered the interaction (i.e. through a component).
Repeated calls to this will return a cached value.
how do i use message edit
!d discord.Message.edit
await edit(*, content=..., embed=..., embeds=..., attachments=..., suppress=False, delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
The content must be able to be transformed into a string via `str(content)`.
Changed in version 1.3: The `suppress` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.11)") instead of `InvalidArgument`.
async def login(inter):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
await inter.response.send_message("Connecting to ssh...")
await inter.response.edit_message(content = ":white_check_mark: Connected !")
error
Application Command raised an exception: InteractionResponded: This interaction has already been responded to before
how i gotta update the thing with this function... tell me someone please
!d discord.Interaction.edit_original_response
await edit_original_response(*, content=..., embeds=..., embed=..., attachments=..., view=..., allowed_mentions=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the original interaction response message.
This is a lower level interface to [`InteractionMessage.edit()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionMessage.edit "discord.InteractionMessage.edit") in case you do not want to fetch the message and save an HTTP request.
This method is also the only way to edit the original message if the message sent was ephemeral.
Bruh
can you show me the whole command + how you call it?
How it can be totally different?
chances are, it's called something different OR you forgot to resync
This code is not for this embed
can anyone give me an example how i can use original_response and edit_original_response? i just dont get it
It says new giveaway but as far as i see, i cant able to find the world "new giveaway"
not for this emb
await interaction.response.send_message() #you send ur msg here
msg = await interaction.original_response() #u get msg object here ando stuff with this object
print(msg)
!d discord.Message.edit
await edit(*, content=..., embed=..., embeds=..., attachments=..., suppress=False, delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
The content must be able to be transformed into a string via `str(content)`.
Changed in version 1.3: The `suppress` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.11)") instead of `InvalidArgument`.
class discord.Message```
Represents a message from Discord.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
hash(x) Returns the messageโs hash.
Application Command raised an exception: AttributeError: 'ApplicationContext' object has no attribute 'original_response'
Which Library bu r using?
discord py
Can u show ur code kindly?
@client.slash_command()
async def login(inter):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
await inter.response.send_message("Connecting to ssh...")
msg = await inter.original_response()
print(msg)
ssh.connect(hostname=hostname, username=username, password=password, port=port)
try:
stdin, stdout, stderr = ssh.exec_command('ls')
output = stdout.read()
#await inter.response.send_message("[:white_check_mark:] Connected !")
except:
pass
#await inter.response.send_message("[:x:] Failed !")
This is pycord
Not discord.py
U r using "pycord" library not "discord.py"
It's the name of file bruh
import discord, os, paramiko
from discord.ext import commands
from data import *
Pycord has same module name discord as in discord.py
Good
how to remove that thing
Wdym?
If u Remove that thing u gotta change all ur codes
is any way to edit the original message on pycord?
Idk lol
Wait
!tag discord.Interaction
Ah
Wait
Xd
i removed discord after installing it
File "D:\etc\devv\discord.py\bot.py", line 15, in <module>
@client.slash_command()
AttributeError: 'Bot' object has no attribute 'slash_command'. Did you mean: 'add_command'?
PS D:\etc\devv\discord.py> ```
U installed discord.py?
yes
...
no
Ohk
fixed it...
discord.py removed smth from py-cord
bcs the same name and i had to reinstall pycord
Xd
i was really thinking when i was looking at examples
why they do the things diff than me
i have this error
add intents


