#discord-bots

1 messages · Page 69 of 1

shrewd apex
#
while True:
    try:
        msg = await wait_for()
    except asyncio.TimeoutError:
        ...
        break
    else:
        if msg.content == word:
            break
            ...
        else:
            ...
#

this seems fine

#

in else u can add a counter to check for wrong guesses

tropic burrow
#

shouldn't i like say something

shrewd apex
#

and make a break somewhere

tropic burrow
#

if it the letter is correct

shrewd apex
#

inside else like if count == 10: break

tropic burrow
#

because that would be kinda dumb

#

ye

meager chasm
#

Yes but u need to break out of the loop for current guess

shrewd apex
#

i don't think so if guess is incorrect it can be passed

tropic burrow
#

which will start A new game

pliant gulch
#

Breaking the loop will make the loop stop entirely

#

Did you mean to use continue instead of breaking out of the loop?

tropic burrow
#

THATS WHAT I SAID

pliant gulch
#

I know I was responding to endysis

tropic burrow
#

ok

pliant gulch
#

It doesn't really make much sense to break

tropic burrow
#

do a check and if they have guessed all the words then break but if they guess the letter then continye

pliant gulch
#

Yea that sounds right

meager chasm
#

I DK i never play da hangman b4

#

I thinking that if guess correct then stop

#

otherwise tell da user that they is wrong and do loop again

tropic burrow
#

ok a ran into a problem not related to discord

#

the thing is

light jungle
#

Is it possible to insert an image in discord modals?

pliant gulch
#

continuing is the better option

meager chasm
#

No not start loop after breaking!!! I think u not understand me

pliant gulch
#

Using break after a guess is correct will just lead to repetitive and redundant code

meager chasm
#

Like game over is guess correct

#

If guess is corrcet

pliant gulch
#

Guess in a hang-man context would be a letter

#

Not the entire word

meager chasm
#

ohhh

#

I c

pliant gulch
tropic burrow
#

will this wotk

#
guessed = []

  while guess != 0:
    msg = await client.wait_for('message',check=check)

    if msg.content in word:
      if msg.content in guessed:
        await ctx.channel.send("You've already guessed this.")
      else:
      index = word.find(msg.content)
      guessed.append(msg.content)
      await ctx.channel.send("Correct! Letter (s) was found in letter",index+1)
      continue
 ``` not done
#

i forgot the else

#

@pliant gulch this work?

pliant gulch
#

Ehhh I mean you have a syntax error

tropic burrow
#

ik indentation

#

in the real code i fixed that

pliant gulch
#

Other than that you have an issue with the code I would say

tropic burrow
meager chasm
tropic burrow
#

what?

pliant gulch
#

That would occur when the word being guessed has more than one apperance of the letter

#

For an example if the word was apple and my guess was p

#

I think you can see the issue there?

tropic burrow
#

yes

#

wait

pliant gulch
#

This is mostly due to the word.find finding the first occurrence

#

But also the fact you check if the letter was previously guessed. Making it impossible to progress in words that have the same letter appearing twice

tropic burrow
#

ok

#

then

#

wait what about the index

#

how to search for all

pliant gulch
#

Let me write you a quick example okay?

tropic burrow
#

occurences

tropic burrow
pliant gulch
#

!e ```py
word = list("apple") # Construct a list, so ['a', 'p', ...]
guess = "p" # Pretend this is the user inputted letter.

if guess in word:
word.pop(word.index(guess)) # Remove the character from the list

if len(word) == 0: # Once all characters are removed that means the word has been guessed correctly
print("All letters guessed")

unkempt canyonBOT
#

@pliant gulch :warning: Your 3.11 eval job has completed with return code 0.

[No output]
pliant gulch
#

It's a different method to check if the word is correct, but this fixes the issue with "double letters"

tropic burrow
#

ohhh

pliant gulch
#

Yep it's pretty simple

tropic burrow
#

something like this?

while guess != 0:
    msg = await client.wait_for('message',check=check)
    if msg.content in wordlist:
      wordlist.pop(wordlist.index(msg.content))
#

also wordlist is

#

wordlist = list(word)

pliant gulch
#

What is guess?

#

You should instead do ```py
while len(wordlist) != 0

tropic burrow
#

msg.content

pliant gulch
#

So the loop stops when the word has been guessed

tropic burrow
#

oh

pliant gulch
#

Then outside of the loop you can send a message saying they guessed the word right

#

Does that make any sense?

tropic burrow
#
while len(wordlist) != 0:
    msg = await client.wait_for('message',check=check)
    if msg.content in wordlist:
      await ctx.channel.send(embed=discord.Embed(
        title="You guessed correctly!",
        description=f"{msg.content} was found in the word!"
      ))
      wordlist.pop(wordlist.index(msg.content))
      continue
#

yes

pliant gulch
#

Mhm perfect, now just add an else statement to tell the user they guessed wrong. Then outside of the loop make it send a message saying they guessed it right

#

After that, it should be finished and ready to be played

tropic burrow
#

it just so happened that i managed to get the meaning of the word using an api. should i display that when they get it wrong

pliant gulch
#

As long as the methodology is the same the game should be functional, you can add whatever extra flavour you want

tropic burrow
#
     wordlist = list(word)

  while len(wordlist) != 0:
    msg = await client.wait_for('message',check=check)
    if msg.content in wordlist:
      await ctx.channel.send(embed=discord.Embed(
        title="You guessed correctly!",
        description=f"{msg.content} was found in the word!"
      ))
      wordlist.pop(wordlist.index(msg.content))
      continue
    else:
      await ctx.channel.send(embed=discord.Embed(
        title="You guessed wrong :(",
        description=f"Hint: The meaning of the word is {meaning}"
      ))
      continue
     ```
#

@pliant gulch will this work?

#

like final product

pliant gulch
tropic burrow
#

ok

pliant gulch
#

Granted you have some sort of response outside of the loop?

tropic burrow
#

oh that

#

ill say they won the game

pliant gulch
#

Like ```py
while len(wordlist) != 0:
...

await ctx.send(...)

tropic burrow
#

ok done

#
wordlist = list(word)

  while len(wordlist) != 0:
    msg = await client.wait_for('message',check=check)
    if msg.content in wordlist:
      await ctx.channel.send(embed=discord.Embed(
        title="You guessed correctly!",
        description=f"{msg.content} was found in the word!"
      ))
      wordlist.pop(wordlist.index(msg.content))
      continue
    else:
      await ctx.channel.send(embed=discord.Embed(
        title="You guessed wrong :(",
        description=f"Hint: The meaning of the word is {meaning}"
      ))
await ctx.channel.send(embed=discord.Embed(
    title="GG You won the game!",
    description="please try again"
  ))
      
placid skiff
#

what is word supposed to be? D_D

pliant gulch
#

👏

tropic burrow
#

well i ran into some problems

#

first of all the moment i type in the command it says "you guessed wrong"

#

secondly

#

actually wait nvm ik how to fix that

placid skiff
tropic burrow
#

well it would be split apart because i said

wordlist = list(word)
#

so the length of list will be same as length of word

placid skiff
#

it depends on what word is tbh, and no
You don't send any embed in that while loop, so when that embed is sent you're already out of that while

pliant gulch
#

Can you show your check?

#

Maybe the bot's message with the embed triggered the guessed wrong?

#

Or any other message detected

#

Just make sure that you check for ctx.author == message.user

tropic burrow
placid skiff
#

that will answer the bot too

pliant gulch
#

Yea that's the issue I'm gonna assume

tropic burrow
#

but i want it to be ffa

#

so i cant say m.user == ctx.user

placid skiff
#

!d discord.User.bot

unkempt canyonBOT
pliant gulch
#

This'll ignore all messages from the bot

placid skiff
#

m.author, m is a message

tropic burrow
#

alr done

wild spoke
#

How to make bot respond only when somebody replies to him with a keyword?

tropic burrow
wild spoke
#
if (respond2 in message.content.lower().split(' ')):
        if message.author.bot:
            return
        await message.reply("Не продается", mention_author=False
placid skiff
unkempt canyonBOT
#

The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.

New in version 1.5.

wild spoke
#

I don't understand documentation

#

Im a dumdum

pliant gulch
placid skiff
tropic burrow
#
@client.command()
async def hangman(ctx):
  r = RandomWords()
  word = r.get_random_word(hasDictionaryDef="true")
  length = len(word)
  data = dictionarysearch(word)
  print(word)
  meaning = data[0]["meanings"][0]["definitions"][0]["definition"]
  under = "-"*length
 
  
  mbed = discord.Embed(
    title=f"Length of Word: {length} Reply to guess",
    description=f"{under}"
  )

  await ctx.channel.send(embed=mbed)
  def check(m):
    return m.channel == ctx.channel and not m.user.bot
    
  wordlist = list(word)

  while len(wordlist) != 0:
    msg = await client.wait_for('message',check=check)
    if msg.content in wordlist:
      await ctx.channel.send(embed=discord.Embed(
        title="You guessed correctly!",
        description=f"{msg.content} was found in the word!"
      ))
      wordlist.pop(wordlist.index(msg.content))
      continue
    else:
      await ctx.channel.send(embed=discord.Embed(
        title="You guessed wrong :(",
        description=f"Hint: The meaning of the word is {meaning}"
      ))

  await ctx.channel.send(embed=discord.Embed(
    title="GG You won the game!",
    description="please try again"
  ))
placid skiff
#

you can't use any user package if you don't know how to read the docs

placid skiff
#

you just set a title and a description

wild spoke
#

If MessageType.reply: ?

#

Or what?

placid skiff
#

I sent you what you need D_D
I can't do it for you

tropic burrow
#

i kinda did in a weird way

placid skiff
#

that is outside the while

silk fulcrum
#

ctx.send

tropic burrow
#

no this is in the while check my code

placid skiff
#

bruh in that code the ctx.send and the while are on the same indentation level

tropic burrow
placid skiff
#

that means the send is outside

placid skiff
wild spoke
#

Screw it, just gonna use the keyword

tropic burrow
#

.

#

so wait

tropic burrow
#

the intro and end are outside

placid skiff
#

yup

tropic burrow
#

so whats the problem

silk fulcrum
#

if r1 is not None: do stuff ?

#

or just if r1:

#

and do stuff then

#

that has no logic in it, it says "if r1 is None then use it`"

#

do if r1 instead

#

I don't know. What do you want it to do if r1 is None?

#

No idea. I'd probably return. I don't clearly understand what are you making, except that it is reaction role.

#

why are you returning in if too?

#

I think so?

#

what's wrong with that?

#

your query returns none, that means that there is no row with such information you are checking for

#

What do you mean fix?

#

If that is not what you wanted then either your query is wrong or your database doesn't have expected row

#

You can check that by getting all rows from that table if it is not too big and check if there is a row you are looking for

#

If there is then check if data in it is similar with data you are giving to look for it and find where is the difference

#

And if there is not, then either add a row or edit an existing one

scarlet aurora
#

how can I make ```py
def check(m):
return m.content == 'yes' and m.channel == echannel

            msg = await self.bot.wait_for('message', check=check)
            await echannel.send("Confirmed")``` work only on reply, not on message
scarlet aurora
swift pumice
#

@slate swan on which server do you host your bot?

#

just cuz🗿

silk fulcrum
scarlet aurora
#

thanks man

#

W 👍

cerulean shale
#

@silk fulcrum yo 👋

maiden fable
#

Master meets another Master 🙏

placid skiff
#

But two Hunters can never met

maiden fable
#

Yes! Because if two Hunters meet, others will only see one in a few min 😄

shrewd apex
#

hmm

scarlet aurora
glossy shore
#

Hi, Can anyone help me choose the right discord package with python
I've always used discord.py for my discord bot development
but now, when I discovered new things I can do with discord
like

- Slash Commands
- Buttons
- Lists

I noticed that it is not available with the normal discord.py package
I learned about 2 other packages called PyCord Dinsnake
I want something that could be reliable in the log-run ... which one should I use ?

scarlet aurora
#

2.01

#

discord.py==2.0.1

#

pip install discord.py==2.0.1

placid skiff
#

you can use discord.py 2.01, but if you want to change package disnake is more suggested

shrewd apex
#

how do u ppl do ur research how come u don't know 6-8 months old news pithink

scarlet aurora
shrewd apex
glossy shore
shrewd apex
#

but if u feel like not keeping up with current affairs with related to what u are doing is not important then i have nothing to say

scarlet aurora
shrewd apex
scarlet aurora
#

he asked a simple valid question, we give an answer, we don't go into why he did not known that

shrewd apex
scarlet aurora
#

you're not him

shrewd apex
#

are u?

scarlet aurora
#

you would know this if you were sMarT oN asTonOmy

shrewd apex
#

I'll just pass the needless argument just saying its good to do a bit of research before jumping head on

scarlet aurora
#

the question only took 2 seconds to answer, you just say 2.0.1

#

that's it, no need to go full sherlock homes on his ass as to why he did not know that

scarlet aurora
scarlet aurora
slate swan
#

nvm awkward

scarlet aurora
#

you wanted to argue that didn't you?

#

I'm down for opinions y'know

placid skiff
#

Hi there Ashley

slate swan
slate swan
scarlet aurora
#

oh ok

#

@slate swan can u help

proud apex
#

What is better to use to create buttons and select menus?

slate swan
scarlet aurora
slate swan
#

refer to the message or explain

scarlet aurora
#
                def check(m):
                    if message.reference and message.reference.message_id == message.id:
                        return m.content == 'yes' and m.channel == echannel

                msg = await self.bot.wait_for('message', check=check)
                await echannel.send("Confirmed")```
#

I want to check if the message replies to the bot

slate swan
slate swan
scarlet aurora
#

u sure?

slate swan
#

yes

paper sluice
#

i think you want to get reference fromm not message

slate swan
#

yes that

scarlet aurora
#

doesn't work

scarlet aurora
paper sluice
#

how can m.ference.message_id be equal to m.id

#

change it to message.id

scarlet aurora
# paper sluice change it to `message.id`
                def check(m):
                    if m.reference and m.reference.message_id == message.id:
                        return m.content == 'yes' and m.channel == echannel

                msg = await self.bot.wait_for('message', check=check)
                await echannel.send("Confirmed")``` so like this?
#

doesn't work @paper sluice

paper sluice
#

any errors?

scarlet aurora
#

no

#

just doesn't work

paper sluice
#

where have you define message?

scarlet aurora
#
    @commands.Cog.listener()
    async def on_message(self, message):

        list = []
        
        channel = self.bot.get_channel(1003147215080013876)

        if message.channel == channel:
            if message.content in list:
                echannel = self.bot.get_channel(1006625124046340147)
                await echannel.send(f"``{message.author}`` wants to be promoted to ``{message.content}``")

                def check(m):
                    if message.reference and m.reference.message_id == message.id:
                        return m.content == 'yes' and m.channel == echannel

                msg = await self.bot.wait_for('message', check=check)
                await echannel.send("Confirmed")```
paper sluice
#

your list is empty....

scarlet aurora
#

just tell me what's the problem bro

silk fulcrum
paper sluice
#

that condition is never true because your list is empty

scarlet aurora
#

astuffirlaah don't worry bout it

paper sluice
cerulean shale
cerulean shale
silk fulcrum
cerulean shale
vocal snow
scarlet aurora
#

don't worry I done it

unreal siren
#

How can i link a github file with my bot? and what type of file does it need to be?

paper sluice
#

github file?

#

what are you trying to do?

tawdry tendon
#

hello

silk fulcrum
silk fulcrum
unreal siren
#

like i have all my commands inside the github file and i just link it with my bot but i got no clue how to do that

tawdry tendon
#

how can I host my bot 24/7

paper sluice
unreal siren
#

or does it need to be another file type?

paper sluice
silk fulcrum
unreal siren
silk fulcrum
paper sluice
unreal siren
#

so i cannot do it remotely?

#

or is there some kind of way

slate swan
#

any one know how get some one id by discord bot?

#

i try

#

not work

paper sluice
silk fulcrum
slate swan
#

and moreoh

#

player = ctx.author.id

unreal siren
slate swan
# silk fulcrum `ctx.author.id` is possible
AttributeError: 'Interaction' object has no attribute 'author'

The above exception was the direct cause of the following exception:

nextcord.errors.ApplicationInvokeError: Command raised an exception: AttributeError: 'Interaction' object has no attribute 'author'```
#

i make it with buttoms

silk fulcrum
# slate swan not work

"not work" is not a valid description of your problem, provide an exception if you get it or else say what you expected to happen and what happened instead

slate swan
#

i know

slate swan
#

He can't put ctx with Interaction

#

ok

silk fulcrum
slate swan
# full lily use `.user` not `author`

The above exception was the direct cause of the following exception:

nextcord.errors.ApplicationInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction```
slate swan
#

command can't use Interaciton only ctx

silk fulcrum
paper sluice
silk fulcrum
slate swan
#
 await interaction.send("?")
        await interaction.send(interaction.id)
        await interaction.send(player)```
silk fulcrum
#

You can only respond to an interaction once

slate swan
#
 await interaction.response.send_message('Sub Please i hope This World', ephemeral=False)
        await interaction.send("?")
        await interaction.send(interaction.id)
        await interaction.send(player)```
#

it working well

silk fulcrum
#

you might use a followup

slate swan
#

it working

silk fulcrum
slate swan
#

ah

#

it wasworking

#

frist 3 messages work but last one not sending

silk fulcrum
#

!d nextcord.Interaction.send

unkempt canyonBOT
#

await send(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, delete_after=None, allowed_mentions=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

This is a shorthand function for helping in sending messages in response to an interaction. If the interaction has not been responded to, [`InteractionResponse.send_message()`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.InteractionResponse.send_message "nextcord.InteractionResponse.send_message") is used. If the response [`is_done()`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.InteractionResponse.is_done "nextcord.InteractionResponse.is_done") then the message is sent via [`Interaction.followup`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Interaction.followup "nextcord.Interaction.followup") using [`Webhook.send`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Webhook.send "nextcord.Webhook.send") instead.
slate swan
#

lol

#

I know this

silk fulcrum
#

That took a time

slate swan
#

yes

silk fulcrum
slate swan
#

oh

silk fulcrum
#

I am not sure if you can respond 4 times even with followups, I only used followup for second response.

slate swan
#

it working dude

#

;/ i not lying

silk fulcrum
#

Hm, okay

slate swan
#

any ideas

#

LOL WORK NVM

#

i just fix small thing

#

wait

#

why the frist one have other id???

silk fulcrum
slate swan
#

@silk fulcrum this should do what id message id or user await interaction.send(interaction.id, ephemeral=True)

slate rapids
silk fulcrum
slate rapids
silk fulcrum
#

I don't think you need it

slate rapids
#

anyone ogt a fix

slate swan
#

that clicked the buttom

silk fulcrum
cerulean shale
silk fulcrum
#

Looks weird, are you using a custom context? @slate rapids

cerulean shale
#

F string, f'{ctx.author.avatar.url}'

silk fulcrum
silk fulcrum
# slate rapids

If you are not using a custom context, and it doesn't look like you do, then try using .display_avatar.url instead of .avatar.url

silk fulcrum
cerulean shale
silk fulcrum
cerulean shale
#

Nvm

#

Nothing

silk fulcrum
#

Ok.

silk fulcrum
slate rapids
#

my code works on replit

slate rapids
silk fulcrum
slate rapids
crystal glen
#

Does anyone know a free easy-to-use online database for python?

silk fulcrum
#

!pip aiosqlite

unkempt canyonBOT
crystal glen
#

I don't want to host it my self

silk fulcrum
crystal glen
#

I want to make changes using apis

placid skiff
#

python provides a free database called sqlite, you will just need a .db file and then connect to it

crystal glen
silk fulcrum
placid skiff
#

aiosqlite is just the sqlite versione compatible with asyncio

crystal glen
#

Okay

#

I'm trying to make a chat app, But I need a database to store the chats

#

And I don't wanna host anything myself

slate swan
#

Sorry but when iclick buttom it work but when i click again it send nextcord.errors.ApplicationInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction i need reload all bot for it work again @silk fulcrum

crystal glen
#

I want a website that is already hosted or smth like that

silk fulcrum
silk fulcrum
crystal glen
#

https://www.npoint.io/ I want something like this, The problem with this one, It's not editable using python...

slate swan
#
Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x0000017CCFFBE710>:
Traceback (most recent call last):
  File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 848, in invoke_callback_with_hooks
    await self(interaction, *args, **kwargs)
  File "c:\Users\Ibrah\Desktop\Discord Bot\Test.py", line 39, in sub
    await ctx.send(f'Does This Worked!', view=view)
  File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 564, in send
    return await self.response.send_message(
  File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 893, in send_message
    await adapter.create_interaction_response(
  File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\webhook\async_.py", line 204, in request
    raise NotFound(response, data)
nextcord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

The above exception was the direct cause of the following exception:

nextcord.errors.ApplicationInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction```
slate swan
#
@nextcord.ui.button(label= 'Sub', style=nextcord.ButtonStyle.green, disabled= False)
    async def sub(self, buttom: nextcord.ui.Button, interaction: nextcord.Interaction):
        await interaction.response.send_message('Sub Please i hope This World')
        await interaction.send("?")
        if player == interaction.user.id:
            await interaction.send("if You See this You good guy :)")
            await interaction.send("*I think so*")```
silk fulcrum
slate swan
silk fulcrum
slate swan
#

Oh

#
async def sub(ctx):
    global player
    player = ctx.user.id
    view = Sub()
    await ctx.send(f'Does This Worked!', view=view)
    await view.wait()
    if view.value is None:
        return

#

i will remove it

#

wait what is this py Task was destroyed but it is pending! task: <Task pending name='nextcord: on_interaction' coro=<Client._run_event() done, defined at C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py:491> wait_for=<Future pending cb=[Task.task_wakeup()]>> Task was destroyed but it is pending! task: <Task pending name='nextcord: on_interaction' coro=<Client._run_event() done, defined at C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py:491> wait_for=<Future pending cb=[Task.task_wakeup()]>>
@silk fulcrum

silk fulcrum
slate swan
#

remove await view.wait() if view.value is None: return

scarlet aurora
#

what's the best cheapest way to host a discord bot

slate swan
cloud dawn
slate swan
#

banna host i use it and good and online 24/7

scarlet aurora
#

thanks banana host

slate swan
#

a

cloud dawn
scarlet aurora
#

ty

cloud dawn
#

I recommend netcup.

slate swan
#

it need mney

#

i have free one

silk fulcrum
#

free hostes are cringe

cloud dawn
#

Always limitations.

slate swan
slate swan
silk fulcrum
slate swan
#

nvm]

unreal siren
#

so i tried using the randfact for my bot but it gives me an error

unreal siren
silk fulcrum
# unreal siren

What a highlight 💀, how will you see the name of the function

#

and can you send your code not by a screenshot

unreal siren
#

i use notepad++ rn bcs pycharm keeps crashing and the name is "fact"

cerulean shale
cerulean shale
silk fulcrum
cerulean shale
cold sonnet
#

replaced {} with ()

silk fulcrum
#

that is why I am asking for code as a raw text

unreal siren
#
@client.command()
@commands.cooldown(rate=1, per=5)
async def fact(ctx):
    print('Random fact was used')
    rndf = randfacts.get_fact()
    embed = discord.Embed(title=f'(rndf)',
                          color=discord.Color.blue())
    await ctx.send(embed=embed)```
silk fulcrum
cloud dawn
cold sonnet
#

title=rndf

cold sonnet
silk fulcrum
cerulean shale
#

Yea 💀

#

It should be {}

#

Not ()

#

It's an f string 💀

silk fulcrum
#

Oh in title

cold sonnet
#

or just don't use f-strings for one string

cloud dawn
#

I like to make my string represent france.

cold sonnet
#

common France L

cloud dawn
#

fr"Hello World!"

unreal siren
#

and the command also worked with the {} thanks for the help

cerulean shale
#

👍

slate swan
#

YOOO CAT

cloud dawn
unkempt canyonBOT
silk fulcrum
cloud dawn
#

Aren't they all discord ot channels..?

silk fulcrum
#

Um, acutally, they are

primal token
cerulean shale
silk fulcrum
cerulean shale
scarlet aurora
silk fulcrum
maiden fable
#

Do u mind translating what that says?

slate swan
#
@app_commands.command(name="help", description="Get my slash commands!")
    async def help(self, interaction: Interaction) -> None:
        await interaction.response.defer(ephemeral=True, thinking=True)
        if self.tree.get_commands() is None:
            return await interaction.edit_original_response(content="No Slash Commands yet!")
        slash_help = SlashHelp(self)

        await interaction.response.send_message(embed=slash_help.buttons.embeds[0], view=slash_help)

why doesn't this work peepocry

maiden fable
#

Congrats on overwriting the built-in help command! Hope you enjoy your experience

slate swan
#

nice

maiden fable
#

And what isn't working? Explain

slate swan
#

literally not even the first line

#

because it doesnt get triggered

maiden fable
#

I mean, u r using a slash command to check if there are any slash commands.......?

slate swan
#

no

#

no wait

#

💀

hushed galleon
#

double response with the defer and send_message

maiden fable
#

And yea, that should be interaction.followup or smth

slate swan
#

still the command wont get triggered, im high

maiden fable
slate swan
#

it does show

#

it just doesn't trigger the callback

maiden fable
#

So it doesn't show that ephemeral message?

slate swan
#

nop, nor does it defer

#

nor does it print anything

maiden fable
#

Can u try syncing the command once?

slate swan
#

but it is in the internal app command list, and yes I did that too

maiden fable
#

So discord shows interaction failed?

slate swan
#

yep

maiden fable
#

Try changing the name/description of the command then sync the command. Check if they were synced correctly

slate swan
#

did

#

and it synced correctly

maiden fable
#

So its syncing correctly but not triggering the callback? What in the fuck

slate swan
#

same here

maiden fable
#

That's weird

dull knot
#

I want to mention the unbanned user. How can I do that?

maiden fable
#

Are you sure you are on 2.0.1?

slate swan
#

welp thanks hunter

maiden fable
#

You were still on 2.0.0?

slow fog
#

im stuck with 1.7.3

maiden fable
slate swan
#

lemme see 💀 I literally uninstalled the github version to remain consistent with pypi

#

when did they

#

release a new update

maiden fable
#

Tho I don't think it has anything related to yr issue, tho no harm in trying

maiden fable
slate swan
#

nvm, doesn't work

maiden fable
#

Do u have an error handler? Slash error handler

dull knot
maiden fable
#

All cool

#

Tho beware than not everyone will be able to see the mention

maiden fable
#

so the command name is printed when u print the internal slash command list?

slate swan
#

yep

slow fog
# maiden fable Update then?

currently my code will face many issues with the new update and I'm too lazy to edit what it's required to And I see no reason to update since all my needs work fine for the very moment

maiden fable
#

Cool, ig

maiden fable
slate swan
maiden fable
# dull knot wym?

Only those people will be able to see the proper mention, who are either friends with that person or have a mutual server with them. Others will just see @tribal templeuser

#

Like this: @dusky fox

#

Nvm discord changed ping formats, but u get the idea

maiden fable
#

But this is what they will see

dull knot
#

Thx again for the help YesSir

maiden fable
#

All cool

edgy maple
#

Im coding a bot in vsc and I keep getting the error TypeError: expected token to be a str, received <class 'NoneType'> instead which is very confusing because the way I set it up should work just fine

maiden fable
#

Well either yr env file has no variable named TOKEN or u don't have an env file in yr cwd

slow fog
#

i think you must specify the token as an str

maiden fable
#

Nah

slow fog
#

oh wait

maiden fable
#

env files are another way to hide yr token

slow fog
#

i got it wrong

edgy maple
#

this is my env file

#

TOKEN=the token

maiden fable
#

Hm

#

Try printing os.getcwd() and check if the env file resides in the same folder as it prints

cloud dawn
#
from os import environ

from dotenv import load_dotenv

load_dotenv()

token = environ["TOKEN"]
#

load_dotenv doesn't need the path but doing so does increase performance by a small margin.

edgy maple
swift pumice
#

@frail gyro

frail gyro
slate swan
glad cradle
#

!d discord.app_commands.AppCommand

unkempt canyonBOT
#

class discord.app_commands.AppCommand```
Represents an application command.

In common parlance this is referred to as a “Slash Command” or a “Context Menu Command”.

New in version 2.0...
glad cradle
#

!d discord.app_commands.command

unkempt canyonBOT
#

@discord.app_commands.command(*, name=..., description=..., nsfw=False, auto_locale_strings=True, extras=...)```
Creates an application command from a regular function.
silk fulcrum
glad cradle
slate swan
#

I can't do it

silk fulcrum
slate swan
silk fulcrum
slate swan
silk fulcrum
slate swan
silk fulcrum
silk fulcrum
slate swan
#

can't say perfect either but okay

sick birch
#

It’s still up for review on GitHub isn’t it?

slate swan
#

idk lmao

glad cradle
#

maybe it need a little rework (I mean add some better markdown)

slate swan
#

I'm not free to make it look good

glad cradle
#

Can i make a pull request to a gist?

slate swan
#

that ain't possible

glad cradle
#

😩

slate swan
#

pull requests are limited only to repos

glad cradle
#

I would have helped you

silk fulcrum
slate swan
glad cradle
slate swan
#

it's okay, i won't be home for the next 4 days either

#

nor is there any deadline

glad cradle
heavy belfry
#

Hi! every few weeks i get a message like this, my bot is used very rarely and i only test it every few months as i dont use it very much, i first thought it was because it was being used too much (why i kicked it from most servers to see if it would fix the issue) however its still not fixed, can anyone help with this?

hushed galleon
#

thats replit for you

#

other discord bots are running on the same datacenter which makes it easier to hit a 429 Too Many Requests

heavy belfry
#

oh! well, i guess thats a good and bad thing for me haha, thank you very much! time to look for a different server or smth

sick birch
#

This is a temporary solution

glad cradle
#

I know

sick birch
#

I wouldn’t rely on it

glad cradle
#

I know

peak salmon
#

hi, sorry for bothering, i'm losing my mind. is this correct?

async def load_cogs():
  for filename in os.listdir('./cogs'):
    if filename.endswith('.py'):
      await bot.load_extension(f"cogs.{filename[:-3]}")
heavy belfry
sick birch
#

The python interpreter is better and faster than any human one

peak salmon
slate swan
#

can someone help me?.how can i make the code so when i thank someone the point will go to him

slate swan
#

Guys what this mean

livid bobcat
#

Hi can anyone help me I'm making a level system and I have this formula to calculate how much xp it takes to go up 1 level "5 * (get_user_level ^ 2) + (50 * get_user_level) + 100 - xp_from_user" but I know Not how I should do it, that you then really go up a level, so how the bot should recognize that, can anyone tell me what I should do there or how I should do it without having to do thousands of if statements or is there no other way ?

slate swan
#

I mean, what do I need to change here in order to interact with the select menu, only the author of the command that called this menu could

glad cradle
#

he's asking for his problem, he's not helping you

slate swan
#

and why would you put it somewhere?

slate swan
#

I don't know how to do this kind of interaction yet

cold sonnet
#

dunno but

        if interaction.user != self.ctx.author:
            return False
        else:
            return True
```is the same as
```py
        return interaction.user == self.ctx.author
slate swan
#

and the fact that I threw it off is responsible for me so that only the author of the command can press the buttons

#

@slate swan by the way , why can this method be used at all ?

peak salmon
knotty agate
#

is there a way to create an event for all reactions added to messages?

@client.event
async def on_reaction_add(reaction, user):
  print("reaction")

is what i try to use, but it dosent work for messages sent while the bot is offline.

if i send a message then react to it while the bot is online, it prints reaction.

if i send a message while the bot is offline, start then bot, then when the bot is online react to that message it dosent print reaction

pliant gulch
#

Just not possible to do what your asking for based on the gateway API. You could save a message ID somewhere, then every time the bot loads check the message again for an new reactions but that is quite cumbersome, and will not get ALL messages unless you add the ID or at least some way to persist the message across runs

slate swan
#

how to use global check to check if author has role

peak salmon
#

i don't know if this helps, i'm still beginer, but i'm using this

            if intr.user == ctx.author:
                await intr.response.edit_message(view = None)```
slate swan
peak salmon
#

try it and tell me too, i want to know

slate swan
lone lichen
sick birch
#

Programmers not known for their humour

#

I guarantee someone is going to bring out the “um actually”

slate swan
#

can someone help with this i have intents enabled on dev page

sick birch
#

You need to save the intents

#

Right now you’re making them and throwing them away

knotty agate
slate swan
sick birch
#

Same way you’d make a variable

slate swan
slate swan
lone lichen
slate swan
knotty agate
lone lichen
#

try on raw reaction add

dull moon
#

where is the problem

unkempt canyonBOT
#

discord.on_raw_reaction_add(payload)```
Called when a message has a reaction added. Unlike [`on_reaction_add()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_reaction_add "discord.on_reaction_add"), this is called regardless of the state of the internal message cache.

This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
slate swan
#
from http import client
from mimetypes import init
import discord
from discord.ext import commands
import os

from apikeys import *

intents = discord.Intents.default()
intents.members = True

client = commands.Bot(command_prefix="!", help_command=None, intents=intents)

@client.event
async def on_ready():
  print("vital is ready")
  print("--------------")
  await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="you.."))

initial_extentions = []

for filename in os.listdir('./cogs'):
    if filename.endswith('.py'):
        initial_extentions.append("cogs." + filename[:-3])

if __name__ == '__main__':
    for extention in initial_extentions:
        client.load_extension(extention)

client.run(BOTTOKEN)``` Can someone tell me why my `lock` and `unlock` command doesnt work ill send cog if needed (thats where the coding for commands is)
lone lichen
knotty agate
slate swan
#

@peak salmon no working

torn sail
slate swan
lone lichen
lone lichen
knotty agate
torn sail
#

Yep

slate swan
# lone lichen U should only send the cog 😂
from discord.ext import commands

class Moderation (commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self._last_member = None

    @commands.command()
    @commands.has_permissions(manage_channels = True)
    async def lock(self, ctx):
        await ctx.channel.set_permissiona(ctx.guild.default_role, send_messages = False)
        em = discord.Embed(colour = discord.Color.random(), description=f"{ctx.author.mention} is now locked")
        await ctx.send(embed=em)

    @lock.error
    async def lock_error(ctx, error):
        if isinstance(error, commands.MissingPermissions):
            em = discord.Embed(colour=discord.Color.orange(), description=f":warn: {ctx.author.mention}: You're **missing** permission: ``manage_channels``")
            await ctx.send(embed=em)

    @commands.command()
    @commands.has_permissions(manage_channels = True)
    async def unlock(self, ctx):
        await ctx.channel.set_permissiona(ctx.guild.default_role, send_messages = True)
        em = discord.Embed(colour = discord.Color.random, description=f"{ctx.author.mention} is now unlocked")
        await ctx.send(embed=em)

    @unlock.error
    async def unlock_error(ctx, error):
        if isinstance(error, commands.MissingPermissions):
            em = discord.Embed(colour=discord.Color.orange(), description=f":warn: {ctx.author.mention}: You're **missing** permission: ``manage_channels``")
            await ctx.send(embed=em)

async def setup(client):
      await client.add_cog(Moderation (client))``` Is the cog
#

how to make it so that only the author of the command can interact with the select menu ?

dull moon
lone lichen
slate swan
lone lichen
#

Idk by heart

slate swan
#

@lone lichen how to make it so that only the author of the command can interact with the select menu ?

slate swan
unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
lone lichen
#

!d discord.ui.View.interaction_check

unkempt canyonBOT
#

await interaction_check(interaction, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

A callback that is called when an interaction happens within the view that checks whether the view should process item callbacks for the interaction.

This is useful to override if, for example, you want to ensure that the interaction author is a given user.

The default implementation of this returns `True`.

Note

If an exception occurs within the body then the check is considered a failure and [`on_error()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View.on_error "discord.ui.View.on_error") is called.
lone lichen
#

This @slate swan

dull moon
#

ok i solved it

lone lichen
lone lichen
slate swan
# lone lichen This <@456226577798135808>
    async def interaction_check(self, interaction) -> bool:
        if interaction.user != self.ctx.author:
            return False
        else:
            return True```
it should look something like this ? @lone lichen
dull moon
#

i hate myself

lone lichen
lone lichen
lone lichen
#

U basically overwrite the method

slate swan
#

!error

#

where is the link to the error python thing

#

that checks errors

sick birch
lone lichen
#

!d discord.on_error

unkempt canyonBOT
#

discord.on_error(event, *args, **kwargs)```
Usually when an event raises an uncaught exception, a traceback is logged to stderr and the exception is ignored. If you want to change this behaviour and handle the exception for whatever reason yourself, this event can be overridden. Which, when done, will suppress the default action of printing the traceback.

The information of the exception raised and the exception itself can be retrieved with a standard call to [`sys.exc_info()`](https://docs.python.org/3/library/sys.html#sys.exc_info "(in Python v3.10)").

Note

`on_error` will only be dispatched to [`Client.event()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.event "discord.Client.event").

It will not be received by [`Client.wait_for()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_for "discord.Client.wait_for"), or, if used, [Bots](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#ext-commands-api-bot) listeners such as [`listen()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen") or [`listener()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Cog.listener "discord.ext.commands.Cog.listener").

Changed in version 2.0: The traceback is now logged rather than printed.
lone lichen
#

This?

slate swan
lone lichen
#

!pastebin

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.

slate swan
#

no not a pastebin bru

#

where u paste in ur code and it will tell you errors

lone lichen
#

!eval

unkempt canyonBOT
#
Missing required argument

code

#
Command Help

!eval [python_version] <code, ...>
Can also use: e

*Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.

If multiple codeblocks are in a message, all of them will be joined and evaluated, ignoring the text outside of them.

By default your code is run on Python's 3.11 beta release, to assist with testing. If you run into issues related to this Python version, you can request the bot to use Python 3.10 by specifying the python_version arg and setting it to 3.10.

We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*

slate swan
#

not it but ill try it

#

!eval 2.0.0 import discord
from discord.ext import commands

class Moderation (commands.Cog):
def init(self, bot):
self.bot = bot
self._last_member = None

@commands.command()
@commands.has_permissions(manage_channels = True)
async def lock(self, ctx):
    await ctx.channel.set_permissiona(ctx.guild.default_role, send_messages = False)
    em = discord.Embed(colour = discord.Color.random(), description=f"{ctx.author.mention} is now locked")
    await ctx.send(embed=em)

@lock.error
async def lock_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        em = discord.Embed(colour=discord.Color.orange(), description=f":warn: {ctx.author.mention}: You're **missing** permission: ``manage_channels``")
        await ctx.send(embed=em)

@commands.command()
@commands.has_permissions(manage_channels = True)
async def unlock(self, ctx):
    await ctx.channel.set_permissiona(ctx.guild.default_role, send_messages = True)
    em = discord.Embed(colour = discord.Color.random, description=f"{ctx.author.mention} is now unlocked")
    await ctx.send(embed=em)

@unlock.error
async def unlock_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        em = discord.Embed(colour=discord.Color.orange(), description=f":warn: {ctx.author.mention}: You're **missing** permission: ``manage_channels``")
        await ctx.send(embed=em)

async def setup(client):
await client.add_cog(Moderation (client))

lone lichen
slate swan
lone lichen
slate swan
#
    def __init__(self, ctx):

        options = [
            discord.SelectOption(label = "Основные", emoji= "🔷", description= "Основные команды сервера", value="1"),
            discord.SelectOption(label = "Модерация", emoji= "🔷", description= "Команды для модерирования сервера", value="2"),
            discord.SelectOption(label = "Взаимодействие", emoji= "🔷", description= "Команды взаимодействия между участниками", value="3"),
        ]

        super().__init__(placeholder='Список команд сервера', min_values=0, max_values=3, options=options)
        self.ctx = ctx
    async def callback(self, interaction: discord.Interaction):
        ckick = self.values[0]
        if ckick == '1':
            await interaction.response.send_message(
                embed = discord.Embed(description= f'', colour=0xF1C40F),
                delete_after=60
            )
        elif ckick == '2':
            await interaction.response.send_message(
                embed = discord.Embed(description= f'', colour=0xF1C40F),
                delete_after=60
            )
        elif ckick == '3':
            await interaction.response.send_message(
                embed = discord.Embed(description= f'', colour=0xF1C40F),
                delete_after=60
            )
        else:
            await interaction.response.send_message(ckick)
    async def interaction_check(self, interaction) -> bool:
        if interaction.user == self.ctx.author:
            return False
        else:
            return True


class SelectMenuHelpView(discord.ui.View):
    def __init__(self):
        super().__init__()

        self.add_item(SelectMenuHelp())```
sick birch
#

I mean you're referencing self.ctx but you haven't defined it

#

I would suggest taking in a member argument into the view

slate swan
#

@sick birch

Traceback (most recent call last):
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 113, in wrapped
    ret = await coro(arg)
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 762, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "c:\Users\ToxicPenguin\Desktop\проекты на Python\disocrd bot python\cogs\osnov.py", line 152, in __help__
    view = SelectMenuHelpView()
  File "c:\Users\ToxicPenguin\Desktop\проекты на Python\disocrd bot python\cogs\osnov.py", line 99, in __init__
    self.add_item(SelectMenuHelp())
TypeError: __init__() missing 1 required positional argument: 'ctx'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 755, in process_application_commands
    await ctx.command.invoke(ctx)
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 312, in invoke
    await injected(ctx)
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 119, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: __init__() missing 1 required positional argument: 'ctx'```
slate swan
sick birch
#

You have to pass it in from your function

#

And pass it down throughout your "tree"

#

Command -> View -> Select

slate swan
#

@sick birch
I don't know what kind of tree it is transmitted by. But nothing works

sick birch
slate swan
#

@sick birch I need to use async def interaction_check(self, interaction) -> bool: or it can all be done through if

#

guys why it send this error ```py
Traceback (most recent call last):
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 848, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "c:\Users\Ibrah\Desktop\Discord Bot\main.py", line 163, in count
for i in range(count):
TypeError: 'SlashApplicationCommand' object cannot be interpreted as an integer

The above exception was the direct cause of the following exception:

nextcord.errors.ApplicationInvokeError: Command raised an exception: TypeError: 'SlashApplicationCommand' object cannot be interpreted as an integer```

#

Why does the error say ( is not closed even tho it is?

sick birch
#

Here's an example:


class MySelectMenu(discord.ui.Select):
  def __init__(self, ...) -> None:
    super().__init__(...)

  async def callback(
    self, 
    select: discord.ui.Select, 
    interaction: discord.ui.Interaction,
  ) -> None:
    ...

class MyView(discord.ui.View):
  def __init__(self, *, author: discord.Member, ...) -> None:
        super().__init__(...)
    self.author = author
    self.add_item(MySelectMenu(...))

  async def interaction_check(self, interaction: discord.Interaction) -> bool:
    return interaction.user == self.author

@bot.command()
async def my_command(ctx: commands.Context, ...) -> None:
  view = MyView(author=ctx.message.author)
  await ctx.send(view=view)

An example of passing down the invoking member down @slate swan

sick birch
slate swan
slate swan
# sick birch Here's an example: ```py class MySelectMenu(discord.ui.Select): def __init__(...
Traceback (most recent call last):
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 113, in wrapped
    ret = await coro(arg)
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 762, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "c:\Users\ToxicPenguin\Desktop\проекты на Python\disocrd bot python\cogs\osnov.py", line 149, in __help__
    view = SelectMenuHelpView()
TypeError: __init__() missing 1 required keyword-only argument: 'author'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 755, in process_application_commands
    await ctx.command.invoke(ctx)
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 312, in invoke
    await injected(ctx)
  File "C:\Users\ToxicPenguin\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 119, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: __init__() missing 1 required keyword-only argument: 'author'```
#

anyone know why there are errors did I miss input something?

slate swan
#
class MyView(discord.ui.View):
  def __init__(self, *, author: discord.Member, ...) -> None:
        super().__init__(...)
    self.author = author
    self.add_item(MySelectMenu(...))

  async def interaction_check(self, interaction: discord.Interaction) -> bool:
    return interaction.user == self.author```
I just did it already and it was still a mistake.  you use author only in myView and don't pass it anywhere else
#

@sick birch Thanks, but I didn't understand anything from your explanation. I only realized when I looked at how I did the same thing in button

sick birch
#

You need to get author into your view so you can check for it in interaction_check

slate swan
#

can someone tell me why these are errors

edgy maple
#

im using a cog from another file and I did this setup on the main file, where do i run this func?

slate swan
#

@sick birch I said thank you

edgy maple
slate swan
#

can someone PLEASE help me with this idk why its an error

silk fulcrum
slate swan
#

it says "error" is not defined

silk fulcrum
#

You forgot a comma in function definition, between ctx and error

silk fulcrum
#

You're welcome

silk fulcrum
slate swan
# silk fulcrum You're welcome
from discord.ext import commands
import os 

class Moderation (commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self._last_member = None

    @commands.command(pass_context = True)
    @commands.has_permissions(manage_roles = True)
    async def role(self, ctx, user : discord.Member, *, role: discord.Role):
        
        if role in user.roles:
            await ctx.send(f"{user.mention}: already has {role}")
        else:
            await user.add_roles(role)
            em = discord.Embed(discord.Color.random(), description=f"Added {role} to {user.mention}")
            await ctx.send(embed=em)

    @role.error
    async def role_error(self, ctx, error):
        if isinstance(error, commands.MissingPermissions):
            em = discord.Embed(discord.Color.orange(), description=f"{ctx.author}: You're **missing** permission: `manage_roles`")
            await ctx.sen(embed=em)

    @commands.command(pass_context = True)
    @commands.has_permissions(manage_roles = True)
    async def removerole(self, ctx, user : discord.Member, *, role: discord.Role):
        
        if role in user.roles:
            await ctx.send(f"{user.mention}: does not have {role}")
        else:
            await user.add_roles(role)
            em = discord.Embed(discord.Color.random(), description=f"Removed {role} from {user.mention}")
            await ctx.send(embed=em)

    @removerole.error
    async def role_error(self, ctx, error):
        if isinstance(error, commands.MissingPermissions):
            em = discord.Embed(discord.Color.orange(), description=f"{ctx.author}: You're **missing** permission: `manage_roles`")
            await ctx.sen(embed=em)

    async def setup(client):
      await client.add_cog(Moderation (client))``` Do you know why the command doesnt work or is there like something wrong I don't understand the Bot does nothing when I do `,role {user}`
#

Is what the terminal said

silk fulcrum
#

loading extensions is now async

#

meaning that you need to await your .load_extension

slate swan
#
    for extention in initial_extentions:
        client.load_extension(extention)```
#

this?

silk fulcrum
slate swan
#

Wait so what do I do I'm lost

silk fulcrum
slate swan
silk fulcrum
#

oh gosh I really gotta go, sorry.
@sick birch can u help them?

slate swan
#

oof ok ill wait for robin

edgy maple
winged coral
#

Forbidden is what you want

#

!d discord.Forbidden

unkempt canyonBOT
#

exception discord.Forbidden(response, message)```
Exception that’s raised for when status code 403 occurs.

Subclass of [`HTTPException`](https://discordpy.readthedocs.io/en/latest/api.html#discord.HTTPException "discord.HTTPException")
silk fulcrum
winged coral
#

Yeah, I assume they know that or would ask if they had an issue

glad cradle
cold sonnet
#
async def setup(client):
    await client.add_cog(Moderation(client))
```should be outside of the cog
#

from folder import file

glad cradle
silk fulcrum
#

no

cold sonnet
#

just folder

#

from folder import file

slate swan
glad cradle
#

just folder
eg:
from folder import foo

slate swan
#

command still doesnt work

cold sonnet
#

yes

glad cradle
cold sonnet
#

but you shouldn't import cogs

slate swan
cold sonnet
#

can you send a screenshot of your folder

cold sonnet
glad cradle
silk fulcrum
cold sonnet
#

await it

silk fulcrum
#

he's not making packages

slate swan
cold sonnet
#

I don't have an __init__.py in my project

glad cradle
cold sonnet
#

yes

glad cradle
#

an init file probably would fix he's problem

silk fulcrum
cold sonnet
#

what's your current working directory?

slate swan
#
import discord
from discord.ext import commands
import os

from apikeys import *

intents = discord.Intents.default()
intents.members = True

client = commands.Bot(command_prefix="!", help_command=None, intents=intents)

@client.event
async def on_ready():
  print("vital is ready")
  print("--------------")
  await client.change_presence(activity=discord.Activity(type=discord.ActivityType.competing, name="ur mom"))

initial_extentions = []

for filename in os.listdir('./cogs'):
    if filename.endswith('.py'):
        initial_extentions.append("cogs." + filename[:-3])

if __name__ == '__main__':
    for extention in initial_extentions:
        client.load_extension(extention)

client.run(BOTTOKEN)``` is my main.py
daring olive
#

@slate swan pls remove the server invite from your code block, or use a pastebin

#

oop you got it

glad cradle
cold sonnet
#

this part

slate swan
#
from distutils import extension
import discord
from discord.ext import commands
import os

from apikeys import *

intents = discord.Intents.default()
intents.members = True

client = commands.Bot(command_prefix="!", help_command=None, intents=intents)

@client.event
async def on_ready():
  print("vital is ready")
  print("--------------")
  await client.change_presence(activity=discord.Activity(type=discord.ActivityType.competing, name="ur mom"))

initial_extentions = []

for filename in os.listdir('./cogs'):
    if filename.endswith('.py'):
        initial_extentions.append("cogs." + filename[:-3])

if __name__ == '__main__':
    for extention in initial_extentions:
        client.load_extension(extension)

client.run(BOTTOKEN)```
glad cradle
cold sonnet
#

like a setup_hook event

#

and await client.load_extension(extention) instead of client.load_extension(extention)

#

like

@bot.event
async def setup_hook():
    for extention in initial_extentions:
        await client.load_extension(extention)
#

this is just an example

#

!d discord.ext.commands.Bot.setup_hook what does this even take

#

nothing, ok

slate swan
#

Bro i put await and it does this how many damn times do i have to say?????

silk fulcrum
cold sonnet
#

I just explained it

cold sonnet
slate swan
#

so do I get rid of if __name__ == '__main__':

cold sonnet
#

yes

#

put that code in a setup_hook event

#

I'm gonna check if that overwrites something important

slate swan
#
async def setup_hook():
    for extention in initial_extentions:
        await client.load_extension(extention)```
cold sonnet
#

yes

slate swan
#

so that?

cold sonnet
#

yes

cold sonnet
slate swan
#
from discord.ext import commands
import os 

class Moderation (commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self._last_member = None

    @commands.command(pass_context = True)
    @commands.has_permissions(manage_roles = True)
    async def role(self, ctx, user : discord.Member, *, role: discord.Role):
        
        if role in user.roles:
            await ctx.send(f"{user.mention}: already has {role}")
        else:
            await user.add_roles(role)
            em = discord.Embed(discord.Color.random(), description=f"Added {role} to {user.mention}")
            await ctx.send(embed=em)

    @role.error
    async def role_error(self, ctx, error):
        if isinstance(error, commands.MissingPermissions):
            em = discord.Embed(discord.Color.orange(), description=f"{ctx.author}: You're **missing** permission: `manage_roles`")
            await ctx.sen(embed=em)

    @commands.command(pass_context = True)
    @commands.has_permissions(manage_roles = True)
    async def removerole(self, ctx, user : discord.Member, *, role: discord.Role):
        
        if role in user.roles:
            await ctx.send(f"{user.mention}: does not have {role}")
        else:
            await user.add_roles(role)
            em = discord.Embed(discord.Color.random(), description=f"Removed {role} from {user.mention}")
            await ctx.send(embed=em)

    @removerole.error
    async def role_error(self, ctx, error):
        if isinstance(error, commands.MissingPermissions):
            em = discord.Embed(discord.Color.orange(), description=f"{ctx.author}: You're **missing** permission: `manage_roles`")
            await ctx.sen(embed=em)

async def setup(client):
    await client.add_cog(Moderation (client))``` (cog)
cold sonnet
#

do you get an error

slate swan
cold sonnet
#

you sure you loaded the cog

#

add a print to check

glad cradle
slate swan
cold sonnet
#
@client.event
async def setup_hook():
    for extention in initial_extentions:
        await client.load_extension(extention)
        print("loaded" + extention)
#

extension would be right but ok

slate swan
#

it said in terminal

cold sonnet
#

then it should work

#

oh you have error handlers bruh

slate swan
#

yea?

cold sonnet
#

first of all, make one global error handler

#

an on_command_error event in your main file

slate swan
#

i mean i would if i new how..

cold sonnet
#

and remove these repetitive things

slate swan
#

so remove error handlers from cog file?

cold sonnet
#

yes

slate swan
#

done

cold sonnet
#
@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, ...):
        ...
slate swan
cold sonnet
#

yes

#

oh wait

#

you need to put something at the end

slate swan
#

like?

#

Anyone good with python here?
I'm trying to work on some stuff todo with google sheets, And I'm not exactly the best at python xd

cold sonnet
#
@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        em = discord.Embed(discord.Color.orange(), description=f"{ctx.author}: You're **missing** permission: `manage_roles`")
        await ctx.send(embed=em)
    else:
        raise error
#

you always have to raise the error if it's none of the above

#

this is why you didn't get an error before

slate swan
#

so what do I put in the . . .

#

...

cold sonnet
#

you had commands.MissingPermissions before

slate swan
#

so do I put that in the brackets?

cold sonnet
#

do what you did before

#

that's not exactly what we do here...

slate swan
cold sonnet
#

claim a help channel I suggest

#

if anyone knows what's the issue, they'll help

slate swan
cold sonnet
#

what's your question

#

also, did you get an error now?

slate swan
#

im still writing

cold sonnet
#

oh ok

slate swan
# cold sonnet oh ok
async def on_command_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        em = discord.Embed(discord.Color.orange(), description=f"{ctx.author.mention}: You're **missing** permission: ")
        await ctx.send(embed=em)
    else:```
#

what do I do for the permission:

cold sonnet
#

!d discord.ext.commands.MissingPermissions

unkempt canyonBOT
#

exception discord.ext.commands.MissingPermissions(missing_permissions, *args)```
Exception raised when the command invoker lacks permissions to run a command.

This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
cold sonnet
#

I see it has a missing_permissions attribute

#

so it's error.missing_permissions

slate swan
#

do I put in {}

cold sonnet
#

yes

slate swan
#

ok im gonna try the role cmd now

#

doesnt work..

cold sonnet
#

do you get an error

#

do you get an output

slate swan
#

discord.ext.commands.bot Privileged message content intent is missing, commands may not work as expected.

cold sonnet
#

enable message content intents

slate swan
cold sonnet
#

intents = discord.Intents.default()
intents.members = True
intents.message_content = True

#

or you could just do
intents = discord.Intents.all()

slate swan
#

alr

#

imma try now

#

still doesnt work and there was no errors

slate swan
cold sonnet
#

I see

#

I don't know why it doesn't work

slate swan
#

no your good

cold sonnet
#

your post is pretty much the same as magnet's was before

slate swan
#

what can I do to fix? I'm really trying to start making command tonight

cold sonnet
#

it's easier actually

slate swan
#

I have

async def setup_hook():
    for extention in initial_extentions:
        await client.load_extension(extention)
        print("loaded" + extention)```
cold sonnet
#
@bot.event
async def setup_hook():
    await client.load_extension("tickets")
cold sonnet
slate swan
#

oh you wern't talking to me mb

#

im gonna open a help channel

#
async def setup_hook():
    await client.load_extension("tickets")``` is what he said a few mins ago
#

Did it work?

#

Je ne saurais pas que je suis un peu nouveau dans le codage, vous pouvez créer un canal d'aide et quelqu'un vous répondra

#

Oh okay

#

didn't know

slate swan
#

how do I delete a message from the select menu ?
await interaction.message.delete()

odd mango
#

how can i get a category by name?

quaint epoch
unkempt canyonBOT
#

discord.utils.get(iterable, /, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.utils.find "discord.utils.find").

When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.

To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.

If nothing is found that matches the attributes passed, then `None` is returned.

Changed in version 2.0: The `iterable` parameter is now positional-only.

Changed in version 2.0: The `iterable` parameter supports [asynchronous iterable](https://docs.python.org/3/glossary.html#term-asynchronous-iterable "(in Python v3.10)")s...
odd mango
#

thanks

odd mango
#

guild.create_category_channel?

quaint epoch
#

!d discord.Guild.create_category_channel

unkempt canyonBOT
#

await create_category_channel(name, *, overwrites=..., reason=None, position=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Same as [`create_text_channel()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.create_text_channel "discord.Guild.create_text_channel") except makes a [`CategoryChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.CategoryChannel "discord.CategoryChannel") instead.

Note

The `category` parameter is not supported in this function since categories cannot have categories.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
odd mango
#

thanks

finite falcon
#

error is occuring when i add thumbnail someone help pls

slate swan
#

hi for the first time I'm trying to make a bot but I have an error that could explain to me?

wicked atlas
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

finite falcon
# slate swan

bot = commands.Bot(command_prefix = "$", intents=discord.Intents.all())

#

copy and paste that

wicked atlas
#

enabling all intents isn't the best practice. It's better just to request the intents that are required.

wicked atlas
#

and take note that the line of code they provided you with changed some stuff from what you had originally

finite falcon
cold sonnet
#

not embed....

finite falcon
#

does anyone know i can make my bot loop send a embed in a channel every 2 hours

wicked atlas
#

what is it called

potent spear
#

exts

wicked atlas
#

breuh, alright then
b

wicked atlas
#

yeah thanks

slate swan
#

thank you his walk but how do I my a description? please

wicked atlas
#

Description of what?

slate swan
wicked atlas
#

Your bot's profile?

slate swan
wicked atlas
#

That can be done through the dev portal, on your application's page

slate swan
wicked atlas
#

You can't dynamically change your description, no

#

Usually bot's like to display statistics like that in their status though

slate swan
wicked atlas
#

There's an example of this page of the docs this

cold sonnet
#

set presence in your Bot constructor

#

oh wait no

#

not for that kind of a status

strange carbon
#

yall know how to fix this its supposed to print a house

#

C:\Users\youse\Downloads>python seff.py
File "C:\Users\youse\Downloads\seff.py", line 1
print ("
^
SyntaxError: unterminated string literal (detected at line 1)

cold sonnet
#

\ cancels out the thing that's next to it

#

you have to put 2 next to each other to see one

#

wait

#

hmmm

wicked atlas
#

You're gonna want to use a codeblock when tyrping that eval command

strange carbon
#

!e print (" )
(
^ )
/ \ ---
/ | |
/ _ \ |
/ () |
/
/| __ __
| | | | |
| || || |
| __ _ |
| | | | | | *
| | 0| |
| | ***
| | | | *****
///////////// "

unkempt canyonBOT
#

@strange carbon :x: Your 3.11 eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     print ("              )
003 |            ^
004 | SyntaxError: unterminated string literal (detected at line 1)
cold sonnet
#

!e print(" / \\")

unkempt canyonBOT
#

@cold sonnet :white_check_mark: Your 3.11 eval job has completed with return code 0.

 /   \
strange carbon
cold sonnet
#

exactly like that

strange carbon
#

@cold sonnet

cold sonnet
#

your homework sucks

slate swan
#
    @commands.command()
    async def purge(ctx, amount=11):
        amount = amount+1
        if amount > 101:
            em = discord.Embed(color=discord.Colour.random(), description="I can not delete more than 100 messages")
            await ctx.send(embed=em)
        else:
            await ctx.channel.purge(limit=amount)
            em2 = discord.Embed(color=discord.Color.random(), description="Seccefully cleared messages")
            await ctx.send(embed=em2)``` Can someone help me fix this error
strange carbon
cold sonnet
#

as an argument

slate swan
#

?

cold sonnet
#

yes

strange carbon
cold sonnet
#

!e print(" \/\/\/\/")

unkempt canyonBOT
#

@cold sonnet :white_check_mark: Your 3.11 eval job has completed with return code 0.

 \/\/\/\/
cold sonnet
#

should be good

#

put two \'s everywhere I suppose

#

not just there where it's yellow

#

pink

#

whatever

#

even though it works right

slate swan
#

why is the status not displayed?

sick birch
# slate swan

Because you have 2 on_ready events and the last one will always take precedence

slate swan
slate swan
sick birch
slate swan
#

I don't really know the problem robin will have to help

#

Oops

wicked atlas
slate swan
#

already installed

wicked atlas
#

Yeah, but you need to import discord in your code

slate swan
mossy jacinth
#

why is my slash command not being shown? I waited long enough

#

or was it bot.slash_command

#

i forgor

wicked atlas
#

global slash commands take a while to sync

#

anything between 10 minutes to an hour or so I think, unless they somehow got that to speed up

slate swan