#General Help

1 messages · Page 10 of 1

next bloom
#

i've tried placing it like

e.thumbnail(url=user.avatar.url)

and like

e.thumbnail(user.avatar.url)
sudden path
#

It is set_thumbnail

#

b!rtfm pyc set_thumbnail

open bearBOT
sudden path
#

✨ Read the docs ✨

next bloom
#

my ide autocompleted it like that

#

so i tho that wasn't the wrong thing on it

rigid wave
#

Hi, how to fix that?
https://prnt.sc/WiJrk9vVuKVN
Use: bridge

This error appears when using the normal commands but slash command its work
Error: ```
'Context' object has no attribute 'respond'

Lightshot

Captured with Lightshot

slow dome
#

you are forcing it to be a commands.Context while it is actually a bridge context

rigid wave
slow dome
#

show code

#

again

rigid wave
#

@slow dome

slow dome
#

does it not work?

rigid wave
#

not work

rigid wave
slow dome
#

gj

regal jacinth
#

have any example to get application_id by name?

unique glacier
#

Hi so I'm trying to dynamically set the options for a select menu through class variables though @discord.ui.select doesn't seem to have access to the class (dosen't have access to self). The code snipped bellow represents what I'm trying to do. Any way to get around this?

    def __init__(self, ctx):
        super().__init__(timeout=15)
        self.ctx=ctx
        self.feature = None
        self.options = []
        for feature in features:
            self.options.append(discord.SelectOption(label=feature["friendly_name"], description=feature["description"]))
    @discord.ui.select( 
        placeholder = "Choose a feature to setup!", #
        min_values = 1, 
        max_values = 1, 
        options = self.options
    )

Can the options field access self?

slow dome
unique glacier
slow dome
#

that works

half dust
#

Can someone please give me a list of reaction ids?

inland acorn
#

#969691826078482442

rigid wave
inland acorn
#

#969691826078482442 message

worthy bobcat
#

how can i cache member in voice only?3

sick stirrup
#
Application Command raised an exception: AttributeError: 'LinkageButtonsView' object has no attribute 'disable_all_items'
```Not sure why this is occuring. LinkageButtonsView is a subclass of `discord.ui.view.View()`
supple ravineBOT
#
Controls the library's cache policy when it comes to members.

This allows for finer grained control over what members are cached.
Note that the bot's own member is always cached. This class is passed
to the ``member_cache_flags`` parameter in :class:`Client`.

Due to a quirk in how Discord works, in order to ensure proper cleanup
of cache resources it is recommended to have :attr:`Intents.members`
enabled. Otherwise the library cannot know when a member leaves a guild and
is thus unable to cleanup after itself.

To construct an object you can pass keyword arguments denoting the flags
to enable or disable.

The default value is all flags enabled.

.. versionadded:: 1.5

.. container:: operations

    .. describe:: x == y

        Checks if two flags are equal.
    .. describe:: x != y

        Checks if two flags are not equal.
    .. describe:: hash(x)

           Return the flag's hash.
    .. describe:: iter(x)

           Returns an iterator of ``(name, value)`` pairs. This allows it
           to be, for example, constructed as a dict or a list of pairs.

Attributes
-----------
value: :class:`int`
    The raw value. You should query flags via the properties
    rather than using this raw value.```
gilded widget
#

asher ^

#

you can set it to only cache members in voice

gilded widget
worthy bobcat
#

thx

sick stirrup
gilded widget
#

okay that works, was confused by what you said first

#

I'm assuming you're on a version that doesn't have the function

#

what version are you running

rose shard
#

How to fetch data of selected from dname? (Its mongodb)

inland acorn
rose shard
#

I mean can i use selected as a filter for the data of dname

slender lintel
#

Hey how can I make it so that as soon as you select an option on the select menu, this option is deleted directly from the select menu history so that you can see the placeholder again

next bloom
#

hey guys how can i check if an user has a role?
i was with ext.commands and now i'm trying bridge but i don't find anything related to roles on bridge

#

with ext.commands i was using the @commands.has_role decorator

pulsar flint
#

when running the code:

    @bot.command()
    @commands.has_permissions(ban_members=True)
    async def ban(self, ctx, user: discord.Member, *, reason):
        await ctx.guild.ban(user, reason=reason)

i get the error:

gnoring exception in command ban:
Traceback (most recent call last):
  File "C:\Users\alexj\Desktop\EpicGiant Bot\venv\lib\site-packages\discord\commands\core.py", line 126, in wrapped
    ret = await coro(arg)
  File "C:\Users\alexj\Desktop\EpicGiant Bot\venv\lib\site-packages\discord\commands\core.py", line 853, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "C:\Users\alexj\Desktop\EpicGiant Bot\cogs\moderation.py", line 11, in ban
    await ctx.guild.ban(user, reason=reason)
  File "C:\Users\alexj\Desktop\EpicGiant Bot\venv\lib\site-packages\discord\guild.py", line 2907, in ban
    await self._state.http.ban(user.id, self.id, delete_message_days, reason=reason)
  File "C:\Users\alexj\Desktop\EpicGiant Bot\venv\lib\site-packages\discord\http.py", line 353, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

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

Traceback (most recent call last):
  File "C:\Users\alexj\Desktop\EpicGiant Bot\venv\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\alexj\Desktop\EpicGiant Bot\venv\lib\site-packages\discord\commands\core.py", line 357, in invoke
    await injected(ctx)
  File "C:\Users\alexj\Desktop\EpicGiant Bot\venv\lib\site-packages\discord\commands\core.py", line 134, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

my bot and i have ban permissions. why do i get a missing permissions error message?

crimson gale
#

idk but it seems to be tripping up when you try to ban someone with the bot

pulsar flint
#

yes

#

i know

gentle spire
#

is there any change using Selectmenu in 2.0.0rc1 version?

#

after update pycord to 2.0.0rc1 version

#

interaction failed when select

crimson gale
#

you need to respond to interaction

proven plume
#

Hi, quick question

#
@bot.command()
@commands.is_owner()
async def delete(ctx, nombre):
    
    salon_del = await bot.fetch_channel(ctx.channel)#on prend le channel ou a eu la commande
    await salon_del.purge(limit=nombre)#on supp les messages (la var nombre c'est le nb messages supp)
    await salon_del.send(f"Ok,{ctx.author.mention}, j'ai supprimé{nombre} messages!", delete_after= 5.0)#on signale que c'est delete et on supp le message 5 sec apres
#
Traceback (most recent call last):
  File "C:\Users\celia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\bot.py", line 360, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\celia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 927, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\celia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\ext\commands\core.py", line 190, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In channel_id: Value "🍃・le-salon" is not snowflake.
#

and I dont understand the doc abt snowflake

gentle spire
crimson gale
proven plume
steady lotus
#

Is check_interaction() a good way to check if an interaction was pressed/exited etc

proven plume
#
@bot.command()
@commands.is_owner()
async def delete(ctx, nombre = 0):
    print(ctx.channel.id)
    salon_del = await bot.fetch_channel(ctx.channel.id)#on prend le channel ou a eu la commande
    await salon_del.purge(limit=nombre)#on supp les messages (la var nombre c'est le nb messages supp)
    await salon_del.send(f"Ok,{ctx.author.mention}, j'ai supprimé{nombre} messages!", delete_after= 5.0)#on signale que c'est delete et on supp le message 5 sec apres
crimson gale
#

salon_del = await bot.fetch_channel(ctx.channel)#on prend le channel ou a eu la commande this line is essentially useless

proven plume
#

already modify this

crimson gale
#

youre making an unnecssary api call when you already have the channel via ctx.channel

#

@proven plume ^

proven plume
#

how should I modify he codeN

#

now I have this error

#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: '>' not supported between instances of 'str' and 'int'
Exception ignored in: <function _ProactorBasePipeTransport.del at 0x0000028050F84790>

crimson gale
#

remove the first two lines, replace salon_del with ctx.channel for the purge line and with ctx for the send line

proven plume
#

k

#

imma try ty

#

working

#

ty

#

❤️

next bloom
#

is there any decorator like ```py
@commands.has_role(role_ID)

on bridge?
crimson gale
#

checks from the commands extension work for any type of command

ancient gazelle
#

Any help in how do I get date, time input from user? Using slash commands.

crimson gale
#

take string and parse it

ancient stag
#

when i try to run my code, i get this error:

discord.errors.ExtensionFailed: Extension 'cogs.events' raised an error: ExtensionFailed: Extension 'cogs.help' raised an error: TypeError: 'type' object is not subscriptable

from this section of code

    def __init__(self, help_command: "MyHelpCommand", options: list[discord.SelectOption]):
crimson gale
#

its List if youre using the typing module, just list if in 3.10+

#

it also seems youre not using 3.10

#

@ancient stag

ancient stag
#

i have pycord 2.0 installed

crimson gale
#

pycord version has nothing to do with your issue

#

we are talking about python versions right now

ancient stag
#

oh py

#

how would i check that?

crimson gale
#

simplest way to check is to just open python in cmd

ancient stag
crimson gale
#

you need to import List from typing and use that as the type hint

ancient stag
#

ok, ive done that

crimson gale
#

show me the arguments again with the change applied

ancient stag
#

all of it?

crimson gale
#

just the function def

#

incl arguments

ancient stag
#
def __init__(self, help_command: "MyHelpCommand", options: list[discord.SelectOption]):        
TypeError: 'type' object is not subscriptable
crimson gale
#

change list to List

ancient stag
#

no longer outputting errors. thanks gx_zeroTwoHeart

crimson gale
#

remember, you cant use the lowercase versions of list, tuple and whatever else might be affected as type hinting in versions below 3.10

#

to use them as type hinting you need to import them from the typing module

next bloom
#

how can i handle the errrors with bridge? i'm getting this error
AttributeError: 'BridgeCommand' object has no attribute 'error'

#

i'm trying like it was ext.commands tho

#
@restart.error
async def restart_error(ctx, error):
    if error == 'MissingRole':
     des = "Necesitas el rol <@&735506792494399638> para reiniciar el bot"
     color=discord.Color.red()
     name='Fallo al reiniciar'
     await embed(ctx, des, color, name)
    else:
     print(error) 
hushed basalt
#

Is there anyway to use @discord.ui.button on @commands.command without interactions?

Because when i use ctx.send they send a message but, the bot say interaction failed

glass nova
#

What to do if send_audio_packet sends audio correctly but i hear "pttt" sounds instead of the actual audio

#

(that happens with encode=True, because if i pass in False i dont even hear the pttt sounds)

opal storm
#

Can anyone help me in #980112836330151946 been a while since I opened it

hushed basalt
#

I had to think

slender lintel
#

Hey how to set options as button in slash command?
Example Picture:

hushed basalt
#

I can use the bot's edit_message through interaction.response.edit_message() so that the bot doesn't get an error that the interaction failed

crimson gale
#

choices

crimson gale
hushed basalt
#

hum i can try

#

let me check

terse plinth
slender lintel
#

like a picture

terse plinth
#

with the options

#

how else

#

theres an example there

#

learn from it and implement

hushed basalt
#

i will try to edit the bot message with interaction

slender lintel
crimson gale
#

its called problem solving

#

essential skill in life

terse plinth
#

lol

terse plinth
#

try out things

#

read the docs

slender lintel
#

ok

#

thanks

frigid lark
#

How can I add the 🌎 emoji to a message?

#

I get everytime "Unknown Emoji"

crimson gale
#

has to be the emoji itself or a unicode representation

ancient gazelle
#

Just asking if , /check @Role pings the role or not?

crimson gale
#

no

frigid lark
#

the emoji itself?

crimson gale
#

anywhere where you can use rich text can have emojis

ancient gazelle
crimson gale
#

copy from there or use the emoji picker (iirc windows + comma)

crimson gale
ancient gazelle
#

Okay thank you

crimson gale
frigid lark
#

can I not use it like :earth _ americas:

crimson gale
#

no thats a discord thing

#

with custom emoji you have to use the special tag

frigid lark
#

Its not a custome emoji

crimson gale
#

i know i just mentioned it for the sake of mentioning it

frigid lark
#

I dont get it...

crimson gale
terse plinth
#
    @commands.Cog.listener()
    async def on_application_command_error(self, context:discord.ApplicationContext, exception):
        
        if isinstance(exception, commands.NSFWChannelRequired):
            await context.respond('> **Error : Command can only be run on channels marked NSFW**')

This is present in another cog from the original command
However, it doesnt run when the error does take place. The command just times out without responding

#

console is clear

frigid lark
terse plinth
crimson gale
#

its not gonna get parsed by discord if its sent by bots

prime frost
#

Anyone know why custom emojis arent working in ephemeral messages spawned by a dropdown menu in a particular server?

#

They work fine in one server but not in another, bot has admin perms in both

#

Please ping me in the response if anyone knows the solution, thanks

crimson gale
prime frost
#

I'd assume so since its working in Server 1, the emojis are from a different server completely (which the bot is in but none of the commands are ran there)

#

The emojis work in the second server for normal commands which dont have an ephemeral response

crimson gale
#

¯_(ツ)_/¯

tropic fractal
#

Does bot.before_invoke call for slash commands too?

#

I'd assume so considering its discord.Bot

crimson gale
#

yep

#

from the looks of it

tropic fractal
#

sweet

limpid ginkgo
#

how do i register a slash command that only works in dms?

next bloom
#

how can i get the command given, i tried setting it on ctx but if the command doesn't exist, it throws a big error on ctx but a small error

#

this is the code

@bot.event
async def on_command_error(ctx, error):
    if error == 'MissingRole':
     des = "Necesitas el rol <@&735506792494399638> para reiniciar el bot"
     color=discord.Color.red()
     name='Fallo al reiniciar'
     await embed(ctx, des, color, name)
    else:
     des = f"Error: {error}"
     color=discord.Color.red()
     name=f'Fallo con el comando {ctx}'
     await embed(ctx, des, color, name) 
crimson gale
#

youre going about checking what kind of error it is entirely wrong

#

it should be isinstance(error, commands.errors.MissingRole)

next bloom
#

on the if?

crimson gale
#

yes

#

then you can stack more on top of it with elif

next bloom
#

yeah ty

crimson gale
#

hm i wonder

next bloom
#

i was going to fix that right after

crimson gale
#

is it possible to use a match-case statement to check for errors without needing elif?

next bloom
#

idk tbh

#

i even have that flower on my name xD

vague walrus
#

Hi there,
I have a problem where my PC (Windows 10) has pycord version 2.0.0b1 installed, but my Raspberry PI (Debian, Rasperry PI Desktop) only has verson 1.7.3. I work on the bot on my PC and some features I've implemented doesn't seem to work when ran on my PI (it acts like a server so I can turn off my PC at night). Is there a way to install a given version of pycord? I can't seem to find it on the website neither here, on Discord.

zinc kraken
#

Commands do not work when I use cogs
main.py

import discord
from discord.ext import commands
import sys
import traceback

bot = discord.ext.commands.Bot(command_prefix="=")

# list
initial_extensions = [
    'cogs.math',
    'cogs.economy',
]

# load cogs
for extension in initial_extensions:
    try:
        bot.load_extension(extension)
    except Exception as e:
        print(f'Failed to load extension {extension}.', file=sys.stderr)
        traceback.print_exc()```
math.py
```py
from discord.ext import commands


class Math(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

@commands.command()
async def multiple(ctx, num1: int, num2: int):
    await ctx.send(num1 * num2)


def setup(bot):
    bot.add_cog(Math(bot))```
vague walrus
#
from discord.ext import commands


class Math(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

  @commands.command()
  async def multiple(ctx, num1: int, num2: int):
      await ctx.send(num1 * num2)


def setup(bot):
    bot.add_cog(Math(bot))```
Make sure commands.command() is inside the class.
#
In the same column as your __init__ function```
crimson gale
#

though you should upgrade to py-cord==2.0.0rc1

vague walrus
#

I see, thank you!!

zinc kraken
vague walrus
#

In a cog every function's first arg must be 'self'. So your multiple function should be as follows:

async def multiple(self, ctx, num1: int, num2: int): [...]```
#

Self represents the class itself

crimson gale
#

*instance

vague walrus
#

Ahh, my bad

zinc kraken
#

oh
do i need to add self to ctx.send?

crimson gale
#

no

vague walrus
#

nope

crimson gale
#

only when making a method for a class

zinc kraken
#

it's still trowing the same error

crimson gale
#

code please?

zinc kraken
#
    @commands.command()
    async def multiple(self, ctx, num1: int, num2: int):
        await ctx.send(num1 * num2)
crimson gale
#

did you restart the bot first?

#

and save changes?

zinc kraken
#

i think so let me try

#

now it works

#

thanks

unique glacier
#

Hey how would I set my help command to MinimalHelpCommand. I'm using discord.Bot

steady lotus
#

i was thinking

#

how crazy would it be to have dynamic slash commands

#

so i have an array of names

#

and each of those names become a command

#

i reached the part where i made the command

#

but actually getting the command in discord isnt working

atomic thistle
#
Ignoring exception in on_typing
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
TypeError: on_typing() takes 1 positional argument but 3 were given

I passed only one argument in the function, but it is saying I passed three. What do I do?

verbal mango
#

why does this keep happening

atomic thistle
#

ahh. I meant to do on_raw_typing. That's why I had passed one argument. thanks

verbal mango
#

its like multiple on_ready() are being constantly called

finite cliff
#

how to import options?

finite cliff
#

reset modules are imported

#

but only discord.commands is giving problem

gilded widget
#

you'll need a way to make sure the task isnt running

#

i.e. use the is_running() method on the task

gilded widget
#

its just Option

finite cliff
#

its not being recognized

gilded widget
#

you probably aren't on the right version then

#

check your pycord version

#

if its 1.7.3 then yeah, discord.commands doesn't exist there

finite cliff
#

0.0 i used cmd to install pycord

#

but the version is 0.1.1

finite cliff
gilded widget
#

yeah you definitely have the wrong pycord installed

#

uninstall that

#

pip install py-cord==2.0.0rc1

finite cliff
craggy rapids
#

btw is that webhook or embed?

#

i wanna make something like that

#

i think its webhook ...

ornate spade
#

it looks like a webhook message which contains an embed

craggy rapids
ornate spade
#

of course

craggy rapids
#

docs?

#

ah nvm i got the docs

gentle spire
#

is there a way to delete ephemeral message?

#

or a way to get user who select SeleteMenu

weak hearth
#

why doesn't this work?

ornate spade
#

on_application_command_error

atomic thistle
#

How do I get all the default stickers of discord so that my bot can use them?

agile roost
#

Is that normal ?

frail olive
#

sorry, I just new to use about “help” channel. what is this cool things? how can I make a channel with only threads?wow

opal storm
#

Ok so I have this linux machine, and it has 3.9(pre installed) and I have python version 3.10, which I use for coding. I don't know why but some stuff does not work on the linux machine while it works fine on my pc. How can I upgrade it without it literally messing up the installation(since it then goes to initframs if I remove python3.9)

#

I don't wanna keep doing python3.10 everytime

opal storm
sick stirrup
#

or it just doesn't work?

rigid wave
opal storm
#

and i'll just use python3.10 for the time being

frank wadi
#

Does anyone know why it doesn't work?

#
    @slash_command()
    async def helper(self, ctx: commands.Context):
        embed = discord.Embed(title="help", description="helper1")
        embedd = discord.Embed(title="help", description="helper2")
        embeddd = discord.Embed(title="help", description="helper3")
        select = Select(
            placeholder="Wybierz Kategorie Pomocy",
            max_values=1,
            min_values=0,
            options = [
            discord.SelectOption(label="Informacyjne", description = "Wyswietl kategorie Informacyjne."),
            discord.SelectOption(label="Administracyjne", description = "Wyswietl kategorie Administracyjne."),
            
        ])
        async def thecallback(interaction):
            select.callback = thecallback
            view = View()
            view.add_item(select)
            await ctx.respond(embed=embed, view=view)
            if len(select.values) != 0:
                for choice in select.values:
                    if choice == "Informacyjne":
                        await interaction.respond.edit_message(content=embedd)
                    elif choice == "Administracyjne":
                        await interaction.respond.edit_message(content=embeddd)```
frank wadi
#

Please??

half marsh
#

Also you dont set the view and respond inside the cb func

inland acorn
#

how to edit the followup message

polar harness
#

heyy y'all, just a quick question

#

is the read message intent required if we wish something to be executed when pinged? (using the message.content method)

#

or are there any alternative ways to detect pings without that intent as well?

inland acorn
#

i read it somewhere but never tried

low knot
#

is there a possibility to add app commands when right clicking a vc?

crimson gale
#

nope

inland acorn
#

i sent a follow up message after using a slash command in ephemeral, can i send another ephemeral followup message after it?

crimson gale
half marsh
inland acorn
#

can we edit it rather?

#

the followup message

half marsh
#

Maybe

inland acorn
#

or send another followup

#

in both cases, how to do

half marsh
#

If you wanna do something after clicking the button, you can send respond, or interaction.message.edit

weak hearth
#

how do you make it so the user info part can't be clicked on?

#

like that

limpid ginkgo
#

how do i edit slash command interaction message

peak jacinth
#

How do I add discord.ext ? This is the error I get

slow dome
slender lintel
peak jacinth
#

How do I fix this error?

ancient gazelle
#

How do I setup discord.Option() for roles?

half marsh
robust nebulaBOT
#

Install pycord:

pip uninstall discord.py
pip install py-cord

Install pycord beta:

pip uninstall discord.py
pip install py-cord==2.0.0b7

Install pycord alpha from git:

pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
ancient gazelle
#

!option

ancient gazelle
#

AttributeError: module 'discord' has no attribute 'Bot'

#

Why does this happen at times?

inland acorn
ancient gazelle
#

yes

inland acorn
#

make sure u used py-cord, not pycord

ancient gazelle
#

pip freeze gives me this

#

py-cord==1.7.3

inland acorn
#

hmm

#

pip uninstall -U py-cord discord.py discord

#

try this

#

then reinstall

ancient gazelle
#

??

inland acorn
#

all

ancient gazelle
#

still the same

#

it's weird

inland acorn
#

show full error

#

and code

ancient gazelle
#

cause a couple days back the code worked

#

Traceback (most recent call last):
File "d:/Prediction Bot/main.py", line 7, in <module>
bot = discord.Bot()
AttributeError: module 'discord' has no attribute 'Bot'

#

from discord.ext import commands
import discord

bot = discord.Bot()

inland acorn
#

try installing latest version

#

2.0.0.b7

#

or git one

ancient gazelle
#

can you give me the command for the git one.

inland acorn
#

!install

robust nebulaBOT
#

Install pycord:

pip uninstall discord.py
pip install py-cord

Install pycord beta:

pip uninstall discord.py
pip install py-cord==2.0.0b7

Install pycord alpha from git:

pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
inland acorn
#

last

#

uninstall pycord too

#

there should be not any other conflicting package

#

how to edit en ephemeral message in button callback func

ancient gazelle
#

turns out I was using Python 3.7

#

my bad.

low knot
#

What is this called in the docs?

low knot
#

And for messages?

jovial chasm
#

wdym?

#

oh

#

they're below

low knot
#

nvm all good its right under it

#

thanks !

low knot
#

Are there any tutorials or examples to follow and learn how they work?

supple ravineBOT
#

Here's the context menus example.

low knot
#

Thank you so much!

frank wadi
#

hi

#

what is wrong?

#
Traceback (most recent call last):
  File "c:\Users\darkm\OneDrive\Desktop\Lambda Pycord\pycord.py", line 1, in <module>
    from discord.ext import commands
  File "C:\Users\darkm\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py", line 23, in <module>
    from . import abc, opus, sinks, ui, utils
  File "C:\Users\darkm\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\abc.py", line 60, in <module>     
    from .voice_client import VoiceClient, VoiceProtocol
  File "C:\Users\darkm\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\voice_client.py", line 55, in <module>
    from .gateway import *
  File "C:\Users\darkm\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\gateway.py", line 37, in <module>
    import aiohttp
  File "C:\Users\darkm\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\__init__.py", line 6, in <module>
    from .client import (
  File "C:\Users\darkm\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\client.py", line 35, in <module>
    from . import hdrs, http, payload
  File "C:\Users\darkm\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\http.py", line 7, in <module>
    from .http_parser import (
  File "C:\Users\darkm\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\http_parser.py", line 15, in <module>
    from .helpers import NO_EXTENSIONS, BaseTimerContext
  File "C:\Users\darkm\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\helpers.py", line 667, in <module>
    class CeilTimeout(async_timeout.timeout):
TypeError: function() argument 'code' must be code, not str
PS C:\Users\darkm\OneDrive\Desktop\Lambda Pycord>```
dapper ibex
#

Testing out some localized commands and the names show up just as expected. But there seems to be some issues with discord's 'autocomplete' (not sure if Autocomplete means anything more special than string/pattern matching). Basically, it shows commands (localized) when I type in the default/English name, but it doesn't match the localized names.

Is there something more I need to do or is this a product of localization features being in early stages?

slow dome
gleaming vale
#

Hi, quick question. Is it normal that the pictures detached to a respond to a slash command are black for all other people except the one who used the slash command?

worthy basin
#

I think that just means that the image is loading

unique glacier
frank wadi
#

thanks i have

spring badger
#

Meow

#

Anyone Here?

#

I have one issue \

#

I wannt to send nothing in Response to Slash command

#

how can I do that?

#

Cause ctx.defer() just says bot is thinking But, I want the bot to say nothing on Slash commands

#

@here

frigid lark
#

you can send a message and delete it after a second

frigid lark
#
await ctx.respond("text", delete_after=1)
spring badger
#

But, Why Can't I just send nothing?

gilded widget
#

discord requires a response

#

it's a discord api limitation

spring badger
obsidian garnet
#

One message removed from a suspended account.

#

One message removed from a suspended account.

crude temple
#

is there any way to get a user's email? There's no email attribute in discord.User

gilded widget
supple ravineBOT
# gilded widget p.tag idw

Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.

gilded widget
prime frost
#

Anyone know why custom emojis arent working in ephemeral messages spawned by a dropdown menu in a particular server but in normal commands invoked in the same server they do?

https://cdn.no1irishstig.co.uk/4qtf1.png

sudden path
prime frost
sudden path
#

Slash command responses are webhooks. And webhooks need external emotes perms, based off the everyone role.

prime frost
#

I see, but that wasnt from a slash command, it was a dropdown

sudden path
#

Any interaction response.

slow dome
finite cliff
#

how can i get message in channel from starting to last msg

finite cliff
#

how can i get datetime of a msg when it send with a custom timezone?

inland acorn
#

how can i add a callback when someone dismiss a ephemeral message sent by my bot

is it even possible?

crimson gale
#

no

inland acorn
fickle glacier
#

quick question: is it possible to get a users created at/joined at time as unix time?

half marsh
inland acorn
half marsh
#

By using view.children

#

Then choose the children you want the callback to invoke

half marsh
inner iris
#

Is it possible to create a discord.Emoji just from a string like <:emoji_name:123456...>?

dapper ibex
#

So I'm getting the PrivilegedIntentsRequired error. I know that the fix is to enable it both in the code and in the developer portal. But my bot is verified so it's not possible to toggle the content intent on.

I've fully migrated to slash commands, but wanted to ease the transition with one or two traditional commands until the expiration date.

Does anyone know a solution for this apart from straight up applying for the intent?

inner iris
dapper ibex
#

They were working yesterday though, before I switched over to pycord for this migration 🤔

crimson gale
#

its not a privileged intent yet. it will become such on august 31st

#

@dapper ibex ^

dapper ibex
crimson gale
#

huh

dapper ibex
#

I have one idea, since my pre-migration code just needed the intent declared in-code. Maybe I just need to ignore the exception

crimson gale
#

oh yeah discord.py stable still uses api v9 which doesnt enforce the message content intent

dapper ibex
#

I was actually using discord.js but grew to hate js so I very painfully rewrote it in python

#

lol

crimson gale
#

ah, i see lol

#

i dipped my toes into the js side of making bots for a bit

#

that turned into alot of work and it just kinda fell off gradually

dapper ibex
#

Well I can except the exception but obviously that doesn't make it work. I started this at 5 am so I'm not smart right now.
I guess I'll just have to wait for discord to approve my request for one (1) command (if they'll even do that).

#

something something 'limitation breeds innovation'

ancient gazelle
#

Hey there community,
I know this might be a really dumb question but I want to make my bot as a sub class in my project. What I mean with that is that I want to have a driver code that can call functions of the bot. My bot is basically like an event listener and a few other commands.
My driver code listens for some events and triggers the discord functions accordingly. I tried using tasks.loop() but my driver code runs 24/7.
What i really want is to have my bot in form of a Class such as a cog and call certain functions if needed. Any help with that?

crimson gale
#

you can make it repeat at specific times

ancient gazelle
#

It's like a loop going through a list, so I don't want to disturb the flow of the loop if that makes sense.

craggy flame
#

is there any maximum amount of choice in slash cmd option choice?

crimson gale
#

25

#

if you need more than that then consider looking into autocomplete

slender lintel
#

interaction doesn't have a delete attribute?

#

doing something like this

crimson gale
#

delete_original_message() i think

#

also you dont need the msg variable

slender lintel
#

I need that variable for something else mm

crimson gale
#

no you dont

#

await interaction.delete_original_message()

slender lintel
crimson gale
#

hm

slender lintel
#

for later use mm

crimson gale
#

mk

slender lintel
#

how to disable a select menu?
is it dropdown_variable.disabled = True?
I'm not using a class

crimson gale
#

yes

#

dont forget you have to edit the message with a new view containing the modified object

ancient gazelle
#

Any way of running the bot as an object of a class?

#

Like a cog but it is stand alone and does not require another class.

craggy rapids
#

btw why my task is never runned

#

no error shown

#

wait i need to start the loop

#

eh yes i started the loop but nothing happends too

paper harbor
#

side question:
how do I disable a button after it was clicked

paper harbor
#

is someone invisible for me?

craggy rapids
paper harbor
stable tiger
#

I ve been getting same buggish behavior with Forum threads, I guess, not ready for public release alueriSmogeInTheRain

slender lintel
#

how do i disable all the buttons in a view when i have reacted to one of them, i tried this but it doesnt work

    button1 = [x for x in self.children if  x.custom_id == "decline_trade"][0]
    button1 = [x for x in self.children if  x.custom_id == "accept_trade"][0]```
half marsh
slender lintel
steep verge
#

Huh? Can someone help me?

sick stirrup
#

How do I catch exceptions which are not DiscordExceptions (an event that catches all exceptions?)
on_application_command_error catches exceptions as DiscordExceptions

sick stirrup
steep verge
sick stirrup
steep verge
sick stirrup
#

cool

steep verge
sick stirrup
#

I do have it in place

#

After looking at the docs, seems like it only gets triggered if an exception occurs in a .event() and not a command

frigid lark
#

how can I add reactions to a slash command message?

sick stirrup
frigid lark
#

ye

sick stirrup
#

You can try ctx.message.add_reaction()

#

That is, if the ctx object has the message attribute.

vocal crane
#

is there a way to make it so my slash command has more then 25 options??

#

or a way to make it so it's possible to filter between the selections of each option

sick stirrup
slender lintel
#

Why isn't the bot writing? on_typing event

@bot.event
async def on_typing(channel, user, when):
    channels = bot.get_channel(980818985270509589)
    if type(channels) != discord.channel.TextChannel:
        await channels.trigger_typing()
slender lintel
#

All good i haved

atomic thistle
#

How do I make the bot repeat a task everyday at a certain time?

sudden path
#

Use tasks.

supple ravineBOT
#

Here's the background task asyncio example.

slender lintel
#

Is there a way to make some slash commands visible to specific roles or permissions?

#
client = discord.Client(debug_guilds=[965533467557371944])
client = discord.Client()

@client.event
async def on_ready():
    print(f"We have logged in as {client.user}")

@client.slash_command
async def hello(ctx):
    await ctx.respond("Hello!")```

'Client' object has no attribute 'slash_command' this is my error and google wont help me, whys it happening?
#

ofc client.run is there just no in what i showed

idle wagon
#

Hi on_member_join get invite code and inviter. Someone knows a reliable way to use?

#

In API i found this.

#

But in the pycord documentation I did not find an inviter? and code

crimson coral
#

the member_add (or member_join) event, when fired, doesn't come with invite information

slender lintel
#

How can I query that something only happens to a certain category?

crimson coral
#

can you elaborate?

crimson coral
crimson coral
slender lintel
# crimson coral can you elaborate?

Yes, um, I have a Modmail support means the IDs are stored in a channel in the topic and now I have the on_typing event and I have to tell him somehow that he should only do it in this one category. I hope you understand me HmmGe

slender lintel
#

import discord
bot = discord.Bot(debug_guilds=[965533467557371944])
bot = discord.Bot()

@bot.event
async def on_ready():
print(f"We have logged in as {Bot.user}")

@bot.slash_command
async def hello(ctx):
await ctx.respond("Hello!")

#

Traceback (most recent call last):
File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 2, in <module>
bot = discord.Bot(debug_guilds=[965533467557371944])
AttributeError: module 'discord' has no attribute 'Bot'

crimson coral
#

@bot.slash_command(), needs brackets

#

wrong version

#

install py-cord==2.0.0rc1

slender lintel
crimson coral
#

how did you install it before

slender lintel
crimson coral
#

then do the same but with py-cord==2.0.0rc1

slender lintel
#

alr

slender lintel
# crimson coral i think you wanna check `message.channel.category.id`?

Mhmm i have tried this but this is not working.

@bot.event
async def on_typing(channel, user, when):
    topic = channel.topic
    category = discord.utils.get(channel.guild.categories, id=939910389536280577)
    if topic in category is None:
        print("No")
        if topic:
            member = channel.guild.get_member(int(topic))
            if member:
                await member.trigger_typing()

so:

    category = discord.utils.get(channel.guild.categories, id=939910389536280577)
    if topic in category is None:
        print("No")
crimson coral
#

uhhh

#

if topic in category is None

#

what are you trying to do here

slender lintel
crimson coral
#

what was the final message

slender lintel
crimson coral
#

i think you've approached it wrong

slender lintel
# crimson coral what was the final message

Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\jackd\appdata\local\programs\python\python310\lib\site-packages (from aiohttp<3.9.0,>=3.6.0->py-cord==2.0.0rc1) (6.0.2)
Requirement already satisfied: idna>=2.0 in c:\users\jackd\appdata\local\programs\python\python310\lib\site-packages (from yarl<2.0,>=1.0->aiohttp<3.9.0,>=3.6.0->py-cord==2.0.0rc1) (3.3)
WARNING: You are using pip version 22.0.4; however, version 22.1.1 is available.
You should consider upgrading via the 'C:\Users\jackd\AppData\Local\Programs\Python\Python310\python.exe -m pip install --upgrade pip' command.

The final rough part

crimson coral
slender lintel
slender lintel
crimson coral
crimson coral
slender lintel
# crimson coral you should check if `channel.category == category`
@bot.event
async def on_typing(channel, user, when):
    topic = channel.topic
    category = discord.utils.get(channel.guild.categories, id=939910389536280577)
    if channel.category == category:
        print("No")
        if topic:
            member = channel.guild.get_member(int(topic))
            if member:
                await member.trigger_typing()

Is that correct?

crimson coral
slender lintel
crimson coral
slender lintel
crimson coral
#

it should at least be printing the version, right?

slender lintel
#

yeah, 3.10.4

crimson coral
#

can you do py -3 -m pip list

slender lintel
# crimson coral can you do `py -3 -m pip list`

Package Version


aiohttp 3.7.4.post0
aiosignal 1.2.0
async-timeout 3.0.1
attrs 21.4.0
chardet 4.0.0
charset-normalizer 2.0.12
discord.py 1.7.3
frozenlist 1.3.0
idna 3.3
multidict 6.0.2
pip 22.0.4
py-cord 2.0.0rc1
setuptools 58.1.0
typing_extensions 4.2.0
yarl 1.7.2

crimson coral
#

completely uninstall discord.py and py-cord, then reinstall py-cord==2.0.0rc1

slender lintel
#

alr

slender lintel
#

what is it?

crimson coral
#

probably py -3 -m pip remove

#

im stupid

#

uninstall, not remove

slender lintel
#

ye

crimson coral
#

uninstall...

slender lintel
#

lol

#

i sorted it just me being dumb

slender lintel
# crimson coral uninstall...

Not sure if ive made progress here but ive now got Bot is not defined
import sys
print(sys.version)
import discord
bot = discord.Bot(debug_guilds=[965533467557371944])
bot = discord.Bot()

@bot.event
async def on_ready():
print(f"We have logged in as {Bot.user}")

@bot.slash_command()
async def hello(ctx):
await ctx.respond("Hello!")

crimson coral
#

you 100% sure that's the error...?

slender lintel
# crimson coral you 100% sure that's the error...?

I got it sorry, but PS C:\Users\jackd\Documents\Felbcord Py> py -3 main.py 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] Ignoring exception in on_connect Traceback (most recent call last): File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 352, in _run_event await coro(*args, **kwargs) File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 793, in on_connect await self.register_commands() File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 460, in register_commands await self.http.bulk_upsert_command_permissions( File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 338, in request raise HTTPException(response, data) discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed

It starts but i get this error

half marsh
robust nebulaBOT
#

Install pycord:

pip uninstall discord.py
pip install py-cord

Install pycord beta:

pip uninstall discord.py
pip install py-cord==2.0.0b7

Install pycord alpha from git:

pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
half marsh
#

use rc ver

slender lintel
unique glacier
crimson coral
#

and did you invite with the applications.commands scope

slender lintel
crimson coral
#

you must invite with the necessary scope

#

?tag missing_access

hearty rainBOT
slender lintel
crimson coral
slender lintel
#

alright ty!

crimson coral
#

the example only uses the decorator, but the direct implementation looks something like py async def test_command(ctx, text: discord.Option(str, "Example"))

#

or let's say for the last example on that link py async def say(ctx: discord.ApplicationContext, attachment: discord.Option(discord.Attachment, "A file to attach to the message", required=False))

slender lintel
# crimson coral if you get the member object from the command, you can do `await member.edit(nic...

@bot.slash_command(name = "nick", description = "Change nickname of a user")
async def nick(ctx, member: discord.Member, *, ):
if ctx.author.guild_permissions.administrator:
await member.edit(nick=Censored nickname)
else:
await ctx.respond("You do not have the permissions to use this command", ephemeral=True)

How would i sort this i have alot of errors and my aim isnt to nick a different name every time, I want to /nick (user) then it will nick to censored nick as this is for inappropriate nicks/invis names

crimson coral
#

well you need to figure out the censorship logic yourself

inner iris
#

I am defining a class in a cog like this

class Cog(commands.Cog):
    def __init__(self, bot: commands.Bot):
        self.bot = bot

    class MyModal(discord.ui.Modal):
        def __init__(self, *args, **kwargs):
            super().__init__(*args, **kwargs)
        
        def callback(self, interaction):
            #do stuff

And my question is how I can access the bot object in the methods of MyModal.

#

Is that possible without passing the bot as an arg or kwarg to the class?

#

Or how would I in general access attributes and methods of the Cog?

slender lintel
# crimson coral well you need to figure out the censorship logic yourself

Hey sorry to bother you,

Traceback (most recent call last):
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 352, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 793, in on_connect
    await self.register_commands()
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 286, in register_commands
    if key2 in match[key][i].keys():
IndexError: list index out of range```
I am getting this error and my commands have stopped working
```import sys
print(sys.version)
import discord
bot = discord.Bot(debug_guilds=[965533467557371944])
bot = discord.Bot()

@bot.event
async def on_ready():
    print(f"We have logged in as {bot.user}")

@bot.slash_command(name = "addslowmode", description = "Add slowmode to a channel")
async def slowmode(ctx, channel_id, amount: int):
    if ctx.author.guild_permissions.manage_messages:
        channel = bot.get_channel(int(channel_id))
        await channel.edit(slowmode_delay = amount)
        await ctx.respond(f"{channel} has been slowed to {amount} seconds :white_check_mark:", ephemeral=True)
    else:
        await ctx.respond("You do not have the permissions to use this command")

@bot.slash_command(name = "nick", description = "Change nickname of a user")
async def nick(ctx, member: discord.Member,*,name):
    if ctx.author.guild_permissions.administrator:
      await member.edit(nick= name)
      name = ["Censored"]
    else:
        await ctx.respond("You do not have the permissions to use this command", ephemeral=True)```

(Bottom command isnt finished)
#

still figuring out the bottom command

hybrid canyon
#

Im getting this error and not sure why, it only occurs in VSCode, and not my server host

slender lintel
inner iris
#

nvm, I thought intents are only used for those three...

crimson coral
#

well for that implementation, all is exactly what you want

#

you need to update to py-cord==2.0.0rc1 on your local machine too

vocal crane
crimson coral
#

if you want more than 25 options use autocomplete instead

hybrid canyon
#

So whats the difference between py-cord==2.0.0rc1 and py-cord==2.0.0b

crimson coral
#

though note autocomplete isn't enforced, so you should have a check inside the command too

crimson coral
slender lintel
vocal crane
supple ravineBOT
#

Here's the slash autocomplete example.

crimson coral
#

refer to that

slender lintel
vocal crane
#

thanks

crimson coral
#

the same as you did on your server...?

hybrid canyon
slender lintel
hybrid canyon
#

run it in your terminal

crimson coral
#

i think we might have mixed up some feedback

#

@slender lintel can you paste the exact error you're getting

steady lotus
#

using bot.get_application_command(), how would i get a slashgroup command

slender lintel
crimson coral
#

didn't you remove the command

vocal crane
#

@crimson coral how many choices are there per option?

#

like max

crimson coral
#

probably 25?

slender lintel
vocal crane
#

damnn so u cant have more then that alright

crimson coral
#

in autocomplete it doesn't matter since you're generating choices

vocal crane
#

oh alright

crimson coral
slender lintel
# crimson coral what is the command code here
Traceback (most recent call last):
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 126, 
in wrapped
    ret = await coro(arg)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 856, 
in _invoke
    await self.callback(ctx, **kwargs)
  File "C:\Users\jackd\Documents\Felbcord Py\main.py", line 23, in nick
    await member.edit(nick= name)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\member.py", line 808, in edit    data = await http.edit_member(guild_id, self.id, reason=reason, **payload)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 353, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

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

Traceback (most recent call last):
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, 
in invoke
    await injected(ctx)
  File "C:\Users\jackd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 134, 
in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

this is the error ^

#
async def nick(ctx, member: discord.Member,*,name):
    if ctx.author.guild_permissions.administrator:
      await member.edit(nick= name)
      name = ["Censored"]
    else:
        await ctx.respond("You do not have the permissions to use this command", ephemeral=True)```

command code
crimson coral
steady lotus
crimson coral
#

actually

crimson coral
#

then access group.subcommands

#

hmm i wonder if there's a shorter way

steady lotus
#

nope

#

there isnt

steady lotus
#

i think thats the only way

crimson coral
#

ah i see

#

subcommands aren't included in the internal application_commands and _application_commands lists

#

they're always invoked under group so i guess it was considered unnecessary

sick stirrup
crimson coral
slender lintel
crimson coral
#

unless im misunderstanding your question

sick stirrup
crimson coral
#

well yeah i was referring to any error handler you have; on_command_error, on_application_command_error etc

sick stirrup
#

For example, there's a 404 error from another lib, and the error is caught in on_application_command_error but the type() for that is the base discord exception class\

crimson coral
#

i don't think it requires DiscordException though?

#

e.g. i just made a dummy command and my error handler catches a generic typeerror just fine

sick stirrup
#

Let me try to show you some screenshots

crimson coral
#

as long as you know how to reference the error you should be fine

#

yeah that'd help

sick stirrup
#

Weird how it's starting to work now lol

#

@crimson coral
So, I tried the print debugging technique and found this:
<class 'discord.commands.errors.ApplicationCommandInvokeError'> is the Error cls of on_error

crimson coral
#

ahh now that we can work with

#

if you get ApplicationCommandInvokeError or CommandInvokeError, access error.original for the real error

sick stirrup
#

This is my testcase command

crimson coral
#

i personally just rerun the error handler, but alternatively you can check for it at the start and handle that

#

e.g.

async def on_command_error(self, ctx, error):
    if isinstance(error, commands.CommandInvokeError):
        await self.on_command_error(ctx, error.original)```
sick stirrup
#

Thanks for that

crimson coral
#

all good

frank wadi
#

hi

#

i need help with a command

#

but in pycord ;//

#
@client.command(pass_context=True)
async def ostrzezenia(ctx, member: discord.Member = None):
    if not member.guild_permissions.kick_members:
        embed=discord.Embed(title="**Error 404**", description="Komenda działa tylko dla adminów! **Poprawna forma**: ``v!ostrzezenia <@admin>``", color=0xff0000)
        embed.set_footer(text=f"Wywołane przez: {ctx.author.name}", icon_url=ctx.author.avatar.url)
        await ctx.send(embed=embed, delete_after=5)
        await asyncio.sleep(5)
        await ctx.message.delete()
    else:
        guild = ctx.message.guild.id
        rows = Database.rows("SELECT * FROM ostrzezenia WHERE UserID = ? AND Guild = ? ORDER BY ROWID ASC",
                                str(member), str(guild))
        embed = discord.Embed(
            ctx=ctx,
        )
        embed.set_thumbnail(url=member.avatar.url)

        value = '\n'.join(f' > ![1_](https://cdn.discordapp.com/emojis/979113998857404466.webp?size=128 "1_") `Ostrzeżenie z dnia:` **{row[3]}**\n > ![5_](https://cdn.discordapp.com/emojis/979113999901794395.webp?size=128 "5_") `Przez Administratora:` **{row[0]}**\n > ![3_](https://cdn.discordapp.com/emojis/979113999520129094.webp?size=128 "3_") `Powód Ostrzeżenia:` **{row[2]}**\n\n' for row in rows)

        embed = discord.Embed(description=value, color=0xFE7D35)
        embed.set_author(name="Lista Ostrzeżeń", icon_url="https://cdn.discordapp.com/emojis/979114000375763024.webp?size=96&quality=lossless")
        await ctx.send(embed=embed)```
sick stirrup
frank wadi
#

Prefixed

sick stirrup
#

What's the error/excepted output? @frank wadi

frank wadi
#

no error

sick stirrup
#

Not sure how you got no error.

Try using print statements to try and debug the code

#

You'll find an error while using the "\n".join() on value.
You need to use a list/tuple to be able to use the list/tuple comprehension.

#

And I don't think discord.Embed(ctx=ctx) is valid .

sick stirrup
hybrid canyon
#

How can i stop this warning from appearing everytime i update/install/uninstall a module?

mild hatch
#

I have a little problem making a group, if i place the group variable inside the class it gets created twice, but if i place it outside the class i get discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: Utilities.info_emoji() missing 1 required positional argument: 'ctx'

rose stratus
#

how can i make a black space like this

sudden path
#

Those are just codeblocks.

regal jacinth
rose stratus
#

ok thanks

vagrant mortar
#

What could be the cause of an interaction to return "Interaction Unknown" when attempting to do a ctx.respond()?

supple ravineBOT
#

cogsReport/manager.py lines 109 to 122

async def assign(self, ctx, member: Option(discord.Member, "What user do you want to assign?"), _id: Option(str, "To which report do you want to assign the user?", autocomplete=get_server_reports)):
    """Server Admins only - Assign a member to a report."""
    if await isManager(ctx):
        report = await ReportFromId(_id, ctx)
        track_google_analytics_event("Assign", f"{report.report_id}", f"{ctx.interaction.user.id}")

        report.assignee = member.id

        await report.addnote(member.id, f"Assigned {report.report_id} to {member.mention}", ctx, ctx.interaction.guild.id)
        await report.commit()
        await report.update(ctx, ctx.interaction.guild.id)
        await ctx.respond(f"Assigned {report.report_id} to {member.mention}")
    else:
        await ctx.respond("You do not have the appropriate permissions to use this command.")```
rose stratus
#

can someone help me pls

ornate fog
rose stratus
#

ok

obsidian garnet
#

One message removed from a suspended account.

ornate fog
obsidian garnet
obsidian garnet
ornate fog
#

NP

slender lintel
#

how do you do cooldowns in slash commands

steady lotus
#

i dont get it

#

do i need a perm to ping a role?

craggy rapids
sudden path
supple ravineBOT
#

Here's the cooldown example.

midnight orbit
#
ModuleNotFoundError: No module named 'dotenv'```
showing this forever trying to use .env...

i've already tried everything from https://stackoverflow.com/questions/59572174/no-module-named-dotenv-python-3-8
steady lotus
#

anyone know why it no work

steady lotus
#

Are command cooldowns any user per command or per user per command

unique flume
inland acorn
#

how to invoke a slash subcommand?

gilded widget
#

as in like, through code?

#

there should be ApplicationContext.invoke if you're using cogs, otherwise you should just be able to call the function

desert escarp
#

the first pic is the error i got and the second is my code can someone let me know what to do

gilded widget
#

did you uninstall discord.py before installing pycord

desert escarp
#

yea

#

@gilded widget u there?

gilded widget
#

pls dont ping

#

make sure you install the latest version and not 1.7.3

#

do pip install py-cord==2.0.0rc1

desert escarp
desert escarp
#

alright did it

#

nothings happening now

#

no error code or nothing

#

but the commands still wont work

gilded widget
#

so no errors?

#

if you're using prefixed commands then you need to have the message content intent

ebon spruce
#

Is there a fix?

async def command_not_found(self, cmd):

        ctx = self.context
        bot = ctx.bot
        return await ctx.deny(f"{cmd} does not exist")```
**ERROR**

AttributeError: 'TextChannel' object has no attribute 'news'```

gilded widget
#

if that doesnt fix it then update to github master branch

desert escarp
gilded widget
#

videos are not accurate

#

this is a good place to get started w pycord

desert escarp
#

alright ill look into it

gilded widget
#

and docs

desert escarp
#

okii thank you

opaque marsh
#

Ignoring exception in command lyrics:
Traceback (most recent call last):
File "C:\Users\shan's python work\PycharmProjects\da_pycord_botto\venv\lib\site-packages\discord\commands\core.py", line 126, in wrapped
ret = await coro(arg)
File "C:\Users\shan's python work\PycharmProjects\da_pycord_botto\venv\lib\site-packages\discord\commands\core.py", line 860, in _invoke
await self.callback(ctx, **kwargs)
File "C:\Users\shan's python work\PycharmProjects\da_pycord_botto\bot.py", line 386, in lyrics
await ctx.respond(embed=embed)
File "C:\Users\shan's python work\PycharmProjects\da_pycord_botto\venv\lib\site-packages\discord\commands\context.py", line 227, in respond
return await self.interaction.response.send_message(*args, **kwargs) # self.response
File "C:\Users\shan's python work\PycharmProjects\da_pycord_botto\venv\lib\site-packages\discord\interactions.py", line 686, in send_message
await self._locked_response(
File "C:\Users\shan's python work\PycharmProjects\da_pycord_botto\venv\lib\site-packages\discord\interactions.py", line 933, in locked_response
await coro
File "C:\Users\shan's python work\PycharmProjects\da_pycord_botto\venv\lib\site-packages\discord\webhook\async
.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

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

Traceback (most recent call last):
File "C:\Users\shan's python work\PycharmProjects\da_pycord_botto\venv\lib\site-packages\discord\bot.py", line 993, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\shan's python work\PycharmProjects\da_pycord_botto\venv\lib\site-packages\discord\commands\core.py", line 357, in invoke
await injected(ctx)
File "C:\Users\shan's python work\PycharmProjects\da_pycord_botto\venv\lib\site-packages\discord\commands\core.py", line 134, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction

im getting this bigass error

#

lemme send the code

#

holup

#
@client.slash_command(description="Get the lyrics to your favorite song >:)")
async def lyrics(ctx, song:Option(str, "Enter the name of the song for which you want the lyrics!")):
    song = urllib.parse.quote_plus(song)
    async with aiohttp.ClientSession() as lyricsSession:
        async with lyricsSession.get(
                f'https://some-random-api.ml/lyrics?title={song}') as jsondata:
            if not 300 > jsondata.status >= 200:
                return await ctx.send(f'Recieved poor status code of {jsondata.status}')

            lyricsData = await jsondata.json()  # load the json data into its json form

    error = lyricsData.get('error')
    if error:
        return await ctx.send(f'Recieved unexpected error: {error}')

    songLyrics = lyricsData['lyrics']  # the lyrics
    songArtist = lyricsData['author']  # the author's name
    songTitle = lyricsData['title']  # the song's title
    songThumbnail = lyricsData['thumbnail']['genius']
    for chunk in textwrap.wrap(songLyrics, 4096, replace_whitespace=False):
        embed = discord.Embed(
            title=songTitle,
            description=chunk,
            color=discord.Color.blurple(),
            timestamp=datetime.datetime.utcnow()
        )
        embed.set_thumbnail(url=songThumbnail)
        await ctx.respond(embed=embed)
#

der u go

crimson gale
#

it could be taking longer than 3 seconds to respond

#

have you tried deferring the interaction?

weak hearth
#

any1 know why i get this error?

crimson gale
#

code

ivory zenith
#

how do i make my command ephemeral?

#

i m using ctx.respond

reef iron
#

await ctx.respond("Hello!", ephemeral=True)

reef iron
ivory zenith
#

hi, how do I sync the command for every guild that invited the bot, without needing to restart the bot? cuz rn if i invite the bot to a guild, i need to restart the bot in order to see the commands on that guild

reef iron
#

If you remove that, a command becomes "global" so it can be used in every server.

reef iron
#

I think there are 2 ways to fix this.

  1. for result in serveractions.find({}):
  2. list(serveractions.find({}))
#

Your current code makes results a cursor object, not a list that you can use with a for loop.

weak hearth
#

Oh

reef iron
weak hearth
#

Okii lmfao

reef iron
#

One or both of my solutions will work CB_fingerguns

weak hearth
#

very confident i see 👀 😄

reef iron
#

The code isn't exactly complicated shrug

weak hearth
#

guessing i change it to result??

#

oh

#

wait

reef iron
#

result[]

ivory zenith
weak hearth
reef iron
#

the error you sent doesn't appear to be in your code

#

it also is easier to send a copy of your code rather than a screenshot

#

oh and this is a super simple error, you should also be able to fix it yourself

weak hearth
reef iron
#

Your error states that the error is on like 158 results["Discord Invite"] but this isn't in the screenshot you sent.

weak hearth
#

i dont see the problem tbh

reef iron
#

the error states results

#

while you have result

#

you probably didn't reload your code

weak hearth
#

oh

#

i am stupid lmfaoo

reef iron
#

please consider following starter courses Python

#

you have to be able to read a simple error like this

steady lotus
#

is it possible to create commands using commands.Command() class

#

not decorator

slender lintel
#

How do i add a space in the slash command name

reef iron
#

There are sub commands though.

slender lintel
#

How do u make sub commands

craggy rapids
reef iron
reef iron
craggy rapids
#

i mean like

#

grab the channel id from user when user use / cmd

#

uhhhh

#

simpliedly like i need to grab the channel id when a user use the commands

reef iron
craggy rapids
#

okie tryin

#

well it work but i got another question

#

ctx.message.author.guild_permissions.administrator

#

AttributeError: 'NoneType' object has no attribute 'author'

reef iron
#

slash commands don't have a message

craggy rapids
#

is it ctx.author.guild_permissions.administrator

reef iron
#

ctx.author, not ctx.message.author

craggy rapids
#

okie

#

sweet, thanks for your helps

frigid lark
#

How can I add emoji reactions to a slash command?

#

To the message what the bot sends

reef iron
#

message = await ctx.interaction.original_message()
await message.add_reaction("👍 ")

steady lotus
#

If I want to register a command for all guilds the bot is in but not want to make them global how would I do that

humble talon
steady lotus
#

Hmm

humble talon
#

But as someone who had that exact idea, it's almost always better to use globals, there's also a limit on "local" ones

#

of like 100 I think

steady lotus
#

Does that work in cogs

humble talon
#

Not sure about setting it up with variable params

#

How many servers is your bot in?

steady lotus
desert dagger
steady lotus
humble talon
desert dagger
#

Uh

steady lotus
#

So 200 commands

#

100 global 100 local?

desert dagger
#

Nvm im dumb

slow dome
#

if you wanted to count local commands, just double it

steady lotus
#

Wait

#

Sub commands aren't counted as part of the 100?

inner talon
#

why isn't Client.get_message() working? it says 'Client' object has no attribute 'get_message'

slender lintel
#

Um i see your token, which Pycord version do you have?

opal storm
#

need help in #981191104751861790

terse gazelle
#

Hello guys, I'm having some troubles importing Modal and InputText from discord.ui. I've inspected .ui but neither of those two are not included in. My version is 2.0.0b1

sleek grove
slender lintel
reef iron
sleek grove
slender lintel
inner talon
sleek grove
#

I have a other question

#

Thats weird

frigid lark
#

rc1

slender lintel
#

yeah but this also working

frigid lark
#

b7 still have some bugs which are fixed in rc1

sleek grove
#

Now only that shows up

slender lintel
frigid lark
sleek grove
#

Yes

frigid lark
#

you need ctx.respond() for slash commands

buoyant saddle
#

I have a question, there is a ctx.guild.owner , is there a ctx.guild.administrator ?

delicate relic
#

Guys, i have a question how do i start a thread from a slash_command message, since ctx.respond doesn't work with create_thread()?

reef iron
#

create_thread can be used on either a text channel or a message

#

so just use ctx.channel.create_thread()

reef iron
buoyant saddle
slender lintel
#

How would i use interaction.response.send_message to send a message with buttons, For all i can see is that i can send it without as a regular message

#

I have a slash command that has a question then has button "next question" its a sereis of quetions

slender lintel
#

questions*

reef iron
#

@slender lintel I don't know your code but you could just use ctx.respond with a view too

slender lintel
reef iron
slender lintel
#

ill loook at that

delicate relic
reef iron
#

you want to use ctx.respond and create a thread on the response?

delicate relic
#

Ye

reef iron
#

message = await ctx.interaction.original_message()
await message.create_thread()

delicate relic
#

this is how it looks

delicate relic
buoyant saddle
slender lintel
# reef iron https://github.com/Pycord-Development/pycord/blob/master/examples/views/confirm....

Sorry im still confused, class View(discord.ui.View):

 async def button_callback(self, button, interaction):
     await interaction.response.send_message("", ephemeral=True)
   

@bot.slash_command(name="staffapp", description="staff app questions") 
async def button(ctx):
 await ctx.respond("Would you like to apply for staff?", view=View()) 
``` This is the code, But i dont want it to be a regular message it responds with i want a regular message with buttons
reef iron
#

read the docs

reef iron
#

assuming it is working code

slender lintel
#

message

reef iron
#

you want to add a button to someone else's message?

slender lintel
slender lintel
#

I want to have when i click "Yes i do" to enter the next button message

reef iron
#

just repeat a respond or send

#

you'll also have to combine that with a wait_for('message') if you want the bot to do something with the age response

#

like fr look at the example, it's all there

slender lintel
slender lintel
# reef iron just repeat a respond or send
    @discord.ui.button(label="Next Question", style=discord.ButtonStyle.primary, emoji=":white_check_mark:")
    async def button_callback(self, button, interaction):
         await interaction.response(Content="Why do you want to be staff at felbcord?", label="Next Question", view=View()) 


@bot.slash_command(name="staffapp", description="staff app questions") 
async def button(ctx):
    await ctx.respond("Would you like to apply for staff?", view=View()) ```

Sorry im not understanding, May you explain more?
fresh brook
crimson gale
#

view timeouts are different

#

i mean the command

slender lintel
# slender lintel (This is a staff app if your wondering lol)

Anyone able to help? I've got my slash command saying the message with buttons but i want the "Yes i do" to go onto another question with a button.. I know i can have it so it responds to another message but i cant figure out how to add buttons..? Please help

paper harbor
slender lintel
#
    @discord.ui.button(label="Next Question", style=discord.ButtonStyle.primary, emoji="✅", custom_id="Next1")
    async def button_callback(self, button, interaction):
         await interaction.response(Content="Why do you want to be staff at felbcord?", label="Next Question", view=View()) 


@bot.slash_command(name="staffapp", description="staff app questions") 
async def button(ctx):
    await ctx.respond("Would you like to apply for staff?", view=View()) 

``` code
paper harbor
#

Ah, ok. so simply add another button inside the callback. you could create a new view for the new message and a whole new button. if you don't want to make a whole new class, you could use this code as a short way of making a button:

testlol = discord.ui.Button(label=f"test",
            style=discord.ButtonStyle.green,
            emoji="😁")```
slender lintel
#

Thanks

#

Ill try it now

slender lintel
paper harbor
#

the new button has to be in the callback

slender lintel
paper harbor
#

so i'm not doing the method of buttons your doing. you do with classes but i do just short boi code so here example of what i would do:

@lol.command()
async def lol(ctx):
  #BUTTON
  testlol = discord.ui.Button(label=f"test",
            style=discord.ButtonStyle.green,
            emoji="😁")
  #FIRST BUTTON CALLBACK
  async def testlol_callback(interaction):
    firstbuttonembed = discord.Embed(bla bla bla)
    #SECOND BUTTON
    testlol = discord.ui.Button(label=f"test",
            style=discord.ButtonStyle.green,
            emoji="😁")
    #SECOND BUTTON CALLBACK
    async def testlol2_callback(interaction):
      secondbuttonembed = discord.Embed(bla bla)
      bla bla```
slender lintel
#

I dont know if i messed it up or i am being stupid

paper harbor
#

so select the whole button1_callback and then press tab, to bring it up one tab and also tab the testlol button

#

tabs on discord are slightly off, so when you copy and paste, it pastes weird

slender lintel
#

alr

slow dome
slender lintel
#

latter?

slender lintel
slow dome
#

first of all, view is not defined

slender lintel
paper harbor
#

it's gonna be hard to help cuz there's a no-code-giving rule except for tiny snippets

slender lintel
#

i dont wanna copy, I just wanna understand how to do it

slow dome
#

?tag ex

slow dome
#

?tag guide

hearty rainBOT
slender lintel
#

lol

slow dome
slender lintel
#

ty

slender lintel
zealous vapor
#

Is there a way to get all the messages in a channel?

slender lintel
slender lintel
#

Ill have a look at what u just sent

slow dome
#

you want to respond to it with a message with buttons?

slender lintel
slow dome
#

just do it like

class View(discord.ui.View): # Create a class called View that subclasses discord.ui.View
    @discord.ui.button(label="Click me!", style=discord.ButtonStyle.primary, emoji="😎") # Create a button with the label "😎 Click me!" with color Blurple
    async def button_callback(self, button, interaction):
        await interaction.response.send_message("You clicked the button!", view = View2())

class View2(discord.ui.View): # Create a class called View that subclasses discord.ui.View
    @discord.ui.button(label="Click me!", style=discord.ButtonStyle.primary, emoji="😎") # Create a button with the label "😎 Click me!" with color Blurple
    async def button_callback(self, button, interaction):
        await interaction.response.send_message("You clicked the button!", view = View3())

...
#

it may not be the most efficient

slender lintel
#

lol ima read the code there so i can understand it for myself 😄

slender lintel
slow dome
#

?

slender lintel
slow dome
#

if you are creating a button instance, you create a button with

view = discord.ui.View()
view.add_item(discord.ui.Button(label="label", style=style=discord.ButtonStyle.primary, callback=corotine))
#

do you know object oriented programming

#

at all?

slender lintel
# slow dome at all?

I dont know if this is the same thing, I know a bit of css but if not no. I dont, Should i?

slow dome
#

you should probably learn object oriented programming before learning py-cord

slender lintel
slow dome
#

py-cord uses object oriented programming

slender lintel
#

Alright, Does it take long to learn or?

slow dome
#

so if you don't know oop (for short), you will struggle

slow dome
slender lintel
slender lintel
slow dome
#

?tag lp

hearty rainBOT
#
slow dome
#

someone of these may help

slender lintel
slow dome
#

np

slender lintel
#

sheesh is there a way to make this dark mode xD

#

my eyes 🤣

#

How can I make it send message.content only after it has already sent new_ticket_embed?

clever lava
#

you can make another one or just send a regular message

slender lintel
clever lava
#

oh

slender lintel
#

Yeah..

clever lava
#

then when do you want to message.content be sent

slender lintel
#

After the second message so after the ticket open

clever lava
#

guys

#

await role.edit()

#

what kind of parameters can i fit in this

#

await role.edit(color = discord.Colour.blurple())

#

this is an example

#

theres any more?

sudden path
#

b!rtfm pyc role.edit

clever lava
#

ty

#

can i create roles?

#

using the bot

sudden path
#

b!rtfm pyc guil.create_role