#Basic Pycord Help

1 messages · Page 45 of 1

silent shore
sage tendon
#

of course its working

silent shore
sage tendon
#

yea

silent shore
#

i remember they stopped it

#

that's why there is py-cord "the new discord.py api"

sage tendon
#

yea the creator came back and went on to create the most batshit insane implementation of application commands possible

#

thats why i wouldnt recommend it for modern bots either way

silent shore
mild trout
#

sorry for the stupid question again, but for things like my logger config should i also make a separete file and import it on each cog or how would you do it?

sage tendon
#

i will never touch loggers with a 10 foot pole

#

so cant help with that

mild trout
#

oh why is that

#

is it bad to use on a discord bot?

sage tendon
#

idk its confusing af to me

mild trout
#

oh

lofty parcel
#

You mean the logging module?

mild trout
#

yeah

lofty parcel
#

Wouldn't just placing it in the main file work for everything else?

mild trout
#

im not sure... i will try

tidal vessel
mild trout
#

for some reason python imports confuse me

sage tendon
silent shore
#

slash command is not registering

sage tendon
#

do not use requests

silent shore
tidal vessel
sage tendon
#

its not async, it blocks your entire bot

silent shore
#

im using a good api that's return infos about movie

silent shore
sage tendon
silent shore
#

something like this?

silent shore
sage tendon
#

aiohttp

sage tendon
silent shore
silent shore
sage tendon
#

also, you dont have to write the full name all the time
almost everything you need has shortcuts
e.g. discord.SlashCommandGroup or discord.Option

sage tendon
silent shore
#

kk

sage tendon
#

no its just caching so shrug

sage tendon
#

that is because vscode sucks

#

or rather pylance

silent shore
#

was giving me the error

#

not pycord

little cobalt
silent shore
sage tendon
#

yea i already said its unnecessary

silent shore
#

anyways the slash command still not registering

sage tendon
#

are you loading the cog before on_ready now?

#

and remove the guild_ids thing if you want it available globally

#

dont even think that can work for subcommands

silent shore
#

working now

#

thanks again

#

the last time i used pycord was like from 3 years

sage tendon
#

read the guide & docs

mild trout
silent shore
sage tendon
#

yea but it still blocks your bot

silent shore
#

nope

#

used with aiohttp

sage tendon
#

ah

silent shore
#

here

silent shore
sage tendon
#

discord.Embed

silent shore
#

to just preview the embed and the ill code it

sage tendon
#

its really not that hard
shouldnt take longer than 5m

#

just try it

silent shore
#

just like a prototyppe

sage tendon
#

but yea they do exist

silent shore
#

gimme

#

cuz im a person who must make everything perfect

sage tendon
#

google it yourself

silent shore
#

ah ye sure

lapis dock
sly pebble
#

im wacked rn whats going on

#
def string_check(message):
    print(type(message.channel))
    print(f"Is Another Author: {message.author.id != initiator}")
    print(f"Is discord.DMChannel: {message.channel == discord.DMChannel}")
    print(f"Is discord.channel.DMChannel: {message.channel == discord.channel.DMChannel}")
    if message.author.id != initiator or message.channel != discord.DMChannel:
        print("flagged")
        return False
    print("not flagged")
    return len(message.content) > 0

console output:

<class 'discord.channel.DMChannel'>
Is Another Author: False
Is discord.DMChannel: False
Is discord.channel.DMChannel: False
flagged
#

better formatting

#

and not a screenshot

#

i've tried the same thing with is and is not

#

same results

sage tendon
#

message.guild?

#

also lol

#

you need to use isinstance

#

not ==

sly pebble
#

yea the == was a last ditch

#

forgot about isinstance tho ty

silent shore
#

any suggestions or info to put it on the embed?

sage tendon
#

make the image the image and not the thumbnail

#

will make it slimmer too

silent shore
sage tendon
#

yea that looks better imo

#

Now fix your emojis to be unicode and not discord style and you're set

#

also, Rating*

silent shore
#

its just for prototyping

#

dw

sly pebble
#

you're cooking with that embed

silent shore
#

its a bot so you search about any movie/series send its give you this embed with all info

sly pebble
#

i've got this block of code and i'd like to get the values from a select back from the view, but it doesn't have the values attribute yet

events_view = Events()
await ctx.author.send(embed=embed, view=events_view)
view_finished = await events_view.wait()
if not view_finished:
    event_select = events_view.get_item("yeag")
#

here's my callback

#
async def event_select_callback(self, select, interaction):
    self.disable_all_items()
    await interaction.response.edit_message(view=self)
    print(select.values)
    self.stop()
silent shore
#

i just worked with view only once, and forget everything about it

sly pebble
#

do i gotta permanently attach those values to the select or smth?

lofty parcel
stray pasture
#

I am so confuse, Trying to debug why the guild.audit_logs is not working properly with the after param. (and do a PR to fix it)
As per discord doc If after is used, the list is reversed and appears in ascending order (older entries first)
But in my debugging, I have found that discord is returning the newest first ? Is discord doc wrong ?

stray pasture
#

yes I have seen the lastest PR

#

that change the audit logs

#

That is why I was testing again

#

if they are returning the newest first (contrary to the doc), that is why that iterator is failing

errant trout
stray pasture
#

is literally says in the doc to do that

errant trout
#

hm let's see

#

actually

#

fairly sure our logic is broken for Object(0)

#

everything else works as expected

stray pasture
stray pasture
#

to work as expected

errant trout
#

no, 0 is allowed

#

but our request ignores it

#

i.e. go to http.py -> get_audit_logs and change if after to if after is not None

stray pasture
#

If after is used, the list is reversed and appears in ascending order (older entries first) So if we want to continue the async iterator the after value need to be updated to the newest in the list (-1)

stray pasture
errant trout
#

you're probably also right on the index

#

i'll pr with both adjustments

#

huh, it's already 0 on master

stray pasture
#

it should be -1

#

with 0, it does infinte loop

errant trout
#

ah

stray pasture
stray pasture
errant trout
#

hm, is your limit working as expected?

stray pasture
#

I put limit as None

#

because I want to retrieve all entry after a specific one

errant trout
#

right, but can you test with limit anyway

stray pasture
stray pasture
errant trout
#

yeah, but i'm asking because my limit just isn't working lol

stray pasture
#

oooh strange !

#

I can test it to

#

it is not respecting your limit ?

stray pasture
errant trout
#

this needs a lot more thought huh

stray pasture
#

the audit_logs have been broken for a while

#

more than 1 year 😄

#

there have been a few PR to try to fix it, but still broken

#

I can try to fix it as well, but the index change and the accepting of 0 is a great start

errant trout
#

i'll work on it some more

#

the raw request method is fine so it's just a matter off making sure the iterator works... all our other iterators are fine so this is rather odd

stray pasture
#

yeah, not sure why did one is like that. I have raise a few Issue on the GitHub mentioning the index need to change with the explication behind it. But could not find why the id=0 was not working 😄

#

so did not raise PR

stray pasture
errant trout
#

sure

stray pasture
#

thank you !

stray pasture
#

I tested a bit the Pr you put, it seems to have fix the issue. I can do more testing later, need to go sleep

stray pasture
mellow spire
#

which feature is this like search option in select menu

fresh sierra
mellow spire
fresh sierra
#

If that’s what you want

mellow spire
fresh sierra
#

Discord could have done great things

mellow spire
fresh sierra
#

But sélect menu don’t create menu

mellow spire
oblique jasper
#

Traceback (most recent call last):
File "/opt/render/project/src/.venv/lib/python3.11/site-packages/discord/client.py", line 400, in _run_event
await coro(*args, **kwargs)
File "/opt/render/project/src/.venv/lib/python3.11/site-packages/discord/bot.py", line 1178, in on_connect
await self.sync_commands()
File "/opt/render/project/src/.venv/lib/python3.11/site-packages/discord/bot.py", line 754, in sync_commands
app_cmds = await self.register_commands(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/render/project/src/.venv/lib/python3.11/site-packages/discord/bot.py", line 531, in register_commands
prefetched_commands = await self._bot.http.get_guild_commands(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/render/project/src/.venv/lib/python3.11/site-packages/discord/http.py", line 367, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
whats this eror about

fresh sierra
#
def subcommand(group: str):
    def decorator(command: bridge.BridgeCommand):
        multicog_metadata[str(command.slash_variant.id)] = group
        multicog_metadata[str(command.ext_variant.)] = group
        return command

    return decorator

I need inside my cog to be able to get a command inside a dict, however if i use the name or ext_variant which is equal to the same in this case, it will get the wrong command. How can i get some get of id / unique thing for a command using the variant of a commands.command

fresh sierra
oblique jasper
fresh sierra
echo wraith
#

I believe it isn't possible, but asking to be sure. Is it possible to change the selected option in a dropdown after an interaction? Like "resetting" the component?

fresh sierra
echo wraith
fresh sierra
#

i was doing like so in my memory

#

or remove view and add it again if that doesnt work

#

not the best but

river oriole
#

How does BridgeCommand work with Options?

I have my code like this:

@bridge.bridge_command(
    name="whois",
    description="Gives you information about a user",
)
@bridge.guild_only()
async def _whois(
    self,
    ctx: bridge.BridgeContext,
    member: Option(
        discord.Member, "The user you want to know more about", required=False
    ) = None,  # type: ignore
):
    member = member or ctx.author
    await ctx.respond(embed=self.whois(member))

Which works fine for Slashcommands and when I use the Text Command without Args/Options. But when I add an arg in the Textcommand then I get following error:

[2024-07-07 15:49:08] [ERROR ] cogs.ErrorHandler: Converting to "Option" failed for parameter "member".
Ignoring exception in on_command_error
Traceback (most recent call last):
  File "/Users/dominik/Development/D-20/.venv/lib/python3.9/site-packages/discord/client.py", line 400, in _run_event
    await coro(*args, **kwargs)
  File "/Users/dominik/Development/D-20/cogs/ErrorHandler.py", line 39, in on_command_error
    name=f"{error.original.__class__.__name__}",
AttributeError: 'BadArgument' object has no attribute 'original'
sage tendon
#

you need BridgeOption i think

#

since 2.5

river oriole
#

I see. Thank you

deft kestrel
#

its possible to send mumlti embeds in one message?

little cobalt
#

;3

deft kestrel
#

My bot isnt receiving on_ban and on_invite_creation events even though i have all intends enabled

sage tendon
#

on_ban isn't a thing

#

and it's on_invite_create

#

and it's on_member_ban

deft kestrel
#

on_member_ban

#

yeah

#

i dont receive events on both of them

sage tendon
#

show your code

deft kestrel
sage tendon
#

show how you load the cog

#

and also your bot definition

deft kestrel
sage tendon
#

yea.. i meant more lol
where do you load your cogs

#

in on_ready by any chance?

deft kestrel
#

wait

#

i wrote something weird

#

should i be on ready?

sage tendon
#

btw, bot.load_extensions("cogs") loads everything

sage tendon
deft kestrel
#

ah okay

#

well i do

#

that what i had

sage tendon
#

yea, lol

#

load it before

#

the cogs

deft kestrel
#

ah

sage tendon
#

also, your cogs won't load at all that way unless i'm wrong lol

#

because i dont think your code ever leaves bot.run

deft kestrel
#

it loads

sage tendon
#

ah

sage tendon
# deft kestrel

also, why so complicated lol
its not like you ever import your main bot file, so thats just unecessary

deft kestrel
#

wdym

sage tendon
#

do you even know why that if __name__ is there?

fresh sierra
#

.rtfm on_member_ban

sly karmaBOT
fresh sierra
#

name is a good things to do

sage tendon
#

it's unnecessary

fresh sierra
#

I will not debate about that

sage tendon
#

do you ever import your main bot file?
No.
Ergo: Unnecessary

fresh sierra
#

I do

#

Ergo: what you think/do is not valid for everyone

sage tendon
#

lmao

fresh sierra
#

Reload will be more appropriate in my case

echo wraith
#

Is there a way with discord.Forbidden to have more context on for ex. what permission the bot was lacking if it tried to do something in a server, etc...?

sage tendon
#

isn't it in the message?

echo wraith
sage tendon
#

ah

#

well, typically, the action you're trying to do leaves only one possible permission

echo wraith
lofty parcel
#

Missing Permissions is usually role or channel permissions.

echo wraith
#

Ok by plaing a bit in the debugger I found a hacky way

#

yeah no noway I do that

#

It's because you get error.response

sage tendon
#

ngl i just handle it in the command

#

if i know that can happen

tranquil jolt
#

Presumably silly question(s):

most of my bot framework is from discord.py, so it has discord.intents and specific debug_guild target information. I've removed them as per the pycord "my first bot" tutorial, and it seems they're unneeded. So... I presume, pycord automatically sets the intents, and sets the target guild to be any server the bot is currently within, am i right with that presumption?

sage tendon
#

intents are a kwarg in your bot definition

#

and the guilds, yea, of course lol

tranquil jolt
#

i had a debug_guilds value, i think

#

so that must've restricted which guilds were being targetted

echo wraith
sage tendon
tranquil jolt
#

fairs fair 🫡 was just curious when transitioning from the discord.py style to the pycord style :3

tidal vessel
#

Guys, one question, can a user command also be a normal application command at the same time?
Or do I have to make a separate command?

class UsersCommands(commands.Cog):
    def __init__(self, bot):
        super().__init__()
        self.bot = bot
    
    @commands.user_command(name="Profile")
    async def profile_user(self, ctx, user):
          # ...
tidal vessel
wise dust
#

This is probably a very silly question, but do commands in slash command groups register as individual commands?

#

In relation to Discord's application command limit

wise dust
#

Awesome, thank you!

sage tendon
errant trout
#

if they meant the new user apps, you can pass multiple contexts

sage tendon
#

judging from their code the mean context menu commands & slash commands

#

which i wouldnt know how that'd work without duplicating it

errant trout
#

yeah that isn't a thing

wild prairie
#

How can I have members submit an image through a slash command and keep that image forever (besides downloading it)? The discord image URL eventually times out. Is there a way I can get a permanent link?

sage tendon
#

I mean, you'll have to download it lol

#

that's the only reliable way

#

one dumb hacky idea I just had is uploading it to Imgur and saving the reference in a db

errant trout
wild prairie
errant trout
#

is this through an ephemeral command

#

since that's a different matter

wild prairie
fresh sierra
#

What does it change ?

errant trout
#

then yeah, you have to reupload it or save it

fresh sierra
#

Ephemeral are not saved and not ephemeral are saved ?

errant trout
#

ephemeral images are deleted quickly yes

#

i'd say, on submit just reupload the image to wherever the response is recieved

sage tendon
#

wait actually

errant trout
#

i.e., instead of sending attachment.url, convert it with await attachment.to_file() and send it in a new message

fresh sierra
#

Wait I’m a little bit confused

errant trout
#

then you can always use the discord link within discord

sage tendon
#

cant you have an image storage server with only the bot in it, upload it there for storage, and then later access it again

fresh sierra
#

When you send a image to discord with an url send and get with message (discord message€

wild prairie
fresh sierra
#

You can use the link and send it few days later ?

wild prairie
errant trout
#

if it's an ephemeral command, the image will be gone within the hour

fresh sierra
wild prairie
fresh sierra
#

That cached the image

errant trout
#

cache is weird, but it's meant to delete as soon as the message is gone

fresh sierra
#

Maybe other will not be able to see it

#

You have some free thing online

#

To upload image and get a permanent link

errant trout
#

even if it's not an ephemeral command, if the message is deleted by anyone else then the attachment is gone. The safest way to retain it is for you to either save it or reupload it immediately to discord.

wild prairie
errant trout
#

infinitely

#

within discord

#

the expiry does not apply to image urls if you send it in a message or embed

#

it's only to gate other websites from using it

sage tendon
#

attachment urls last 24h exactly though, just to bring that number up too

errant trout
#

right, but for their purpose it's irrelevant

wild prairie
#

That doesn't make sense, because (unrelated to this) I sent an image, copied it's discord URL and linked to it in a message, and after a few days, the image was no longer accessible. Or is it different because it was opening in browser?

errant trout
#

yes, opening it in your browser is different

wild prairie
#

Gotcha.

Do I need to send the image back, or if I reply with a public response, the URL will last forever too?

errant trout
#

you could respond with it publicly, but i'd personally just reupload it elsewhere to be safe (maybe log all command usages in a channel?)

#

(and reminder that you can put uploaded images inside rich embeds #app-commands message)

wild prairie
shell radish
sage tendon
#

...no way

#

which on top?

shell radish
#

shouldn’t matter

hexed herald
#

hey, am I somehow able to get on_error piped to a cog listener?

#

I don't want to overwrite the normal action (for now) but want to assign a listener

sage tendon
#

then do that

#

like any other listener

hexed herald
#

and in my test it's also not working

sage tendon
#

oh, i was thinking about on_command_error

hexed herald
#

ohh, yeah that's easy with just @...listen but I want the "normal" error

sage tendon
#

then youll have to overwrite the event

hexed herald
#

and what do I have to put into bot.dispatch() ?
first would be smth like on_event_error
but how do I pass event, *args, **kwargs?

sage tendon
#

why do you need that top-level event though?

hexed herald
#

what do you mean with top-level event?

sage tendon
#

like why do you need on_error
what are you trying to do

hexed herald
#

I just want to log every error happening in the bot and be able to access it later using a command

#

but still have it raised in the console/log

deft kestrel
#
@discord.slash_command(name='purge', description='Purge messages from a channel')
    @commands_ext.guild_only()
    @discord.default_permissions(manage_messages=True)
    @commands_ext.has_permissions(manage_messages=True)
    @commands_ext.bot_has_permissions(manage_messages=True)
    @discord.option(name='amount', description='The number of messages to purge')
    @discord.option(name='include_user', description='Include messages from this user')
    @discord.option(name='exclude_user', description='Exclude messages from this user')
    @is_blocked()
    @analytics("purge")
    async def purge_messages(self, ctx: discord.ApplicationContext, amount: int, include_user: discord.Member = None, exclude_user: discord.Member = None):
        await ctx.defer()
        if amount > int(get_key("Moderation_MaxPurge", "1000")):
            await ctx.respond('The maximum amount of messages to purge is {amount}.'.format(amount), ephemeral=True)
            return
        
        messages = []
        async for message in ctx.channel.history(limit=amount):
            if include_user and message.author != include_user:
                continue
            if exclude_user and message.author == exclude_user:
                continue
            if (datetime.datetime.now(datetime.UTC) - message.created_at).total_seconds() >= 1209600:
                continue
            messages.append(message)

        chunks = [messages[i:i+100] for i in range(0, len(messages), 100)]
        for chunk in chunks:
            await ctx.channel.delete_messages(chunk)

        await ctx.respond('Successfully purged {messages} messages.'.format(messages=str(len(messages))), ephemeral=True)

This throws an error about an unknown message and deletes the deferred (bot thinking) message

sage tendon
#

well, exclude that message

deft kestrel
sage tendon
#

yea, again, either dont defer (should still be within the time limit if you're lucky?) or make sure you dont delete the defer message itself

deft kestrel
#

Fixed it by adding invisible=True, ephemeral=True into defer parameters

#

I want the purge method be able to delete beyond 100 messages which can't be in time limit when the user chooses to delete for example 500 msgs

sage tendon
#

oh yea, i missed that

#

you cant respond to non-ephemeral defers with an ephemeral response, or vice versa

deft kestrel
#

oh

#

well I figured it out

deft kestrel
#

get_key gets an entry from configuration file, or adds it with the second parameter if it isn't there

#

that's just a check to prevent people from purging 100000 messages

young skiff
#
discord.errors.ValidationError: Command names and options must be lowercase. Received "Katze" in locale de

Why doesn't py-cord just do a .lower()?

sage tendon
#

why don't you just make the string lowercase

young skiff
lapis dock
#

The reasoning is that we dont want to do anything that the dev does not expect so we are telling the dev that something needs to be changed instead of doing it ourselfs. Also it prevents people from wondering why capitol letters are not working when in reality we are changing the input in the background.

slate idol
#

Is it possible to use the selection of the first Option in a command to determine which Autocomplete is returned in the second Option of a command?

The beginning of the Command code, with where I want the autocomplete to trigger:

async def gift(
    ctx,
    what: Option(str, "...", choice=["Activate", "Learn"]),
    which: Option(str,autocomplete=discord.utils.basic_autocomplete(giftlist_autocomplete)
)
    # [slash command code goes here]```

The autocomplete code I'm wanting to fill out, but don't know if it's feasible:
```py
async def giftlist_autocomplete(ctx: discord.AutocompleteContext):
  if ctx.??????? == "Activate":
    # do X
  elif ctx.??????? == "Learn": 
    # do Y```
is there something I can pass where I have `ctx.???????` ?
sage tendon
slate idol
#

So would if ctx.options == "Activate" work in the above? I'm terrible at parsing APIs 😭 my brain just refuses to make the connection between the list of things and how to implement them.

sage tendon
#

no, it's a dict

slate idol
#

if "Activate" in ctx.options.values(): ?

sage tendon
#

no

#

wait, yea

slate idol
#

Thank you!

sage tendon
#

also, the kwarg is choices=, not choice=

#

in the option

slate idol
#

thank you!

sage tendon
#

you could also do if ctx.options["what"] == "Activate"

young skiff
#

Is there something like on_interaction_error? for views

sage tendon
#

doesn't that also count as application command

young skiff
#

I mean catching errors that are executed when clicking buttons

sage tendon
#

I am aware

#

and I'm saying that I think that'd also count as application command error

young skiff
#

Ah, you're right, I thought it worked another way, thanks

young skiff
#

I am trying to respond with an error message when an unexpected error is obtained when clicking any button. I am already using on_application_command_error, but when the error comes from a component it is not executed only if it comes from a command, I still do not understand how I can do it

errant trout
young skiff
errant trout
#

the library doesn't have a general view error handler, no

edgy nest
errant trout
#

you could perhaps subclass a view and assign it a single on_error

#

yeah

young skiff
#

okay thanks

deft kestrel
#

somebody can help me?
i am trying to delete channels that dont have categories but the code include categories
and when i am trying to check the channel type its doesnt saying true:

    @subcommand("staff")
    @commands.slash_command(name = "channel-delete", description = "Delete the currnt channel")
    async def channel_delete(self, ctx):
        guild = ctx.guild
        channels = guild.channels
        for channel in channels:
            if channel.category is None:
                print(channel.type)
                if channel.type == "text":
                    print(channel, channel.type)
                    # try:
                    #     await channel.delete()
                    # except Exception as e:
                    #     print(channel, e)
                elif channel.type == "category":
                    pass

output:

text
text
text
category
category
category
text
text
text
text
text
text
text
text
text
text
text
text
text
category
text
category
text
text
text
text
text
text
text
text
text
category
category
text
text
text
text
text
text
text
sage tendon
#

if isinstance(channel, discord.CategoryChannel)

deft kestrel
#

ok thanks

lethal loom
#

Hello, I would like to replace the image from a post so that it does not add two images but somehow I can't get it to work because I get a file back and no path.

Code:

            test = discord.File(file)
            await interaction.edit(attachments=[test], view=view)```

Error

Traceback (most recent call last):
File "C:\Users\jurek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\discord\ui\view.py", line 426, in _scheduled_task
await item.callback(interaction)
File "c:\Users\jurek\Documents\Development\Python\DC Bots\Xenority\Xenority-Main-Pycord-V2-PY\cogs\dev\images.py", line 417, in callback
test = discord.File(file, str)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jurek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\discord\file.py", line 99, in init
self.fp = open(fp, "rb")
^^^^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not File

deft kestrel
lethal loom
errant trout
#

if it's discord.File, then pass file=file and attachments=[] instead

lethal loom
#

thx

quartz umbra
#

so when using add_reaction, how do I use discord emojis (built-in) that don't have a unicode version

sage tendon
#

\🇸

tepid coyote
#

Would there be a reason why when I disable the presence intent my bot throws an error even though I don’t use it

sage tendon
#

hm, weird

sage tendon
#

and as you can see, it can cause issues

quartz umbra
sage tendon
#

(or maybe that works??)

#

because its not a normal s

sage tendon
#

can you show the error you get

tepid coyote
# sage tendon can you show the error you get
raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
sage tendon
#

well, dont pass it in the intents= kwarg

tepid coyote
#

actually i think i know why

quartz umbra
#

fo my case

lapis dock
lapis dock
#

Just need to backslash and than copy/paste. 😉

quartz umbra
#

wait so

#

\🇸

#

Ohhhhhhh

#

wait that is so smart

#

\💀

#

yoooo

lapis dock
#

Just a fyi you have to use copy message

quartz umbra
#

im flabbergasted

quartz umbra
#

but

#

that is crazy

lapis dock
#

for some reason highlight does not always work

lapis dock
#

and than that will copy the backslash as well so you need to remove that after pasting

sage tendon
#

a unicode finder website just says "replacement character" for the escaped letter emojis tho

lapis dock
#

Because the letter emojis are a combination character and an actual letter.

sage tendon
#

ah

river oriole
#

Did the Bridge Prefix for the Bot change in 2.5? I cant use the prefix anymore for my Bot, which worked in 2.4:

from discord.ext.bridge import Bot

bot = Bot(command_prefix=commands.when_mentioned_or("!"), intents=intents)
lapis dock
#

do you have the message content intent enabled on both the bot and the discord developer portal?

river oriole
#

Oh i forgot about that. I removed that. My bad. Thank you

grim estuary
#

discord.Member.can_send() means whether I can send DMs or not?

lapis dock
#

No

grim estuary
#

Should I create a DM and use can_send() from it?

lapis dock
#

That tells you if you are allowed to send x content to a DM assuming you can send a message in the first place. It is used for checking if for example you have permissions to send an image.

#

You should try to send the message to the user and catch the exception to determine if you can send DMs or not

grim estuary
#

Are there no other ways?

lapis dock
#

No

grim estuary
#

Thank you

echo wraith
#

Man I would just have uploaded the image to s3 or smth

lean garnet
#

Hi, I don't see anything about user apps in the documentation, it hasn't been updated yet?

sage tendon
#

documentation is updated

lean garnet
sage tendon
#

thats not how it works

lean garnet
#

ho

tidal vessel
#

Do user apps need additional permissions or settings in the discord portal?

sage tendon
#

check default_command_integration_types in discord.Bot

sage tendon
#

on new apps it seems pre-checked

tidal vessel
#

ok, ty

lean garnet
sage tendon
#

They will show up if you install it as user app

#

if they work is another question

lofty parcel
#

It doesn't magically make all your commands as user app commands too.

lean garnet
#

ok thanks

sage tendon
#

e.g. any commands that do stuff like create channels or roles won't work

lofty parcel
#

The repo has examples.

sage tendon
errant trout
#

well, it will work if the bot is in the guild

sage tendon
#

yea

#

thats expected

#

but i really hoped it'd take on the user's permission in the guild to do such actions

errant trout
#

that's more of an oauth thing

#

which i guess you could pull off but the lib isn't made for it

sage tendon
#

user apps would've been even more great if they added that

#

i had a huge amount of ideas

#

Is there a way to differentiate commands that originate from a user install vs guild install?

#

Like from ctx or smth?

#

i don't want to have to duplicate commands just to know 100% where a command came from, and i doubt that's the intention

sage tendon
#

wait no

#

that just tells me where a command was executed

#

but if a command is run on a server with a user-installed app, the context will still be guild

errant trout
#

see Interaction.authorizing_integration_owners

#

it's not the most clear but ultimately it's implemented to discord's spec

sage tendon
#

that is one mouthful, if not two

#

so.. what happens if a user is installed on a guild and the user calling the command? will both be supplied?

errant trout
sage tendon
#

according to the docs it can only be one

#

so i'd assume guild is preferred

errant trout
#

probably

short osprey
#

can someone give me a example code for the new polls feature?

lapis dock
#

It similar to an embed in how you make it. Just look over discord.Poll and than you can pass poll=my_poll into send/respond/etc

lucid crest
#

I used this in 2.5.0

SlashCommandGroup(name="example", description="example command", guild_only=True, xxx)

Now its changed to contexts (discord.InteractionContextType)
But in the Docs it says
The location where this command can be used. Cannot be set if this is a guild command.

Can someone give me a quick code example how to used it with 2.6.0 - or do I even have to set it?

short osprey
sage tendon
#

screenshot

short osprey
#

yea

#

just have this now

#

i know its not correct yet

#

but the class doesnt work

sage tendon
#

did you actually install 2.6

#

also you defined that outside of the command lol

short osprey
sage tendon
#

and.. what

short osprey
short osprey
shell radish
#

guild command refers to commands that are local to a specific guild

lapis dock
sage tendon
#

also.. does this actually work?

short osprey
#

rlly

#

i dunno

#

but deleted that part

#
@discord.slash_command(name='poll')
    async def poll(ctx, question: str, duration: int, *options: str):
        if len(options) < 2:
            await ctx.send("Je moet ten minste twee opties geven!")
            return
        
        if len(options) > 10:
            await ctx.send("Je kunt maximaal tien opties geven!")
            return

        poll = discord.Poll(
            question=question,
            duration=duration,
            allow_multiselect=False
        )
        
        for option in options[1:]:
            poll.add_answer(text=option)
        
        message = await ctx.send(embed=poll)
        poll_message = await message.create_poll(poll)
        
        await ctx.send(f"Poll gecreëerd: {poll_message.jump_url}")
        
        class discord.Poll():```
#

what need to be in the class

#

i mean

sage tendon
#

...my guy

short osprey
#

xD

sage tendon
#

poll = discord.Poll()

short osprey
#

srry

lapis dock
#

you sohuld not need to do class poll anywhere

sage tendon
#

and you do not use ctx.send in slash commands

shell radish
sage tendon
#

usually you dont, and i know they wanna respond

short osprey
#

alr

#
@discord.slash_command(name='poll2', description='Poll Commando')
    async def poll2(self, ctx, question):

        poll = discord.Poll(
            question=question,
            duration=6,
            allow_multiselect=False
        )
        
        poll.add_answer(text='hoi')
        poll.add_answer(text='hai')
        
        message = await ctx.send(embed=poll)
        poll_message = await message.create_poll(poll)
        
        await ctx.repsond(f"Poll gecreëerd: {poll_message.jump_url}")```
#

got this now

#

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.description: This field is required

#

get this error

lapis dock
#

poll= not embed=

#

sorry if I confused you earlier

short osprey
#

oh

#

np

#

ofc

sage tendon
#

and type respond correctly

short osprey
#

xD

#

but its working thx

lapis dock
#

poll_message = await message.create_poll(poll) also not sure what this does. But you dont need it

short osprey
#

does somebody know why i get this error and how to fix it?

sage tendon
#

use @discord.option instead of the discord.Option typehint

#

in short, pylance sucks

#

why not attach the poll to the message?

shell radish
#

honestly discord.Option typehint sucks

sage tendon
#

^^^^

short osprey
#

yk

lapis dock
shell radish
#

i'd like my typehints with my AquaticCreature objects thank you

short osprey
sage tendon
#

pylance sucks, as i already said

lapis dock
#

Thats a warning not a error. The code will still run

sage tendon
#

and using the decorator is still recommended by me

shell radish
#

usually, the thing after : is used as typehinting, however, we thought it was a good idea to put that as a way to get the Option passed there instead

short osprey
errant trout
#

nahh Option >>> decorator

sage tendon
#

its objectively worse

errant trout
#

i've been using it since 2.0 with literally 0 issues, while i've spent countless hours in this channel giving help to people using the decorator GuraShrug

#

if it ain't broke don't fix it

lofty parcel
#

Typehinting on top

weary meteor
#
        class FairnessView(discord.ui.View):
            def __init__(self, custom_id, fairness_results):
                self.custom_id = custom_id
                self.fairness_results = fairness_results
                super().__init__(timeout=None)

                @discord.ui.button(label='Provably Fair', custom_id=self.custom_id, style=discord.ButtonStyle.grey, emoji='✔️')
                async def button_callback(self, button, interaction: discord.Interaction):
                    await interaction.respond(fairness_results)

Inside of a command: 

await msg.edit(embed=embed, view=FairnessView(random_id, fairness_results=result))
self.bot.add_view(FairnessView(random_id, result))```
why exactly does the view not get edited into the msg
weary meteor
#

simply a msg i send and then edit later

little cobalt
#

use ctx.edit pls

weary meteor
#

oh i can just do that?

#

well even with that change, the button does not show up

little cobalt
#

Is the view outside of the command?

weary meteor
#

its inside of the command as a class

#
@commands.slash_command(name='coinflip')
    async def hi(self, ctx: discord.ApplicationContext, bet: Option(str, "Enter your bet amount!"), side: Option(str, "Choose your side!", choices=['Heads', 'Tails'])):

        class FairnessView(discord.ui.View):
            def __init__(self, custom_id, fairness_results):
                self.custom_id = custom_id
                self.fairness_results = fairness_results
                super().__init__(timeout=None)

                @discord.ui.button(label='Provably Fair', custom_id=self.custom_id, style=discord.ButtonStyle.grey, emoji='✔️')
                async def button_callback(self, button, interaction: discord.Interaction):
                    await interaction.respond(fairness_results)```
little cobalt
#

And the button is inside of the view class?

weary meteor
#

yep

#

oml

#

the callback is indented into the init

#

        class FairnessView(discord.ui.View):
            def __init__(self, custom_id, fairness_results):
                super().__init__(timeout=None)
                self.custom_id = custom_id
                self.fairness_results = fairness_results

                # Define and add the button in the init method
                button = discord.ui.Button(
                    label='Provably Fair',
                    custom_id=self.custom_id,
                    style=discord.ButtonStyle.grey,
                    emoji='✔️'
                )
                button.callback = self.button_callback
                self.add_item(button)

            async def button_callback(self, interaction: discord.Interaction):
                await interaction.response.send_message(str(self.fairness_results), ephemeral=True)

In my command (which is in a cog):
fairness_view = FairnessView(random_id, fairness_results=result)
await ctx.edit(embed=embed, view=fairness_view)
self.bot.add_view(fairness_view)```

The view is in-fact not persistent
quartz umbra
#

hi, why can't i access message.content? I have the intent enabled in the developer portal?

#

Do I need to change it in code too? Atm, I'm using all intents

#

output ```
ChatGPT:
whytho | bnudyd:
purpurpetals:
ChatGPT:
ChatGPT:
ChatGPT:

quartz umbra
#

this is so confusing

#

nvm

#

im just a silly guy 😭

lethal loom
#

Hi, why the default_command_entext and the other default one are not working? i can use the command in dms

    def __init__(self):
        intents = discord.Intents.all()
        command_prefix = commands.when_mentioned_or("-")
        default_command_contect={IntegrationType.guild_install}
        default_command_integration_types={InteractionContextType.guild}
        super().__init__(command_prefix=command_prefix, intents=intents, default_command_contect=default_command_contect, default_command_integration_types=default_command_integration_types)
    ```
sage tendon
#

you mixed them up

#

and you typed it wrong

#

you typed contect
and just switch around the {}, they're just in the wrong positions

#
        default_command_context={InteractionContextType.guild}
        default_command_integration_types={IntegrationType.guild_install}
#

should've been clear from the name
integration type goes into the integration type field, not command context

#

and im p sure guild_install is the default anyway

#

and.. i'm not sure if its smart making your bot subclass the exact same name as the default class, might cause issues

haughty grove
#

my app gets a permision error when i require move_members permission but works fine when i require administrator permission

#

im server owner so permissions shouldnt be a problem

#

any ideas why this happens?

sage tendon
#

dont use has_permissions for slash commands

#

use @discord.default_permissions

#

also, it's because you dont have that exact permission
you still need it even with admin, which is one of the reason has_permissions should be avoided

haughty grove
haughty grove
lethal loom
slate idol
#

I'm struggling with adding options to a Dropdown. I can write permanent ones in just fine, but in order to add_option() nothing seems to actually add itself to the list? Unfortunately the official example includes magical list population due to using roles.

I'm unlcear about where to position it (inside the class for the specific Dropdown? as a function inside that class? async? ) and what the exact code would read.

I've tried:
DropdownView.add_option(discord.SelectOption(label="RESULT"))
But it doesn't do anything. My Dropdown's Class is called DropdownView

edgy nest
#

Can we see some more code?

slate idol
#
class DropdownView(discord.ui.View):
    @discord.ui.string_select(
        #select_type=discord.ComponentType.string_select,
        placeholder="Select up to 3 dice...", 
        min_values=1, 
        max_values=3,
        options=[discord.SelectOption(label=str(f"TEST")),discord.SelectOption(label=str(f"TEST2")),discord.SelectOption(label=str(f"TEST3"))]
    )
    
    async def die_lister(self, interaction: discord.Interaction):
        # code that doesn't matter until I can add things to Options
        DropdownView.add_option(discord.SelectOption(label="RESULT"))
    
    async def dice_select_dropdown(
        self, select: discord.ui.Select, interaction: discord.Interaction
    ) -> None:
        
        pool=[]
        rpool=[]
        # more code that doesn't matter right now
        view = discord.ui.View(timeout=None)
        view.add_item(GoButton(rpool, pool)) 
        
        response = (
            f"**You selected the following dice**: "
            + f", ".join(die for die in select.values)
        )
        
        await interaction.response.send_message(response, view=view)```
#

I just don't know where to stick add_option() or what the preface should be.

slate idol
# little cobalt At the select or where?

Current code: Rolls some dice from a /command and includes this dropdown at the end of the response.
Desired code: Include the die results as selectable to re-roll.
Challenge: How to add options to a dropdown list that aren't hard-coded (see: "TEST"s vs. "RESULT").

#

So.. yes, at the Select?

little cobalt
#

Subclass the select

errant trout
#

(the latter is somewhat more tedious)

slate idol
#

I had missed that example in the list somehow, thank you!

quartz umbra
#

how to listen for when someone replies to a message

sage tendon
#

to one of the bot's messages?

tidal vessel
#

Guys, a question, I previously used the guild_only parameter so that the command group only works on servers but I get a message that this parameter is already obsolete. Is this the correct way to do it now?

sage tendon
#

contexts

#

but yes

tidal vessel
tidal vessel
sage tendon
#

ngl im not sure why they require a set instead of a list

#

but yea its correct

tidal vessel
#

okay, thanks

errant trout
#

maybe we should have a contexts decorator similar to has_permissions

lofty parcel
#

That'd be cool

sage tendon
#

dont think that needs its own decorator tbfh

#

too little functionality for it to be one imo

#

and it really is just a direct property of the slash command, so having it there feels more natural

errant trout
#

i mean

sage tendon
#

i jsut still wonder why its a set when most everything in the lib is a list

deft kestrel
#

Fixed cog reloading and synchronising (2+ years old issue)
what's that issue?

errant trout
#

same for guild_only, having something like @commands.contexts(guild_only=True) seems fairly in line with the library

errant trout
#

you could unload but it fucked up with syncing

sage tendon
errant trout
#

indeed, ultimately decorators are usually shortcuts

#

like how we have @default_permissions, you can actually set default_member_permissions in the command decorator instead because that's what it's called on the API

echo wraith
#

Has contexts= been implemented for SlashCommandGroup yet or not?

sage tendon
#

yes

#

could have just looked at the docs

echo wraith
#

I was lazy this time...

#

InteractionType looks soo much like IntegrationType

sage tendon
#

good thing that it's InteractionContextType :)

echo wraith
sage tendon
#

ah

#

but interactiontype is very old

echo wraith
#

for integration_types

haughty grove
#

how would i get the possible args of a command to display them in the help menu?

embed = discord.Embed(
            title=f"{cog_name} Commands",
            description="\n".join(
                f"`/{command.qualified_name} (args)` {command.description}" 
                for command in cog.walk_commands()
            )
        )
sage tendon
haughty grove
sage tendon
#

hm

shell radish
fast grotto
#

do you guys know any complete currency symbol api? because when i search on google, the apis i found are either incomplete or even if they are compete they are pricy

sage tendon
#

wdym currency symbol API

fast grotto
sage tendon
#

just make that yourself, it's not like there's thousands of currencies

#

just do like the 50 most common ones

fast grotto
#

if i had the time for it sure, but i'm mostly looking for an api

#

because someone has already done what i will be doing on the internet

sage tendon
#

I doubt it take you even an hour at most

#

using an API for such a simple thing is overkill imo

#

there's probably even just a list of all currency symbols you can download

fast grotto
#

i'm mostly want to use an api becasue i'm handling js code - i asked here because i thought some people might have that implemented in their own bot

sage tendon
#

I just made chatgpt generate a js dict of all currencies in like 10 seconds
i trust you can do the same

fast grotto
#

ok ty

lean garnet
lean garnet
#

Hi,
I saw that Pycord now supports Premium Apps, but I don't see how to limit an order to a premium user?
On the documentation I only see servers boosters or nitro subscriber for premium or premium_subscribers

#

and there is no exemples on the github repo

lapis dock
lapis dock
#

#1260606876547289100 message

lean garnet
#

thanks

tranquil thicket
#

HI, I basically have a url that would usually open a website, but is there a way for it to redirect directly to open a mobile application on mobile, and then use the website only on desktop?

lean garnet
#

you will have to use javascript tho

tranquil thicket
charred zodiac
#

how would one go about handling the discord.ext.commands.errors.CommandNotFound exception and making the bot respond to the user informing them that the command is not valid?

lofty parcel
ivory beacon
#

@sage tendon
how to do that now ?🙂
interaction_metadata doesn't have any data 🙂💔

broken pivot
#

how close thread in forum?

lofty parcel
#

Read the docs

slate idol
#

Is there a way to display content in columns / tables?
Neither keyword appears in the pycord documentation so I'm hoping there's another workaround?

slate idol
#
antelopes: 5```
trying to make the numbers all line up.
lofty parcel
#

You have to work with formatting yourself.

broken pivot
#

a

#

I understood

lofty parcel
#

Forum posts are threads.

slate idol
lapis dock
slate idol
#

EeveeHands
Thanks.

slate idol
#

The sleekest solution I've found, for others looking to use columns and tables:

aDictionary = {'antelopes':1, 'bears':5, 'cats':12, 'dogs':4, 'elephants': 99999}
print(f"`{'Animal ':<10}` {'Quantity':>10}`")
for first,second in aDictionary.items():
    print(f"`{first :<10}` {second:>10}`")```
replacing `print` with using the content however is needed. 
results:
`Animal       Quantity`
`antelopes           1`
`bears               5`
`cats               12`
`dogs                4`
`elephants       99999`
sage tendon
#

i havent read up but why not make an embed with 2 fields, one "Animal" and one "Quantity"

#

that way its lined up vertically and leftbound

slate idol
#

My initial digging into fields didn't give me any sense that they'd be stacked horizontally.

sage tendon
#

Fields are side by side up to 3 in a row

#

also, idk this syntax, what does it do?

slate idol
#

adds spaces in an f-string up to that number of characters: <10 is left-aligned, >10 is right-aligned.

sage tendon
#

ohh, thats cool

slate idol
#

Way sleeker than adding libraries and all their requisite funky syntax.

#

New question: how to fields?
I've got lots of embeds, in my efforts I kept get complaints about either not having a description= but then I'd add it and it would complain that fields shouldn't have a description=.

sage tendon
#

it's value=

#

and yea i think a description is mandatory for the embed itself

#

title isn't tho

slate idol
#

Right, so I think I was sticking it in the wrong place... I deleted that code like two hours ago, let's see if I can throw something together...

sage tendon
#

oh yea i forgor i can show you, 1s

slate idol
#
testfield = discord.EmbedField(name="Testfield", value="Testvalue")
discord.Embed(title=str(f"{Person}'s Skills"), description=SkillPage, fields=testfield)```
that ain't it 😦 
`TypeError: 'EmbedField' object is not iterable`
sage tendon
#

my code isnt really flexible enough to show you properly lmfao but yea i meant kinda like this

sage tendon
#

way easier imo

#

but if you wanna use fields=, it has to be a list of embedfields

slate idol
#

Could you show me your code block for that embed?

sage tendon
#

its ugly because of how my command works but yea

slate idol
#

Thank you!!! 💞

sage tendon
#

nice

#

and yea inline=True forces fields onto their own row (i think)

slate idol
#

Opposite:
inline = is it in the same line?

sage tendon
#

oh nvm i mixed it up

#

yea inline=False forces it onto its own row

sage tendon
ivory beacon
#

@sage tendon
look at this
it's not working anymore

sage tendon
#

yea well shrug

ivory beacon
#

i need a solution

sage tendon
#

good luck

ivory beacon
#

message._interaction.data
is working btw

ivory beacon
sage tendon
#

man i dont even most remotely remember what the problem was

sage tendon
ivory beacon
ivory beacon
#

but as there is InteractionMetadata 🙂

#

there is no data dict

sage tendon
sage tendon
ivory beacon
#

i need to access the raw interaction data:)

sage tendon
#

yea no clue sorry

ivory beacon
slate idol
#

EeveeHands fields don't stay inline on mobile

edgy nest
#

never have

lapis dock
#

was justs scrolling down to tell you this

#

problem is normal text might not stay in line either

#

table like formatting is a pain on discord

slate idol
#

😭 k thanks for all the help, folks! I'll return with a solution if I find something.

sage tendon
#

I also had my share of issues with embeds on mobile

#

sorry

fresh sierra
#

rip pycord 2.6 breaking change

lapis dock
#

what?

fresh sierra
#

looks like its not some big issue

#

my terminale is full of error, i will check

#

what the difference between bot_dm and private message ?

#

is it for user app comalnd ?

lapis dock
#

DM with only the bot. Or a DM with another user/group DM

fresh sierra
#

thanks

sage tendon
#

I have never looked into modals much but is it possible to have a message command pop up a modal, and once you submit that modal, the bot can ctx.respond in chat to the original interaction? or does that not work

fresh sierra
#

it will respond with the modal and then followup

#

so yes it should work

broken pivot
#
Ignoring exception in modal <cogs.reports.ReportModal object at 0x00000267636EBDD0>:
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ui\modal.py", line 341, in dispatch
    await value.callback(interaction)
  File "c:\Users\user\Documents\HOFFMAN\cogs\reports.py", line 93, in callback
    print(channel.available_tags)
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\encodings\cp1251.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f97a' in position 222: character maps to <undefined>```
broken pivot
errant trout
broken pivot
# errant trout could you perhaps show the full callback where you print available_tags?
async def callback(self, interaction: discord.Interaction):
        channel: discord.ForumChannel = await interaction.guild.fetch_channel(1260978288080195636)

        with open(f"{FOLDER}/data/score.json", "r", encoding="utf-8") as file:
            SCORE = load(file)

        SCORE["reports"] += 1

        with open(f"{FOLDER}/data/score.json", "w", encoding="utf-8") as file:
            dump(SCORE, file)

        description = ""
        for i in self.children:
            if i.label != "Ваш никнейм":
                description += f"**{i.label}:** {'Неизвестно' if i.value == '' else i.value} \n"

        embed = discord.Embed(
            title=f"Репорт #{SCORE['reports']}",
            description=f"**Отправитель:** {interaction.user.mention} \n **Никнейм отправителя:** {self.children[0].value if self.children[0].label == 'Ваш никнейм' else 'Неизвестно'} \n **Игровой сервер:** {interaction.guild.name} \n\n" + description,
            colour=discord.Colour.red()
        )

        thread = await channel.create_thread(name=f"Репорт #{SCORE['reports']}", embed=embed, content=interaction.user.mention, view=ReportAdopt())
        await thread.edit(pinned=True, applied_tags=channel.available_tags[1])

        await interaction.response.send_message("Репорт создан", ephemeral=True)```
#
Ignoring exception in modal <cogs.reports.ReportModal object at 0x000001E9DA4F7710>:
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ui\modal.py", line 341, in dispatch
    await value.callback(interaction)
  File "c:\Users\user\Documents\HOFFMAN\cogs\reports.py", line 93, in callback
    await thread.edit(pinned=True, applied_tags=channel.available_tags[1])
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\threads.py", line 678, in edit
    payload["applied_tags"] = [tag.id for tag in applied_tags]
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'ForumTag' object is not iterable```
#

I'm trying to get a tag from the forum to attach it to the thread

errant trout
#

applied_tags in edit should be a list

#

and i think you already fixed the previous error?

broken pivot
lapis dock
errant trout
#

well the code they posted already forced encoding to utf-8, no clue if they actually fixed it since they ran into a different error instead

lapis dock
#

#1132206148309749830 message

broken pivot
#

it seems to me that these are library errors

lapis dock
#

the second error you posted is a library error but it is because you are passing the argument incorrectly.

broken pivot
lapis dock
#

channel.available_tags[1] you are getting a single tag and passing in a place that needs a list of tags

broken pivot
#

a, I understood

lapis dock
errant trout
#

I doubt it, I think it's more likely the traceback is reporting the wrong error line because they updated the file

#

Encoding would be completely unrelated to that print

broken pivot
errant trout
#

You can just change the 1 to 1:2

broken pivot
errant trout
#

For indexing

broken pivot
#

a, I need one tag

errant trout
#

1 gets item at position 1, 1:2 gets the items from position 1 to 2 exclusive, thus you just get a list of 1 item

broken pivot
#

if I change to 1:2, I will use 2 tags at the same time

errant trout
#

Nope, it'll be 1

#

My general point is that'll return a list for you already, not a single object (which fixes the issue)

chrome plover
#

is the error code 520 from cloudflare caused by too many requests to discord? Or is it a vps issue?

errant trout
#

What's the full error in your console

#

Vps might have been temp banned? I forget

chrome plover
#

its a whole html

errant trout
#

Oh no

#

You might wanna reach out to your support team

chrome plover
#

but the bot seems to be working fine?

errant trout
#

Oh? I guess it's not as bad as I thought

#

Getting html in console generally isn't a great sign

chrome plover
#

it just stops that command

errant trout
#

Does it not give a line it errors on?

#

Yep

broken pivot
#

I'm surprised, thank you.

errant trout
#

Allgood

chrome plover
#

well it was in a traceback block that had to do with sending a DM to user or sending a message in a channel so not exactly

errant trout
#

Try-except? Try without it

chrome plover
#

yea well ok but idk how to replicate it

#

it doesn't happen

errant trout
#

Oh it isn't consistent?

chrome plover
#

but sometimes every 5-7 days

#

yea

errant trout
#

Hmm

#

You can probably ignore it, but it does sound like your vps has some weird inconsistency with discord

chrome plover
#

could be

#

I'll contact them I guess, that's the only thing I can do

#

ty

errant trout
#

Allgood

broken pivot
#

how I can get thread from interaction? interaction.channel return forum channel

sage tendon
#

why do you only have interaction?

#

nvm

broken pivot
#

I found a slightly different way to get the thread

sage tendon
#

?
I meant why you only have interaction and not ctx

#

ctx.channel should return the thread

broken pivot
sage tendon
#

ah

echo wraith
#

Is it right that Interaction not found can happen when you defer if your internet is slow cuz you are too slow to get it and send it back?

#

Becuase defer is a response

lapis dock
#

Yes. In most cases you should defer as the first line in your callback if you need to defer in the first place. If this is how you have it than it is just an internet speed issue

sage tendon
#

defer allows you to respond within 15 minutes

echo wraith
#

Yes thanks, was answering to someone elses question but wanted to be sure that internet was the issue before saying it 😆

fresh sierra
#

which part of the code has fixed the unload ?

#

because i still got some issue reload the cog

#
2024-07-12 05:49:49 [WARNING] : Failed to load extension Slashs.Antiraid.antiroleupdate: Extension 'Slashs.Antiraid.antiroleupdate' raised an error: CommandRegistrationError: The command antiroleupdate is already an existing command or alias.
#

because i did overwrite
add_application_command, add_command, invoke, invoke_application_command

#

got also some issue about group not found

2024-07-12 06:00:18 [CRITICAL] : Failed to add slash command antimove: Group 'antiraid' not found
vague plaza
#

how to send photo? is the only way via embedding it into a text message?

#

tried to look for "photo" in the docs but no results somehow

sage tendon
#

file=

vague plaza
#

can you add more details

sage tendon
#

that's the kwarg you need to pass your image to in ctx.respond

vague plaza
#

literally new to discord bot development but ive been developing in python for quite some time

oak onyx
#

What is the difference between on_member_update and on_user_update

#

Called when a User updates their profile.

Called when a Member updates their profile.

sage tendon
#

user could be any user the bot has cached, member only guild members

oak onyx
#

Hmm, I don't fully understand, but I guess I will find out over time

#

But I have another question, are these attributes not available because of any intent?

#

The docs don't metion any needed intent

#

avatar_decoration, is_migrated and jump_url

sage tendon
#

can you not access it?

oak onyx
#

yes

#

exactly

sage tendon
#

what does it return?

oak onyx
#

None

#

hmm

#

nvm.

oak onyx
sage tendon
#

I mean is_migrated is just a bool for one

#

and the others are correctly typehinted in their return type last I checked

oak onyx
#

I think not

#

and vs code does also not recognize them

sage tendon
#

vscode is a bad IDE

oak onyx
#

Well, I don't think thats the problem here, since vs code works for the other attributes

sage tendon
#

Its probably because it's in user and not overwritten by member

#

which is sad that vscode can't even detect that

sage tendon
#

yea, I checked, it is

oak onyx
#

but I don't even know where it gets avatar_decoration from, since it is not mentioned in discord.member.py

sage tendon
#

shrug not sure if pycord remembered to implement that you can have an avatar decoration per server now

#

gotta ask a maintainer

mossy violet
sage tendon
#

pycharm

oak onyx
#

meh, I don't like it

#

I used it for a year at work but hmm

sage tendon
#

vscode sucks because it tries to work for every language, and thus sucks at all of them equally

#

pycharm is great for python.

fresh sierra
sage tendon
#

DMs

#

user installation events are also upcoming

fresh sierra
fresh sierra
sage tendon
fresh sierra
#

Well see

sage tendon
#

it's just because its inherited from discord.User

#

and apparently vscode is too stupid to recognise that

fresh sierra
#

I got them in mine

errant trout
#

Member uses a decorator to inherit attributes from User

#

(per-guild avatar decos are fairly recent and haven't been implemented)

sage tendon
#

ah yea i looked into this more, and i forgot that i tested this with ctx.author, which is a union of User and Member

#

if i explicitly typehint it as member it doesnt show either

#

mb

oak onyx
#

see apparently PyCharm is too stupid to recognise that 😆

sage tendon
#

thats not how it works

#

i didnt know it was inherited in this way

pulsar ferry
#

Hey all - starting a new bot and i dont have any cogs yet... just have 1 simple slash command right now and its been showing in the server, but it doesnt seem to be updating as i make changes and add new arguments to it... is there some sort of refresh/register command im missing?

sage tendon
#

restart discord

#

ctrl+r

pulsar ferry
#

that was easy... thanks... i quess quitting out and opening again doesnt do it

sage tendon
#

it does, but ctrl+r is faster

#

unless you mean basically just minimizing discord to the taskbar

#

you can also just use the command once and itll update immediately, but if you have many required options, thats just slower most of the time

noble flax
#

When using a slash command and providing a dropdown/list for an autocomplete, is it purely text you can display or do emoji's work? (providing you know the id etc.)

civic lotus
#

Hi! I want to know how User app works and how to do it

echo wraith
civic lotus
#

how to "invite" now

#

i found i think

echo wraith
civic lotus
#

oh

#

very cool

cyan prism
#

so I have

#

with this for setup

#

I have a file named spamDetect,py in the cogs folder with a class named spamDetect and a function named detectSpam()

#

how

frail basin
#

Is the spamDetect function an async function?

echo wraith
cyan prism
echo wraith
#

The none type error means that get_cog is returning none

errant trout
#

ah

cyan prism
frail basin
errant trout
#

what happens when you print bot.cogs

cyan prism
#

get this

echo wraith
cyan prism
#

I have an identical function pretty much

#

this is the spam thing

errant trout
#

then yeah remove await

cyan prism
#

ohhh

#

I'm stupid wait

errant trout
#

also would probably be better to put a listener inside the cog instead

cyan prism
#

they're both async

#

I'm just blind

#

and got confused

#

thanks for the help lol

errant trout
#

autocomplete will not render any formatting etc.

noble flax
#

Thank you

pulsar ferry
#

How do i go about making some of these arguments optional and add descriptions to them?

@bot.slash_command(description="Run a backtest")
async def backtest(
    ctx,
    start_date: str,
    end_date: str,
):
sage tendon
#

use the @discord.option decorator below the slash command decorator

sage tendon
#

just use the decorator, its a million times better than the typehint and more flexible

#

and has the same args

pulsar ferry
#

how to i make it optional though?

sage tendon
#

required=False

bleak abyss
#

Is there a way to keep data from the first execution of an autocomplete, so i don't have to execute a new api request each time the user write something ?

pulsar ferry
sage tendon
#

yea

#

check the docs its all there

pulsar ferry
#

yeah i couldnt find the page for the decorator

#

just this #1132206148309749830 message

sage tendon
#

discord.Option

#

as i said its the exact same args

#

its the same thing really, just written differently

pulsar ferry
#

ah missed that- found it now thanks

bleak abyss