#Basic Pycord Help

1 messages · Page 47 of 1

sage tendon
#

discord in the list

limpid marten
#

guh

sage tendon
#

uninstall that and py-cord yes, uninstall both and then only reinstall py-cord (make sure to include the dash)

#

if not you might have leftover discord.py files in the directory

limpid marten
#

ight

#

okay i uninstalled both

#

okay now im 100% sure i did everything right

sage tendon
#

show your pip list again

#

also sidenote but idk why you have a DateTime package, python has a built in datetime package, might mess things up

limpid marten
limpid marten
sage tendon
#

meh then its probably a dependency, then leave it

#

yea looks good

limpid marten
#

okay so i think i

#

fully converted my code into PURE PYCORD

sage tendon
#

if it runs

#

and works

limpid marten
#

everything runs fine

#

ok so now onto this

#
@bot.bridge_command()
async def fight(ctx, user):
    member = ctx.author
    gifs = ['https://tenor.com/view/murro-punch-punching-mad-madness-gif-24184117', 'https://tenor.com/view/meme-memes-memes2022funny-meme-face-punch-gif-25436787', 'https://tenor.com/view/mochi-cat-vans-gif-21776348', 'https://tenor.com/view/hasbulla-hasbik-funny-trending-meme-gif-21766562']
    randomgif = ''.join(choices(gifs))
    print(randomgif)
    embed = discord.Embed(title=f"{member} has {''.join(choices(['punched', 'hit', 'knocked', 'slammed']))} {user}")
    embed.set_image(url=randomgif)
    await ctx.send(embed=embed)
sage tendon
#

yea, those are not proper gif links

#

you need to copy the acutal gif link from the site, e.g. https://media1.tenor.com/m/x39il9SwZK0AAAAC/murro-punch.gif for the first one

limpid marten
#

oh ill try

sage tendon
#

just right click the gif and click copy image link

limpid marten
#

ay that might work

#

lemme see

sage tendon
#

not sure what this is for though..

limpid marten
sage tendon
#

but why ''.join lol

#

just do choices(gifs)

#

never heard of that either lol, i just use random.choice()

limpid marten
#

wont it do like the dumb []

sage tendon
#

no

#

and use random.choice

limpid marten
sage tendon
#

ah
yea but choice is different from choices

limpid marten
#

peak coding

sage tendon
#

choice selects a single item from the given iterable

#

choices returns multiple, as a list

limpid marten
#

my lord this code is like

#

absolutely cooked

#

yippee!

#

ok so now i actually have to make it work when someone pings the user

#

so its
.superkomfort has knocked @usernamehere
and not
.superkomfort has knocked @spiral wharf

#

should be easy actually

limpid marten
#

now i actually see how much better pycord is

sage tendon
#

yea you just put discord.Member as typehint

pulsar ferry
#

Is it possible to hide specific args from showing in the slash command to discord user?

sage tendon
#

why hide?

pulsar ferry
#

I want to use the same function that can be invoked by slash in discord by another command in the program but don’t want use to be able to give a value for it

sage tendon
#

wdym another command

pulsar ferry
#

Function *

sage tendon
#

can you show what you mean

pulsar ferry
#

I have 2 commands on my bot optimize() and backtest(). Backtest takes a bunch of args provided by user. Optimize() is a function that runs on a schedule (not slash command) but it calls backtest().

When backtest is called, there is a “system” flag so it modifies logic if user is using it with slash or if optimize() is calling it.

I don’t want user to see “system” as an arg

sage tendon
#

honestly I'd just make the actual code of the backtest command a separate function which you call directly from the slash command, and then you just pass idk system=False in your code

#

that way you can just remove the arg from the command

pulsar ferry
#

Hmm okay may have to do a bunch of refactoring then 😅

sage tendon
#

not really lol

#

make a new function, paste the entire code there, then just call that function from the command and from your optimize function
that's it really

#

just wondering how it even works rn like, without a command invocation you don't have stuff like ctx or anything lol

pulsar ferry
#

Gotta run will explain later tough

mellow pebble
#

is it possible to get user activity status

#

i got a wierd idea of using it in getting information of current song playing in spotify

rugged lodgeBOT
mellow pebble
#

any example code ?

shell radish
#

why do you need example code for this

mellow pebble
#

i will figure it out

sage tendon
# rugged lodge

"the activities that the user [...] is doing" sounds so weird

mellow pebble
#

i got it thanks

#

working

#

yay

#

but here's the thing, it works only if you have the bot in the server somehow i doesn't for the user installed app

sage tendon
#

it does, but only for the invoking member

#

the problem is that other members are only passed as their user equivalent for user apps

#

and I'm p sure user objects don't have the activities

#

that or they blocked it anyway (discord)

shell radish
sage tendon
#

yea

mellow pebble
#

true it's okkay :D

sage tendon
#

user apps are unfortunately a little too limited imo

fresh sierra
#

how to disable all logger.info to work from py-cord but not from my code (if possible ofc)

frail basin
#

create a new logger instance which isnt named "discord"

fresh sierra
#

no my goal is to keep discord logger to have the warning etc

frail basin
#

logging.getLogger('discord').setLevel(logging.WARNING)

bitter meteor
#

how to remove field from embed?

sage tendon
#

May be a stupid question but just dont add it in the first place (?)

bitter meteor
#

but what if you want to modifly embed?

#

or just send one more?

sage tendon
bitter meteor
#

oh ok thanks

fresh sierra
#

Ig it’s too specific

limpid marten
#

how do i make user app commands?

#

(or something along these lines)

#

i wanna be able to use russian roulette everywhere

sage tendon
#

did you already enable user install in the developer website?

limpid marten
#

yup!

sage tendon
#

and you already installed it on yourself?

rugged lodgeBOT
#

Here's the slash users example.

limpid marten
#

i think so

sage tendon
#

ah, that's, faster probably yea

#

read that

sage tendon
#

no offense but probably another one of Lumas crazily overcomplicated ideas that achieve the same thing as something much easier

limpid marten
#

its the thought that counts

limpid marten
errant trout
#

Do you remember actually using the oauth url to install it to your user

sage tendon
#

If your bot has the "add app" button on its profile you can use that too

limpid marten
sage tendon
#

what is that cat emoji in the bottom right

limpid marten
#

i have a little kitty following my cursor at all times

#

its on top of your pfp now!

sage tendon
#

oh lol

limpid marten
fresh sierra
fresh sierra
limpid marten
# limpid marten

anyways now ill implement this on every (possible) command now

errant trout
#

So set log level on startup and then just use getLogger like everyone else suggested

limpid marten
#

so i can stop RELYING ON OTHER BOTS!

sage tendon
fresh sierra
sage tendon
#

you only receive User objects for any User apart from the command invoker for example

#

so it can quickly break if you use e.g. member.roles

limpid marten
sage tendon
#

only the global avatar though, but yes

fresh sierra
#

But ig I will just overwrite the .info func to then if a special key is there is work and else it does not emit

limpid marten
#

exactly what im lookin for

sage tendon
#

it cant access the guild-specific one except for the one of the person that used the command

limpid marten
#

eh i dont mind that

errant trout
fresh sierra
#

if yes this will also add the log from py-cord

errant trout
#

Why do you have to use the discord name?

sage tendon
#

Luma with all your requirements just fork pycord and change everything

#

literally you want to rewrite like half the library

fresh sierra
errant trout
#

This isn't even pycord related, theyre trying to tackle a core package now

sage tendon
#

ah

fresh sierra
fresh sierra
#

and i didnt change a lot of thing only the class of the bot to create hybrid command

fresh sierra
# errant trout What

by using that logging when my bot is rate limit or anything else its log it inside the terminale right ?

errant trout
#

I guess? But you have to receive all the logs :)

#

(See docs for how to filter logs, I'm not bothering to explain that here)

fresh sierra
#

if i set it to warning i get everything else than warning, but its okay i will continue to use logger.log. It seems not really logic

#

also i got another issue, im trying if the logger is more than a certain level to send it via a webhook to discord

#

so i will first focus on that

#

thanks for the help tho

pulsar ferry
#

is there a way to close out a ctx.defer() without sending a response back (i.e ctx.response())

sage tendon
#

no

#

you always have to respond to interactions, no matter if deferred or not

pulsar ferry
#

ok thansk

fresh sierra
#

You could try defer -> ctx.delete?

sage tendon
pulsar ferry
sage tendon
#

like you should give the user something

pulsar ferry
#

it still just says thinking..

sage tendon
#

then make sure that cant happen

pulsar ferry
#

the user has 60 seconds to review the arguments they provide otherwise i want it to delete

sage tendon
#

but why do you defer?

#

make a modal

#

oh nvm

pulsar ferry
#

I am

fresh sierra
pulsar ferry
#
async def _confirm_action(ctx, embed):
    class ConfirmView(View):
        def __init__(self, timeout=60):
            super().__init__(timeout=timeout)
            self.value = None

        @discord.ui.button(label="Confirm", style=discord.ButtonStyle.green)
        async def confirm(self, button: discord.ui.Button, interaction: discord.Interaction):
            self.value = True
            await interaction.message.delete()
            self.stop()

        @discord.ui.button(label="Cancel", style=discord.ButtonStyle.red)
        async def cancel(self, button: discord.ui.Button, interaction: discord.Interaction):
            self.value = False
            await interaction.message.delete()
            self.stop()

        async def on_timeout(self):
            # Check if the message still exists before attempting to delete
            if self.message:
                try:
                    await self.message.delete()
                except discord.NotFound:
                    pass  # The message was already deleted

    view = ConfirmView()
    await ctx.send(embed=embed, view=view)
    await view.wait()
    return view.value
sage tendon
#

just use ctx.respond..

pulsar ferry
#

so they can cancel and re send command if they provide bad arg

#

just getting rid of the defer as this is instant and going to put it after

#

but it peaked the curiosity if it were possible

sage tendon
#

why do you defer at all then..

#

just respond and delete the message if the user doesnt do anything

tidal vessel
#

Can you help me with this problem? The command returns an error that it needs permissions but the Bot is admin on the server. It also has intents enabled.

This is the first time I try to modify the nick of a member, is something wrong?

Error:
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

sage tendon
#

are you the server owner?

tidal vessel
sage tendon
#

and trying to use the command?

tidal vessel
#

yes

sage tendon
#

bots cant edit server owners

tidal vessel
#

ooohh

sage tendon
#

also, use ctx.respond(), its shorter and does the same thing

tidal vessel
mellow pebble
#

i noticed one more thing, the subcommands of a group does not work in user installable apps

#

like if i have a group called emotes a

#

and i have a emote named smile so it won't show up in user installable apps

#

but only works in server that has teh bot

errant trout
mellow pebble
#

let me try

#

it worked thanks

warm linden
#

can someone give me a doc on selects and modals please

rugged lodgeBOT
#

Here's the modal dialogs example.

#

Here's the dropdown example.

warm linden
#

thanks

mellow pebble
#

is there any cog.listener for users as in user installable apps

rugged lodgeBOT
#

Here's the slash cog example.

mellow pebble
#

like i want to make a afk that works anywhere ( i don't think that will work )

#

but is there possibilisty it would ?

limpid marten
#

what are the exact limits of user apps

#

i noticed my spotify command doesnt work in servers that the bot is not in

sage tendon
#

they're quite limited

#

you of course can't join vcs since you're not actually in the server

#

you only ever get user objects instead of member objects except for the person calling the command

#

you can't take any actions on the guild, in fact you barely get a guild object to begin with

#

make sure to limit commands that don't work on user install to only being used if your bot is installed on a guild to not confuse your users

sage tendon
mellow pebble
mellow pebble
limpid marten
#

but i also noticed that fmbot's /spotify command also doesnt work in other servers

sage tendon
#

I mean yea, as I said, it's not possible to join VCs with a user app lol

errant trout
#

When were any new events announced

limpid marten
#

its supposed to show currently listening

sage tendon
#

ah

fresh sierra
#

If you access to the channel to check that it might be the issue since the bot can’t access to that channel

sage tendon
#

yea you cant get activities of anyone other than the command invoker

#

because for anyone but the person using the command, you only get the User object, which doesnt have activities

limpid marten
sage tendon
#

then i guess they limited that too

#

user apps really are too limited

limpid marten
#

or maybe my code is absolutely ass

sage tendon
#

print(member.activities) ig

limpid marten
#

what do i do with that

sage tendon
#

check if there are any? lol

limpid marten
#

okay sure

#

alot

sage tendon
#

yea i mean then the spotify activity will be there too if you open spotify

#

oh wait no its right there lol

limpid marten
#

except if i use the command in dms

sage tendon
#

yea because DMs dont have a member object to pass

#

as you can see it tells you "User" object

limpid marten
#

oh

sage tendon
#

commands that need activities can only work in guilds, and if you have a user app, only on the person calling the command

limpid marten
#

so i can try and fix it but itll only work on the person using the command?

sage tendon
#

yea

#

because you only get the Member object for the command user, no one else

limpid marten
sage tendon
#

same

limpid marten
#

i actually have no idea how to do this

sage tendon
#

i also had a ton of ideas for user apps but they were all ruined

limpid marten
#

i REALLY want to do this but i have no idea how

sage tendon
#

well i told you the limits
i'd probably just limit it to guild installs

limpid marten
#

im fine with the limits

#

i dont mind if only i can use the command

sage tendon
#

ah

#

if i'm reading that right

limpid marten
#

and added my own embed

#

and other stuff

#

and got this

sage tendon
#

i mean..

for activity in member.activities:
    if not isinstance(activity, discord.Spotify):
        continue
    # your code here
#

ah

#

yea

#

why is this greyed out lol

limpid marten
limpid marten
#

but it clearly reaches people

sage tendon
#

do if not user

#

== None should be avoided anyway, if anything it's is None

sage tendon
limpid marten
#

oh

limpid marten
sage tendon
#

yea

limpid marten
#

still greyed out but should work technically

sage tendon
#

weird

#

well try to get into that if clause and print something ig

#

if it works then ignore what your IDE says, but weird

limpid marten
sage tendon
sage tendon
limpid marten
#

oh!

#

my bad

sage tendon
#
@bot.slash_command ()
async def spotify(ctx, user: discord.Member = None):
    if not user:
        user = ctx.author
    for activity in user.activities:
        if not isinstance(activity, Spotify):
            continue
        embed = discord.Embed(title=f"{activity.title}",
        url=activity.track_url,
        description=f"**{activity.artist}** · *{activity.album}*"
        colour=0x27b300)
        embed.set_author(name=f"Now playing - {user.name}",
        icon_url=user.avatar)
        embed.set_thumbnail(url=activity.album_cover_url)
        return await ctx.respond(embed=embed)
    await ctx.respond("User isn't listening to Spotify", ephemeral=True)
#

thats how i'd do it

limpid marten
#

also yeah the greyed out part actually works

sage tendon
#

yea weird, then its just VSC being dumb

limpid marten
#

peak ide

sage tendon
#

pycharm >>>>>>>>>>>>

limpid marten
#

i did use pycharm

#

but it broke someday and i just switched to vsc

#

honestly i dont even remember

sage tendon
limpid marten
#

yeah thats a good idea too

#

should i switch back to pycharm

sage tendon
#

i would

limpid marten
#

ill switch

sage tendon
#

also i'd recommend using the @discord.option decorator to handle options with defaults etc

#

that way you can set descriptions, make it not-required without needing = None in the function header, pass a default etc

limpid marten
#

HOLD ON THERES A FEATURE SO PEOPLE CAN CODE WITH YOU???

#

hop on

#

what pycharm plugins are recommended

lucid crest
#

is there an event that triggers when a user installs the app for himself ( discord.IntegrationType.user_install )

spark zealot
#

how can I get a roles ID just from its name?

lucid crest
frail ocean
#
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discord.com:443 ssl:default [Temporary failure in name resolution]

How to solve?

fresh sierra
frail ocean
#

Thx

fresh sierra
warm linden
#

how to i make my select menu work for a longer period of time where it doesnt time out and cam be reused

rugged lodgeBOT
#

Here's the persistent example.

warm linden
#

as in something like this zervy?

        self.add_item(discord.ui.InputText(
            label="User ID:",
            placeholder="",
            custom_id="persistent_view:id",
        ))
fresh sierra
#

.tag persistent

sly karmaBOT
#

The Issue

When you send a message with a view, button for example
if your bot restarts, you will lose the ability to use this button.

How To Fix This

  1. Set your view timeout to None
  • By default, the view timeout value is set to 300 seconds
  1. Pass a custom_id value to the view
  • Custom ids must be unique
  • Chose a custom id that has a meaning in relation to your view
  1. Add the view to the bot
  • You can use the method Bot.add_view(YourViewClass())
  • Make sure to add the view when the bot begin ready
warm linden
#

thanks bro

echo wraith
#

How do I fix this?

cold jay
#

Is Pycord supposed to work with mypy? It doesn't seem to be detecting types from it when I run mypy on my project 🤔

sage tendon
limpid marten
sage tendon
sage tendon
echo wraith
cold jay
sage tendon
#

never heard of that, and frankly, I think typehints as they are in python are enough

limpid marten
sage tendon
#

so if it doesn't work it probably isn't supported by pycord

sage tendon
limpid marten
#

aw alright

sage tendon
#

I have the ultimate edition

#

so that won't help

cold jay
limpid marten
#

but why can i avatar.url but i cant banner.url

sage tendon
#

there's no way discord.Bot returns anything but a discord.Bot

cold jay
#

Yeah, VS Code seems to not even know that discord.Bot is a class... I'm thinking it can't find the types for Pycord, but I'm not sure why

sage tendon
#

yea, my tip is don't use vsc

#

it just kinda shitty

fresh sierra
#

well im using vsc i have no issue at all about that

cold jay
sage tendon
#

if you ctrl+click discord.Bot it should bring you to the appropriate file in Pycord tho
if it doesn't chances are you didn't install it properly

fresh sierra
#

for everything

sage tendon
#

yea that's one thing vsc does do properly at least

limpid marten
sage tendon
#

if it doesn't do that something is wrong

cold jay
#

I thought so, maybe there's something wrong. I have it installed with Poetry, how did y'all install it?

sage tendon
sage tendon
#

pip install py-cord

#

yes, the dash matters

sage tendon
#

and venv, yes

limpid marten
#

why does the search work so slowly in pycord doc 😭

cold jay
sage tendon
#

e.g. if I look for Member, discord.Member is like the tenth result
why.

limpid marten
#

that too

sage tendon
#

but it has no delay for me

limpid marten
sage tendon
#

yea doesn't do that for me

#

probably an extension if I had to guess

limpid marten
#

i do have a couple

sage tendon
limpid marten
#

ITS PROBABLY FROM ANOTHER WEBSITE

sage tendon
#

what browser even is that

limpid marten
#

opera

#

gx

#

im this close to going to firefox

sage tendon
#

salute please do

limpid marten
#

yknow what sure

sage tendon
#

hands down ogx is the worst big browser if I had to pick

limpid marten
#

can i transfer data

sage tendon
#

p sure there's an import process yea

limpid marten
#

yeah saw it

#

holy lord its like instant now

limpid marten
sage tendon
#

lol

#

and please, for adblock, get NOTHING but ublock origin

limpid marten
#

just did

sage tendon
#

also #general lol

cold jay
#

I did some testing @sage tendon @fresh sierra, and it looks like my typing tools freak out when mypy is set to use strict typing (types won't even appear in VS Code if I have the setting set up in mypy's config file). Is this expected?

little cobalt
#

for what do you really need mypy?

cold jay
#

To make sure I'm using everything correctly in my project, afaik it's used pretty widely

#

Just seemed like best practice to make sure I'm coding good

sage tendon
#

I can just talk for myself but I have never seen anyone use that

little cobalt
#

you cannot really use anything wrong if you know what you are doing

sage tendon
#

and seems unnecessary

#

you don't need typehints all that often anyway

#

just for function parameters and if you feel fancy, function return values
Both of which are hard to get wrong

cold jay
sage tendon
#

yea but Pycord is a whole big library

cold jay
#

To be fair I haven't used mypy a ton in my Python programs yet, but it seemed like best practice from all the projects I've seen using it. Would you guys know if strict mode is just not supposed to be used or something?

sage tendon
#

your bot is like 1% of the code probably

sage tendon
cold jay
#

Well yeah ofc, but it doesn't change the fact that I want to make sure I write good code. Typing just helps ensure that

#

Alright, sounds good

sage tendon
#

if you typehint at all you're already better than many

cold jay
#

I'm coming from type-forced languages like Rust, I just like ensuring bugs don't get introduced where they could be avoided. Better to catch them now before they pop up later on lol

#

But is Pycord itself not meant to work with strict typing? That's moreso a question outside of the scope of my project, is that some faulty behavior with Pycord or is that intentional?

sage tendon
cold jay
#

I can open an issue for that on GitHub if it'd be better too

cold jay
#

Yeah, but I'd still like to type everything if I can, it's not really much more work from my perspective.

#

I'll go ahead and just make an issue then, I should be good outside of that. Unless you got any other thoughts haha

sage tendon
cold jay
fresh sierra
#

type hint is always a good thing to do

cold jay
#

Rust enforces it, it's all I know anyway 😭

#

Should be good once I get this issue posted though, thanks for the help up to this point 🙏🙏🙏

sage tendon
#

strict typing is also often a hindrance and annoying, in my limited experience with python

little cobalt
#

I do it in python to for more autocomplete at the IDE

sage tendon
#

in python I have functions that can return like 3 different types
pain to do in java

#

well, impossible in java unless you duplicate the code
in python you can easily typehint it

little cobalt
sage tendon
#

yes

#

| None is python's any lol

#

not really but close enough I know

#

and correct me if I'm wrong but I think if you typehinted something like

number: int = string_function()

it would show a warning in your IDE

#

as long as the string function has a return type hinted

limpid marten
#

ay @sage tendon i took your advice to do some doc surfing and now my banner command works woohoo!

sage tendon
#

docs >>>>

#

istg

#

I need this channel for myself like once a month max

limpid marten
#

stack overflow is 70% a miss

#

docs are 80% a hit

sage tendon
#

no fuck stackoverflow

limpid marten
#

yeah true.

#

nobody pays attention to our dear pycord

sage tendon
#

I have yet to find an actual error in the docs
And everything is there

#

well some very obscure classes are missing but if you need those the question is rather "what are you doing"

warm linden
#

can someone help me with this please: TypeError: LeakCodeModal.__init__() missing 1 required keyword-only argument: 'title'
cogs/panels.py:

class LeakCodeModal(discord.ui.Modal):
    def __init__(self, *, title: str) -> None:
        super().__init__(title="Leak Code")

main.py:

    async def on_ready(self):
        if not self.persistent_views_added:
            from cogs.panels import LeakCodeModal, StartMessageModal, FinalModal
            self.add_view(LeakCodeModal())
            self.add_view(StartMessageModal())
            self.add_view(FinalModal())
            self.persistent_views_added = True
edgy nest
warm linden
#

?

tidal vessel
warm linden
fickle salmon
#

@errant trout here's the whole method

from discord import Poll, PollMedia, PollAnswer
@commands.slash_command(guild_ids=[717808299675877406], name="poll")
async def poll(self, ctx, question: Option(str), option1: Option(str), option2: Option(str)):
    """Start a poll"""
    try:
        await ctx.response.defer()
    except:
        pass
    poll = Poll(question=PollMedia(question), answers=[PollAnswer(option1), PollAnswer(option2)], duration=1, allow_multiselect=False)
    print(poll.to_dict())
    await ctx.respond(poll=poll)```
#

I just checked and discord.__version__ prints 2.6.0

#
  File "/usr/local/lib/python3.11/site-packages/discord/commands/core.py", line 138, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/discord/commands/core.py", line 1078, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "/crewbot/cogs/misc.py", line 106, in poll
    await ctx.respond(poll=poll)
  File "/usr/local/lib/python3.11/site-packages/discord/interactions.py", line 618, in respond
    return await self.followup.send(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/discord/webhook/async_.py", line 1790, in send
    data = await adapter.execute_webhook(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/discord/webhook/async_.py", line 224, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message```
errant trout
#

hm, using the same code it worked on my end...

#

long shot, rename the command function?

fickle salmon
#

trying py-cord==2.6.0 real quick

#

still broken

#

rename doesn't work either

#

pycord supports python 3.12 right?

#

I just realized my dev container was still using 3.11

#

same error with 3.12

little cobalt
errant trout
#

idk i literally can't repro

#

what if you change the token

#

if you wanna dig through source, it's all handled here (just ctrl+f for poll)

#

maybe try sending it with content?

fickle salmon
#

weird

quiet siren
#

I'm having some issue with having selecting a news channel with a discord.TextChannel type in a command, I have it as

async def setchannel(ctx: discord.ApplicationContext, channel: discord.TextChannel):

bot can list other channels fine, but it seems that news channel are not accepted as a valid option there, is there another selector I have to use for that?

sage tendon
#

the type of option is handed to discord which then chooses what to display to you
i suppose they made it so you cant put news channels there

quiet siren
#

hm, that's certainly interesting

sage tendon
#

I have the same behaviour for my bot though, never noticed that

#

i never noticed my announce command which is supposed to announce stuff in announcement channels doesnt work in announcement channels

vague plaza
#

can I delete the bot's own messages simply by passing the message id?

sage tendon
#

await bot.get_message(<id>).delete()

#

wont work if its not cached, keep that in mind

#

so any messages sent before the bot started wont work using that

#

if you want to delete uncached messages its a bit more of a pain, since you need to store the channel ID too

vague plaza
#

its fine I'll store that

#

I want to delete uncached messages

sage tendon
#

yea then you can do

message = await bot.get_channel(<channel_id>).fetch_message(<message_id>)
await message.delete()
vague plaza
#

thanks, so what is delete_messages() used for then?

sage tendon
#

well, if you wanna delete more than one message in the same channel

#

but it needs a list of messages

vague plaza
#

but id still end up needing the whole
bot.get_channel(<channel_id>).fetch_message(<message_id>)

right?

sage tendon
little cobalt
#

keep in mind that get_x can be None

#

;3

sage tendon
#

i know zervy

little cobalt
#

not you

sage tendon
#

:>

little cobalt
#

other users dont now it

#

;3

sage tendon
#

but as long as the channel exists, get_channel shouldn't be None

vague plaza
vague plaza
little cobalt
sage tendon
#

yea you can pass a check function to purge where you can just do return message.author.id = <bot_id>

sage tendon
little cobalt
#

use both and check if its in the cache

sage tendon
#

I personally have never had get_channel fail as long as said channel exists
I'm not sure if pycord limits cache itself when the bot is in too many servers, but i doubt you'll ever have problems with it

vague plaza
sage tendon
#

Because you wanna send as few API requests as possible

#

API requests take time, and they also count towards the, well, API ratelimit

vague plaza
#

oh so get simply checks in the cache

sage tendon
#

yes

little cobalt
#

.get_x

sly karmaBOT
#

Any function that starts with get_ in Py-cord is retrieving the related object from your bots cache. If the object is not in the bots cache the get_ method will return None. Because of this behavior you should check if the get_x method is None and if it is use the fetch_x method.

Why Is Using fetch_ Without Using get_ First Bad?
The fetch_ method makes a call to the discord API. This API call is unneeded if you already have the information. It will also make your command take longer because it will have to send and than wait for a response from the discord API. It will also contribute to the discord APIs global rate limit of 50 requests per second.

What Is Cache?
The cache is a temporary storage inside your bot. It holds many objects from members to messages. When you restart your bot the cache will be empty. When the cache is full it will delete older objects to make space for the new objects.

sage tendon
#

get is instant, fetch needs an API call which can take ~300ms or so to come back

#

can add up a lot, plus ratelimit issues if you do it a lot

#

there's also discord.utils.get_or_fetch but i find it a bit weird personally

#

for completeness sake

vague plaza
#

good thanks, I just learnt something new. Whats the discord rate limit?

sage tendon
#

well, pycord handles that itself
and fetching stuff like channels should have quite a high one
dont worry about it

little cobalt
#

I do it like this

sage tendon
#

but still, use get whenever possible

vague plaza
#

Absolutely, I will

sage tendon
little cobalt
#

I try to get more and more into OOP

vague plaza
#

thanks, I think Ill stick to the original
try get
except fetch

#

no nvm im dumb I meant

sage tendon
#

get wont throw exceptions

#

:>

vague plaza
#

if get is none ill go for fetch

sage tendon
#

yes

vague plaza
#

wait so get_channel is not async?

#

didnt know that

sage tendon
#

no, because it only works on the cache which is in memory

#

its so fast that async is unnecessary

sage tendon
#

but news channels are TextChannel

errant trout
#

Discord does not agree

sage tendon
#

weird

#

i was gonna suggest that but i wasnt sure that was a valid option type

errant trout
#

We don't have a NewsChannel class because it serves little purpose, but it's its own type

sage tendon
#

plus it contains any channel, right?

errant trout
#

GuildChannel is any channel in the guild yes

sage tendon
#

so even categories?

errant trout
#

Probably

sage tendon
#

let us see

errant trout
#

Otherwise you can refine it with the channel_types param

#

Also lol #1226541894113431663 message

sage tendon
#

with discord.TextChannel as the main type too?

errant trout
#

Yeah

#

Main type can be any channel class if you use channel_types, it gets overridden anyway

sage tendon
#

does contain categories

#

interesting

#

never seen that before

#

but you cant make it list only announcement channels right?

errant trout
#

You can if you set channel_types

sage tendon
#

nvm found it

#

im dumb

#

oh i can even omit the input type

fickle salmon
errant trout
#

...what if you don't defer?

sage tendon
#

if i had to guess (uneducated guess!) you can't send a poll after deferring for some reason
that, or pycord bug with deferring and polls

fickle salmon
#

works without defer

errant trout
#

Deferred send works fine for me

#

Does your bot have permissions in the channel

fickle salmon
#

yes?

sage tendon
#

send us your code please i wanna test too

fickle salmon
#

the poll gets sent without defer

sage tendon
#

like the minimal breaking code

fickle salmon
#

with defer it says empty message

#

@sage tendon #1132206148309749830 message

sage tendon
#

lets see

errant trout
#

idk looking through the source there's zero reason for it to not work

fickle salmon
#

😄

sage tendon
#

option typehint spotted i hope you stub your toe

errant trout
#

Yoooo he's real for that

fickle salmon
#

I'm not rewriting a 2000 line bot just because you have an opinion

sage tendon
#

also, why ctx.response.defer

#

why not ctx.defer

fickle salmon
#

why not

sage tendon
#

shorter

fickle salmon
#

same thing

sage tendon
#

a defer can fail?

fickle salmon
#

yes

sage tendon
#

wtf

#

how?

errant trout
#

If you've already responded/deferred

sage tendon
#

but as the first line?

little cobalt
errant trout
#

It's possible they do processing somewhere else

#

Idk

echo wraith
#

How can I type hint a drop-down / drop-down values to say it is a str drop-down?

errant trout
#

Str dropdown is default

#

You don't need to do anything special there

echo wraith
#

That's not what I meant

fickle salmon
#

can you repro @sage tendon

errant trout
#

Then what

sage tendon
#

i can reproduce

errant trout
#

Wtf

fickle salmon
#

good

#

nelo couldn't

#

😄

sage tendon
#

im not getting any error

#

just an infinite defer

fickle salmon
#

then you can't?

#

uh

#

I get a stack trace

sage tendon
#

3 different results

fickle salmon
#

but yes infinite defer

sage tendon
#

amazing

echo wraith
#

If I access dropdown.values I want to type hint something in a way that it know it is a list of str | None

sage tendon
#

if i pass any content, it works

errant trout
#

then list[str | None]

fickle salmon
#

you get the poll and the content?

sage tendon
#

yes

fickle salmon
#

I just get the content

sage tendon
#

wiat im stupid

#

yes, same

#

yea i can reproduce, minus the error

fickle salmon
#

does your bot not log errors?

echo wraith
sage tendon
#

uhh

errant trout
#

Why

fickle salmon
#
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
    """ Send help message when a mis-entered command is received. """

    print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr)
    traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)```
little cobalt
#

command errors but what is for events?

sage tendon
#

i have an error handler that eats the error i think

fickle salmon
#

do this

#

you should get the same stack

sage tendon
#

its a listener, but it doesnt handle that type of error i think

echo wraith
#

I want to type hint m drop-down so that it's values are typed as list[str]

lapis torrent
#

Hey I'm doing some type checking on my project and getting weird type errors.

Code like guild = await bot.fetch_guild(GUILD_ID) is returning types.guild.Guild instead of discord.guild.Guild according to the pyre type checker. This is causing all sorts of weird type issues downstream. Seems to happen for other core classes like Messages, Interaction, etc. Any thoughts as to why?

lapis torrent
sage tendon
#

yea okay if i force the error to be printed, i get it too
404 @fickle salmon

little cobalt
fickle salmon
#

you mean 400?

sage tendon
#

1s i may be stupid

#

without defer it works fine btw

fickle salmon
#

yes

#

it does

sage tendon
#

yea 400 mb

fickle salmon
#

why can't nelo repro

sage tendon
#

nelo

#
@discord.slash_command()
    async def poll(self, ctx: discord.ApplicationContext):
        """Start a poll"""
        await ctx.defer()
        poll = discord.Poll(question=discord.PollMedia("question"),
                            answers=[discord.PollAnswer("option1"), discord.PollAnswer("option2")], duration=1,
                            allow_multiselect=False)
        print(poll.to_dict())
        try:
            await ctx.respond(poll=poll)
        except Exception as e:
            print(e)

This is my minimal code that throws the error

#

can you try exactly this code

errant trout
#

ok, can repro, but fully convinced this is a discord error

#

defer -> respond results in Interaction.followup.send - this is equivalent to Webhook.send
the weird thing is, regular webhooks can send polls

#

they use the exact same method for sending, yet only followup webhooks fail

#

I'll see if I can raise it with them, somehow...?

lofty parcel
#

Kek?

deft kestrel
#

is it possibile to create a command that only a user can see? like a guild command but just for a user

errant trout
rugged lodgeBOT
#

Here's the slash users example.

vague plaza
#

is therea bug within the pycord library? When I try to replace an image by using

message_to_edit.edit(content=post_caption, file=discord.File(post_bytes))

it just adds the new image without replacing the old one

sage tendon
#

try files=[discord.File...]

shell radish
#

to remove the current attachments

sage tendon
errant trout
sage tendon
#

i see

deft kestrel
errant trout
#

2.6 yes

deft kestrel
#

Version: 2.4.1

#

f

sage tendon
#

bruh

deft kestrel
sage tendon
#

update, test, and find out

#

unless you use bridge, not really

little cobalt
vague plaza
maiden bloom
shell radish
maiden bloom
#

Oh. I was told by someone in here that it used semantic versioning when v2.5 was released lol. I asked if there were breaking changes and they told me it was a minor release and I should learn semantic versioning. What's funny is I had a breaking change when moving to 2.5 lmao

shell radish
#

we try to avoid breaking changes but if discord changes something, then it's out of our control

maiden bloom
#

Anyway, I came to say when I searched "textchannel" in docs.pycord.dev it gave me a cloudflare error but not anymore so nvm guess it was a glitch

sage tendon
shell radish
stoic patio
#

discord bot cached_message attribute takes up memory right

stoic patio
#

good to know

#

no wonder why my bot memory just goes ⬆️

mellow pebble
#

well for the options in a slash command how to not make it compulsory, like let's say i have a emote cmd to wish good morning, how do i make it such that it can do it without adding a user as a parameter, it works with user apps but not in server where the bot is

    async def goodmorning(self, ctx: discord.ApplicationContext, user: discord.User = None):
        gif = await get_gif("anime_goodmorning")

        if user == None:
            embed = discord.Embed(
                title=f"{ctx.author.display_name} Wishes Goodmorning",
                color=0x2F3136,
            )

            embed.set_image(url=gif)
            await ctx.respond(embed=embed)

        if user != None:
            embed = discord.Embed(
                title=f"{ctx.author.display_name} Wished {user.display_name} A Goodmorning",
                color=0x2F3136,
            )

            embed.set_image(url=gif)
            await ctx.respond(embed=embed)
torpid umbra
#

i want to take a mp3 file as input from the user , how can I do that?

rugged lodgeBOT
#

Here's the slash options example.

echo wraith
torpid umbra
torpid umbra
torpid umbra
#

working fine with images

sage tendon
#

show your code

torpid umbra
torpid umbra
sage tendon
#

any error?

torpid umbra
#
Traceback (most recent call last):
  File "C:\Users\praff\PycharmProjects\AutomatedScreening\.venv\lib\site-packages\discord\commands\core.py", line 138, in wrapped
    ret = await coro(arg)
  File "C:\Users\praff\PycharmProjects\AutomatedScreening\.venv\lib\site-packages\discord\commands\core.py", line 1082, in _invoke
    await self.callback(ctx, **kwargs)
  File "C:\Users\praff\PycharmProjects\AutomatedScreening\core\platforms\discord\client.py", line 127, in say
    await ctx.respond("Here's your file!")
  File "C:\Users\praff\PycharmProjects\AutomatedScreening\.venv\lib\site-packages\discord\interactions.py", line 616, in respond
    return await self.response.send_message(*args, **kwargs)
  File "C:\Users\praff\PycharmProjects\AutomatedScreening\.venv\lib\site-packages\discord\interactions.py", line 957, in send_message
    await self._locked_response(
  File "C:\Users\praff\PycharmProjects\AutomatedScreening\.venv\lib\site-packages\discord\interactions.py", line 1288, in _locked_response
    await coro
  File "C:\Users\praff\PycharmProjects\AutomatedScreening\.venv\lib\site-packages\discord\webhook\async_.py", line 222, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction```
sage tendon
#

add await ctx.defer() as first line of the command

#

your internet is too slow to upload the file in time i guess

torpid umbra
# sage tendon your internet is too slow to upload the file in time i guess
        @self.slash_command(name="attach_file")
        @option(
            "attachment",
            Attachment,
            description="A file to attach to the message",
            required=True,  # The default value will be None if the user doesn't provide a file.
        )
        async def say(
                ctx: ApplicationContext,
                attachment: Attachment,
        ):
            """This demonstrates how to attach a file with a slash command."""
            await ctx.defer()
            if attachment:
                file = await attachment.to_file()
                self.process_audio(file.fp)
                await ctx.respond("You will recieve the response in your dm. Please keep the permission to get Dm open")
            else:
                await ctx.respond("You didn't give me a file to reply with! :sob:")

this is the code and I've a pretty decent internet

sage tendon
#

self.slash_command
what

little cobalt
#

lol

torpid umbra
#

I'm inheritingg it to create a client

sage tendon
#

You shouldn't get a 404 with that code

torpid umbra
#

class DiscordClient(Bot):

sage tendon
#

unless you take 15+ minutes to respond

#

also, your else will never be reached lol

torpid umbra
#

it reponse 404 in 15 secs 😅

torpid umbra
sage tendon
#

required is true by default, you dont have to specify that btw

torpid umbra
#

first I want to make it work , optimisation can be done later

sage tendon
#

oh, i see now

#

i think
File "C:\Users\praff\PycharmProjects\AutomatedScreening\core\platforms\discord\client.py", line 127, in say
await ctx.respond("Here's your file!")

#

this is the issue, however that gets called when you run that command

#

unless im missing smth

#

what even is that file path

sage tendon
torpid umbra
deft kestrel
#

is it possible to map every command name and description?

errant trout
#

Like, load them from a file or something?

deft kestrel
#

no
for example:

for command in bot.all_commands:
  print(command.name, command.description)
errant trout
#

Oh

#

Did that not already work for you?

deft kestrel
#

i am asking because when i printed bot.all_commands i didnt see description

errant trout
#

Uhh it'll still be on the command object

sage tendon
#

cant you use the walk_commands thing

deft kestrel
fresh sierra
#

since ur using slash

deft kestrel
vital bramble
#

What is the rate limit for channel creation in a guild? And what channel types are affected by this?

sage tendon
#

i only know channel renames, which is 1 rename per 10 minutes per channel
i think channel creation will have a relatively low ratelimit as well

#

id honestly just try to run into it deliberately but thats up to you lol

errant trout
#

honestly no clue, it just let me create 100 channels in 13 seconds

sage tendon
#

o.o

errant trout
#

(50 each on 2 bots)

deft kestrel
#

@bot.slash_command( contexts={discord.InteractionContextType.private_channel}, integration_types={discord.IntegrationType.user_install}, )
what if i want that command in a DM with a bot?

#

i mean what's the context name

errant trout
#

private_channel is correct

deft kestrel
errant trout
#

?

deft kestrel
#

i see only that but

errant trout
#

eh, bot_dm?

sage tendon
#

private_channel is correct

#

restart discord after changing anything like that about a command

#

Just realised it's kinda difficult to even get into a user app's DMs, like you have to use a command to do so

dense summit
#

Hey there, what's the limit of options in slash commands?

little cobalt
#

But why do you ask?

dense summit
# little cobalt But why do you ask?

I have a command that should rotate images by a specified number of degrees, so i want to know what's the limit of images i can pass in a slash command

sage tendon
#

wouldnt a single option that can handle a zip file be preferable

dense summit
sage tendon
#

why do you want to rotate so many images

dense summit
vital bramble
sage tendon
#

holy shit

#

thats a lot

vital bramble
#

yeah, I guess bots that are in multiple guilds have lower limits...

sage tendon
#

no lol

vital bramble
#

hm...

#

well that's what it said for me xD

sage tendon
#

what
screenshot

vital bramble
#

oh so it's 2000/day

sage tendon
vital bramble
#

doesn't it?
I thought x-ratelimit-remaining says that?

#

or limit

sage tendon
#

thats.. how many channels you can still create

#

lol

vital bramble
#

yeah during 24 hours...

#

right?

sage tendon
#

yea

vital bramble
#

that's exactly what I was saying lol

sage tendon
#

you said bots in more guilds have smaller ratelimits

vital bramble
#

oh that was just an assumption...

#

oh I read your message wrong... thought you responded to the other.

quartz umbra
#

Hello. How can I create a private text channel, which only 1 role, and 2 members can view the channel? I think you use the overwrites argument in Guild.create_text_channel, but my question is how to get the @everyone role so i can set the view channel permission to null

#

does index 0 of guild.roles return this?

#

nvm found Guild.default_role

echo wraith
#

What is @timid shuttle

errant trout
#

just a bot

edgy nest
errant trout
#

:9

sacred gale
#

I have a string I am using in an embed

#

but the output returns this instead of pinging someone with the @ like @sacred gale

#

how to make it ping someone

rancid arrow
fresh sierra
#

just remove the test

#

`

sacred gale
#

?

#

oh its supposed to be f"Buyer: `<@{self.buyer}>`

rancid arrow
#

Remove the backticks

#

`

sacred gale
#

it works, thanks guys

rancid arrow
#

As a side note since it’s an an embed they won’t be notified

sacred gale
#

oh

#

thats fine

#

but is there any way to do it like this and ping them or no?

rancid arrow
#

No since it turns it into raw text

#

Joey come on

sacred gale
#

man

rancid arrow
#

I don’t think he recognized me

sacred gale
#

no no i did

#

kinda crazy we found each other here at this time

rancid arrow
#

No I’ve been here for ages I like looking at the questions for fun

sacred gale
#

someone give this man helper role

little cobalt
#

lol

hazy turret
#

Hello everyone!

What options do I have to embed a video on Discord so that another user cannot download it?
If I send the video directly to the channel, I can't disable the download of the video, can I?

echo wraith
vague plaza
#

how can I send an album of images (or a mix of images and videos) in a single message?

mossy violet
vague plaza
#

is that something that works for sure or is that something youre suggesting to try

mossy violet
#
async def send_album(ctx)
  file_list = [
    discord.File("path/to/...")
    discord.File("path/to/...")
  ]

await ctx.send(content="message", files=file_list)```
#

I've not tested it personally, no, but i see nothing wrong with it?

oblique sable
#

did i type it incorrectly or?

echo wraith
#

yes

red mist
#

I'm confused about your type hinting...

#

Yea

#

Internet not loading my messages

oblique sable
#

thanks

#

thats better

red mist
#

is your respond now yellow too? ;3

oblique sable
echo wraith
oblique sable
#

should be good now

red mist
#

Huh I mean yeah but interesting that it's blue 😂

hazy turret
fresh sierra
red mist
#

I use application myself and it's yellow 💀

sage tendon
#

it depends on your theme...

echo wraith
#

Sorry for your eyes

sage tendon
#

bro

#

return as the last statement in a command is wild

lofty parcel
#

Why white mode

echo wraith
echo wraith
#

drunl

#

drunk

sage tendon
#

also idk about yall but i hate this style of

functioncall(
    args, kwargs, owo
)
#

it just looks weird imo

#

like at least for shorter calls

echo wraith
#

because thinking uses your brain

#

and using your brain makes your brain age

#

and so you die faster

sage tendon
#

black?

echo wraith
sage tendon
#

depends?

#

also yea idk i just use the default whatever thingy, "reformat file" on save and thats it

echo wraith
#

I cant always decide

#

and I try to use new things too so I change sometimes

fresh sierra
sage tendon
#

it depends on your IDE theme.

#

nothing else.

echo wraith
hazy turret
#

Why does the whole thing not work although the file parameter is specified in the docs under create_thread?

video_file = await video.to_file()
thread = await channel.create_thread(name=title, content=message, file=video_file)

Error:

400 Bad Request (error code: 50008): Cannot send messages in a non-text channel```
sage tendon
#

your channel is not a text channel

hazy turret
sage tendon
#

print the channel name first to ensure its correct

hazy turret
sage tendon
#

well, then i dont know

tidal vessel
#

One question, does the bot attribute of the User object also work for other Bots? I want to check if a message is sent by a Bot

sage tendon
#

yes

tidal vessel
#

ok ty

hazy turret
# sage tendon well, then i dont know
    @commands.slash_command(
        name="create_video_thread",
        description="create_video_thread",
    )
    @option(
        "channel",
        description="Forum Channell",
        type=discord.ForumChannel,
    )
    @option("title", description="Titel ")
    @option("message", description="Message")
    @option(
        "video",
        description="Video",
        type=discord.Attachment,
    )
    async def create_video_thread(
        self,
        ctx: discord.ApplicationContext,
        channel: discord.ForumChannel,
        title: str,
        message: str,
        video: discord.Attachment,
    ):

        try:
            await ctx.defer(ephemeral=True)

            if not isinstance(channel, discord.ForumChannel):
                await ctx.respond(
                    "No forum Channel", ephemeral=True
                )
                return

            video_file = await video.to_file()
            channel_type = channel.type
            print(channel_type) # Gives me forum

            thread = await channel.create_thread(
                name=title, content=message, file=video_file )```
haughty grove
#
Ignoring exception in on_connect
Traceback (most recent call last):
  File "C:\Users\luca\PycharmProjects\***\.venv\lib\site-packages\discord\client.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\luca\PycharmProjects\***\heart\bot.py", line 63, in on_connect
    await self.sync_commands(delete_existing=False)
  File "C:\Users\luca\PycharmProjects\***\.venv\lib\site-packages\discord\bot.py", line 742, in sync_commands
    registered_commands = await self.register_commands(
  File "C:\Users\luca\PycharmProjects\***\.venv\lib\site-packages\discord\bot.py", line 595, in register_commands
    data = [cmd["command"].to_dict() for cmd in filtered_deleted]
  File "C:\Users\luca\PycharmProjects\***\.venv\lib\site-packages\discord\bot.py", line 595, in <listcomp>
    data = [cmd["command"].to_dict() for cmd in filtered_deleted]
AttributeError: 'Command' object has no attribute 'to_dict'```

i cant figure out why this error occurs, any ideas?
fresh sierra
sage tendon
#

for me its always the same color

fresh sierra
#

For you

#

I was talking for me

sage tendon
sage tendon
restive sundial
#

I am trying to read the docs and I am confused, how do you actually create application commands?

sage tendon
#
# in a cog
@discord.slash_command()
async def name(...)

# without cogs
@bot.slash_command()
async def name(...)
restive sundial
sage tendon
#

show your code

restive sundial
sage tendon
#

show your pip list

#

also whats that class from lol, and why

restive sundial
#

oh

#

I installed pycord

#

and not py-cord

sage tendon
#

because the import worked

haughty grove
#
aiocache==0.12.2
aiohttp==3.9.5
aiosignal==1.3.1
async-timeout==4.0.3
attrs==23.2.0
brawlstats==4.1.1
cachetools==5.3.3
certifi==2024.2.2
charset-normalizer==3.3.2
dnspython==2.6.1
frozenlist==1.4.1
geographiclib==2.0
geopy==2.4.1
idna==3.7
motor==3.5.1
multidict==6.0.5
pillow==10.3.0
py-cord @ git+https://github.com/Pycord-Development/pycord@5ad95dc1dd8db8bd1b674c184cd032c5d1bbbb07
pymongo==4.7.1
python-box==7.1.1
python-dotenv==1.0.1
requests==2.31.0
typing_extensions==4.11.0
urllib3==2.2.1
yarl==1.9.4

ive tried 2.6.0 too

haughty grove
sage tendon
#

why are you using a git version and not 2.6

haughty grove
#

cus i was testing out user apps

#

and forgot to change it back

#

but yeah i will use 2.6

#

i still have the problem tho

errant trout
#
def load_module(module_name):
    module = __import__(module_name, fromlist=[''])
    loaded_modules.append({'name': module_name.split('.')[-1], 'help_text': module.help_text})
    module.setup(bot)

# Load all modules
module_dir = 'modules'
for filename in os.listdir(module_dir):
    if filename.endswith('.py'):
        module_name = filename[:-3]
        load_module(f'{module_dir}.{module_name}')
```are these meant to be cogs?
sage tendon
#

you didnt just reinstall py-cord @ 2.6 in about .5 seconds

haughty grove
sage tendon
#

test it again

#

if it's magically solved now we'd be poking at nothing

errant trout
#

the version is completely unrelated

#

they have some weird module loading that isn't relevant to this library

restive sundial
#

I get no errors, the cog loads but unlike the help command from the main file this command doesn't register

import discord
from discord.ext import commands
import aiohttp
import os

help_text = """
`/image [image]` - Sends an image if you don't have image perms
"""

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

    @discord.slash_command(name="image", description="Send an image if you don't have image perms")
    async def image(self, ctx: discord.ApplicationContext, image: discord.Attachment):
        temp_file_path = "temp_image.png"  # Temporary file path to save the image

        async with aiohttp.ClientSession() as session:
            async with session.get(image.url) as response:
                if response.status == 200:
                    with open(temp_file_path, 'wb') as f:
                        f.write(await response.read())
                else:
                    await ctx.respond(f"Failed to download image: {response.status}")
                    return

        try:
            await ctx.respond(file=discord.File(temp_file_path, spoiler=image.is_spoiler()))
        except OSError as e:
            await ctx.respond(f"Failed to send image: {e}")
            raise
        finally:
            os.remove(temp_file_path)  # Clean up the temporary file
def setup(bot):
    bot.add_cog(ImageEverywhere(bot))
sage tendon
#

nelo i think you're mixing the 2 people up rn

restive sundial
#

what could be the issue here

errant trout
#

oh that's whack

sage tendon
#

also... you dont have to download the entire file just to upload it again lol

restive sundial
sage tendon
#

also whats the point of not giving people image perms if you're gonna give them a bot to send images

restive sundial
#

also still can't use it everywhere, did I miss something crucial?

sage tendon
#

okay first of all, what do you mean "everywhere"

errant trout
#

...disnake does have application commands

restive sundial
sage tendon
#

all bots are apps

restive sundial
#

when you add it you can use the commands everywhere exernal apps are allowed

errant trout
#

user apps? you never set a context

rugged lodgeBOT
#

Here's the slash users example.

sage tendon
#

thats a user app
and you need to make your bot user installable and install it on your account

#

its on by default for new bots though

#

Also I'm not quite sure right now but if you lack permission to send images, can you actually bypass that like that?

errant trout
#

like what

sage tendon
#

like they did

#

with a user app command

errant trout
#

no clue, but typically Attachment option doesn't work without channel permissions

sage tendon
#

My guess is it'd be forced to be ephemeral

fresh sierra
#

To send message without perm with a bot u can pass them inside an embed if it’s picture

sage tendon
#

lets try

#

You can already abandon that command again :)

haughty grove
sage tendon
#

do you still run into the same issue on 2.6?

restive sundial
#

well, no free image perms for me

sage tendon
#

i mean which server doesnt have image perms

#

but "use external app" perms

hazy turret
sage tendon
#

ah
yea then i truly dont know

ebon swift
#

does anyone have a link to an exemple/in the doc of how I could make a slash command that will display a color picker so my user can choose a color ?

sage tendon
#

doesnt exist

#

you'll have to make that some other way, usually you just give them color choices that have the actual hex codes as values

ebon swift
#

or I could make them input the hex color directly 🤔

#

thank you

sage tendon
#

well, yea lol

#

but thats not really a color picker then

ebon swift
#

you're right but the most important thing for me is that my user can input precise colors

sage tendon
#

yea i'm not sure right now but i think if you put discord.Color as input type it should convert the hex color to a discord.Color
but i dont do stuff with color often, could be wrong

ebon swift
#

thank you I'll see

loud kayak
#

Haven't used Pycord or VS Code in a while, why am I getting this IDE error?

sage tendon
#

pylance is sensitive

#

and you should use the decorator because that way is.. messy

loud kayak
#

its how ive always done it and seems clean to me

#

do i just ignore the ide warning?

shell radish
#

you can make pylance ignore those warnings with some setting thing

sage tendon
loud kayak
#

idk how

sage tendon
#

also do you not put descriptions or anything lol

loud kayak
#

never used the decorator side of things besides making commands and checks

sage tendon
#

its the exact same args

loud kayak
sage tendon
#

name, type are positionals

#

but no description :)

sage tendon
#

here, an example command of mine with quite a few options

#

but yea the reason you get that warning is that i think it's not really intended to use function calls in place of typehints
i mean it works yes but its kinda hacky i think

sage tendon
# loud kayak

also reading this text... choices can be attachments?

#

gotta test that tomorrow

sage tendon
#

very much same

#

big if true

red mist
quartz umbra
#

How can I set the thumbnail of an embed to a local file? Btw, this is in a cog. This is my project structure:

.
├── LICENSE.txt
├── README.md
├── __init__.py
├── __pycache__
│   ├── drawer.cpython-311.pyc
│   ├── firebase_helper.cpython-311.pyc
│   └── helper.cpython-311.pyc
├── assets
│   ├── JosefinSans.ttf
│   ├── __pycache__
│   │   └── drawer.cpython-311.pyc
│   ├── axe_icon.png
│   ├── crystal_icon.png
│   ├── dia_pot_icon.png
│   ├── drawer.py
│   ├── leaderboard.png
│   ├── neth_pot_icon.png
│   ├── smp_icon.png
│   ├── sword_icon.png
│   └── uhc_icon.png
├── cogs
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-311.pyc
│   │   ├── config_cog.cpython-311.pyc
│   │   ├── info_cog.cpython-311.pyc
│   │   ├── ranks_cog.cpython-311.pyc
│   │   ├── stats_cog.cpython-311.pyc
│   │   └── ticketing_cog.cpython-311.pyc
│   ├── config_cog.py
│   ├── info_cog.py
│   ├── ranks_cog.py
│   ├── stats_cog.py
│   └── ticketing_cog.py
├── config.json
├── database.db
├── helpers
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-311.pyc
│   │   ├── config_helper.cpython-311.pyc
│   │   └── firebase_helper.cpython-311.pyc
│   ├── config_helper.py
│   └── firebase_helper.py
├── main.py
├── requirements.txt
└── service_account.json

8 directories, 40 files
shell radish
#

mmm minecraft

sly karmaBOT
#
f = discord.File("some_file_path", filename="image.png")
e = discord.Embed()
e.set_image(url="attachment://image.png")
await messagable.send(file=f, embed=e)```
shell radish
#

where (what file/cog) are you trying to add the file to the embed

quartz umbra
errant trout
#

as long as you don't start the path with a /, it'll act relative to your bot's main file

#

so e.g. use assets/crystal_icon.png with the example the bot shows above

quartz umbra
errant trout
#

mhm

quartz umbra
#

alright, lemme give that a shot, thanks

sage tendon
#

wait can you do chaining with embed stuff? like .set_image().set...

errant trout
#

yeah

#

embeds and polls, someone also requested it for views so maybe it can slip into 2.7

sage tendon
#

neat

#

but python doesn't support it if you do it in new lines right

errant trout
#

it works with brackets

sage tendon
#

like I saw in some java code

this.that()
.andthat()
.andthose()

errant trout
#

not as neat as other languages, but it's possible