#discord-bots

1 messages · Page 142 of 1

vocal snow
#

What is that supposed to do exactly

slate swan
#

bro what

slate swan
austere vale
#
  @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
vocal snow
slate swan
#

send

unkempt canyonBOT
#

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...
vocal snow
#

You can pass the datetime to this and get the formatted string directly

split forge
#

raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'redeem' raised an exception: AttributeError: 'Interaction' object has no attribute 'author'

#

D:

bright wedge
#

interaction.user

split forge
#

wa

vocal snow
# slate swan send

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

bright wedge
#

Interaction.user return the member who use the interaction

potent light
#

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.
potent light
split forge
#

to use key?

potent light
split forge
#

I have normal key system but I need / commands

bright wedge
potent light
bright wedge
potent light
potent light
bright wedge
split forge
potent light
bright wedge
#

It is what it is

potent light
bright wedge
potent light
potent light
bright wedge
#

Using PIL or any same module, you create a image looks like a embed,and do whatever you want inside.

potent light
bright wedge
#

depends on you!

slate swan
#

are there any instagram apis?

quick gust
#

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

bright wedge
tidal hawk
dapper cobalt
#

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

dapper cobalt
#

might not be the best solution, but it's your task to make it better

naive briar
#

You know you can store the message object in the dictionary

dapper cobalt
#

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

quick gust
#

might be of use

dapper cobalt
#

no, don't define self

#

remove self completely

dapper cobalt
# quick gust

id is the interaction's id, not the message's. And I believe application_id is the bot's id..

slate swan
#

No

dapper cobalt
#

yes, it is.

#

perfect! i'm glad to help

quick gust
dapper cobalt
#

thought you were highlighting what should be used

slate swan
#

Hey @dapper cobalt can does interaction has attr of channel?

quick gust
#

yep thats mb

slate swan
dapper cobalt
unkempt canyonBOT
#

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.
naive briar
#

!d discord.Interaction.channel

unkempt canyonBOT
slate swan
#

No man :[[

dapper cobalt
slate swan
#

Coooolll

#

It's mean instead of interaction.responsw

#

We can use interaction.channel

#

Huh?

naive briar
#

You still have to respond something to the interaction

#

Or the user will get interaction fail

slate swan
#

interaction.response.defer will work?

naive briar
#

You would still get interaction fail after 15mins

slate swan
#

Btw can we get the msg id that just sent from interaction

#

like
message = interaction.channel.send()
print(message.id)

slate swan
#

Cooooolll

upbeat gust
#

But why are you using interaction.channel.send?

slate swan
#

Because
msg = interaction.response.send_message()
print(msg.id)
Will always return none

#

because u need to do msg = interaction.original_message()

upbeat gust
#

that's why you use

slate swan
#

inter.send doesn't return

upbeat gust
#

^

slate swan
upbeat gust
#

Not message

slate swan
#

@tidal hawk dude

slate swan
upbeat gust
#

He did though

naive briar
#

Noice

upbeat gust
tidal hawk
slate swan
#

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

naive briar
#

It is an coroutine, so, you need to await it

slate swan
slate swan
#

I will definitely check that outtt

naive briar
unkempt canyonBOT
#

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.
tidal hawk
severe mural
#

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:"

slate swan
#

Both of them will work

#

1st one assuming u have both giveaway channel id and suggest channel id in suggest_channels index

dull knot
#

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?

austere vale
#
  @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)

dull knot
slate swan
slate swan
dull knot
slate swan
#

yup

naive briar
#

It should be datetime object

dull knot
dull knot
slate swan
#

huh ? the example i showed is exactly how its used

dull knot
#

Do I just put Docstrings after?

#

Alright, lemme try lol

slate swan
#

doc strings go at beginning of the func

quick gust
#

think thats it..

slate swan
#

docstrings are better

tough lance
#

There are multiple options for that

quick gust
#

personal preference

tough lance
#

Like description arg in commands.Param()

dull knot
#

Also, came back for a new question

quick gust
#

I'd personally use the description arg for a short description and docstrings for a longer one

dull knot
#
    """         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"![RAB](https://cdn.discordapp.com/emojis/1014204456964993034.webp?size=128 "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](https://cdn.discordapp.com/emojis/998371293265145877.webp?size=128 "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)

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

slate swan
quick gust
dull knot
slate swan
#

yup

quick gust
#

what is it

slate swan
#

no clue but if its too long itll return a command error

dull knot
#

Probably somewhere around 60+ Charas?

slate swan
#

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)
naive briar
#

What not responded

slate swan
#

show traceback

naive briar
#

Which interaction

#

Please be more specific

slate swan
#
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?

weary rain
#

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 Latom

naive briar
#

!d discord.InteractionResponse.defer - I don't know what are you saying exactly. But I guess you mean this

unkempt canyonBOT
#

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...
slate swan
#

What is thi

slate swan
#

Its already sent that is why I want to edit it.

#

What's the problem with that

naive briar
#

You did not send it with that interaction

#

It's a different interaction

slate swan
#

Oooooooh

#

I used the wrong inter

#

Thanks @naive briar and @slate swan

#

if ur using a component its a message interaction

naive briar
weary rain
weary rain
#

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

slate swan
#

also deferring helps

weary rain
#

yeah i did, its kind of big though xd

slate swan
#

are u doing db stuff?

naive briar
#

!paste

unkempt canyonBOT
#

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.

weary rain
weary rain
slate swan
#

which command? lol

weary rain
#

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

slate swan
#

jishaku does have support for slash commands

#

oh jk

#

lmao

weary rain
#

xD its syncing i think

slate swan
#

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

weary rain
#

yeah i'll try making a hybrid/normal command instead and see how that goes Latom thanks for your time ^
hv a great day man

slate swan
#

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

naive briar
#

Where is that self from

slate swan
#

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

dull knot
#

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"![RAB](https://cdn.discordapp.com/emojis/1014204456964993034.webp?size=128 "RAB") 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"**![PAL](https://cdn.discordapp.com/emojis/998371293265145877.webp?size=128 "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)

It Kicks the Target-user but it won't DM

#

I tried lol. But I just couldn't figure it out

dull knot
naive briar
slate swan
#

is there any errors?

dull knot
dull knot
#

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.
ripe blaze
#

I think its because the id is an int

#

and not a string

dull knot
dull knot
ripe blaze
naive briar
#

Totally not disnake at all

dull knot
dull knot
ripe blaze
#

I never used disnake
but try pinging the member

dull knot
dull knot
#

Hence, the User Cannot be found error?

#

Although, I found it weird that it works on prefix, but not on slash whydishappen

restive leaf
#

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

slate swan
#

wait u have disnake.Member param

#

wtf

slate swan
dull knot
#

Lol, just noticed but I've been working on it for like 2 hrs LOL

slate swan
#

are u sure the prefix command is exactly the same?

slate swan
#

is the prefix command the same as ur slash command?

dull knot
#

So, yeah, they're the same. Unless I did something wrong there lol

slate swan
#

does the user actually get dmed?

#

oh i see the screenshot

dull knot
shrewd apex
#

hybrid_command when?

dull knot
#

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)
naive briar
restive leaf
#

any example?

slate swan
#

could also do a single command with multiple options of languages and input the message id

restive leaf
#

is there any way to get info which alias is command called?

alpine cove
#

or do some webscraping and save it in a .csv or smth

alpine cove
restive leaf
#

i know i can use translating api

alpine cove
restive leaf
#

but i dont know how to do translation in multiple commands like: !en {text} !it {text} etc.

alpine cove
#

oh yea i get u

#

check the docs and exmaples

#

*examples

#

If you want to dm me and I'll help you out

restive leaf
#

what do you have to type in the docs to find it

alpine cove
slate swan
alpine cove
#

dull knot
slate swan
#

;-;

#

Gimme code again

dull knot
#

I placed a local if statement inside the else statement so that it would see that first. Or I might be mistakes

slate swan
dull knot
#

Let me send the Slash command one

slate swan
#

Yes pls

dull knot
#
    """         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"![RAB](https://cdn.discordapp.com/emojis/1014204456964993034.webp?size=128 "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](https://cdn.discordapp.com/emojis/998371293265145877.webp?size=128 "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)
slate swan
slate swan
slate swan
#

Imma make code simple

alpine cove
#

disnake sucks anyways

dull knot
#

It's the library itself?

#

Ouch lol

slate swan
#

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

dull knot
#

Alright, lemme try

slate swan
#

Just replace that else

#

that wont work bro

#

his entire thing is dming the user.

#

Let him see 💀

#

Idk disnake

#

its an internal issue.

slate swan
#

he cant dm a user with slash but it works with prefix

dull knot
#

Pretty much lol

slate swan
#

According to the code that should work atleast in dc.py

slate swan
#

ur not understanding dude

slate swan
dull knot
#

Guess I'll figure that one out later. I'm pooped lol.

slate swan
dull knot
#

Thanks for the help though. Appreciate it

slate swan
# slate swan 🙂

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

unkempt canyonBOT
#
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**.
slate swan
#

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

naive briar
#

Like /kick blah blah blah

dull knot
naive briar
#

What's the options you chose

slate swan
#

Can u just click on dm_user?

dull knot
dull knot
slate swan
#

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":

naive briar
dull knot
dull knot
naive briar
#

No

#

You already have a default argument

dull knot
#

I guess I'ma try that later. for now, I'ma eat

slate swan
#
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

naive briar
#

You mean in the bot's profile or in the default help command

#

You have to set it yourself in dev portal

slate swan
#

Set that in application

slate swan
naive briar
#

You can

slate swan
#

Ofc

naive briar
#

Just :pithink: or some emoji

slate swan
naive briar
#

Yeah

slate swan
#

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

naive briar
slate swan
#

Wdym?

naive briar
#

Most likely

slate swan
naive briar
#

At least that's what dpy does

slate swan
slate swan
#

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.
naive briar
#

What

slate swan
#

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

naive briar
#

It looks like disnake just cannot find the member

slate swan
#

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 💀

alpine cove
naive briar
#

The command will be invoked after it converted all the argument

#

Idk what are you talking about

slate swan
#

so ur saying it never reaches the dm_user ?

naive briar
#

You look like you're saying that it the kicked the member before the command is being used

slate swan
#

what

naive briar
#

Or the callback is being called

slate swan
#

u guys are saying that dm_user is never true

naive briar
#

Are you really sure that the user is in the server before using that command

slate swan
#

omg

#

im going to blow my brains out

naive briar
slate swan
#

THEN IT WOULDNT TRY TO DM THE USER

#

HOLY

#

Imma not talk 💀

naive briar
#

It's not DMing the user

#

It can't even convert the arg to member

#

The first check isn't even being executed

slate swan
#

can you not read?

naive briar
#

Read what

slate swan
#

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

naive briar
#

I can't see WHERE this error is even related to the member DMing

slate swan
#

Bruh

slate swan
naive briar
#

Why would you want to kick the member that isn't in the server in the first place

slate swan
#

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

naive briar
#

What what

slate swan
#

;-;

#

sigh. u tried

#

I am bad at explaining

#

nah was fine explanation catgal just trolling at this point

naive briar
#

How am I trolling first of all

slate swan
#

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

slate swan
#

idk how tf it works with prefix to begin with

naive briar
#

!d disnake.Client.get_user

unkempt canyonBOT
slate swan
#

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()

slate swan
#

Bruh why this thing so complicated

slate swan
#

yes but that still isn't the issue here

slate swan
#

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..

naive briar
#

People can have more than 1 mutual servers

slate swan
#

Leave that matter ig

#

Possibly a delayed message

alpine cove
slate swan
#

When u delete a channel

#

Probably

#

Could be

slate swan
alpine cove
#

yea

slate swan
#

!purge 100

#

Same as that

#

That one

alpine cove
#

mh

slate swan
#

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

#

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

alpine cove
slate swan
#

This bot is sus

slate swan
#

Maybe lol

#

nah it actually "nukes" look at the descrip

alpine cove
slate swan
#

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

slate swan
#

i would pay to see that happen lmao

#

wheres ur callback

#

oh

#

i see yea idk i dont use dpy or views. they trash

naive briar
#

Why are you even checking custom ids

#

The library handle all of that

#

Just put custom_id in the deco is fine

dull knot
slate swan
#

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

dull knot
slate swan
#

ahh that explains that

dull knot
# slate swan 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

slate swan
#

just move the member.send above the member.kick

dull knot
#

Ahh, alright

#

Thanks

slate swan
#
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)
dull knot
slate swan
#

i would use a try except with the member.send tho cause if a user has their dms closed it'll stop the code

dull knot
#

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

slate swan
#

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

dull knot
dull knot
slate swan
#

nah that is used to allow users to use that command in dms

dull knot
slate swan
#

sure.

#

ahh nah

#

no purge for disnake.DMChannel

upbeat otter
dull knot
#

Well, can't do anything about it I guess

upbeat otter
slate swan
#

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

upbeat otter
#

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

dense horizon
#

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.

maiden fable
#

Nice, at the same time

dense horizon
maiden fable
dense horizon
#

That's not exactly what I want

#

I want it to be completely hidden no one can see that I even executed it

maiden fable
#

I mean ephemeral is for that only

dense horizon
#

It hides the message, not the command itself

maiden fable
dense horizon
#

I want used /privacy-policy to be hidden

maiden fable
#

Now when I dismiss the message the command also goes

dense horizon
#

Oh, how can I dismiss it programatically?

maiden fable
#

You cannot

#

the person has to click Dismiss Message

#

I don't think the delete method works on ephemeral messages tho not sure

dense horizon
#

Yeah, it doesn't work I tried

maiden fable
#

yea then no way of dismissing it by code

dense horizon
#

damn

#

even no hacks?

maiden fable
#

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

dense horizon
#

Got it 😦

#

Hmm, that's too bad, but thanks anyway.

shrewd apex
#

not sure

maiden fable
#

Worth a try

shrewd apex
#

or if u are so paranoid just use the dms

dense horizon
#

Nop, can't use dms

dense horizon
maiden fable
#

istg the Interaction object is hella weird

#

Thanks Discord

cursive spindle
#
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?

maiden fable
#

!d os.walk

unkempt canyonBOT
#

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)`.
shrewd apex
#

pathlib when

maiden fable
#

Me who uses neither: lemon_clown

cursive spindle
#

what takes as first parameter?

maiden fable
#

and a good explanation

shrewd apex
#

default ()

vocal snow
#

if only the error told you what was wrong with the code

merry sail
maiden fable
#

I mean the error does

shrewd apex
maiden fable
vocal snow
maiden fable
shrewd apex
#

i think he only needs glasses

merry sail
#

come on hunter

cursive spindle
maiden fable
#

I am at that point rn where I have stopped understanding sarcasm anymore, sorry guys

maiden fable
#

@shrewd apex can ya help him?

vocal snow
#

yes asher is soo good at helping asher can definitely help 😃

maiden fable
#

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

vocal snow
#

no no i dont want to lol

#

im sure @shrewd apex does tho 👍

maiden fable
#

Stop it please😔

vocal snow
#

do you have an on_message listener

cursive spindle
#

need 1 or 3?

maiden fable
#

3

shrewd apex
maiden fable
#

True tho

#

@cursive spindle

shrewd apex
#

just copy paste and change the path

cursive spindle
#

trying to get my cog files and load the extensions inside theses folders

shrewd apex
#

imagine

#

whats ur cog folder name

slate swan
#

@maiden fable yes u can complete hide a slash command

maiden fable
#

?

slate swan
#

Wait wrong mention

#

💀

maiden fable
#

All cool

slate swan
#

@dense horizon u can completely hide a slash command in discord.py

dense horizon
#

Tell me pls how

shrewd apex
#

climax point

cursive spindle
cursive spindle
slate swan
#

imma edit according to ur code

shrewd apex
#

why u have subdirectories first time saw such cogs

#

just unpack u are gonna load them all anyways

dense horizon
# slate swan Show ur code
@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()```
cursive spindle
#

i want it works like that

#

anyway thank you!i will search

shrewd apex
cursive spindle
#

😛

#

i wont do that, if i add another folder change the code too

slate swan
#

Check if that works

maiden fable
slate swan
#

It was only for slash command, but seems u using hybrid command

slate swan
#

I checked earlier

maiden fable
#

I thought it only disabled the command for others

slate swan
#

Nah just hides it

maiden fable
#

Either a new discord update or I am rusty

slate swan
#

Or old idk

maiden fable
#

or I am rusty

ember nest
#

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?

slate swan
#

In intregations u can see the default permission thing

maiden fable
#

Yea

slate swan
#

Like waiy

slate swan
#

Ahh can't vheck in mobile

#

interaction.user

#

@ember nest

ember nest
#

So I can do

user = interaction.user

?

#

@slate swan

slate swan
#

Yes

#

U can do that

#

in slash command u have to define interaction as discord.Interaction

#

Then it will work

ember nest
#

Yeah I did that

slate swan
#

Then u r good to go

ember nest
#

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

slate swan
#

Hybrid commands has limitations and too confusing

ember nest
#

Oh

slate swan
#

So stick with slash for now

ember nest
#

Alright tysm

slate swan
#

:]

ember nest
#

Another question sorry @slate swan

maiden fable
#

can you run this:

for dirp, dirn, file in os.walk:
    print(dirp, dirn, file)
ember nest
#

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
#

Thats why this thing doesn't work

slate swan
#

Can u show the code 💀

#

I always need the code xd

ember nest
#

In dm can?

slate swan
#

Yep

ember nest
#

Alright check dm @slate swan

slate swan
#

Okay

#

how do i add a icon in my embed again

slate swan
#

Or top left corner icon

#

got it ty

turbid shale
#

Anyone here good at discord python?

maiden fable
#

depends on the question

turbid shale
maiden fable
#

I ain't got much experience with slash commands, no

sick birch
turbid shale
maiden fable
#

That too

sick birch
turbid shale
#

#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...

▶ Play video
#

@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

sick birch
#

What's the error?

turbid shale
#

something with imports option

sick birch
#

Can you paste the full traceback?

turbid shale
#

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)

polar dawn
#

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?

median gale
#

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

sick birch
#

There may be a namespace confliction as pycord uses the same package name as discord.py

median gale
#

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

polar dawn
median gale
#

what is the best tool to be coding bots with nowadays?

sick birch
turbid shale
sick birch
median gale
turbid shale
sick birch
turbid shale
polar dawn
sick birch
polar dawn
turbid shale
sick birch
turbid shale
# sick birch 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

turbid shale
sick birch
#

So it looks like you're using discord.py rather than pycord

turbid shale
sick birch
#

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

turbid shale
#

i installed pycord

sick birch
sick birch
#

Try pip list and send us the output

turbid shale
#

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

ember nest
#

Anyone here is good at slash commands I am trying to make one but I have problems

#

Poll command

sick birch
ember nest
#

Can you help me making a poll slash command ? @sick birch

turbid shale
sick birch
sick birch
turbid shale
ember nest
sick birch
#

I don't use my DMs and it's beneficial for everyone here

ember nest
#

But like this everyone can have my codes bruh

sick birch
ember nest
#

Wtv

sick birch
ember nest
#

I am trying to make a poll command like this

sick birch
#

Not 100% sure what pycord is, maybe just an alias but could be messing with the installation

ember nest
sick birch
ember nest
#

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)
                
slate swan
#

you need to do option1, 2, 3 ,4 inside the param if you are trying to do as that one

ember nest
#

Yeah but idk how to do it

slate swan
#

oh lol

ember nest
#

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

sick birch
#

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

ember nest
#

Yeah but how to make the reaction number 1 react on option 1 etc

turbid shale
sick birch
# turbid shale 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

ember nest
#

How to put all this options in params option1, 2, 3, ...... (options) tho ? @sick birch

sick birch
ember nest
#

But how to make the bot reacts on it now

turbid shale
slate swan
#

the code where u are trying to use option

sick birch
unkempt canyonBOT
#

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.
ember nest
#

Bruh I don't understand this already opened

slate swan
ember nest
#

Can u just take my code, edit it and send and I'll read and learn what u did ? @sick birch

sick birch
ember nest
#

I mean I'll search about what u did and what commands u did etc

sick birch
#

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>?

hushed galleon
turbid shale
turbid shale
sick birch
#

<t:UNIX_TIMESTAMP:R>

hushed galleon
#

replit supports multiple directories too, but thats probably not the cause then

slate swan
sick birch
#

You need to have the actual unix timestamp in there

slate swan
#

i linked u

sick birch
#

!e

from datetime import datetime
print(int(datetime.now().timestamp()))
unkempt canyonBOT
#

@sick birch :white_check_mark: Your 3.11 eval job has completed with return code 0.

1669483836
slate swan
#

also that

hushed galleon
#

nextcord has the same format_dt() utility that dpy does

sick birch
#

!d discord.utils.format_dt

unkempt canyonBOT
#

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...
sick birch
#

You can add timedelta(seconds=10) + datetime.now()

ember nest
#

@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

sick birch
#
async def poll(interaction: discord.Interaction,channel: discord.TextChannel, question: str, option1: str, option2: str, option3: str = None, option4: str = None, option5: str = None, ...):
ember nest
#

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

turbid shale
#

does anyone here have a slash command code

naive briar
#

lol

#

!d datetime.timedelta

unkempt canyonBOT
#

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...
ember nest
#

I did that now it do that @sick birch

sick birch
#

timedelta(seconds=10) is the timedelta
datetime.now() is now
Add them together using a simple +

timedelta(seconds=10) + datetime.now()
ember nest
sick birch
#

You can pass that new timestamp into discord.utils.format_dt()

naive briar
#

Just change discord to nextcord

sick birch
#

!d nextcord.utils.format_dt

unkempt canyonBOT
#

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...
ember nest
#

I don't understand

sick birch
# ember nest How <@432643355634171905>
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

turbid shale
#

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

sick birch
sick birch
turbid shale
ember nest
sick birch
#

Kick it and re-invite it with the proper perms

sick birch
sick birch
ember nest
turbid shale
sick birch
unkempt canyonBOT
#

@sick birch :white_check_mark: Your 3.11 eval job has completed with return code 0.

[5, 2, 8, 7, 3, 4]
sick birch
#

Try reinstalling

turbid shale
sick birch
ember nest
sick birch
sick birch
ember nest
#

What is list comp

turbid shale
naive briar
#

List comprehension

sick birch
ember nest
turbid shale
sick birch
#

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

ember nest
#

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

sick birch
#

We can guide you through it (as I'm attempting to do now) but not that

ember nest
#

Bruh but I don't understand in that way

sick birch
cinder tulip
#

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?

ember nest
sick birch
#

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

sick birch
ember nest
sick birch
#

Oh wait there was a mistake

#

it's == not !=

turbid shale
#

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.

Discord Developer Portal

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?

ember nest
austere vale
#

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

cinder tulip
sick birch
cinder tulip
#

like, it wont send the message if it's the bot to say it

ember nest
sick birch
turbid shale
#

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.

sick birch
unkempt canyonBOT
#

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.

cinder tulip
#

do i put it like this 💀

turbid shale
#

all these codes fucking suck 😂

sick birch
#

See that last code block especially

sick birch
#

It should ignore all messages from the bot itself

sick birch
#

Copy pasting them won't work hence the error

ember nest
slate swan
#

u have alot of patience @sick birch lmfao

austere vale
sick birch
ember nest
#

Wtv I'll just try to do it on my own thanks

sick birch
austere vale
sick birch
#

Tis the nature of discord bots

cinder tulip
ember nest
sick birch
primal token
#

Patience is key in general programming

cinder tulip
#

so it should be something like this

slate swan
cinder tulip
#

sorry if im so slow at this, but im slowly learning xd

sick birch
cinder tulip
#

oh so just if

sick birch
#

Because once the function runs the first statement, and returns, the rest of the code won't run

austere vale
glad cradle
sick birch
#
if condition:
  return

# other code

is the same as

if condition:
  pass
else:
  # other code
primal token
slate swan
#

lmfao

sick birch
#

excuse me

cinder tulip
#

OH

slate swan
#

yo chill

sick birch
#

i know the guy with 0 examples contributed aint talkin

cinder tulip
primal token
cinder tulip
#

it should be numbers till 255 and there should be 4 of them

sick birch
#

wrong i live in 127.0.0.1

primal token
#

good one

glad cradle
#

I live in localhost:3000

primal token
#

get ddosed kid

turbid shale
#

someone host my bot plz

austere vale
#

i use sparked host to host mine

primal token
#

Anyway, all jokes a side i love robin and snipy, all very kind people

sick birch
# turbid shale someone host my bot plz

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

glad cradle
#

why I can't add reactions 😭

slate swan
austere vale
cinder tulip
#

BRO ROBIN YOU JUST FIXED MY CODE THANK YOU VERY MUCH widepeepoHappyRightHeart

austere vale
#

robin flexing

glad cradle
#

ok Robin

primal token
#

"Im staff at the python discord btw" -Robin

#

Robin you're the reason why we have no reactions

sick birch
#

it's just the nature of this channel

#

second highest traffic

primal token
cinder tulip
glad cradle
#

then delete this channel

cinder tulip
#

lol

primal token
glad cradle
#

mobile skill issue

sick birch
#

anyway gettin a bit off topic

cinder tulip
sick birch
#

no worries

glad cradle
#

you're passing ... (ellipsis) where you can't

primal token
#

it's ellipsis😭

turbid shale
#

i have good opsec

glad cradle
sick birch
#

That's why when you look for a provider go with reputable ones. E.g Amazon Web Services, Google Cloud Platform, Oracle

primal token
sick birch
#

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

turbid shale
cinder tulip
#

@sick birch UHHHH WE GOT ANOTHER ONE

slate swan
#

but u cant beat their free tier they provide lol

sick birch
turbid shale
#

ill give u my acc token right now, idc