#discord-bots
1 messages · Page 142 of 1
bro what
return an embed with mentions
@commands.command()
@commands.has_permissions(kick_members=True)
async def giveaway(self,ctx):
await ctx.send("Let's start with this giveaway! Answer these questions within 15 seconds!")
questions = ["Which channel should it be hosted in?", "What should be the duration of the giveaway? (s|m|h|d)", "What is the prize of the giveaway?"]
answers = []
def check(m):
return m.author == ctx.author and m.channel == ctx.channel
for i in questions:
await ctx.send(i)
try:
msg = await self.bot.wait_for('message', timeout=15.0, check=check)
except asyncio.TimeoutError:
await ctx.send('You didn\'t answer in time, please be quicker next time!')
return
else:
answers.append(msg.content)
try:
c_id = int(answers[0][2:-1])
except:
await ctx.send(f"You didn't mention a channel properly. Do it like this {ctx.channel.mention} next time.")
return
channel = self.bot.get_channel(c_id)
time = self.convert(answers[1])
if time == -1:
await ctx.send(f"You didn't answer with a proper unit. Use (s|m|h|d) next time!")
return
elif time == -2:
await ctx.send(f"The time should just be an integer. Please enter an integer next time.")
return
prize = answers[2]
await ctx.send(f"The giveaway will be in {channel.mention} and will last {answers[1]}!")
embed = nextcord.Embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)
embed.add_field(name = "Hosted by:", value = ctx.author.mention)
presentDate = datetime.datetime.now()
unix_timestamp = datetime.datetime.timestamp(presentDate)*1000
embed.set_footer(text=f'Ends at <t:{unix_timestamp+time}>!')
my_msg = await channel.send(embed = embed)
await channel.send(f"Ends at <t:{unix_timestamp+time}>!")
await my_msg.add_reaction("🎉")
```can someone help me please? i am trying to get the timestamp to work so that it shows in the member's timezone when the giveaway ends
Return an embed or send an embed?
send
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.11)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
You can pass the datetime to this and get the formatted string directly
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'redeem' raised an exception: AttributeError: 'Interaction' object has no attribute 'author'
D:
interaction.user
wa
ok, so you can have a list as an attribute of the view class, append the mention in the button callback, and then join and send it
Interaction.user return the member who use the interaction
?
Is there anyway to create an embed like this:
-Text
-Image
-Text below the image?
embed.description = f"Good news!"
embed.set_image(url = f"https://media0.giphy.com/media/{getGiphy('send it')}/giphy.gif")
embed.add_field(name = "result", value = "Your form.")```
doesn't work apparently.
how tf
It's interaction.user
wdym to use key?
Im making key system on tree command
I have normal key system but I need / commands
You can use PIL module to write on a image.
No, I mean how to add text below the image embed?
You can't, only the footer is bellow the image.
I don't understand what you mean by key system. Do you want to get a role to a user when they interact?
Thanks for the info bro
now when I use /redeem {key} it should give it a premium role
Discord api is kinda limited tbh
It is what it is
heeey
Yeah so basically if you can't give role to user (you shouldn't actually because add_roles() only works on members) then use member = interaction.guild.get_member(interaction.user.id) to get the object of the member then use member.add_roles(premium_role_obj)
You can create a "fake embed"
sadge vibes
can you give an example
thanks
Using PIL or any same module, you create a image looks like a embed,and do whatever you want inside.
That's smart though I think it's unecessary. I will just add all the text to the embed description and have it on top.
depends on you!
are there any instagram apis?
its defined inside another function, of course itll not work inside any other function
well i dont really understand what ure trying to do so
Wanna you wanna do?
There's a cool api from RapidAPI
For that you may want to store your embed in a document in a local embeds variable.
I.e.
bot = commands.Bot(...)
embeds = {}
Then append the embed from the first command inside this document and let the key be the author's id so only the author can edit that embed. Just like that
@bot.slash_command()
async def sendembed(self, ctx, *, text):
embed = discord.Embed(description=text)
msg = await ctx.send(embed=embed)
embeds[str(ctx.author.id)] = {"embed": embed, "messageId": msg.id, "channelId": ctx.channel.id}
You need to store both the channel's id and the message's id so you can get the message you want to edit, as well as the embed's data that you want to work with.
Finally, editing the embed.
@bot.slash_command()
async def editembed(self, ctx, *, text):
embed = embeds[str(ctx.author.id)]["embed"]
msgId = embeds[str(ctx.author.id)]["messageId"]
channelId = embeds[str(ctx.author.id)]["channelId"]
# Now fetch the message
channel = self.bot.get_channel(channelId)
msg = await channel.fetch_message(msgId)
# Then edit the embed
embed.description = text
# Following it with the message
await msg.edit(embeds=[embed])
And you're done.
crap he's not working on a cog I just realized that
no wait
let me make it match your environment
@slate swan pretty sure it's fine now. If you face an error lmk
might not be the best solution, but it's your task to make it better
You know you can store the message object in the dictionary
Still, the message's object does not have an ID. I just noticed that since it's an interaction's response.
I believe you need to send the embed as a normal message. Basically, get the interaction's channel, then send the message to that channel.
I believe it would be that way
msg = await interaction.channel.send(...)
Never used nextcord, hence I don't know its syntax
What's channel?
You need to define it, but instead of defining it then using it, just use it straight away. interaction.channel.send() should work.
mhm
id is the interaction's id, not the message's. And I believe application_id is the bot's id..
No
underlined the wrong thing, was talking about the channel_id
ah right
thought you were highlighting what should be used
Hey @dapper cobalt can does interaction has attr of channel?
yep thats mb
In discord.py
!d discord.Interaction
class discord.Interaction```
Represents a Discord interaction.
An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.
New in version 2.0.
!d discord.Interaction.channel
The channel the interaction was sent from.
Note that due to a Discord limitation, DM channels are not resolved since there is no data to complete them. These are PartialMessageable instead.
No man :[[

Coooolll
It's mean instead of interaction.responsw
We can use interaction.channel
Huh?
You still have to respond something to the interaction
Or the user will get interaction fail
defer?
interaction.response.defer will work?
You would still get interaction fail after 15mins
ahhhhhhhhhh
Btw can we get the msg id that just sent from interaction
like
message = interaction.channel.send()
print(message.id)
That works
Cooooolll
But why are you using interaction.channel.send?
Because
msg = interaction.response.send_message()
print(msg.id)
Will always return none
because u need to do msg = interaction.original_message()
that's why you use
inter.send doesn't return
^
this is after inter.send
I think it's response
Not message
get instagram information like the username full name amount of followers the amount of people you follow bio etc
@tidal hawk dude
Can u make it clear via a example?
He did though
Noice
what don't you understand-
?
So @slate swan
wwe do like
await interaction.response.send_message()
After that
msg = interaction.original_message()
Like dat?
original_response()
Oh ye
So does it has any params?
Or we can now just directly get msg objects
It is an coroutine, so, you need to await it
can u send link
Ye just checked
I will definitely check that outtt
!d discord.InteractionMessage
class discord.InteractionMessage```
Represents the original interaction response message.
This allows you to edit or delete the message associated with the interaction response. To retrieve this object see [`Interaction.original_response()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction.original_response "discord.Interaction.original_response").
This inherits from [`discord.Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") with changes to [`edit()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionMessage.edit "discord.InteractionMessage.edit") and [`delete()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionMessage.delete "discord.InteractionMessage.delete") to work.
New in version 2.0.
Google "RapidAPI Instagram Data"
thx
ok thx.
and other last please little example there "for in suggest and giveaway in suggest channel in giveaway channel?" uhmm my think bad..
example
think no?
or think "for suggest_channel, giveaway_channel in suggest_channels, giveaway_channels:"
Both of them will work
1st one assuming u have both giveaway channel id and suggest channel id in suggest_channels index
Quick question. How do I add this in my code?
It's that description for the args when doing Slash/cmds
Kinda like the description bit in this code:
@commands.slash_command(name="yeet", description="Usage: Ban @user")
@commands.has_permissions(administrator=True)
async def ban(self, inter, member: disnake.Member, reason='No Reason provided', dm_user = False):
Like, how do I do it? So it shows?
@commands.command()
@commands.has_permissions(kick_members=True)
async def giveaway(self,ctx):
await ctx.send("Let's start with this giveaway! Answer these questions within 15 seconds!")
questions = ["Which channel should it be hosted in?", "What should be the duration of the giveaway? (s|m|h|d)", "What is the prize of the giveaway?"]
answers = []
def check(m):
return m.author == ctx.author and m.channel == ctx.channel
for i in questions:
await ctx.send(i)
try:
msg = await self.bot.wait_for('message', timeout=15.0, check=check)
except asyncio.TimeoutError:
await ctx.send('You didn\'t answer in time, please be quicker next time!')
return
else:
answers.append(msg.content)
try:
c_id = int(answers[0][2:-1])
except:
await ctx.send(f"You didn't mention a channel properly. Do it like this {ctx.channel.mention} next time.")
return
channel = self.bot.get_channel(c_id)
time=humanfriendly.parse_timespan(answers[1])
if time == -1:
await ctx.send(f"You didn't answer with a proper unit. Use (s|m|h|d) next time!")
return
elif time == -2:
await ctx.send(f"The time should just be an integer. Please enter an integer next time.")
return
prize = answers[2]
await ctx.send(f"The giveaway will be in {channel.mention} and will last {answers[1]}!")
embed = nextcord.Embed(title = "Giveaway!", description = f"{prize}", color = ctx.author.color)
embed.add_field(name = "Hosted by:", value = ctx.author.mention)
epochEnd=nextcord.utils.format_dt(pyTime.time()+time)
embed.set_footer(text=f'Ends at <t:{epochEnd}:F>!')
my_msg = await channel.send(embed = embed)
await channel.send(f"Ends at {epochEnd}!")
await my_msg.add_reaction("🎉")
await asyncio.sleep(time)
new_msg = await channel.fetch_message(my_msg.id)
users = await new_msg.reactions[0].users().flatten()
users.pop(users.index(self.bot.user))
winner = random.choice(users)
await channel.send(f"Congratulations! {winner.mention} won the prize: {prize}!")
could someone help me with this error please? it should be in the line epochEnd=nextcord.utils.format_dt(pyTime.time()+time)
Just so my question won't be forgotten as well. Just a quick answer would do. I'll handle the rest lol
@slate swan you can help him, it's disnake
i use docstrings
@commands.slash_command(name="yeet", description="Usage: Ban @user")
@commands.has_permissions(administrator=True)
async def ban(self, inter, member: disnake.Member, reason='No Reason provided', dm_user = False):
"""
Command description
Parameters
-----------
member: Member you want to ban
"""
Show inports
Imports*
What's pyTime
Wait, that works? LOL. Didn't know. Thanks!
yup
It should be datetime object
Wait, wait. I think I'm still confused. Let me try it if it works first
Like, where do I input the docstrings? Especially when an argument already takes in the argument "disnake.member"
huh ? the example i showed is exactly how its used
doc strings go at beginning of the func
command.description
think thats it..
docstrings are better
There are multiple options for that
personal preference
Like description arg in commands.Param()
I went with Docstrings lol. they looked neater and more manageable, I guess.
Also, came back for a new question
I'd personally use the description arg for a short description and docstrings for a longer one
""" Kick """
@commands.slash_command(name="kickies", description="Usage: Kick @user")
@commands.has_permissions(administrator=True)
async def kick(self, inter, member: disnake.Member, reason='No Reason provided', dm_user=False):
"""
Command description
Parameters
------------------------------
dm_user: Input True or False
member: Member you want to Kick
reason: The reason for the Kick
"""
if member.guild_permissions.administrator or member.top_role >= inter.author.top_role:
embed = disnake.Embed(title="", description=f" Administrators cannot be kicked!", colour = disnake.Colour.random())
await inter.send(embed=embed, delete_after=10)
else:
await member.kick(reason=reason)
Kick_Embed = disnake.Embed(title="", description=f"** Reason: __{reason}__**", colour=disnake.Colour.random())
Kick_Embed.set_image(url=f"{random.choice(Ban_Hammers)}")
if dm_user is True:
Kick_DM_Embed = disnake.Embed(title="", description=f"Reason: {reason}", colour = disnake.Colour.random())
await member.send(content=f"You have been Kicked in __**{inter.guild.name}**__", embed=Kick_DM_Embed)
await inter.send(content=f"{member} has successfully been Yeeted", embed=Kick_Embed)
I have this yeet cmd that DMs after a Kick. When I made it using Prefix Cmds, it worked, but when I did Slash, it stopped working. I tried removing the Try/Except bit, as well as the error handlerand it didn't show any errors
u cant put long ones in doc strings lol
theres a limit to the text size?
Only kicks, no DM
yup
what is it
no clue but if its too long itll return a command error
Probably somewhere around 60+ Charas?
Bro why does this gives me error that interaction has not responded to yet
async def deny_callback(interaction: discord.AppCmdInter):
if interaction.user.id == user.id:
accept.disabled = True
deny.disabled = True
start = False
invite = discord.Embed(title='Game Invitation Denied 😔', description=f'{user.mention} denied {inter.user.mention}\'s game invitation.', color=discord.Color.red())
await interaction.edit_original_message(embed=invite, view=view)
deny.callback = deny_callback
await inter.send(content=user.mention, embed=invitation, view=view)
What not responded
show traceback
Ignoring exception in view <View timeout=180.0 children=2> for item <Button style=<ButtonStyle.danger: 4> url=None disabled=True label='Deny' emoji=<PartialEmoji animated=False name='❎' id=None> row=None>:
Traceback (most recent call last):
File "C:\Users\Divi\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\interactions\base.py", line 460, in edit_original_message
data = await adapter.edit_original_interaction_response(
File "C:\Users\Divi\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\webhook\async_.py", line 222, in request
raise NotFound(response, data)
disnake.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Divi\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ui\view.py", line 370, in _scheduled_task
await item.callback(interaction)
File "D:\Shrey\MiniGamez\Extensions\rps.py", line 30, in deny_callback
await interaction.edit_original_message(embed=invite, view=view)
File "C:\Users\Divi\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\interactions\base.py", line 470, in edit_original_message
raise InteractionNotResponded(self) from e
disnake.errors.InteractionNotResponded: This interaction hasn't been responded to yet
did you defer?
I see
hey is there any tools for diagnose slow commands for dpy? i've asked in the official server, but i've been ignored 3 times 
!d discord.InteractionResponse.defer - I don't know what are you saying exactly. But I guess you mean this
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...
What is thi
ur using .edit_original_message which is used to edit a deferred response or an already sent response
Its already sent that is why I want to edit it.
What's the problem with that
Oooooooh
I used the wrong inter
Thanks @naive briar and @slate swan
if ur using a component its a message interaction

does anyone know? i've looked into jishaku but i saw it doesn't support app commands
What do you mean exactly
so i hv this command that takes approximate 5~6 seconds to load, which is not ideal,
i wanted to diagnose which part is taking a lot of time.
i was recommended jishaku, but i saw it doesn't support slash commands as of now
show the command
also deferring helps
yeah i did, its kind of big though xd
are u doing db stuff?
!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.
yes
which command? lol
there's 3 in there, equip list, equip item and unequip item
list takes 3~5 seconds
equip and unequip takes a whole lote more
so my main question is, like is there a profile for dpy? so that im able to at least know which part i should focus on fixing
jishaku does have support for slash commands
The Problem Jishaku's sync doesn't call d.py's tree.sync(), meaning it doesn't localize slash commands The Ideal Solution Either call the tree.sync method, or call t...
oh jk
lmao
xD its syncing i think
i guess you could try to copy the cmd and make it a chat cmd so you can use jishaku. otherwise i would assume its ur db slowing it down
yeah i'll try making a hybrid/normal command instead and see how that goes
thanks for your time ^
hv a great day man
I created a start here
class RockPaperScissors(commands.Cog):
def __int__(self, bot):
self.bot: commands.InteractionBot = bot
self.start = None
Bu it still says rps class has no start
if self.start == False:
return
else:
await inter.send(f'{inter.user.mention} wins!')
"Attribute error" RPS has no start attribt
Where is that self from
wdym
@ commands.slash_command(name='rps', description='Play a game of rock paper scissors.')
async def rps_cmd(self, inter: discord.AppCmdInter, user: discord.Member):
@naive briar
Sorry to suddenly butt-in but my brain just won't work lol. I just got back at coding so I might've missed some parts that makes this code not work:
""" Kick """
@commands.slash_command(name="kickies", description="Usage: Kick @user")
@commands.has_permissions(administrator=True)
async def kick(self, inter, member: disnake.Member, reason='No Reason provided', dm_user=False):
if member.guild_permissions.administrator or member.top_role >= inter.author.top_role:
embed = disnake.Embed(title="", description=f" Administrators cannot be kicked!", colour = disnake.Colour.random())
await inter.send(embed=embed, delete_after=10)
else:
if dm_user is True:
Kick_DM_Embed = disnake.Embed(title="", description=f"Reason: {reason}", colour = disnake.Colour.random())
await member.send(content=f"You have been Kicked in __**{inter.guild.name}**__", embed=Kick_DM_Embed)
await member.kick(reason=reason)
Kick_Embed = disnake.Embed(title="", description=f"** Reason: __{reason}__**", colour=disnake.Colour.random())
Kick_Embed.set_image(url=f"{random.choice(Ban_Hammers)}")
await inter.send(content=f"{member} has successfully been Yeeted", embed=Kick_Embed)
It Kicks the Target-user but it won't DM
I tried lol. But I just couldn't figure it out
It only seems to work on Prefix cmds. It won't DM when I do it on Slash
Are you sure that you have DMs open?
is there any errors?
It sent on my Alt's DMs when I did prefix
Not that I saw any. I mean, there was one that said <user id> cannot be found. But it didn't specify at which location
This was the error, I think. My terminal got flooded so I'm unsure lol. But I think it was this one
Ignoring exception in slash command 'kickies':
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/disnake/ext/commands/interaction_bot_base.py", line 1262, in process_application_commands
await app_command.invoke(interaction)
File "/home/container/.local/lib/python3.9/site-packages/disnake/ext/commands/slash_core.py", line 681, in invoke
await call_param_func(self.callback, inter, self.cog, **kwargs)
File "/home/container/.local/lib/python3.9/site-packages/disnake/ext/commands/params.py", line 821, in call_param_func
kwargs[param.param_name] = await param.convert_argument(
File "/home/container/.local/lib/python3.9/site-packages/disnake/ext/commands/params.py", line 474, in convert_argument
return await self.verify_type(inter, argument)
File "/home/container/.local/lib/python3.9/site-packages/disnake/ext/commands/params.py", line 460, in verify_type
raise errors.MemberNotFound(str(argument.id))
disnake.ext.commands.errors.MemberNotFound: Member "955690076141146122" not found.
This error came from another code. But the only difference is that I moved the sub-if statement below the elif statement
But the arg was written as member: disnake.Member though?
are you using discord.py?
Totally not disnake at all
Is Disnake faulty? or sumthing?
I never used disnake
but try pinging the member
I did.
And, also, I had a thought about why this error might have occurred but I'm not entirely sure.
Could it also be because the user is kicked before the bot DMs them?
Hence, the User Cannot be found error?
Although, I found it weird that it works on prefix, but not on slash 
Hi, i have a question. I want to create command to translate but i dont know how i can do it?
I want to create commands !en, !it, !pl etc. [+40 commands] but creating every command to translate is bad idea so i want to ask is there a good way to do it
the user isn't in the server
wait u have disnake.Member param
wtf
yea if ur trying to dm after kicking it wont because the user no longer exists
But why did it work when I tried Prefix?
Lol, just noticed but I've been working on it for like 2 hrs 
are u sure the prefix command is exactly the same?
Wym?
is the prefix command the same as ur slash command?
Yep. It's essentially the same code. All I did was change commands.slash_command(name=..., desc=...) to commands.command(name=...)desc=...#)
So, yeah, they're the same. Unless I did something wrong there lol
Yup. Only when I swap it with Prefix. But not when I do it on Slash. Let me confirm that again. Lemme do the code again lol
hybrid_command when?
Yup. Works when it's done on prefix
I'll resend the code for reference
""" Kick """
@commands.command(name="kickies")#, description="Usage: Kick @user")
@commands.has_permissions(administrator=True)
async def kick(self, inter, member: disnake.Member, reason='No Reason provided', dm_user=False):
if member.guild_permissions.administrator or member.top_role >= inter.author.top_role:
embed = disnake.Embed(title="", description=f":RAB: Administrators cannot be kicked!", colour = disnake.Colour.random())
await inter.send(embed=embed, delete_after=10)
else:
await member.kick(reason=reason)
Kick_Embed = disnake.Embed(title="", description=f"**:PAL: Reason: __{reason}__**", colour=disnake.Colour.random())
Kick_Embed.set_image(url=f"{random.choice(Ban_Hammers)}")
if dm_user is True:
Kick_DM_Embed = disnake.Embed(title="", description=f"Reason: {reason}", colour = disnake.Colour.random())
await member.send(content=f"You have been Kicked in __**{inter.guild.name}**__", embed=Kick_DM_Embed)
await inter.send(content=f"{member} has successfully been Yeeted", embed=Kick_Embed)
.
Custom command handler or use for loop to create the commands
any example?
could also do a single command with multiple options of languages and input the message id
is there any way to get info which alias is command called?
you could use some translating api
or do some webscraping and save it in a .csv or smth
selenium
i know i can use translating api
I replied to wrong one
but i dont know how to do translation in multiple commands like: !en {text} !it {text} etc.
oh yea i get u
check the docs and exmaples
*examples
If you want to dm me and I'll help you out
what do you have to type in the docs to find it
translator bruh
Try dming the member first then kick him
⇧
I did that. RIght? Or am I doing it wrong lol
I placed a local if statement inside the else statement so that it would see that first. Or I might be mistakes
.
Let me send the Slash command one
Yes pls
""" Kick """
@commands.slash_command(name="kick-yeet", description="Usage: Kick @user")
@commands.has_permissions(administrator=True)
async def kick(self, inter, member: disnake.Member, reason='No Reason provided', dm_user=False):
"""
Command description
Parameters
------------------------------
dm_user: Input True or False
member: Member you want to Kick
reason: The reason for the Kick
"""
try:
if member.guild_permissions.administrator or member.top_role >= inter.author.top_role:
embed = disnake.Embed(title="", description=f" Administrators cannot be kicked!", colour = disnake.Colour.random())
await inter.send(embed=embed, delete_after=10)
else:
await member.kick(reason=reason)
Kick_Embed = disnake.Embed(title="", description=f"** Reason: __{reason}__**", colour=disnake.Colour.random())
Kick_Embed.set_image(url=f"{random.choice(Ban_Hammers)}")
if dm_user is True:
Kick_DM_Embed = disnake.Embed(title="", description=f"Reason: {reason}", colour = disnake.Colour.random())
await member.send(content=f"You have been Kicked in __**{inter.guild.name}**__", embed=Kick_DM_Embed)
await inter.send(content=f"{member} has successfully been Yeeted", embed=Kick_Embed)
not the issue
its a lib thing apparently.
they said its somkething weird with how slash cmd handles perms differently or something? idk lmao
if member.......:,
elif dm_user is True:
kick_dm_embed=........
await member.send(...)
member.kick(.....)
elif dm_user is False or dm_user is None:
embed=.....
member.kick()
await inter.send(...)
@dull knot try dat
Alright, lemme try
Just replace that else
that wont work bro
his entire thing is dming the user.
Let him see 💀
Idk disnake
its an internal issue.
Bruh
he cant dm a user with slash but it works with prefix
Pretty much lol
Bruhh
ur not understanding dude
simplest way to solve is just dm user before kicking.
Guess I'll figure that one out later. I'm pooped lol.
🙂
Thanks for the help though. Appreciate it
no shit. but that isn't the issue. the issue is his current code works perfectly fine using prefix cmd but not with slash
Maybe his slash not even syncing who knows 💀💀
the slash works just doesn't dm user. his posted trace back
Lemme see
If statement should be beneath else statement
And last await call should be beneath if statement
Idk
Lol
huh no
mobile
his code is fine.
Maybe lol
ur brain gotta hurt.
!d disnake.Member.send
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, suppress_embeds=False, allowed_mentions=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`.
At least one of `content`, `embed`/`embeds`, `file`/`files`, `stickers`, `components`, or `view` must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://docs.disnake.dev/en/latest/api.html#disnake.File "disnake.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.11)") of [`File`](https://docs.disnake.dev/en/latest/api.html#disnake.File "disnake.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed "disnake.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.11)") of [`Embed`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed "disnake.Embed") objects. **Specifying both parameters will lead to an exception**.
when he switches slash_command to command. it kicks AND dms. when he switches it to slash_command it kicks but DOES NOT dm
now do u understand?
Ye
But member object should be the same in prefix as well as slash command xd
My brain is actually hurting lol
How do you call the slash command
Like /kick blah blah blah
Yep. Like this
What's the options you chose
Can u just click on dm_user?
All of them
/yeet member: (Mention someone here) dm_user: True reason: (Input Reason here)
wym?
in the option just click dm_user i wanna see then what happens
no offense but yall slow. if he didnt set dm_user to true he would never et an error lmfao
If u input normally With msg True it willl always be string
So it cant be dm_user is True
what are u talking ab dude
It will be dm_user is "True":
Set the dm_user typehint to bool
Pretty much. It's set to false if left empty
But won't that be a required argument?
I guess I'ma try that later. for now, I'ma eat
Ignoring exception in slash command 'kickies':
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/disnake/ext/commands/interaction_bot_base.py", line 1262, in process_application_commands
await app_command.invoke(interaction)
File "/home/container/.local/lib/python3.9/site-packages/disnake/ext/commands/slash_core.py", line 681, in invoke
await call_param_func(self.callback, inter, self.cog, **kwargs)
File "/home/container/.local/lib/python3.9/site-packages/disnake/ext/commands/params.py", line 821, in call_param_func
kwargs[param.param_name] = await param.convert_argument(
File "/home/container/.local/lib/python3.9/site-packages/disnake/ext/commands/params.py", line 474, in convert_argument
return await self.verify_type(inter, argument)
File "/home/container/.local/lib/python3.9/site-packages/disnake/ext/commands/params.py", line 460, in verify_type
raise errors.MemberNotFound(str(argument.id))
disnake.ext.commands.errors.MemberNotFound: Member "955690076141146122" not found.
his dm_user option is not the issue. again it is something internal
You mean in the bot's profile or in the default help command
You have to set it yourself in dev portal
Set that in application
Yea
You can
Ofc
Just :pithink: or some emoji
Yeah
Yep
The emoji should be in the server the bot in
So the bot can use
Just incase xd
After reaching 100+ Servers
And i forgot about member limitations
^^
Ye
I thought you guys are talking about how the bot is only kicking but not DMing
Wdym?
Most likely
nah. the bot kicks and dms with prefix but doesnt with slash. its weird
The input dm_user will be a string if he doesn't provide a type annotations
At least that's what dpy does
That's what i was telling 💀
okay so then dm_user would be false and it wouldnt try to dm the user if that was the case but IT STILL DOES
hence the error
Ignoring exception in slash command 'kickies':
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/disnake/ext/commands/interaction_bot_base.py", line 1262, in process_application_commands
await app_command.invoke(interaction)
File "/home/container/.local/lib/python3.9/site-packages/disnake/ext/commands/slash_core.py", line 681, in invoke
await call_param_func(self.callback, inter, self.cog, **kwargs)
File "/home/container/.local/lib/python3.9/site-packages/disnake/ext/commands/params.py", line 821, in call_param_func
kwargs[param.param_name] = await param.convert_argument(
File "/home/container/.local/lib/python3.9/site-packages/disnake/ext/commands/params.py", line 474, in convert_argument
return await self.verify_type(inter, argument)
File "/home/container/.local/lib/python3.9/site-packages/disnake/ext/commands/params.py", line 460, in verify_type
raise errors.MemberNotFound(str(argument.id))
disnake.ext.commands.errors.MemberNotFound: Member "955690076141146122" not found.
What
bro this error is what happens when he uses a slash command and tries to kick/dm
this error is not provided when he uses prefix and it works fine
It looks like disnake just cannot find the member
yes because it kicked them lol
but when using prefix it works. its something weird internally with slash commands
Does disnake has get_user method?
ur trolling dude
Just asking 💀
fair enough
The command will be invoked after it converted all the argument
Idk what are you talking about
huhhhhhhh
so ur saying it never reaches the dm_user ?
You look like you're saying that it the kicked the member before the command is being used
what
Or the callback is being called
u guys are saying that dm_user is never true
Are you really sure that the user is in the server before using that command
.
It's never true. And what about it? 🤨
It's not DMing the user
It can't even convert the arg to member
The first check isn't even being executed
can you not read?
Read what
BRO if member is None then how it can be kicked
THe problem is that dm_user is always not true
So the dm user is not working but orefix
Prefix*
U IDIOT THE MEMBER IS NONE BECAUSE THEY GET KICKED HOLY SHIT
can yall not fuckign read what he siad.
Then just use get_user method
I can't see WHERE this error is even related to the member DMing
Bruh
................ read
Why would you want to kick the member that isn't in the server in the first place
Let me explain.
When u kick the member then the member is not in the server means disnake.Member or after kicking done the member will return None
What what
;-;
sigh. u tried
I am bad at explaining
nah was fine explanation catgal just trolling at this point
How am I trolling first of all
Does disnake have get_user method, third time asking
Xd
You are all wrong it's a simple java script mistake with the Libraries
yeah it does. but still would not work as the member isn't in the server anymore
YES JAVASCRIPT !!
idk how tf it works with prefix to begin with
!d disnake.Client.get_user
get_user(id, /)```
Returns a user with the given ID.
Bro member.id will always be the same
you cant dm users that you dont share a sever with. i dont know how tf the bot is even doing it in the first place
If we do
user = self.bot.get_user(member.id)
await user.send()
So just send the msg then dm
Bruh why this thing so complicated
I mean then kick
yes but that still isn't the issue here
U can dm users you're friends withhttps://cdn.discordapp.com/emojis/961898333167816724.png?size=48&quality=lossless
its a bot
im actually curious now lmfao. how tf did the bot dm him after kicking
Bro, this things sucks also discord.py
I guess all first do
channel.clone
Then do
chanel.delete
but if i swap that still works
something wrong here
Like wtf?
huh
Does it matter tho
Yeah the nuke commands, i just swapped it, but still works 💀
Nuking is mean don do that
I mean channel nuke bruh
Not server nuke ;-;
Damn..
People can have more than 1 mutual servers
whats that?
Do u know purge command?
yea
mh
there is a bot called NukeBot lmao. but it does not do what you would think it would.
its in like 80k servers
Rip
But to delete or remove all messages from a channel u can use nuke command
lmfao
Nuke means, delete that channel and recreate same channel
he mustve kept getting it termed or something
nuke has many diff meanings
With same permission same name in same category
makes sense
This bot is sus
It's for nuke protection
Maybe lol
nah it actually "nukes" look at the descrip
still its not bulletproof
I shall go now bye for good
imagine if he just actually made it a nuke bot and blew up all 80k servers lmfao
Pancake out
funny af
😂😂😂
i would pay to see that happen lmao
wheres ur callback
oh
i see yea idk i dont use dpy or views. they trash
Why are you even checking custom ids
The library handle all of that
Just put custom_id in the deco is fine
Isn't that because of the conditional inside a conditional?
no like u kicked the user right? u shouldn't be able to dm the user unless that user is in another server with the bot
In that case, I guess it's because my alt is in many of my emoji notepad servers lol.
ahh that explains that
Also, you mentioned smth about messaging the user before kicking but how would I make that work? I thought that was what I did with my conditional-inside-conditional code
just move the member.send above the member.kick
if dm_user is True:
Kick_DM_Embed = disnake.Embed(title="", description=f"Reason: {reason}", colour = disnake.Colour.random())
await member.send(content=f"You have been Kicked in __**{inter.guild.name}**__", embed=Kick_DM_Embed)
await member.kick(reason=reason)
Kick_Embed = disnake.Embed(title="", description=f"**:PAL: Reason: __{reason}__**", colour=disnake.Colour.random())
Kick_Embed.set_image(url=f"{random.choice(Ban_Hammers)}")
await inter.send(content=f"{member} has successfully been Yeeted", embed=Kick_Embed)
Actually, I tried this one (Inside the conditional) and it just returned an error lol. Wasn't able to see which type though since I have exception handlers and error handlers.
Also tried placing it inside the If conditional and it still returned an error
i would use a try except with the member.send tho cause if a user has their dms closed it'll stop the code
I don't think that'll happen. Unless you have the dm_permission parameter set to True
I made a DM command before and I tested it out by setting dm_permission to true n false.
False just DMs user regardless of their DMs being closed or open
no im saying if the user has their dms closed
you will not be able to dm them. the bot will error out
dm_permission is something completely different
that is used for allowing users to use bot cmds inside the dms
try:
if member.guild_permissions.administrator or member.top_role >= inter.author.top_role:
embed = disnake.Embed(title="", description=f":RAB: Administrators cannot be kicked!", colour = disnake.Colour.random())
await inter.send(embed=embed, delete_after=10)
else:
try:
member.send()
await member.kick(reason=reason)
Kick_Embed = disnake.Embed(title="", description=f"**:PAL: Reason: __{reason}__**", colour=disnake.Colour.random())
Kick_Embed.set_image(url=f"{random.choice(Ban_Hammers)}")
except:
await member.kick(reason=reason)
Kick_Embed = disnake.Embed(title="", description=f"**:PAL: Reason: __{reason}__**", colour=disnake.Colour.random())
Kick_Embed.set_image(url=f"{random.choice(Ban_Hammers)}")
await inter.send(content=f"{member} has successfully been Yeeted", embed=Kick_Embed)
this is what im referring to.
this will try to dm and if it cant just kick
Ahhh, ALright. I gotchu lol
But from what I recall, dm_permission was said to check whether a user has closed or open DMs though?
So, if I wanted to use purge inside DMs, would that work as well? LOL. ALways wanted to purge some msgs in my bot msg
You can't clear messages in direct messages
💀 fetch the history of the channel and delete every single message lmao, hoping that your Ip doesn't get ratelimited
It will be
async def anything(self, interaction, button):
what i changed is it was , (self, button, interaction
There is no need of if interaction.custom_id
Remove those line from ur buttons
yeah 'cause the callbacks would hit for those specific buttons only, and if you are comparing the custom id for the current interaction which is of that button witht he custom id of another button, it will never be true and the button would never work
I'm sure nobody would understand that
Ofc
Hi, Is that possible to hide the slash command in discord.py? For example when I execute this: /test hello it will send me a hello message but no one except me would see the message and command executed.
ephemeral=True in send method
yes
^^
Nice, at the same time
That doesn't work
eh?
That's not exactly what I want
I want it to be completely hidden no one can see that I even executed it
I mean ephemeral is for that only
It hides the message, not the command itself
I want used /privacy-policy to be hidden
Now when I dismiss the message the command also goes
Oh, how can I dismiss it programatically?
You cannot
the person has to click Dismiss Message
I don't think the delete method works on ephemeral messages tho not sure
Yeah, it doesn't work I tried
yea then no way of dismissing it by code
Nah
Because the message isn't controlled by the Discord API
Its controlled by the client
When you refresh the client the message goes away
This is because its a temporary message which isn't saved like other (like this one) messages are saved
delete_original_response should delete the message
not sure
Worth a try
thats hidden its only visible to the user
or if u are so paranoid just use the dms
Nop, can't use dms
Worth a try, thanks
async def load_extensions():
for folder in os.listdir(COG_PATH):
print(f"Folder: {folder}")
asyncio.run(load_extensions())
how i can see the files from folder in listdir?
!d os.walk
os.walk(top, topdown=True, onerror=None, followlinks=False)```
Generate the file names in a directory tree by walking the tree either top-down or bottom-up. For each directory in the tree rooted at directory *top* (including *top* itself), it yields a 3-tuple `(dirpath, dirnames, filenames)`.
pathlib when
Me who uses neither: 
can i have any example?
what takes as first parameter?
https://www.geeksforgeeks.org/os-walk-python/
There is an example here
and a good explanation
default ()
if only the error told you what was wrong with the code
that would be revolutionary
I mean the error does
look at his profile
it was sarcasm hunter 😔
No comments
i think he only needs glasses
come on hunter
you confuse me so much with this 😄
I am at that point rn where I have stopped understanding sarcasm anymore, sorry guys
Sorry 😦
@shrewd apex can ya help him?
yes asher is soo good at helping asher can definitely help 😃
Well sure you can too
He wanna access subfolders but I pinged Asher (before I was gonna ping u only) because he was here when he asked for help
Stop it please😔
do you have an on_message listener
3
just copy paste the for loop and run it
just copy paste and change the path
trying to get my cog files and load the extensions inside theses folders
@maiden fable yes u can complete hide a slash command
?
All cool
@dense horizon u can completely hide a slash command in discord.py
Tell me pls how
climax point
cog
why u have subdirectories first time saw such cogs
just unpack u are gonna load them all anyways
@hybrid_command(name='test', help='Shows the message of the argument')
async def test_command(self, ctx: Context) -> None:
# This doesn't work
await ctx.interaction.delete_original_response()```
this is why im asking for help 😛
i want it works like that
anyway thank you!i will search
just copy paste the for loop in the link and change path to cogs
from discord import app_commands
@hybrid_command(name='test', help='Shows the message of the argument')
@app_commands.default_permissions(administrator=True)
async def test_command(self, ctx: Context) -> None:
# This doesn't work
await ctx.interaction.delete_original_response()```
Check if that works
That only disables the command for others not hides it
It was only for slash command, but seems u using hybrid command
It hides from whole slash menu but doesn't hide for administrator
I checked earlier
I thought it only disabled the command for others
Nah just hides it
Either a new discord update or I am rusty
or I am rusty
So I had this as prefix command
user = ctx.message.author
So I wanted to make a slash command but Idk how to get author of interaction can someone help me?
In intregations u can see the default permission thing
Yea
Like waiy
.
Can someone help
Yes
U can do that
in slash command u have to define interaction as discord.Interaction
Then it will work
Yeah I did that
Then u r good to go
Btw can u tell me I am trying to make a professional bot so do u suggest me to use prefix commands or slash or hybrid ?
@slate swan
Slash
Hybrid commands has limitations and too confusing
Oh
So stick with slash for now
Alright tysm
:]
Another question sorry @slate swan
can you run this:
for dirp, dirn, file in os.walk:
print(dirp, dirn, file)
So I have a prefix poll command so I have def
async def poll(msg, channelid, question: str, *options):
So I want to turn it into slash command but idk how to set option to be maximum is 10 but user can just do 1 or 2 as he want between 1-10
@slate swan
@slate swan
Ahhh
Can u show the code 💀
I always need the code xd
In dm can?
Yep
Alright check dm @slate swan
Thumbnail or a image
Or top left corner icon
got it ty
Anyone here good at discord python?
depends on the question
Have u made a bot with slash commands
I ain't got much experience with slash commands, no
Ask your question
Have you?
That too
Just ask your question, you'll have a higher chance of getting help
#by Digiwind
#from https://youtu.be/Fa7Jtfv2wgI
#uses Pycord, a fork of Discord.py
import discord
from discord import Option
from discord.ext import commands
from discord.ext.commands import MissingPermissions
bot = discord.Bot()
servers = [] #server ids
@bot.event
async def on_ready():
print("We have logged in!")
In this video, we code ban and kick slash commands in Python with Pycord, a fork of Discord.py that supports slash commands. This is the second video in our Discord Moderation Bot series (first video was about making mute/timeout slash commands). If you found this video helpful, please consider subscribing and liking the video! If you have any q...
@bot.slash_command(guild_ids = servers, name = "kick", description = "Kicks a member")
@commands.has_permissions(kick_members = True, administrator = True)
async def kick(ctx, member: Option(discord.Member, description = "Who do you want to kick?"), reason: Option(str, description = "Why?", required = False)):
if member.id == ctx.author.id: #checks to see if they're the same
await ctx.respond("BRUH! You can't kick yourself!")
elif member.guild_permissions.administrator:
await ctx.respond("Stop trying to kick an admin! 🙄")
else:
if reason == None:
reason = f"None provided by {ctx.author}"
await member.kick(reason = reason)
await ctx.respond(f"<@{ctx.author.id}>, <@{member.id}> has been kicked from this server!\n\nReason: {reason}")
@kick.error
async def kickerror(ctx, error):
if isinstance(error, MissingPermissions):
await ctx.respond("You need Kick Members and Administrator permissions to do this!")
else:
await ctx.respond("Something went wrong...") #most likely due to missing permissions
raise error
bot.run('token') #token: KEEP THIS SAFE, from your developer portal
this doesnt work at i keep getting an error
What's the error?
something with imports option
Can you paste the full traceback?
Traceback (most recent call last):
File "main.py", line 6, in <module>
from discord import Option
ImportError: cannot import name 'Option' from 'discord' (/home/runner/pi/venv/lib/python3.8/site-packages/discord/init.py)
Hi there. Here's a code tht I didnt quite understand
def get_prefix(client, message):
with open("prefixes.json", "r") as f:
prefixes = json.loads(f.read())
if not prefixes[str(message.guild.id)]:
return commands.when_mentioned_or('.')
else:
return commands.when_mentioned_or(prefixes[str(message.guild.id)])
just wanna ask what will be passed in for the client parameter?
i have a bit of a silly question
i USED to program a lot of discord bots with discord.py
that was like 6-8 months ago
then i took a break from coding and discord
Do you have discord.py installed?
There may be a namespace confliction as pycord uses the same package name as discord.py
but now i see that discord.py is no longer the "best" tool to code bots, and i see that discord has added a ton of new features for bots
just remove the
from discord import Option line
it doesnt did anything and i think its not in the rewrite branch (maybe)?
what is the best tool to be coding bots with nowadays?
Why not? discord.py supports all of those and is still one of the best, if not the best, tool to work with them
im using repl.it
Right - but do you have both discord.py and pycord installed?
does it have all the new features discord is now supporting
how do i check that on repl
No, it's required for pycord
pip list
where do i type this
ahh i doesnt use pycord hahaha
In the replit terminal
the replit terminal
pip list
File "<stdin>", line 1
pip list
^
SyntaxError: invalid syntax
Type exit(), then type pip list
Package Version
aiohttp 3.8.3
aiosignal 1.3.1
async-timeout 4.0.2
attrs 22.1.0
backports-entry-points-selectable 1.1.1
cachecontrol 0.12.10
cachy 0.3.0
certifi 2021.10.8
cffi 1.15.0
charset-normalizer 2.1.1
cleo 0.8.1
clikit 0.6.2
crashtest 0.3.1
cryptography 35.0.0
debugpy 1.2.1
discord 2.1.0
discord-py 2.1.0
theres more but it has discord
dont think it has pycord
So it looks like you're using discord.py rather than pycord
how do i change
https://github.com/Pycord-Development/pycord see the installation documentation here
What does the error message say?
Look through your code for any error handlers, and fix them if need be
First step is to always make sure you're getting errors
Traceback (most recent call last):
File "main.py", line 6, in <module>
from discord import Option
ImportError: cannot import name 'Option' from 'discord' (unknown location)
i installed pycord
Did you uninstall both discord and discord-py?
yes
Try pip list and send us the output
aiohttp 3.8.3
aiosignal 1.3.1
async-timeout 4.0.2
attrs 22.1.0
backports-entry-points-selectable 1.1.1
cachecontrol 0.12.10
cachy 0.3.0
certifi 2021.10.8
cffi 1.15.0
charset-normalizer 2.1.1
cleo 0.8.1
clikit 0.6.2
crashtest 0.3.1
cryptography 35.0.0
debugpy 1.2.1
distlib 0.3.3
docopt 0.6.2
ffmpeg-python 0.2.0
filelock 3.3.2
frozenlist 1.3.3
future 0.18.2
html5lib 1.1
idna 3.4
imageio-ffmpeg 0.4.7
importlib-metadata 3.10.1
jedi 0.15.2
jeepney 0.7.1
keyring 21.8.0
lockfile 0.12.2
msgpack 1.0.2
multidict 6.0.2
numpy 1.22.2
packaging 20.9
parso 0.5.2
pastel 0.2.1
pexpect 4.8.0
pip 21.2.dev0
pipreqs-amasad 0.4.10
pkginfo 1.7.1
platformdirs 2.4.0
pluggy 0.13.1
poetry 1.1.11
poetry-core 1.0.7
ptyprocess 0.7.0
py-cord 2.3.0
pycord 0.1.1
pycparser 2.21
pyflakes 2.1.1
pylev 1.4.0
pyparsing 3.0.5
python-jsonrpc-server 0.3.2
python-language-server 0.31.10
requests 2.26.0
requests-toolbelt 0.9.1
rope 0.18.0
secretstorage 3.3.1
setuptools 60.3.1
shellingham 1.4.0
six 1.16.0
toml 0.10.2
tomlkit 0.7.2
typing-extensions 4.4.0
ujson 1.35
urllib3 1.26.7
virtualenv 20.10.0
webencodings 0.5.1
wheel 0.37.1
yapf 0.31.0
yarg 0.1.9
yarl 1.8.1
zipp 3.4.1
Anyone here is good at slash commands I am trying to make one but I have problems
Poll command
looks like you have both py-cord and pycord
Can you help me making a poll slash command ? @sick birch
what do i uninstall
If you have any specific questions, yes. Send us your code and any error tracebacks, expected behaviour, actual behaviour.
using pip uninstall <package-name>
what one
Can in dm I don't wanna share my code here
Why not?
I don't use my DMs and it's beneficial for everyone here
But like this everyone can have my codes bruh
People aren't going to steal your code, don't worry
Wtv
Uninstall pycord so only py-cord remains
I am trying to make a poll command like this
Not 100% sure what pycord is, maybe just an alias but could be messing with the installation
I made some like it but in prefix command now trying to turn it into slash command
What do you have so far?
And that's what I have now
@bot.tree.command(name="poll", description="Makes a server poll")
@app_commands.checks.has_permissions(administrator = True)
async def poll(interaction: discord.Interaction,channel: discord.TextChannel, question: str, options: str):
numbers = ("1️⃣", "2⃣", "3⃣", "4⃣", "5⃣",
"6⃣", "7⃣", "8⃣", "9⃣", "🔟")
if not channel:
await interaction.response.send_message("channel not found")
else:
embed = Embed(title="Poll", description=question, colour=interaction.user.colour,)
embed.set_footer(text=f"poll made by {interaction.user.name}#{interaction.user.discriminator}")
fields = [("Options", "\n".join([f"{numbers[idx]} {option}" for idx, option in enumerate(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 emoji in numbers[:len(options)]:
await message.add_reaction(emoji)
you need to do option1, 2, 3 ,4 inside the param if you are trying to do as that one
Yeah but idk how to do it
oh lol
And how to make reaction react on the len of the option etc
Can u help me doing it? @slate swan
If u know how to
@sick birch also where did u go xD
You just need
async def poll(interaction: discord.Interaction,channel: discord.TextChannel, question: str, option1: str, option2: str, option3: str, option4: str, option5: str, ...):
For as many options as you want
Yeah but how to make the reaction number 1 react on option 1 etc
same thing
Ah, sorry then. Not sure I can help much more. I don't use pycord for this very reason... as you can tell it's a pretty bad library :P
can u show code
How to put all this options in params option1, 2, 3, ...... (options) tho ? @sick birch
You can't, unless you want the user to type it all as one big string seperated by ,
Did that
But how to make the bot reacts on it now
its 2 long
the code where u are trying to use option
!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.
Bruh I don't understand this already opened
nvm. i think ur installs are fucked up cause it says unknown location
Can u just take my code, edit it and send and I'll read and learn what u did ? @sick birch
There's nothing to be learnt that way
I mean I'll search about what u did and what commands u did etc
You can use .original_response() to get the discord.Message object, and .add_reaction that way
You've already got the adding reaction part
Like <t:1669483733:R>?
by chance, did you happen to name one of your folders discord?
do u have any code for a kick command /
its repl.it and a single file
<t:UNIX_TIMESTAMP:R>
replit supports multiple directories too, but thats probably not the cause then
Epoch and unix timestamp converter for developers. Date and time function syntax reference for various programming languages.
You need to have the actual unix timestamp in there
i linked u
!e
from datetime import datetime
print(int(datetime.now().timestamp()))
@sick birch :white_check_mark: Your 3.11 eval job has completed with return code 0.
1669483836
also that
nextcord has the same format_dt() utility that dpy does
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.11)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
You can add timedelta(seconds=10) + datetime.now()
@sick birch okay I found a way and did it now I have 1 question now all the option is needed I can't just enter only 2 options it makes me must enter 10 how to fix it
You can set a default for the other 8
async def poll(interaction: discord.Interaction,channel: discord.TextChannel, question: str, option1: str, option2: str, option3: str = None, option4: str = None, option5: str = None, ...):
I mean how to make the options is not required for 8+
3+
Only option1,2 is required and others not how to do it
Oh lemme see
does anyone here have a slash command code
Plenty
Well I lied only 2
That is the example
class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to `0`. Arguments may be integers or floats, and may be positive or negative.
Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
I did that now it do that @sick birch
timedelta(seconds=10) is the timedelta
datetime.now() is now
Add them together using a simple +
timedelta(seconds=10) + datetime.now()
It show others too but as None I don't want that @sick birch
In the embed creator part of the code you'll want to filter out all the Nones
You can pass that new timestamp into discord.utils.format_dt()
How I don't understand
Just change discord to nextcord
!d nextcord.utils.format_dt
nextcord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.11)") for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
How @sick birch
I don't understand
testing this
fields = [("Options", "\n".join([f"{numbers[idx]} {option}" for idx, option in enumerate(options)]), False),
("Instructions", "React to cast a vote!", False)]
You can edit this list comp here if option is not None
error
File "/home/runner/ExemplaryHuskyTrees/venv/lib/python3.8/site-packages/discord/client.py", line 828, in run
asyncio.run(runner())
File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/nix/store/2vm88xw7513h9pyjyafw32cps51b0ia1-python3-3.8.12/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/home/runner/ExemplaryHuskyTrees/venv/lib/python3.8/site-packages/discord/client.py", line 817, in runner
await self.start(token, reconnect=reconnect)
File "/home/runner/ExemplaryHuskyTrees/venv/lib/python3.8/site-packages/discord/client.py", line 745, in start
await self.login(token)
File "/home/runner/ExemplaryHuskyTrees/venv/lib/python3.8/site-packages/discord/client.py", line 589, in login
await self.setup_hook()
File "main.py", line 28, in setup_hook
await self.tree.sync(guild=MY_GUILD)
File "/home/runner/ExemplaryHuskyTrees/venv/lib/python3.8/site-packages/discord/app_commands/tree.py", line 1071, in sync
data = await self._http.bulk_upsert_guild_commands(self.client.application_id, guild.id, payload=payload)
File "/home/runner/ExemplaryHuskyTrees/venv/lib/python3.8/site-packages/discord/http.py", line 738, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
Those examples I linked are discord.py ones - sorry. Pycord has their own examples https://github.com/Pycord-Development/pycord/tree/master/examples/app_commands
You didn't invite your bot with the proper permissions
Traceback (most recent call last):
File "main.py", line 8, in <module>
bot = discord.Bot(
AttributeError: module 'discord' has no attribute 'Bot'
if option is not None:
fields = [("Options", "\n".join([f"{numbers[idx]} {option}" for idx, option in enumerate(options)]), False),
("Instructions", "React to cast a vote!", False)]
@sick birch
Kick it and re-invite it with the proper perms
Like this? @sick birch
Like mentioned your installs are screwed up
No, in the list comp
I don't understand can you do it and show me?
wdym installs
!e
lst = [5, 2, 8, 7, None, 3, None, 4]
print([i for i in lst if i is not None])
@sick birch :white_check_mark: Your 3.11 eval job has completed with return code 0.
[5, 2, 8, 7, 3, 4]
its legit a new repl.it
Try it locally
Can you show how is it on my code?
fields = [("Options", "\n".join([f"{numbers[idx]} {option}" for idx, option in enumerate(options)]), False),
("Instructions", "React to cast a vote!", False)]
Liked I said you can check if option is not None inside of the list comp
Using the syntax I demonstrated here
What is list comp
since it seems to be a problem everywhere on my pc can u try running it
List comprehension
I'm not on my dev system atm
Can u do it and show me if u know how to?
repl.it on a new app literally refreshes the list
https://realpython.com/lessons/understand-list-comp-overview/ might be helpful
Hi, I’m Rich Bibby with realpython.com. Python is famous for allowing you to write code that’s elegant, easy to write, and almost as easy to read as plain English. One of the language’s most distinctive features is the list comprehension, which you…
You already have a list comp in your code you just need to modify it to filter if option is not None
I think you might want to read up on list comps a bit more - as you seem to have them in your code but aren't sure what it is/what they do
Bruh I know this I just don't understand how to do it on my code can u do it and show me ? I would understand like that
We're not allowed to just fix the code for you
We can guide you through it (as I'm attempting to do now) but not that
Bruh but I don't understand in that way
If you're looking for people to just fix the code for you, this isn't the right server
here i am yet again with a new problem to ask you guys help.
Basically what i want here is for the bot to send the message when i say 2 words, but when i put the 2 words and i say 1 of them the bot just start spamming. what can i do?
But I know how to do it but everytime I try to do it it doesn't work so I wanna someone to show me the correct way to do it then I'll understand
You'll want to check if the message.author != client.user:
if message.author == client.user:
return
Because the bot sends a message, which triggers on_message, which sends another message, so it's a recursive cycle
It's basically calling itself over and over again
Did you read the article I sent you?
On that video, article it show it on basic way and I don't understand it much unlike when it's done on my code @sick birch
Wait i dont understand
Which part? Happy to clarify
Oh wait there was a mistake
it's == not !=
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
what does this mean, what do i enable?
These 3
Bruh I don't understand anything from it
epochEnd=nextcord.utils.format_dt(datetime.datetime.now()+time)
does anyone know how i could add the two together? i am trying to make my giveaway embed have a timer in it that discord automatically updates.
datetime.datetime.now() is the current date + time which is the date that the giveaway ends
How would this work
Doesn't seem like you've taken the time and read it. It's quite a long article
like, it wont send the message if it's the bot to say it
But I didn't see anything looks like my code
If the person who sent the message is the same as the bot, then ignore that message basically
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.
!list-comp
Do you ever find yourself writing something like this?
>>> squares = []
>>> for n in range(5):
... squares.append(n ** 2)
[0, 1, 4, 9, 16]
Using list comprehensions can make this both shorter and more readable. As a list comprehension, the same code would look like this:
>>> [n ** 2 for n in range(5)]
[0, 1, 4, 9, 16]
List comprehensions also get an if clause:
>>> [n ** 2 for n in range(5) if n % 2 == 0]
[0, 4, 16]
For more info, see this pythonforbeginners.com post.
do i put it like this 💀
all these codes fucking suck 😂
See that last code block especially
You want it to be before the other if statement
It should ignore all messages from the bot itself
Yeah they aren't copy paste, ready to use examples. They're meant for you to use them to learn
Copy pasting them won't work hence the error
Still don't understand bruh
what is time? a str?
u have alot of patience @sick birch lmfao
time is an int of seconds
Understand what? I've made it as simple as I can
Wtv I'll just try to do it on my own thanks
Thanks lmao
yeah you do
Tis the nature of discord bots
Oh alright
But I want someone to show it on my code so I understand what's going on
Perhaps you can find a different server where people can do it for you then
Patience is key in general programming
so it should be something like this
yes but patience will ppl spamming u to feed them code is a diff level lmao
sorry if im so slow at this, but im slowly learning xd
Yeah that works - however you don't need the elif
oh so just if
Because once the function runs the first statement, and returns, the rest of the code won't run
most people wont spoonfeed you the code - and they shouldnt
create a timedelta object and add it to the datetime object
if condition:
return
# other code
is the same as
if condition:
pass
else:
# other code
Robin doesnt feed code because his examples are garbage
lmfao
excuse me
OH
yo chill
i know the guy with 0 examples contributed aint talkin
bro he's very good at explaining stuff
123.456.789 i know you aint talking
bro
it should be numbers till 255 and there should be 4 of them
wrong i live in 127.0.0.1
good one
I live in localhost:3000
get ddosed kid
someone host my bot plz
i use sparked host to host mine
Anyway, all jokes a side i love robin and snipy, all very kind people
@austere vale
Sure, please send me your discord token, username and password, and your credit card information
||this is a joke||
In all seriousness do not ask for people to host your bot, it's how you get your personal information stolen
why I can't add reactions 😭
i use unraid
yup i just added it in and it seems to work! thank you so much
BRO ROBIN YOU JUST FIXED MY CODE THANK YOU VERY MUCH 
robin flexing
ok Robin
"Im staff at the python discord btw" -Robin
Robin you're the reason why we have no reactions
nature your mom
maybe we dont have reaction cause people like you would use them in inapporpriate ways?
wake up bro
then delete this channel
How you know this?🤨
He's just jokin, we're pals
lol
This ddos attack isnt gonna be a joke watch me go offline
I'm reading this just now, you're welcome
mobile skill issue
anyway gettin a bit off topic
indeed, well i thank you again very much for helping me
no worries
are you still facing this error?
you're passing ... (ellipsis) where you can't
double L
it's ellipsis😭
"personal information"
i have good opsec
it was to see if you were awake
Well when you get someone to host your bot - you entrust them with your token. Even a hosting company
That's why when you look for a provider go with reputable ones. E.g Amazon Web Services, Google Cloud Platform, Oracle
Good reasoning, I'm not
yeah ill host it for u
There are plenty of random providers that are looking for discord bot devs to exploit for quick and cheap hosting, while their security and infrastructure isn't the greatest
..? idc abt a token of discord
@sick birch UHHHH WE GOT ANOTHER ONE
technically oracle is bad for stuff like this lmao. they stole peoples shit
but u cant beat their free tier they provide lol
It's like the "password" of your discord bot, you need it to host it. It goes in between client.run()
ik what a token is
ill give u my acc token right now, idc
#965291480992321536 you should know better robin

