#Basic Pycord Help

1 messages · Page 19 of 1

heavy sky
#

Does anyone know why I'm getting No module named discord.utils when trying to import wavelink? I am using version 3.1.2 of it

red mist
#

I believe, when you pip installed Wavelink it installed discord.py by itself again, usually when installing extra packages you need to make sure it doesn't install the dependencies

#

So

#

What you do is you both pip uninstall discord.py and py-cord

#

And then pip install py-cord

#

Then you can try running it again

heavy sky
#

Oh, ok. Imma give that a try now

red mist
#

lemme know if it worked

#

^~^

heavy sky
#

Will do 🙂

#

That seem to have worked. Thank you so much!

red mist
#

Yw :)

cunning stirrup
#
@commands.slash_command(
    @option("artist", description="Artist Name")
    @option("song", description="Song Name", choices=["Official", "Unleak", "Other"])
    )
   ``` How can i use Options in cogs ?
#

@vital bramble

sage tendon
#

i do it like this

cunning stirrup
#

the thing is @option("artist", description="Artist Name")
^
SyntaxError: invalid syntax

#

idk why i imported it

sage tendon
#

yea because you do it inside the slash command generator
do it outside
i think you can do it inside? but just do it like i do it tbh

cunning stirrup
#

kk thx

little cobalt
sage tendon
#

yea so same as me

#

oh

little cobalt
#

nope ;3

sage tendon
#

you dont import option specifically

#

cringe + L + ratio

little cobalt
#

that I what I not did x3

sage tendon
#

yea idk, i'm minimalistic, i would have left it out if it wasnt required somehow

#

so

#

:3

cunning stirrup
#

'SlashContext' is not defined

#

hmm do i have to import that ?

lofty parcel
#

It is discoed.ApplicationContext

cunning stirrup
#

oh thx

little cobalt
#

;3

lofty parcel
#

Shut

little cobalt
#

xd

cunning stirrup
#

how do i add buttons ? and what should i import?

cunning stirrup
#

thx

tame portal
#

is there a way to get the timestamp from the ApplicationContext in a slash command?

#

ctx.interaction.message and ctx.message are both none

cunning stirrup
#
button = discord.ui.Button(style=discord.ButtonStyle.success, label="Accept Request", custom_id="accept_request")
            view = discord.ui.View()
            view.add_item(button)

         
            song_request_channel_id = 1198607104525733909 
            song_request_channel = self.bot.get_channel(song_request_channel_id)

            if song_request_channel:
                request_message = await song_request_channel.send(embed=embed, view=view)
            else:
                await ctx.send("Error: Song request channel not found.")
                return

            def check(interaction: discord.Interaction, message_id: int):
                return interaction.custom_id == "accept_request" and interaction.message.id == message_id

            try:
                interaction = await self.bot.wait_for("button_click", timeout=60.0, check=lambda i: check(i, request_message.id))
            except asyncio.TimeoutError:
                await ctx.send("Request not accepted. Time expired.")
                return

            if interaction.component.label == "Accept Request":
                
                await interaction.user.send("You accepted a song request! Please send the audio file.")
      ``` any idea why the button says interaction failed but i dont get any errors
tame portal
lofty parcel
#

Just do it.yourself with datetime

tame portal
#

mm fair enough

lapis dock
#

.tag guide

sly karmaBOT
steep cliff
#

Currently using SqlAlchmey as my db ORM. I know it can be asynchronous, but my current setup is not, seems to be working fine tho. Do I have to make it asynchronous?

glad garnet
steep cliff
#

Oh dang, just realized I already switched to asnyn code but forgot :)

green oar
#

Hello there, is there a "preferable" way to store data when making discord bot ? I was gonna use sqlite but idk

#

The purpose is to save basics data when users use reaction

green oar
shell radish
green oar
#

Okay, great hen

#

Thanks for answers !

prime hill
#

quick question: how to supress embeds for slash command responses

lofty parcel
#

What?

prime hill
#

as not embed links in the response

lofty parcel
#

You mean when sending links?

#

Just wrap the link around a <>

prime hill
#

i know that but i saw discord.py docs has a message flag called "supress_embeds"

lofty parcel
#

I'm sure it exists too.

prime hill
#

what am i doing wrong

lofty parcel
#

Probably the webhook doesn't have that kwarg.

lapis dock
hexed herald
#

hey, I have an autocomplete context. Am I somehow able to clear the cached answers?

#

like I first generate a set of answers but if the user changes the first parameter I need to generate other answers for the second parameter

#

in the second picture the parameter is different but the autocomplete results are the same

little cobalt
#

With ctx.options["option name"] you get the selected option

#

So you could change the autocomplete like that

hexed herald
#

yeah, my current code for the second param looks like this

def value_choices(ctx: discord.AutocompleteContext) -> list[str]:
    """Responds with every Role or Channel depending on the setting and searched term"""
    values = []
    entered = ctx.value
    setting: str = ctx.options.items().mapping["setting"]
    if setting is None:
        return ["Please select a setting first"]
    elif setting.endswith("Role"):
        for role in ctx.interaction.guild.roles:
            if entered in role.name:
                values.append(role.name)
        return values
    elif setting.endswith("Channel"):
        for channel in ctx.interaction.guild.channels:
            if entered in channel.name:
                values.append(channel.name)
        return values
    else:
        return ["A super rare bug appeared and I don't know why!"]
#

but if the second param is once generated it won't change without any input

#

unless you redo the whole command selection

#

everyone may ping me in response to the above

deft kestrel
#

Code:

import discord
from discord.ext import commands

bot = discord.Bot()

Error:

PS C:\workspace\digi> python bot.py
Traceback (most recent call last):
  File "bot.py", line 4, in <module>
    bot = discord.Bot()
AttributeError: module 'discord' has no attribute 'Bot'

Info: I did pip install -U py-cord before that

hexed herald
#

are you in an virtual environment?

#

that may cause problems if you don't install the package inside it

grizzled loom
#

I've got

user: discord.Option(discord.Member)

as part of a slash command. Option and implementation is working.
My question is if there is a simple way to refresh the data for "user" at command execution.

Yes yes, I know, this .Option does make sure a member is used as an argument. However it is possible to insert a member, kick the member(or the member leaves after the command was typed but before the typing person hit enter, which can be a large window of opportunity) and only then run the command.
In the aftermath, which i spare you here = D, it can lead to data storage about a user who is no longer part of this specific guild.

Enough said; work you magic please (also please do ping me when you do)
Edit; py-cord-dev==2.5.0rc5

deft kestrel
lofty parcel
deft kestrel
#

ok sorry

#

XD

#
Package              Version
-------------------- -----------
absl-py              2.0.0
aiohttp              3.7.4.post0
astor                0.8.1
async-timeout        3.0.1
attrs                23.2.0
certifi              2023.7.22
cffi                 1.15.1
chardet              4.0.0
charset-normalizer   3.3.2
click                8.1.7
colorama             0.4.6
exceptiongroup       1.2.0
fire                 0.5.0
Flask                2.2.5
gast                 0.2.2
google-pasta         0.2.0
grpcio               1.59.2
h11                  0.14.0
h5py                 3.8.0
idna                 3.4
importlib-metadata   6.7.0
itsdangerous         2.1.2
Jinja2               3.1.2
Keras-Applications   1.0.8
Keras-Preprocessing  1.1.2
Markdown             3.4.4
MarkupSafe           2.1.3
multidict            6.0.4
numpy                1.21.6
opt-einsum           3.3.0
outcome              1.3.0.post0
pip                  23.3.2
protobuf             3.20.3
py-cord              1.7.3
pycparser            2.21
PySocks              1.7.1
regex                2023.10.3
requests             2.31.0
selenium             4.11.2
setuptools           68.0.0
six                  1.16.0
sniffio              1.3.0
sortedcontainers     2.4.0
tensorboard          1.15.0
tensorflow           1.15.0
tensorflow-estimator 1.15.1
termcolor            2.3.0
tqdm                 4.66.1
trio                 0.22.2
trio-websocket       0.11.1
typing_extensions    4.7.1
urllib3              1.26.18
Werkzeug             2.2.3
wheel                0.41.3
wrapt                1.15.0
wsproto              1.2.0
yarl                 1.9.4
zipp                 3.15.0
#

just realized haha

lofty parcel
#

You have a very old version

#

Update your py-cord version

deft kestrel
#

what was the command again

#

pip install --upgrade py-cord

#

got it

deft kestrel
# lofty parcel Update your py-cord version
PS C:\workspace\digi> pip install --upgrade py-cord
Requirement already satisfied: py-cord in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (1.7.3)
Requirement already satisfied: aiohttp<3.8.0,>=3.6.0 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from py-cord) (3.7.4.post0)
Requirement already satisfied: attrs>=17.3.0 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->py-cord) (23.2.0)
Requirement already satisfied: chardet<5.0,>=2.0 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->py-cord) (4.0.0)
Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->py-cord) (6.0.4)
Requirement already satisfied: async-timeout<4.0,>=3.0 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->py-cord) (3.0.1)
Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->py-cord) (1.9.4)
Requirement already satisfied: typing-extensions>=3.6.5 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->py-cord) (4.7.1)
Requirement already satisfied: importlib-metadata in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from attrs>=17.3.0->aiohttp<3.8.0,>=3.6.0->py-cord) (6.7.0)
Requirement already satisfied: idna>=2.0 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from yarl<2.0,>=1.0->aiohttp<3.8.0,>=3.6.0->py-cord) (3.4)
Requirement already satisfied: zipp>=0.5 in c:\users\aange\appdata\local\programs\python\python37\lib\site-packages (from importlib-metadata->attrs>=17.3.0->aiohttp<3.8.0,>=3.6.0->py-cord) (3.15.0)
lofty parcel
#

The newest python version that works with pycord is 3.11

deft kestrel
#

ohhhh python

#

i thought pycord

lapis dock
#

It was both, you had old of both

grizzled loom
deft kestrel
#

no

grizzled loom
#

why not? this list is.. well.. a mess. needlessly harder to maintaine.

deft kestrel
grizzled loom
#

hmmm

deft kestrel
#

may be a good idea tho

#

and yeah it really looks like a mess haha

#

i recognize only half of it

grizzled loom
#

did you try pycharm? it does it for you when ever you hit create new project

deft kestrel
#

i use vscode

#

isn't there an extension for that maybe?

grizzled loom
#

and the free version is great for python. granted, its only good for this one language, but there is pretty solid 🙂

deft kestrel
#

i have jetbrains ultimate

#

i only used intellij

#

i really dont know what pycharm is like

#

you know what you hyped me up now

little cobalt
#

its a IDE

grizzled loom
deft kestrel
#

im gonna try pycharm tomorrow

deft kestrel
little cobalt
#

xd

deft kestrel
#

XDDD

deft kestrel
grizzled loom
#

LovePycord 😂

deft kestrel
#

fr pycord on top

little cobalt
#

you can create a env with

python -m venv env
strong rain
#

Thanks. My bot hosting services was having some network issues, resulting in performance issues

#

I have this code snippet: py async def on_guild_channel_update(before, after): overwrites = after.channel.overwrites overwrites[after.guild.me] = discord.PermissionOverwrite(read_messages=True) return await after.edit(overwrites=overwrites)But I get this error:py Ignoring exception in on_guild_channel_update Traceback (most recent call last): File "/home/container/.local/lib/python3.11/site-packages/discord/client.py", line 399, in _run_event await coro(*args, **kwargs) File "/home/container/main.py", line 497, in on_guild_channel_update await after.edit(overwrites=overwrites) File "/home/container/.local/lib/python3.11/site-packages/discord/channel.py", line 859, in edit payload = await self._edit(options, reason=reason) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/container/.local/lib/python3.11/site-packages/discord/abc.py", line 491, in _edit "id": target.id, ^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'id'

strong rain
# little cobalt "NoneType"

after shouldn't be "None", as that would fall under on_guild_channel_delete, unless on_guild_channel_update also is an event handler for deleting channels?

grizzled loom
#

Also; where is this silly squid when you need it? 🤨

grizzled loom
loud kayak
little cobalt
#

So... I have a serverconfig for my bot and Im not sure if I should use a file for it or send everytime a requests to my database

loud kayak
little cobalt
#

I use MongoDB already for member data

#

but also for a privat bot with a server config?

loud kayak
#

What I do is I have a document in a collection (collection is specific to bot). Each document has the _id as the guild’s ID, for easy access.

#

Then I have a document with _id as BOTCONFIG for global stuff.

grizzled loom
# loud kayak What do you mean by refreshing the data?

let give you an example.

    @slash_command()
    async def some_name(self, ctx: discord.ApplicationContext, user: discord.Option(discord.Member)):
# other code here

User uses the command, gives @loud kayak as an option, goes for a beer, you leave his server, he comes back home and hits enter.

Now there is a member object recieved even though there is no member anymore.
Furthermore when the slash command is a command that saves data (in this case an id and a boolean value) it'd store your id as part of this server even though you are no longer on it.

loud kayak
little cobalt
#

so you full use the Database for all the bot stuff?

loud kayak
#

And no you can’t manually chunk a user into a guild’s members list.

little cobalt
#

even the token at the db?

loud kayak
#

I put the token in .env

#

For each bot

little cobalt
#

I usually use a json for it

loud kayak
#

not a good idea

#

.jsondb

#

f

grizzled loom
#

it is possible*, i tested it.
*not to have text in a channel but to be used as an argument for a slash command

USER A starts the slash command and mentions you. so @loud kayak is written (written, not sent) as argument for the command.
then you leave
only then user A hits enter. you, in this case your member object gets send to the bot(presumably cached?), even though you no longer exist there.

loud kayak
sly karmaBOT
# little cobalt I usually use a json for it

JSON is a convenient and easy-to-read data storage protocol that's widely accepted by most programming languages. However, we caution against its use for storing and retrieving data in an asynchronous environment like a Discord bot. Don’t use json!

  • It's a file-based data storage, which makes it vulnerable to race conditions
  • You'll need to implement your own synchronization primitives to avoid corrupting data
  • If you're not careful, you could accidentally wipe your entire JSON file.

Solution? Use a database. Recommended schema are SQLite, PostgreSQL, and MongoDB.

  • Async libraries exist on pypi for each of these
    sqlite -- aiosqlite (or Danny's wrapper: asqlite)
    postgresql -- asyncpg
    mongodb -- motor
  • Databases organize your data into tables, and are fast at inserting, retrieving, and removing records
  • You can impose uniqueness constraints to ensure against duplication
  • The Python libraries enforce synchronization for you
  • The query language is intuitive, you can get running with simple queries in just a few hours!
little cobalt
#

I dont use json as a db

gilded crow
#

is it possible to have bridge groups and then a second group

#

like this

/vcrole humans add [SLASH]
?vcrole humans add [PREFIX]

#

how would i do it?

#

as BridgeCommandGroup

#

only has @command deco

frail basin
gilded crow
#

can you provide a example

plucky moss
#

Only 2 including this one.

silk spire
plucky moss
#

That was quuick 💀

plucky moss
silk spire
#

No

#

But that can also use the listen decorator if you wa t

plucky moss
#

Ok thanks

#

Its working thanks.

river oriole
#

Does anyone know how I can set the Starter Message for Threads? I use a Webhook which creates the thread but sends the message then as normal message and not as Starter Message. Also for some odd reason is display_name the username

swift gust
#

"Display Name" is what comes up when i message: My name will be Fentanyl provider when my actual username is poosec.gg

little cobalt
#

?tag pomelo

limber wagonBOT
#

Before Pomelo-

member.name          -> username
member.nick          -> guild nick name
member.display_name  -> member.nick OR member.name

After Pomelo-

member.name          -> username
member.global_name   -> global display name (global nick name)
member.nick          -> guild nick name
member.display_name  -> member.nick OR member.global_name OR member.name
swift gust
#

oh no sorry i was answering this guy^

#

"is display_name the username"

river oriole
# little cobalt what is your py-cord version?

Im using the latest Py-Cord Version from PyPi: 2.4.1
But I also tried global_name, but that property doesnt exist on the GuildMember for me. I guess the PyPi Version isnt updated yet

little cobalt
#

you could try the master branch

#

?tag install

limber wagonBOT
#

1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U py-cord

Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.

Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord

river oriole
#

I know. But I cant easily roll back versions then. atm I do py-cord==2.4.1 and update only when I verified that the code works for newer versions. And when I need to reinstall the packages and I dont use a fixed version then it might be that the code breaks

#

I guess i just cope with it

little cobalt
gilded crow
#

it has no docs for bridge sub groups

nova epoch
#

Using py-cord==3.0.0, I cannot get VSCode to recognise the discord import...
Trying to use ```py
import discord
from discord.ext import commands

bot = discord.Bot()``` but apparently none of that exists.

Thanks so much in advance.

shell radish
little cobalt
#

message.content

atomic fern
#

so i have a bot event that resend a attachment sent from member in channel to specific channel but then delete the original message that contain the attachment, but the attachment always 404 after a few minutes, how i can make it permanent or at least not expired in a week?

#

it is said that proxy_url only lasts for a few minutes after original message was deleted

little cobalt
#

do you send the file again?

#

or just the url

atomic fern
#

message.attachments[0]

#

in an embed image

little cobalt
#

usually if you have a message with a image and the message is getting deleted, the image url will also not work anymore

gilded crow
little cobalt
#

mhm

gilded crow
#

Working on this thing for the whole day now

#

Dpy supports multiple sub grouping

#

Can’t someone create a PR

atomic fern
little cobalt
atomic fern
nova epoch
lapis dock
#

Also you are aware that V3 is not really functional for actual projects?

nova epoch
#

I am, just doing a little bit of messing around for when it becomes a full release (yes, I am also aware that it may change substantially before that point, but I am also horiffically bored). In python3 -m pip list I have both py-cord and pycord packages (not too sure where the second one came from, will probably remove if it's not needed) and the discord package as shown in the screenshots attached.

lapis dock
#

pycord is just a random unrelated library. The discord package is also not needed. And v3 should never need to import discord I believe.

nova epoch
#

Okay- managed to get it to finally work. Only took reloading the python interpreter a few times. Now apparently pycord.Bot doesn't exist but I'm assuming that's because it's recognising the pycord lib instead of py-cord so will uninstall both (pycord & discord, keeping py-cord) and will see.

lapis dock
#

👍

nova epoch
#

Still same error even with both unnessicary packages uninstalled: Traceback (most recent call last): File "c:\Users\there\OneDrive\Desktop\utcp-student-hub\utcp-bot\main.py", line 4, in <module> bot = pycord.Bot(pycord.Intents()) ^^^^^^^^^^ AttributeError: module 'pycord' has no attribute 'Bot'

#

^ That's code that I copy-pasted from the v3 docs too...

little cobalt
#

Im not sure if it is a good idea to use py-cord v3

nova epoch
#

That idea crossed my mind too. Just wanted to play around with it but seems like it's gonna be too much hassle. Just gonna head back to 2.4.1 I think.

young skiff
#

How can I implement Linked Roles with my bot?

steep cliff
#

What size can images in embeds be?

little cobalt
#

Im not sure if there is a limit for a embed image

#

as long there it is a gif or image

steep cliff
#

fair enough

#

making a request to an api and can get pretty much any image size, any clue what it renders like/what to request?

little cobalt
steep cliff
#

its a python twitch api lib, making the requests async tho

little cobalt
#

TwitchIO?

#

x3

steep cliff
#

what's the best way to cache results for autocomplete functions? Don't wanna make API/DB calls all the time...

little cobalt
#

store the data in some way

steep cliff
#

@lru_cache?

#

don't think that would work as the input is different while the output might stay the same

#

I'll think about it

lapis dock
steep cliff
#

Thx

lost ocean
#
    @bot.slash_command(guild_ids=[765869842451398667])
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.11/site-packages/discord/bot.py", line 817, in decorator
    result = command(**kwargs)(func)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.11/site-packages/discord/commands/core.py", line 1660, in decorator
    return cls(func, **attrs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.11/site-packages/discord/commands/core.py", line 632, in __init__
    super().__init__(func, **kwargs)
  File "/home/container/.local/lib/python3.11/site-packages/discord/commands/core.py", line 179, in __init__
    from ..ext.commands.cooldowns import BucketType, CooldownMapping, MaxConcurrency
  File "/home/container/.local/lib/python3.11/site-packages/discord/ext/commands/__init__.py", line 18, in <module>
    from .flags import *
  File "/home/container/.local/lib/python3.11/site-packages/discord/ext/commands/flags.py", line 71, in <module>
    @dataclass
     ^^^^^^^^^
  File "/usr/local/lib/python3.11/dataclasses.py", line 1230, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/dataclasses.py", line 1220, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dataclasses.py", line 958, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dataclasses.py", line 815, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'discord.utils._MissingSentinel'> for field name is not allowed: use default_factory```
#

What is this error?

#

running the discord bot on a hosting server for the first time on that host

#

aight nvm, i fixed it

#

just updated pycord lmao

marsh nymph
#

Is there a way to implement individual buttons? Like 1 user has 4 different things and for each thing it spawns 1 button, another user has only 2 things and so on

#

Is there a way to achieve this?

little cobalt
marsh nymph
little cobalt
marsh nymph
#

So how do i add a callback for each individual button? So sometimes there are 5 buttons and sometimes there are 2 and they may have different labels for each user.

little cobalt
#

you could subclass a button and change label at it

#

you could also create 25 buttons x3

#

that would be the limit if im right for button amount

lapis dock
deft kestrel
#

wtf is this shit

#

that happens when i do pip install py-cord

little cobalt
# deft kestrel

if you use Python 3.12, you have to install the master branch

#

?tag install

limber wagonBOT
#

1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U py-cord

Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.

Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord

deft kestrel
little cobalt
deft kestrel
#

oh

#

i thought -m maybe stants for master XD

#

how can i install the master branch

little cobalt
#

that is the master branch

deft kestrel
#

this one?

#

oh okay, thanks 🙂

little cobalt
#

ye

deft kestrel
#

😡

little cobalt
#

That is weird

deft kestrel
#

😭

grizzled loom
#

when a member leaves a server does the bots cache update automatically?

deft kestrel
#

würde python re-install vlt was bringen

little cobalt
#

Dat kannste proberen

deft kestrel
#

ok

#

trye jetzt

#

omg

#

ich weine

little cobalt
#

At the end you could just install Python 3.11 instead

deft kestrel
#

will that make it work

#

i had 3.7 installed before

little cobalt
#

uh

#

Py-cord is 3.8+

deft kestrel
#

ChatGPT says the error happens

#

wait

#

"Install Microsoft C++ Build Tools"

little cobalt
#

oh

#

yea

deft kestrel
#

i installed them

#

still same error

#

💀

little cobalt
#

I just have VSCode and Visual Studio installed for C# and C++ stuff x3

deft kestrel
#

x3

#

😡

little cobalt
#

uh

#

I use a second SSD for games

deft kestrel
#

i have 3 SSDs

#

i have ordered one with 4tb

#

but it doesnt work bc it's M2

#

and my pc/mainboard is from 2018

#

💀

#

brooo

#

why 😭

grizzled loom
deft kestrel
#

works nnow

deft kestrel
#

it doesnt say "Bot"

#

i know the basics ive been using this for years

grizzled loom
deft kestrel
#

oohhhhh

#

i didnt think you meant it in any bad way

#

ur fine dw

#

❤️

dim raptor
#

wait how can i make it so that there is a general /help command and /help <module> cmd without it giving me an error that the command already exists

shell radish
#

You can have a help command with an optional option called module tho

low solar
#

Hello, so basically my command that i made in a cog file doesnt show up (i suppose the cog doesnt load but i dont really know)

async def load():
    await bot.load_extension("cogs.wyciek") ```
thats how i load the cog (it gave me errors so i made it into async def and awaited it, it fixed the issue)

```python
import discord
from discord.ext import commands
from discord import option
import json
import base64
from discord import guild_only
intents = discord.Intents.all()
bot = discord.Bot(intents=intents)

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

    
@discord.slash.command(name="wyciek", description="muehehehe")
@guild_only()
async def wyciek(self, interaction, nick):
#rest of the code

thats the start of the cog

def setup(bot):
    bot.add_cog(wyciek(bot))```
and thats the end
cunning stirrup
#

any idea why my shlash commands say interaction faild or smthing like that but they work fine?

#

tag me when respond thx

low solar
#

if you interaction.respond for example just add interaction.respond.defer() after async def

little cobalt
lapis dock
lapis dock
#

👍

low solar
#

``Traceback (most recent call last):
File "C:\Users\Bulba\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 786, in _load_from_module_spec
setup(self)
File "C:\Users\Bulba\Desktop\bot\cogs\wyciek.py", line 70, in setup
bot.add_cog(wyciek(bot))
File "C:\Users\Bulba\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 646, in add_cog
raise TypeError("cogs must derive from Cog")
TypeError: cogs must derive from Cog

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

Traceback (most recent call last):
File "C:\Users\Bulba\Desktop\bot\main.py", line 157, in <module>
bot.load_extension("cogs.wyciek")
File "C:\Users\Bulba\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 910, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\Bulba\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\cog.py", line 791, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.wyciek' raised an error: TypeError: cogs must derive from Cog
sys:1: RuntimeWarning: coroutine 'ApplicationCommand.call' was never awaited``

lapis dock
#

can you try naming the cog and the command something different

low solar
#

i changed the file name and class to "meow", still the same issue

little cobalt
#

Can you show your pip list?

low solar
#

aiohttp 3.8.6 aiosignal 1.3.1 async-timeout 4.0.3 asyncio 3.4.3 attrs 23.2.0 beautifulsoup4 4.12.3 certifi 2023.11.17 cffi 1.16.0 chardet 3.0.4 charset-normalizer 3.3.2 colorama 0.4.6 deep-translator 1.11.4 discord-protos 0.0.2 env 0.1.0 frozenlist 1.4.1 gitdb 4.0.11 GitPython 3.1.41 googletrans 3.0.0 h11 0.9.0 h2 3.2.0 hpack 3.0.0 hstspreload 2024.1.5 httpcore 0.9.1 httpx 0.13.3 hyperframe 5.2.0 idna 2.10 multidict 6.0.4 pillow 10.2.0 pip 23.3.2 protobuf 4.25.2 psutil 5.9.8 py-cord 2.4.1 pycparser 2.21 PyNaCl 1.5.0 pypresence 4.3.0 pystyle 2.9 python-dotenv 1.0.0 requests 2.31.0 rfc3986 1.5.0 selfcord.py 2.1.0a4402+g573a4cee setuptools 57.4.0 smmap 5.0.1 sniffio 1.3.0 soupsieve 2.5 typing 3.7.4.3 typing_extensions 4.9.0 tzdata 2023.4 tzlocal 5.2 urllib3 2.1.0 yarl 1.9.4

little cobalt
#

Uninstall discord-protos and py-cord

lapis dock
#

can you show a screent shot of your file structure

low solar
#

should i reinstall?

little cobalt
#

Only py-cord

low solar
#

i did

little cobalt
#

I just wonder what selfcord is

low solar
#

so it doesnt interfere

low solar
little cobalt
cunning stirrup
low solar
#

``Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/discord/cog.py", line 786, in _load_from_module_spec
setup(self)
File "/root/bot/cogs/meow.py", line 69, in setup
bot.add_cog(wyciek(bot))
File "/usr/local/lib/python3.10/dist-packages/discord/cog.py", line 646, in add_cog
raise TypeError("cogs must derive from Cog")
TypeError: cogs must derive from Cog

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

Traceback (most recent call last):
File "/root/bot/main.py", line 157, in <module>
bot.load_extension("cogs.meow")
File "/usr/local/lib/python3.10/dist-packages/discord/cog.py", line 910, in load_extension
self._load_from_module_spec(spec, name)
File "/usr/local/lib/python3.10/dist-packages/discord/cog.py", line 791, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.errors.ExtensionFailed: Extension 'cogs.meow' raised an error: TypeError: cogs must derive from Cog
sys:1: RuntimeWarning: coroutine 'Command.call' was never awaited``

it gives me the same error on a vps where i dont have selfcord

little cobalt
little cobalt
low solar
#

same error

#

i changed the class name and setup to "meow" and now it runs without an error but the command doesnt work

lapis dock
#

can you show a screenshot of your file structure

lapis dock
low solar
#

by file structure you mean screenshot of the code? cuz i dont really understand

lapis dock
#

on discord it is not but might just be a copy paste issue

#

like this

low solar
#

the json file isnt in cogs visualstudio is trippin

lapis dock
#

there is no reason for these lines of code

intents = discord.Intents.all()
bot = discord.Bot(intents=intents)

in your cog file. That should be setup in main. I think that is the problem, you are overwting bot or something.

low solar
#

lemme see

#

i removed the 2 lines command still doesnt show up

#
@discord.slash_command(name="wyciek", description="muehehehe")
@guild_only()
async def wyciek(self, interaction, nick):

    await interaction.respond('Check dms!', ephemeral=True)
    user = interaction.user```
#

thats how thte start of the command looks

#

i dont think there is nothing wrong with it ?

lapis dock
#

Can you go through this checklist

#

.tag slashnoshow

sly karmaBOT
#

Application Commands Not Showing Up?

  • Uninstall libraries that conflict with the discord namespace (e.g. discord.py).
  • Invite your bot with the application.commands scope.
  • Load cogs before bot.run() (e.g. not in on_ready).
  • Do not override on_connect.
  • Update to the newest version of py-cord (see ?tag install).
  • Turn off User Settings > Accessibility > Chat Input > Use legacy chat input.
  • Share your code and errors.
lapis dock
#

I think that is all true for you

low solar
#

i checked it couple of times before everything is how it should

#

if pycord 2.4.1 is the newest version ofc

lapis dock
#

It is the latest stable but it should still work for your needs.

low solar
#

it says that self is not accessed

#

maybe its the issue?

lapis dock
#

and the command is indented in the cog class?

class wyciek(commands.Cog):
    def __init__(self, bot):
        self.bot = bot   
    @discord.slash.command(name="wyciek", description="muehehehe")
    @guild_only()
    async def wyciek(self, interaction, nick):
    #rest of the code
#

yeah, i think your indentation is off, with that waarning

low solar
#
import discord
from discord.ext import commands
from discord import option
import json
import base64
from discord import guild_only


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

@discord.slash_command(name="wyciek", description="muehehehe")
@guild_only()
async def wyciek(self, interaction, nick):
#rest ```
lapis dock
#

you just need to indent your entire command+decorators one level

low solar
#
discord.errors.ExtensionFailed: Extension 'cogs.meow' raised an error: AttributeError: module 'discord' has no attribute 'slash'```
lapis dock
#

somewhere you have discord.slash when it should be discord.slash_command

low solar
#

in the cog i onl have 1 command so

#

it works

#

thanks 🙏

lapis dock
#

ye that needs to be discord.slash_command not discord.slash.command

#

🎉

low solar
#

i spent last 4h trying to fix it lmao

sour flint
#

Hello is it possible to make a slash command only visible to the owner of the bot or atleast a select few

lapis dock
#

Overall, you would have to create a guild command for your support server or something. And then use the integration menu to limit it to your needs.

You should still include permission checks in the callback in case someone with admin should not be able to use the command.

#

Or something

sour flint
#

oh thx ❤️

sly ember
#

i have a tag command where it has to create a Tag ID when i create a tag, but somehow its always none, and when i want to delete the tag i get this error, any help?

little cobalt
#

what is tag id?

celest atlas
sly ember
# little cobalt what is tag id?

like i have a tag command same as @rugged lodge bot, and i wanted to have a "tag id" whenever a tag is created, so when i want to delete a tag, i can just enter the id of the tag so i can delete the right one

celest atlas
# sly ember like i have a tag command same as <@882631512829329448> bot, and i wanted to hav...

As taken from the help rules channel

Step 4 - After The Solution Is Found
If you are in "General Help" say that you fixed your issue.

If you are in your own thread use the </close:1001466583253786657> command to close the thread. This helps support staff find active threads faster.
Do not delete messages in your thread so that if someone has the same issue as you they can see how it was solved.
If you have another question it would be best if you close and start a new thread.

Other Notes

  • Remember that support staff are not active at every moment so it might take a bit for your question to get answered.
  • Other users that are not a support staff also can give you valuable information
  • When posting code you should use the format (If posting an error do not add py)

```py
Your code
```

  • Whenever possible do not post an image or screenshot of your code. They are hard to read and support staff often copy and paste bits of the posted code to give support more quickly.
sly ember
#

okay wait

#

this should be the function where the id should be created and the command where the id should be shown, i hope this is enough, if not tell me

celest atlas
sly ember
#

sorry here:

                    
    @tag.command(name="delete", description="Lösche eines deiner Tags")
    @discord.option(name="tag_id",  required=True, autocomplete=autocomplete_context)
    @commands.has_permissions(ban_members=True)
    async def delete(self, ctx: discord.ApplicationContext, tag_id: str) -> None:
        if tag_id.startswith("Nothing"):
            await ctx.respond(embed=discord.Embed(description="Es wurden bisher **KEINE** Tags erstellt.", color=discord.Color.red()), ephemeral=True)
        else:
            async with self.bot.pool.acquire()as conn:
                async with conn.cursor(aiomysql.DictCursor)as cursor:
                    await cursor.execute("SELECT title, input_text FROM tags WHERE tagsID=%s;", (int(tag_id),))
                    temp = await cursor.fetchall()
                    await cursor.execute("DELETE FROM tags WHERE tagsID=%s;", (int(tag_id),))
                    await conn.commit()
                    removed = discord.Embed(title="Removed", description=f"Der Tag mit der ID: **{tag_id}** wurde gelöscht", color=0x019296)\
                        .add_field(name="Tag Titel", value=temp[0]["title"], inline=False)\
                            .add_field(name="Tag Inhalt", value=temp[0]["input_text"], inline=False)
                    await ctx.respond(embed=removed)

#

this is where the error is from in the image

valid cipher
#

Hi, is there a feature implemented to use the discord monetization feature?
if so i cant find it.
i would like to check the Guild Subscription SKU. does a server has a subscription? yes no. thats basicly all i want.
pointing me to a documentation would be enough for me, thanks for your help

rugged lodgeBOT
scarlet knot
#

Btw Am I Getting This Error.. Just Started Now,, Until Now It Was Working Fine Now This Error

serene goblet
#

Can you have both a placeholder and value on discord.ui.inputtext?, I can't see a notice in the docs which suggests that you can't but maybe I'm just not seeing it.

lapis dock
scarlet knot
lapis dock
lapis dock
#

I'm not able to help you debug at the moment sorry.

obsidian stratus
#

What's the maximum length a button label can take

grim estuary
#

Hello! Can you please tell me under what conditions the Unknown interaction error occurs in interaction.response.defer()?

steep cliff
#

15 min without a response iirc

grizzled loom
#

Whats the command to re-open a topic (I closed earlier)

little cobalt
red mist
grizzled loom
#

Done Thanks!

river oriole
#

How would I use BridgeCommandGroup? I found this but im either dont get it or it doesnt work anymore like this. I have this:

tags = bridge.BridgeCommandGroup("")
    @tags.bridge_group()
    async def _(self, ctx: bridge.BridgeContext) -> None:
        pass

But that says that the String needs to be a coroutine. So do I need to use the function there?

icy tinsel
#

How can i get someones avatar url when they use a slash command including a embed?

river oriole
#

Even with SlashCommands it should be ctx.author

wide marten
#

Can someone help

edgy nest
#

idk, can we

grizzled loom
#

Naaah, we are here to post and look at silly pictures in #💩posting
.. .. .. okay okay.. sometimes we also help, if there is a real question, and we happen to know the answer.
Else we role dice and ask for additional information depending on the number, then go offline 😈 🙃

valid cipher
slim scroll
#

How do I create a channel using the PermissionOverwrite to make a channel visible for a certain role and specific member by pressing a button? I cant figure out how permissions work

river oriole
# river oriole How would I use `BridgeCommandGroup`? I found [this](<https://discord.com/channe...

Regarding to this: I have this now, which should be correct

from discord.ext import bridge, commands

from cogs.utils.helper import *
from cogs.utils.permissionCheck import isTeamMember

class Tags(commands.Cog):
    def __init__(self, client: commands.Bot):
        self.client = client
        print("Tags loaded")

    @bridge.bridge_group()
    async def tags(self, ctx: bridge.BridgeContext):
        tags = self.client.DB["Tags"].find()
        ctx.reply(f"> Tags: {', '.join([tag['name'] for tag in tags])}", mention_author=False)

    @tags.command()
    @isTeamMember()
    async def add(self, ctx: bridge.BridgeContext, name: str, *, content: str):
        if self.client.DB["Tags"].find_one({"name": name}):
            ctx.reply(f"> Tag `{name}` existiert bereits", mention_author=False)
            return
        self.client.DB["Tags"].insert_one({"name": name, "content": content})
        ctx.reply(f"> Tag `{name}` wurde erfolgreich erstellt", mention_author=False)

def setup(client: commands.Bot):
    client.add_cog(Tags(client))

But I get this Error upon start:

Traceback (most recent call last):
  File "/Users/dominik/Development/MuchachoBot/venv/lib/python3.9/site-packages/discord/cog.py", line 786, in _load_from_module_spec
    setup(self)
  File "/Users/dominik/Development/MuchachoBot/cogs/Tags.py", line 21, in setup
    client.add_cog(Tags(client))
  File "/Users/dominik/Development/MuchachoBot/venv/lib/python3.9/site-packages/discord/cog.py", line 656, in add_cog
    cog = cog._inject(self)
  File "/Users/dominik/Development/MuchachoBot/venv/lib/python3.9/site-packages/discord/cog.py", line 545, in _inject
    bot.bridge_commands.append(command)
AttributeError: 'Bot' object has no attribute 'bridge_commands'
little cobalt
#

you have to use bridge.Bot

river oriole
#

Ohhh

little cobalt
river oriole
#

Ye figured that. Thank you so much

river oriole
#

Another quick question. ctx.respond is either reply or respond according to the Command Type. When I use the old Commands and add mention_author=False it replys to the message without a Mention. However if I do a SlashCommand it fails, since respond doesnt accept mention_author. Is there another Attribute which works for both, reply and respond or do I need to make a Helper Function for it

#

The first two responses are without mention_author, the last 2 are with it

little cobalt
river oriole
#

Ye I know. So I would need to make my own small helper for it

#

I found another workaround which seems more practical for me. I use allowed_mentions which are available for both, text messages and application messages:

await ctx.respond(f"> Tag `{name}` wurde erfolgreich erstellt", allowed_mentions=discord.AllowedMentions(replied_user=False))
fresh totem
#

Hey how do we setup timeout for View in this case:

  class chooseUser(discord.ui.View):
    def __init__(self, editEmbed):
      super().__
      self.embed = editEmbed

    async def on_timeout(self):
      self.disable_all_items()
      await self.message.edit(content="You took too long! Buttons disabled.", view=self)
        await ctx.respond(embed=rpsEmbed, view=chooseUser(rpsEmbed, timeout=30))
lapis dock
#

You can pass timeout= to the super().__init__() in the init of the view

fresh totem
fresh totem
# shell radish no
        class chooseUser(discord.ui.View):
            def __init__(self, editEmbed, timeout=30):
                super().__init__(timeout=timeout)
                self.embed = editEmbed

            async def on_timeout(self):
                self.disable_all_items()
                await self.message.edit(content="You took too long! Buttons disabled.", view=self)```

wht about this
#

Thank you!

river oriole
#

How can I use on_command_error with bridge.Bot? My old ErrorHandler which worked fine with commands.Bot doesnt work anymore and I couldnt find a Listener for bridge.Bot

river oriole
#

Cant find it. Only discord and ext.commands

little cobalt
#

on_bridge_command_error

river oriole
#

Thank you. Its not in the Docs tho (Only in the Changelog)

little cobalt
#

Ye

river oriole
#

When I looked at the changelog, I realised that its not released yet, so thats prob why. Thank you

young cove
#

I have a simple bot that I want to host along with an sqlite db so I set up a digital ocean vps today and got it working. However, being really uncomfortable with the command line and linux in general (I use pycharm and sqlitebrowser), I'm considering pivoting to a windows virtual machine through azure. Mostly because it seems like it would be easier to use, particularly as I update the bot and manage the db, but I might be wrong. If anyone has a few minutes, I'd love some thoughts on the pros and cons. Is the ubuntu vps worth the steep learning curve? If so, why?

grizzled loom
# young cove I have a simple bot that I want to host along with an sqlite db so I set up a di...

there isn't that much to learn for this purpose. you set up a useraccount with sudo privileges (really easy, you'll find tons of tutorials and good instructions about this step).

then you need to know "cd" -> change directory, to navigate "ls" - list storage to see whats in the folder you're currently in. apt update and apt upgrade + apt dist-upgrade for seeing what new packages are availible + installing them.

ssh - to remote in to your virtual machine. basically giving you a remote terminal. doesnt matter if you use ssh from a linux or windows machine. it's standard for server administration of any kind.

once inside navigate to the folder your bot lives in and you can start it with:python3 filename.py or to have it also runing once your terminal is closed nohub python3 filename.py &
In the second case your bot should have some shut-down command (bot.close()) in your code you can reach via some command OR you can kill it through htop

htop - shows you whats running and allows you to kill processes. closest thing to this in windows would be the task manager as a terminal tool. a little ugglier but with same functionallity: top. simply type one of the two in your terminal, they are self explanatory and should be pre installed.

scp - for transfering files from your machine to your server or vise versa

other than that the install instructions for pycord. there is linux instructions. pip doesn't change at all. sqlite works the exact same as in windows, so if your bot is set up correctly it should do its thing.

#

That's about all there is to it.

grizzled loom
little cobalt
#

and I use Raspberry OS

#

xd

steep cliff
#

Have a link that doesn’t changed while the image it links to does. Want to edit the embed to update the image, but it doesn’t, probably cause discord caches media proxy assets. I tried adding random query parameters (eg. the current time) to make the links different, but the image still doesn’t update. Any ideas?
||sorry for crossposting, figured I broke it down enough to fit it in here instead of the thread.||

lapis dock
young cove
steep cliff
grizzled loom
# young cove Thank you for the comprehensive reply! I guess the question now is are there act...

sounds like you're asking other to convince you one way or the other.

Alright; Here is a practical reason.
When you get deeper into IT you'll need to learn at least some basics about server administration and therefore Linux at some point, regardless of your specialty. Hosting your Bot is a comparatively simple thing to do with a low threshold | point of entry.

If that's not reason enough or you're scared to run something via terminal only or for some reason just fancy windows; go for your azure approache.

dawn prism
#

Hi everyone, quick question here. Do you know if it's possible with py-cord library to get/set permissions to a slash command (not talking about has_permissions decorator) so I can easily show them in a custom help ?

Thanks for the answers ❤️

#

(Since has_permissions is just checking on the call and not storing them anywhere it's not what I want)

grizzled loom
dawn prism
#

I can implement my own way, but wanted first to know if it's already implemented since i found nothing

grizzled loom
# dawn prism I want to show in custom help which permissions are required to use a slash comm...

I see. have some similar logic in place. I dont display it except for a few lines within the bots help text.
With my bot its kick permissions that are relevant and because users who can't kick manually shall not be able to bypass those permissions dangerous commands include a line that's roughly(typing this from memory):

if not ctx.user.guild_permissions.kick_members:
    return await ctx.respond("you need at least kick permissions to run this command. Please contact an admin")

havent found a better way to do it. there were decoraters, prohibiting usage without certain permissions, but they didn't respond.
tbh: I did not research it further after this point, cause the solution worked for me, so I moved on to the next part.

dawn prism
#

Okay thanks.
Yep I think I will use a custom class to store this

grizzled loom
dawn prism
#

👌

steep cliff
dawn prism
#

@grizzled loom Just discovered that @discord.default_permissions() update a default_member_permissions attribute for SlashCommand storing the required permissions for a user to perform a slash command (but the user can't see it at all). 🤩

Problem 🥲 , Permissions class does not give a proper str result since it just shows the 53-bit integer value of the permissions

cunning stirrup
mild storm
#

is there a way to get a user ID from @mild storm for example

cunning stirrup
#
 await interaction.channel.edit(name=f"ticket-closed-{ticket_number}")
        await interaction.response.send_message(embed=embed, view=TicketOptions(bot=self.bot)) 
        button.disabled = True
        await interaction.message.edit(view=self)
``` i get interaction failed but it works idk why can i fix it ?
#

mention me when someone helps thx

grizzled loom
#

you'd even use a dictionary as a dictionary.. sort of 😄

dawn prism
#

Since I just need this once, maybe I will just create a function that reverse it

vapid hazel
#

I am using ordinay cpython interpreter version 3.12.1.
I am using the command pip install -U py-cord to install pycord to my system interpreter.
It happens to fail at the aiohttp build step. I already have aiohttp installed.

error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2

I have tried updating my visual studio tools. Still doesn't work.

vapid hazel
#

so, the --pre option?

#

does not work with the -pre option

#

same error

shell radish
limber wagonBOT
#

1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U py-cord

Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.

Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord

shell radish
#

the last line

cunning stirrup
#

is there a way to load all slash commands at once ?

shell radish
cunning stirrup
#

half of my slash commands doesent load

#

and i have to somehow load them

#

or if i update theme they dont update

#

i mean change the code

#

im new with lsash commands idk how to use them

#

sry

shell radish
#

you can comment out everything, run the bot, then uncomment everything

#

you may also need to refresh your discord to see new commands

cunning stirrup
#

like start without the code

#

then stop

#

then load the code ?

shell radish
#

then stop it, then run it with commands

cunning stirrup
#

the problem is all my normal commands with prefix are not working with the prefix so i have to make them all slash

#

becuse i need some slash commands

#

and idk if i can use both

#

prefix and slash

shell radish
#

you can have both text-based commands and slash commands

cunning stirrup
#

how why is my prefix not working

#

do i have to enable something?

grizzled loom
shy igloo
#
>>> import discord
>>> discord
<module 'discord' from 'C:\\Users\\User\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\discord\\__init__.py'>
>>> discord.ext
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'discord' has no attribute 'ext'

pls help what am I doing wrong?

cunning stirrup
#

but it has 17k members

shy igloo
cunning stirrup
#

pip install discord

grizzled loom
# cunning stirrup no just 2

doesnt matter when it comes to intents. server count is the only thing that could change sth. (when it hits 100). member count is irrelevant. must be sth. else.

shy igloo
#

yeah but that's another library

grizzled loom
#

I thought you had 2 servers?

shy igloo
#

i was shocked when I learned that i've been using py-cord and not discord.py for several months

cunning stirrup
grizzled loom
#

However for message content you also have to turn on this little switch in the developer portal. did you do that?

cunning stirrup
#

yeah but i dont think thats the problem that i cant use both

grizzled loom
#

maybe make it a topic and post some code?

cunning stirrup
#

oh im so dumb i forgot to add Self i had ctx , url

#

now i have a question is it possible to make like that menu when u use a command and it pops up and you can type stuff and use them

#

like this

deft kestrel
#

Is there a way to set my bot's nickname? I don't have a ctx object in this part of the code

I've tried:

await self.user.edit(nickname="Hey Billy")
await self.user.edit(nick="Hey Billy")
await self.user.display_name = "Hey Billy"
shell radish
#

what is self

deft kestrel
#

It's my discord.Bot
Just discovered that this might work (IntelliSense showed it):

await self.get_guild(ID).get_member(ID).edit(nick="Hey Billy")
stray pasture
#

Am I the only one that cant access the integration panel since the phone update ?

#

In server settings

lofty parcel
deft kestrel
#

That worked, thanks guys

dawn prism
#

@grizzled loom i did this and it works

shy igloo
#

What can I do if await attachment.read() just never returns anything? My command function just stops on this step

#

Maybe I can troubleshoot this somehow idk

#

It gets infinitely stuck

fresh totem
#
    @grindlist.command()
    async def create(self, ctx: discord.ApplicationContext, item1: Option(str, "Name of Item 1", choices=[]), amount1: Option(int, "Goal for Item 1", choices=[]),
                     item2: Option(str, "Name of Item 2", choices=[]), amount2: Option(int, "Goal for Item 2", choices=[]),
                     item3: Option(str, "Name of Item 3", choices=[]), amount3: Option(int, "Goal for Item 3", choices=[])):```

How can I make it so it's not mandatory for user to enter into the option and user can leave it blank
little cobalt
#

required=False

#

@fresh totem

fresh totem
# little cobalt required=False
    @grindlist.command()
    async def create(self, ctx: discord.ApplicationContext, item1: Option(str, "Name of Item 1", required=False), amount1: Option(int, "Goal for Item 1", required=False),
                     item2: Option(str, "Name of Item 2", required=False), amount2: Option(int, "Goal for Item 2", required=False),
                     item3: Option(str, "Name of Item 3", required=False), amount3: Option(int, "Goal for Item 3", required=False)):```

still stays the same
little cobalt
#

Can you refresh discord and restart the bot?

fresh totem
lunar isle
#

So, this exists ->
async with message.channel.typing():

It sometimes bugs out and keeps saying "typing" even when the function is over and done with. Is there any way to manually exit the typing

fresh totem
#

GM!

await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"Netflix"))```

How can we set a status without `Watching` `Playing` `Streaming` etc,  plain text
sly karmaBOT
#

Target not found, try again and make sure to check your spelling.

lofty parcel
maiden bloom
#

Does an option choice provide a dropdown?

upbeat lintel
maiden bloom
upbeat lintel
#

I think not, since until you press enter, the option is only selected in your client. But there might be a built-in way to do this, I just haven't come across it yet.

lofty parcel
dim raptor
#

How can i edit a msg that the bot send previous if im using bridge cmds

msg=await ctx.reply("test")
await msg.edit(embed=embed)
#

would that work

sly ember
#

how can i disable a button after one click it doesnt work here

lofty parcel
frozen trout
#

Anyone else having an issue with slash commands not updating?

little cobalt
#

It can take some time sometimes

#

Also refresh your client with ctrl + r

little cobalt
#

I dont really get the error...

little cobalt
#

It was the py-cord version

#

...

dark oak
#

I have a quick question:
interaction.guild.get.role(role_id) will this get the role stored in role_id?

lofty parcel
#

I think that's when you provide extra stuff for a specific option type

lofty parcel
shell radish
#

and if it is cached

little cobalt
round heart
#

quick question that I don't have the ability to test out at the moment. Can custom emoji be used in buttons? For instance, on submit, updating the View to disable buttons and add a spinner emoji

#

Hm, docs suggest yes if I pass in a PartialEmoji or Emoji class. I've never loaded emoji this way, always just using id tags 😅

(Edit: ah, PartialEmoji.from_str("<[a:]name:id>")? )

grave abyss
#

Is there something that blocks the options if nothing has been put in the previous options? In something like this:

@bot.command(name="start")
async def start(
        ctx: discord.ApplicationContext,
        first: discord.Member = None,
        second: discord.Member = None,
        third: discord.Member = None
):
    await ctx.respond(f"User 1: {first}\nUser 2: {second}\nUser 3: {third}")
errant trout
#

using autocomplete you can access values used in other options, but that's about it

errant trout
#

(idk why guild.get_emoji doesn't exist, but there's always the guild.emojis list)

deft kestrel
#

Hey! I'm trying to build many (23+) slash commands with pycord to send an embed but I'm getting

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'SlashCommand' object has no attribute 'Embed'

But if I remove and leave just 1 slash command it's not giving the error anymore, with the same code. Any help?

lofty parcel
deft kestrel
#

Not in home, will provide asap

#

Nvm

#

Here it is

#

Ignore the prints and commented out functions, I was trying to debug the error

#

The problem is, when I add like 23 of those it suddenly gives an error

#

Oh shit I know the error

#

I did a slash command with discord of name

#

Very sorry for my dumbness

dark oak
#

How can I add a reaction to a message sent with a slash command? like message = await ctx.respond("lol")
Because I get this error:

raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'add_reaction'
#

ping me when an answer is here 😄

lofty parcel
#

you have to get the message object with ctx.interaction.original_response()

dark oak
lofty parcel
#

.tias

sly karmaBOT
dark oak
#

alr i will .tias

dark oak
# lofty parcel .tias

Didn't work...

Application Command raised an exception: AttributeError: 'coroutine' object has no attribute 'add_reaction'
/usr/lib/python3.10/asyncio/events.py:80: RuntimeWarning: coroutine 'Interaction.original_response' was never awaited
  self._context.run(self._callback, *self._args)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
lofty parcel
#

did you bother to read the error

dark oak
#

yes.

#

But the message was already sent

lofty parcel
#

thats not what the error says

#

original_response is a coroutine and you didnt await it

dark oak
#

It works now, thanks dark

native laurel
#

Hi, I am transfering my code from discord.py to py-cord.

The issue im running into is creating tags for a forum post, does anyone know a workaround for this?

create_tag() worked in discord.py, but it does not seem like there is a way to create a ForumTag in py-cord, even though "applied_tags" parameter requires a list of "discord.ForumTags"

Thanks in advance 🙂

lofty parcel
native laurel
lofty parcel
#

You create a ForumTag instance and pass it with the channel available tags + the new tag to the method.

native laurel
lofty parcel
flat spindle
#

hi, just starting my first project, have a quick one. i'm understanding that cogs are a great way for me to separate my code and organize functionality. do cog commands all automatically use the bot prefix? do i have to configure any prefixing for the cogs?

lofty parcel
#

They're just an extension, not a different client.

obsidian glacier
#

How can I create two responses to one button? Is there any solution how I can do this?

@discord.ui.button(label="Termin 1 übernehmen", custom_id="claim1", style=discord.ButtonStyle.green)  
    async def button_callback1(self, button, interaction):  
            self.disable_all_items()
            await interaction.response.edit_message(view=self)
            await interaction.response.send_message("Ersten Termin übernommen!", ephemeral=True)

(it's german)

lofty parcel
#

followup.send

obsidian glacier
# lofty parcel followup.send

await interaction.response.followup.send_message

doesn't work for this, also interaction.followup.send_message don't. Could you please tell me how I implement it right? thanks 🙂

lofty parcel
#

interaction.followup.send

#

Not interaction.response.followup

#

Read the docs

obsidian glacier
lofty parcel
pale scroll
#

how to do link buttons

lofty parcel
#

Don't cross post.

flat spindle
#

first shot at using cogs isn't working, for some reason. works on my machine, but running it on my host the commands in the cog aren't getting recognized

shell radish
#

how are you loading your cogs

flat spindle
#

excellent question! definitely the wrong way. i just dropped bot.load_extension('cogs.greetings') above my bot.run

shell radish
#

you have a folder called cogs and a file named greetings.py?

flat spindle
#

indeed

#

err - mine's "utils" and not "greetings", miscopy from the pycord guide i'm referencing

#
    bot.add_cog(Utils(bot)) ```
#

this exists in my utils.py, also from the reference

shell radish
#

do you get an error or what

flat spindle
shell radish
#

just to be sure that the code is all up-to-date between local and prod?

flat spindle
#

yeah

shell radish
#

if not that then idk

flat spindle
#

just the one branch, just made it tonight

#
  bot.load_extension('cogs.utils')```
#

is this something?

shell radish
#

do you have a requirements.txt or something

flat spindle
#

i do yes

#

how did you get "conflicting libraries" from that?

shell radish
#

uhh months of helping people

#

but that shouldn't need to be awaited

flat spindle
#

LMFAO fair enough

shell radish
flat spindle
#

i used pipreqs to generate it

#

guessing that the discord version is wrong, looks bad?

shell radish
#

change discord.py==2.3.2 to py-cord==2.4.1

flat spindle
#

that did it! thank you SO MUCH!

shell radish
#

you're welcome

dim raptor
#

how can i use the @guild_only() for bridge groups?

#

i have it like this but it doesnt work

loud kayak
#

When does bot.owner_ids get populated to where I can fetch the first item?

shell radish
#

It populates them via the discord dev portal with the application info thing

loud kayak
#

Thanks

round heart
#

Is there a way to copy button attributes to a new variable so that I can replace it later?

old_button = button

button = discord.ui.Button(...)

if some_condition:
  button = old_button

But that's by reference, right? And button doesn't have a copy().
Obviously I can do them individually, but would like something a bit easier if possible.

#

(actually I just realized that code wouldn't modify the View, maybe I just have to update each attribute separately)

shell radish
#

idk haven't seriously touched python recently

valid panther
#

Regarding the buttons, I have a button that the type of finish is usually X, amount that the user indicates. It can go from 1min to 3d. The problem is that from time to time I get the error "401 Unauthorized (error code: 50027): Invalid Webhook Token". I think it's because the token in the message has expired.

#

Is there a time limit?

lofty parcel
flat spindle
#

how would i dynamically schedule a loop? is there a way to pass the time/count/etc as a parameter in .start()?

steep cliff
#

Does on_error ever include any kwargs?

flat spindle
#

oh! does a task loop have to be in a cog? or can i work with them in any python file i create?

#

essentially, i'm wanting to be able to schedule loops, and have them persist if the goes down then comes back. i have a database i can use to keep track of state, but I'm not sure how to schedule an execution with a given datetime. if i read in all of my loops running from the db and have times i want them to fire, i'm not sure how to iterate over that and actually create/schedule the loops with those given datetimes.

#

i see a change_interval method, possibly i could use that somehow

#

oh, can i have multiple loops of the same task running in parallel?

neon idol
#

Hello,
I can't install pycord on windows with python 3.12 because aiohttp v3.9.0b0 is not supported (pycord need aiohttp<3.9.0, which can't compile on python 3.12)
Is there a way the cheat the prerequisites locally, or do I need to install python 3.11 ?

edgy nest
#

3.12 is supported on github master branch

neon idol
#

I'll search how to install from git then, thank you

lapis dock
#

.tag intents

sly karmaBOT
#

Pycord Docs - Intents
Discord API Docs - Gateway Intents

import discord
from discord.ext import commands

# Get specific intents for fine control
intents = discord.Intents()
intents.emojis = True
intents.guilds = True
intents.messages = True  # Required for prefix commands!
...
# Get all non-priveliged intents; this excludes presences, members and message_content 
intents = discord.Intents.default()

# Set priveliged intents: these must be enabled on dev portal
intents.members = True
intents.presences = True
intents.message_content = True  # Required for prefix commands >= 2.0.0b5

# Get all intents; all intents must be enabled on dev portal.
intents = discord.Intents.all()

# Apply intents when creating your bot
bot = commands.bot(prefix="?", intents=intents)
lapis dock
#

@lyric spire please use help channels and read the above to answer your question

lyric spire
lapis dock
lyric spire
#

it was saved as that long before i implemetned any of the code

#

when i was setting up the base of the bot on the dev portal

lapis dock
#

And it is the same bot? A good way to make sure of that is to Regen the token and put the new one in the code

lyric spire
#

i think so anyway

#

at least, it goes online whenever i run it

lapis dock
#

Ok. Did you set up the server it is running on?

lyric spire
#

yea

#

well

#

im just running it on my

#

pc

#

im just using it for myself

lapis dock
#

Can you show the pip list

lyric spire
lapis dock
#

Can you show the code that has Intents, you can Ctrl+f main.py or bot.py or similar

lyric spire
lapis dock
#

:/ it looks like you are doing everything right.

#

Is there somewhere in the code that has intents=intents. Can you show that line

lyric spire
shell radish
shell radish
#

not

intents.messages = True
lapis dock
#

Add both.

shell radish
#

messages is included in default

lapis dock
#

Ah ok.

lyric spire
#

thank god

#

that was it

lyric spire
lapis dock
#

My recommendation, don't commission from them again if they won't even give you a working bot.

lyric spire
#

also whilst we're still here, i just tried the help command and it had a panic attack 😭

#

help lps

#

pls

deft kestrel
#

i tested with a diff library

#

and it worked for me

#

and the error didn’t say i mistyped something

#

and i also state on my site “i will not provide tech support figure it out yourself”

#

although tbf it wasn’t up when he commed me

#

😭

deft kestrel
#

ur my friend tho so u got insane discount

#

because these prices are high

#

lmaooo

lapis dock
deft kestrel
#

(jk ily robbo)

#

(kinda

#

(not really)

#

(jk again)

deft kestrel
#

did i not

#

remove that

#

from the fucking

#

code

#

it was broke

#

remove that

#

use the default help command

lyric spire
lyric spire
deft kestrel
#

from the code

#

i tried pasting in an old one i made a while back

#

it didn’t work

#

it has a default help command

#

dw

lyric spire
loud kayak
sly karmaBOT
#

Target not found, try again and make sure to check your spelling.

loud kayak
#

Not a valid method

#

It’s

#

.rtfm bot.get_message

lyric spire
#

(don’t ask why i’m here i was pointed here to ask for help by my friend who commissioned it for me)

deft kestrel
#

just download pycord atp

#

pip uninstall discord discord.py

#

pip install py-cord

balmy dome
#

Why when I want to edit a message using await Paginator.edit(), nothing happens?

@discord.ui.button(label="test")
async def button_callback(self, button, interaction: discord.Interaction):
    
    pages = [pg1, pg2, pg3, pg4.....]
    pagin = Paginator(pages=pages)
    
    await pagin.edit(interaction.message)
steep cliff
balmy dome
balmy dome
lapis dock
balmy dome
#

When editing a message, how do I delete its files?
This code doesn't work - await interaction.response.edit_message(embed=embed, view=view, file=None)

valid panther
shell radish
balmy dome
valid panther
#

@errant trout , I hope I'm not bothering you too much. I am making a command that users can interact with the buttons, that buttons have sometimes 3h-24h waiting time. In that case is it better to make buttons do Persistent Views and when the time expires deactivate it?

The problem I am encountering right now is that if I set a timeout=time and it is longer than x hours, sometimes it fails to find the token.

lapis dock
#

I would say that persistent views are the way to go. Especially as you may need to restart your bot and losing 3-24 hours of "progress" might not be good for the user

little cobalt
errant trout
valid panther
valid panther
coral lake
#

Had a SUPER weird issue last night where an admin sent a slash command that sends a message in a public text chat with some basic buttons.

The bot proceeded to send the message three times and the buttons did not work at all. This seemed to be followed by action repetition in all other functions that the bot was employing.

Does anyone have any similar experience? I've double checked for circular functionality, to no avail, and I've triple checked that my bot is not multi-hosted. Not sure where to go from here. Also no on_message functions or anything of that sorts. The command functions completely as intended if I send it right now... >.<

lapis dock
#

Can you show pip list

#

If it works now it might have just been a discord blip.

deft kestrel
#

I was following the example but i got this error
"
AttributeError: module 'wavelink' has no attribute 'NodePool'
"

grim estuary
#

Hello! I can't figure out what the problem is:

@discord.slash_command(...)
async def command_name(
    self,
    context: discord.ApplicationContext,
    member: discord.Option(discord.Member, name="name", description="description"),
    ...
    ):
    ...

TypeError: Parameter member does not match input type of context.

What's wrong?

hybrid fossil
#

Try this

print(len(guild.members))
hybrid fossil
grim estuary
pale scroll
#

how to activity in bot?

hybrid fossil
#
await bot.change_presence(activity=discord.Game(name="GAME"))
hybrid fossil
#

Try this

#

Or this ctx: commands.Context,

grim estuary
grim estuary
pale scroll
#
from config import TOKEN
from discord import option

admin_id=1028017609809080401

bot=discord.Bot(activity=discord.Game(name="GAME"))


class Звернення(discord.ui.Modal):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

        self.add_item(discord.ui.InputText(label="Short Input"))
        self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))

    async def callback(self, interaction: discord.Interaction):
        embed = discord.Embed(title="Modal Results")
        embed.add_field(name="Short Input", value=self.children[0].value)
        embed.add_field(name="Long Input", value=self.children[1].value)
        await interaction.response.admin_id.send_message(embeds=[embed])

@bot.event
async def on_ready():
    print(f'-----BOT ONLINE-----')
    print(f'-BOT TOKEN: {TOKEN}-')
    print(f'-BOT NAME:{bot.user.name}')
    print(f'-BOT ID:{bot.user.id}')
    print(f'-SERVICE MADE BY ONIX')

@bot.slash_command(name="реквізити",description="Надіслати реквізити")
async def реквізити(ctx):
    embed=discord.Embed(
        title="Реквізити",
        description="Номер картки: ||`XXXX XXXX XXXX XXXX`||\nВласник картки: ||`XXX XXX XXX`||"
    )
    await ctx.respond(embed=embed, ephemeral=True)

@bot.slash_command()
async def modal_slash(ctx: discord.ApplicationContext):
    modal = Звернення(title="Звернення до Технічної адміністрації")
    await ctx.send_modal(modal)

bot.run(TOKEN)```
Is it will work?
hybrid fossil
# grim estuary `ClientException: Too many arguments passed to the options kwarg.`
bot = discord.Bot()

@bot.command()
# this explicitly tells pycord what types the options are instead of it figuring it out by itself
async def join(
  ctx,
  first: discord.Option(discord.SlashCommandOptionType.string),
  second: discord.Option(discord.SlashCommandOptionType.string)
):
  joined = first + second
  await ctx.respond(f"When you join \"{first}\" and \"{second}\", you get: \"{joined}\".")
hybrid fossil
#

Try by yourself bro

#

For me, probably

pale scroll
#

here`s not /modal_slash

pale scroll
#

okay

#
Traceback (most recent call last):
  File "C:\Users\w0rt3x\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ui\modal.py", line 341, in dispatch
    await value.callback(interaction)
  File "c:\Users\w0rt3x\Desktop\Придунавье\Clients\bot.py", line 21, in callback
    await interaction.response.admin_id.send_message(embeds=[embed])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'InteractionResponse' object has no attribute 'admin_id'```
#

huh?

hybrid fossil
#

If you don't code in English, you'll have a hard time making yourself understood.

pale scroll
#

how intercation send user?

hybrid fossil
#

Please...

hybrid fossil
pale scroll
wide jasper
grim estuary
#

😞

hybrid fossil
# pale scroll yeah

You must retrieve the role from the id.
Then retrieve the role members.
Send a message to each member.

hybrid fossil
hybrid fossil
hybrid fossil
pale scroll
wide jasper
grim estuary
hybrid fossil
pale scroll
#

where paste it?

hybrid fossil
#

This is for a slash command

#

You do this with a modal?

pale scroll
hybrid fossil
# pale scroll yes
admin_role = discord.utils.get(interaction.guild.roles, id=00000000)
for admin in admin_role.members:
  await admin.send("Message from the bot")
pale scroll
#

intercation?

hybrid fossil
pale scroll
#

huh?

hybrid fossil
pale scroll
#

where paste it?

hybrid fossil
pale scroll
hybrid fossil
# pale scroll
class HelpDevs(discord.ui.Modal):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

        self.add_item(discord.ui.InputText(label="Short Input"))
        self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))

    async def callback(self, interaction: discord.Interaction):
        embed = discord.Embed(title="Modal Results")
        embed.add_field(name="Short Input", value=self.children[0].value)
        embed.add_field(name="Long Input", value=self.children[1].value)
        admin_role = discord.utils.get(interaction.guild.roles, id=ID вашей роли администратора discord) #<========================
        for admin in admin_role.members:
          await admin.send(embeds=[embed])
pale scroll
hybrid fossil
pale scroll
hybrid fossil
pale scroll
grim estuary
#
... # imports

class ReputationCog(discord.Cog):
    
    def __init__(self, bot: discord.Bot) -> None:
        self.bot = bot
        reputation = bot.create_group("reputation", "Interact with the reputation of all members!")
        reputation.add_command(self.add_reputation)
        reputation.add_command(self.remove_reputation)
        reputation.add_command(self.set_reputation)
        
    @discord.slash_command(name="add", description="Add some reputation to the member")
    async def add_reputation(
            self, 
            ctx: discord.ApplicationContext, 
            member: discord.Option(discord.Member, name="member", description=text.CHANGE_REPUTATION),
            direction: discord.Option(str, name="group", choices=Settings().get_setting("AddDirections"), description=text.DIRECTIONS)
        ):
        ... # command code
    ... # other commands

def setup(bot: discord.Bot):
    bot.add_cog(ReputationCog(bot))
pale scroll
# grim estuary ```py ... # imports class ReputationCog(discord.Cog): def __init__(sel...

class ReputationCog(discord.Cog):
    
============>    def __init__(self, bot: discord.Bot) -> None:
        self.bot = bot
        reputation = bot.create_group("reputation", "Interact with the reputation of all members!")
        reputation.add_command(self.add_reputation)
        reputation.add_command(self.remove_reputation)
        reputation.add_command(self.set_reputation)
        
    @discord.slash_command(name="add", description="Add some reputation to the member")
    async def add_reputation(
            self, 
            ctx: discord.ApplicationContext, 
            member: discord.Option(discord.Member, name="member", description=text.CHANGE_REPUTATION),
            direction: discord.Option(str, name="group", choices=Settings().get_setting("AddDirections"), description=text.DIRECTIONS)
        ):
        ... # command code
    ... # other commands

def setup(bot: discord.Bot):
    bot.add_cog(ReputationCog(bot))```
#

class need __init__

grim estuary
grim estuary
hybrid fossil
#

I don't work in the same way as you, it's hard to get it right the first time.

grim estuary
hybrid fossil
#

hmm

#

I can recommend my way of doing things

grim estuary
hybrid fossil
#
class Example(commands.Cog):
  def __init__(self, bot):
    self.bot = bot

  command_group = commands.SlashCommandGroup("NAME", "DESC")

  @command_group.command(name="sub_command", description="DESC")
  async def cmd_sub(
    self,
    ctx
  ):
#

Something like this

wide jasper
weak spindle
#

member.display_name only gives my name, not username or nick.
I'm using py-cord 2.4.1 and my bot also has members intents set to true

import discord

intents = discord.Intents.default()
intents.members = True
bot = discord.Bot(debug_guilds=[769312138207559680], intents=intents)


@bot.slash_command()
async def displayname(ctx):
    await ctx.respond(ctx.author.display_name)

bot.run(token)
hybrid fossil
limber wagonBOT
#

Before Pomelo-

member.name          -> username
member.nick          -> guild nick name
member.display_name  -> member.nick OR member.name

After Pomelo-

member.name          -> username
member.global_name   -> global display name (global nick name)
member.nick          -> guild nick name
member.display_name  -> member.nick OR member.global_name OR member.name
shell radish
#

Upgrade to master to receive these changes

#

?tag install

limber wagonBOT
#

1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U py-cord

Installing other builds:
Note: You need to have git installed. Use ?tag git to find out how to install git.

Updating the module to master branch (unstable):
pip install -U git+https://github.com/Pycord-Development/pycord

weak spindle
hybrid fossil
weak spindle
#

Alright, thanks

hybrid fossil
lofty parcel
sly karmaBOT
# pale scroll it isnt work

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.

pale scroll
#

here error

lofty parcel
#

use interaction.guild.get_role instead of utils.get

pale scroll
lofty parcel
#

I said use interaction.guild.get_role instead of utils.get

lofty parcel
#

Are you kidding

pale scroll
lofty parcel
pale scroll
#

i bad in English

lofty parcel
#

Definitely need to learn more English if you want to code.

pale scroll
lofty parcel
#

What I said is you use interaction.guild.get_role instead of discord.utils.get. That means you do

admin_role = interaction.guild.get_role(ID here)

NOT combine them

lofty parcel
#

If you can't handle frustration or even using your brain to read instructions, don't bother on coding.

lofty parcel
#

A cat is clearly smarter than you.

pale scroll
#

and i`m beginner in pycord

lofty parcel
#

youre not responding to the interaction

pale scroll
#

i dont responding

lofty parcel
#

Youre not responding to the interaction in the modal callback

pale scroll
#

no?

lofty parcel
#

No, that doesn't respond to the interaction.

#

That just sends a dm

pale scroll
lofty parcel
#

Respond to the interaction before iterating over the members.

lofty parcel
pale scroll
#

@bot.slash_command() async def modal_slash(ctx): modal = HelpDevs(title="Звернення до Технічної адміністрації") await ctx.respond(modal)

lofty parcel
#

No

#

I never told you to modify your slash command callback.

#

Are you reading my messages?

#

You're not responding to the interaction in your MODAL callback

pale scroll
#

it?

lofty parcel
#

You can clearly see your modal callback doesn't take a ctx argument

pale scroll
#

add it?

#

ohh

lofty parcel
#

You're messing up your own code.

#

I never told you to modify your slash command callback.

#

This is why you actually need to understand python basics and the library.

pale scroll
#
from config import TOKEN
from discord import option

admin_id=1028017609809080401

bot=discord.Bot()


class HelpDevs(discord.ui.Modal):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)

        self.add_item(discord.ui.InputText(label="Short Input"))
        self.add_item(discord.ui.InputText(label="Long Input", style=discord.InputTextStyle.long))

    async def callback(self, interaction: discord.Interaction):
        embed = discord.Embed(title="Modal Results")
        embed.add_field(name="Short Input", value=self.children[0].value)
        embed.add_field(name="Long Input", value=self.children[1].value)
        admin_role = interaction.guild.get_role(1028017609809080401)
        for admin in admin_role.members:
            await admin.send(embeds=[embed])
        await interaction.respond()

@bot.event
async def on_ready():
    print(f'-----BOT ONLINE-----')
    print(f'-BOT TOKEN: {TOKEN}-')
    print(f'-BOT NAME:{bot.user.name}')
    print(f'-BOT ID:{bot.user.id}')
    print(f'-SERVICE MADE BY ONIX')
    await bot.change_presence(activity=discord.Game(name="GAME"))


@bot.slash_command()
async def modal_slash(ctx):
    modal = HelpDevs(title="Звернення до Технічної адміністрації")
    await ctx.respond(modal)
    
bot.run(TOKEN)``` what modify
lofty parcel
#

I already told you what you have to modify. It was just one line.

#

You even typed that line before and I even told you where to place it.

#

I'm not going to do it for you, no one here will.

#

We don't spoon feed here. You are not a baby.

pale scroll
#

i just wanna write code...

#

just tell me, what`s line

lofty parcel
#

I already told you above in the conversation.

#

Use your brain.

pale scroll
#

and if it works, I won’t touch you. and I said that I am very bad at English

lofty parcel
#

The world doesn't care if you're bad at English.

#

I already told you what to modify.

#

Where to place it.

pale scroll
#

just reply on this message

lofty parcel
#

And you even typed that line in the chat.

lofty parcel
pale scroll
lofty parcel
#

No

pale scroll
#

await ctx.respond()

#

it?

lofty parcel
#

No

pale scroll
#

i cant find

lofty parcel
#

My god.

#

Literally I just can't believe you're this dumb, you must be Trolling.

pale scroll
lofty parcel
#

Already told you everything.

#

Use your eyes.

pale scroll
#

what write in hooks, embed=embed?

lofty parcel
#

It is feedback to the user that the interaction was successful.

#

Respond with something appropriate to tell the user the users are being dmed

lofty parcel
pale scroll
lofty parcel
#

A coroutine.

#

That means your await it.