#Basic Pycord Help

1 messages · Page 31 of 1

vestal folio
#

3 commands werden geladen

#

häh

#

ja alle 3 da

#

wobei ich ganz nebenbei nen bug gefunden hab nett

sage tendon
#

bezweifle ich ganz stark

vestal folio
#

was es in pycord net gibt

errant trout
#

avatar.url

#

avatar_url is old

vestal folio
frail ocean
#

was ist da ein bug

vestal folio
#

ist nur von der anderen lib die ich voher verwendet hab

vestal folio
sage tendon
#

ach bug bei dir? ja das glaub ich schon eher

vestal folio
#

jezt gehts wieder

#

ohne debug guild

#

kurios

vestal folio
#

scheint tarzächlich das importieren gewesen zu sein

#

aber nun werden die global geladen

#

die befehle

#

ist ungünstig für mich wenn ich dauernd sachen hinzufüge

frail ocean
vestal folio
#

ich habs auch geändert geht wieder

frail ocean
#

dann ist das kein bug lol

vestal folio
#

äääääääääääh

#

seltsam

sage tendon
#

hat doch funktioniert, dann las auch die finger davon

vestal folio
vestal folio
#

da bin ich mir sicher

little cobalt
frail ocean
vestal folio
#
prefix = "t."
bot = commands.Bot(command_prefix=prefix, intents=discord.Intents.all(), debug_guilds=[917174972588392499])```
vestal folio
sage tendon
#

ganz gruselig

errant trout
#

didn't they get ratelimited

#

or is it a new id

frail ocean
sage tendon
vestal folio
errant trout
vestal folio
errant trout
#

ja

vestal folio
#

das könnte sein

#

dann mache ich morgen weiter kann mich eh nicht mehr konzentrieren

sage tendon
#

hab ich zwar schon alles mal gesagt aber shrug

civic quiver
#
class verifyconfigmodal(discord.ui.Modal):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
        
        self.add_item(discord.ui.InputText(label="Verification Question 1:",  placeholder="ex. How old are you?"))
        self.add_item(discord.ui.InputText(label="Verification Question 2:"))
        self.add_item(discord.ui.InputText(label="Verification Question 3:"))
        self.add_item(discord.ui.InputText(label="Verification Question 4:"))

        self.add_item(discord.ui.InputText(label="Verification Confirmation Channel:",  placeholder="Discord Channel ID Here..."))
        
        channel = bot.get_channel(self.children[4].value)

        question1 = self.children[0].value
        question2 = self.children[1].value
        question3 = self.children[2].value
        question4 = self.children[3].value

        async def callback(self, interaction: discord.Interaction):
            await interaction.followup.send_message("Verification finished! Use /verifyconfig to edit!", ephemeral=True)
@bot.slash_command()
async def verifyconfig(ctx: discord.ApplicationContext):
    
    modal = verifyconfigmodal(title="Set verification parameters here:")
    await ctx.send_modal(modal)

There is no error message, and the modal says "something went wrong" when I try to submit

#

Is there something im missing?

#

Last time I encountered this problem, it was because an interaction message wasnt being sent

#

but this one is

shell radish
#

async def interaction should be in-line with def __init__

#

not inside

civic quiver
#

ohhh

#

thanks

civic quiver
#
class verifyconfigmodal(discord.ui.Modal):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
        
        self.add_item(discord.ui.InputText(label="Verification Question 1:",  placeholder="ex. How old are you?"))
        self.add_item(discord.ui.InputText(label="Verification Question 2:"))
        self.add_item(discord.ui.InputText(label="Verification Question 3:"))
        self.add_item(discord.ui.InputText(label="Verification Question 4:"))

        self.add_item(discord.ui.InputText(label="Verification Confirmation Channel:",  placeholder="Discord Channel ID Here..."))
        
        channel = bot.get_channel(self.children[4].value)


    async def callback(self, interaction: discord.Interaction):
        await interaction.response.send_message("Verification finished! Use /verifyconfig to edit!", ephemeral=True)
class MyModal(discord.ui.Modal):
    def __init__(self, verifyconfigmodal, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)


        self.add_item(discord.ui.InputText(label=verifyconfigmodal.children[0].label, placeholder="ex. coolEp1cGamer69"))
        self.add_item(discord.ui.InputText(label=verifyconfigmodal.children[1].label))
        self.add_item(discord.ui.InputText(label=verifyconfigmodal.children[2].label))
        self.add_item(discord.ui.InputText(label=verifyconfigmodal.children[3].label))

How can I assign the child values from the first class to the second one

civic quiver
#

I want to get the value of the input text in verfiyconfig and put that value as the label of the MyModal input texts

shell radish
civic quiver
#

a command is called and a modal shows, it has a couple input fields which when filled in and submitted, will be the labels of the input fields in a separate model, opened by a button.

deft kestrel
#

What is this called the options parameter

#

in pycord

#

i saw this on another bot

#

and i want to know how to do this

#

where in the documentation shows how to make the options parameter

shell radish
deft kestrel
#

thank you

shell radish
#

yw

elder girder
#

Is this a bug or am I doing something wrong? I'm sending a webhook message and I'm setting the wait parameter as true to retrieve the WebhookMessage. But it appears that the data is lost.

Code snippet:

msg = await webhook.send(content, file=file, wait=True, username=f"@{acc.username}", avatar_url=img_url(acc.profile_image, resolution=180, crop_square=True))
print(msg.__dict__, type(msg))

Prints:

{} <class 'discord.webhook.async_.WebhookMessage'>  # WebhookMessage appears empty

When I print out the webhook data inside the Webhook.send() function, it has the data but it appears to be lost when creating the WebhookMessage object.

Inside the Webhook.send() function:

msg = None
if wait:
    print("data:", data)
    msg = self._create_message(data)
    print("\n__dict__:", msg.__dict__)

Prints:

data: {'id': '-----', 'type': 0, 'content': '"Placeholder Text" — via [RecNet](<https://rec.net/image/591913468>) — [@SleepySeal9376](<https://rec.net/user/SleepySeal9376>) — <t:1712992314:R>', 'channel_id': '-----', 'author': {'id': '-----', 'username': '@SleepySeal9376', 'avatar': None, 'discriminator': '0000', 'public_flags': 0, 'flags': 0, 'bot': True, 'global_name': None, 'clan': None}.....(shortened)

__dict__: {}
#

The webhook message is sent successfully.

#

Pycord version is 2.5.1.dev19+g59b9b32b (master branch), Python version is 3.10.11.

sage tendon
#

any particular reason for using the dev branch?

rapid jackal
#

When I have a slash command with a option and the option has choices, is it possible that the user can't type something other than the choices? Like that the choices are only some examples what the user can type?

fresh sierra
#

but i think with autocomplete its possible

little cobalt
#

autocomplete dont really got a limit and it can get changed every time

lone hound
#

what does the delete_messages_seconds and the delete_messages_days parameters in the member.ban() function means?

errant trout
lone hound
lapis dock
#

If that apears to fix the issue please tell me and I will try and craft a PR

elder girder
elder girder
lapis dock
errant trout
#

is there any particular reason you're using __dict__...?

#

we don't really keep raw data on models

echo wraith
#

Heyy, quick questions: are polls messages types supported in pycord v2.5? F. ex. for viewing a poll's fieldsfor moderation?

elder girder
#

Unless those attributes are meant to be accessed via WebhookMessage too..? It does return the WebhookMessage like intended.

errant trout
#

Do the attributes actually not work when you access them

elder girder
#

WHAT

#

they do now

#

idk what happened earlier

elder girder
#

my bad y'all

errant trout
#

Allgood

echo wraith
#

I'll wait that's ok

errant trout
#

There's an open PR for polls if you wanna use that

#

Just note stuff is subject to change

#

Should be fully finished on discord's end next week

echo wraith
errant trout
#

If you ONLY need it for moderation, you can slightly modify message.py to add a poll attribute

echo wraith
#

it's just that I didn't find anything about that in discord's own docs as well, altough I might have missed it

errant trout
#

It's because discord's still working on it

#

So not merged, but they also have a pr

echo wraith
misty sandal
#

Is there a way to develop activities with py-cord?

lofty parcel
lapis dock
misty sandal
#

Are polls already availble?

sage tendon
#

not on stable, no

#

dev branch i think

lapis dock
# misty sandal Are polls already availble?

Like toothy said it is only avalible on a incomplete PR. Everything should work but discord is still making changes on their side so things could break at any time as of now.

frail laurel
#

So I've heard that creating a dictionary for decisions that are booleans with user_ids is a good idea.
I acknowledge the fact that those variables are temp and last only while the session is active but not sure what to do when bot is 24/7.

# I CREATED A SELECT MENU BY SLASH COMMAND, AND AFTER USER DECIDES TO NOT SPECIFY A REASON OF X, THE APPLICATION LISTENS FOR AN INPUT THAT IS A NEXT MESSAGE USER SENDS
[...]
  discord.SelectOption(
      emoji="🔗",
      label="None of the above",
      description="You'll need to give us a reason"
  ),
])
user_states = {}

async def select_reason(self, select, interaction):
    match select.values[0]:
        case "None of the above":
          user_states[interaction.author.id] = True

@self.bot.event
async def on_message(message: Message):
    if message.author == bot.user:
        return

    if user_states.get(message.author.id):  
        user_states[message.author.id] = False  
errant trout
#

save it elsewhere

#

also it might make more sense to take the user input through a modal

sage tendon
#

what even is that typehint in the if lol

frail laurel
#

better than listening for inputs, and making some conditionals

sage tendon
#

it makes no sense

keen relic
#

Ignoring exception in on_connect
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/discord/client.py", line 400, in _run_event
await coro(*args, **kwargs)
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 1178, in on_connect
await self.sync_commands()
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 735, in sync_commands
registered_commands = await self.register_commands(
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 534, in register_commands
desynced = await self.get_desynced_commands(
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 357, in get_desynced_commands
elif _check_command(cmd, match):
File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 272, in _check_command
as_dict = cmd.to_dict()
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 875, in to_dict
"options": [o.to_dict() for o in self.options],
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 875, in <listcomp>
"options": [o.to_dict() for o in self.options],
File "/home/container/.local/lib/python3.10/site-packages/discord/commands/options.py", line 337, in to_dict
"type": self.input_type.value,
AttributeError: 'NoneType' object has no attribute 'value'

sage tendon
#

read the last line of the error

keen relic
# sage tendon read the last line of the error
from dotenv import load_dotenv
import discord 
from discord.ext import bridge
from mod import * 

# Define the ID of the guild where the bot should work
TARGET_GUILD_ID = 1124466493204205689

intents = discord.Intents.all()
custom_activity = discord.CustomActivity(name="𝓤𝓷𝓲𝓽𝓮𝓘𝓷𝓭𝓲𝓪 𝓗𝓪𝓾𝓵𝓮𝓻𝓼 𝓑𝓸𝓽🚛")

bot = bridge.Bot(command_prefix='!', intents=intents, activity=custom_activity, status=discord.Status.dnd)

@bot.event
async def on_ready():
    print("Bot is online")
    print(f"Bot name: {bot.user.name}\n")

    for command in bot.commands:
        print(command.name)

    # Check if the bot is in the target guild
    guild = discord.utils.get(bot.guilds, id=TARGET_GUILD_ID)
    
    print(f"Connected to target guild: {guild.name}")
    
# Get Discord bot token from environment variables
load_dotenv()
DISCORD_TOKEN = os.getenv('DISCORD_TOKEN')
bot.add_bridge_command(banned)
bot.add_bridge_command(unban)
bot.add_bridge_command(ban)

bot.run(DISCORD_TOKEN)
``` see this
fresh sierra
#

cos of bridge

errant trout
keen relic
#

=

errant trout
keen relic
errant trout
#

then remove self

keen relic
#

ok

errant trout
#

(also tbh why not just make this a cog)

keen relic
fresh sierra
#

is there a way in the name_localization to choose if it depend on the user_locale or guild_locale ?

sage tendon
#

it depends on the client's locale because that makes way more sense

#

and no, you cant change it

fresh sierra
#

so its always about user_locale ok

#

is there a way to do that ?

class XP_Setup_View(discord.ui.View):
    def __init__(self, bot, translator, author_id):
        super().__init__(disable_on_timeout=False)
        self.bot: commands.AutoShardedBot = bot
        self.author_id = author_id    
        dropdown = discord.ui.Select(
            placeholder=self.translator.xp.setup.panel.dropdown.placeholder,
            options=[
                discord.SelectOption(label=translator.xp.setup.panel.dropdown.mode.label, value="mode", emoji="🌐", description=translator.xp.setup.panel.dropdown.mode.description),
            ]
        )
        dropdown.callback = self.dropdown_callback
        self.add_item(dropdown)

    async def dropdown_callback(self, interaction: discord.Interaction):
        if interaction.user.id != self.author_id:
            return await interaction.response.send_message(translator.error.no_author, ephemeral=True)

(the translator i pass into the view can be used everywhere without having to do self.translator ?

sage tendon
#

Depending on the structure of your bot, if you have all the views in one file, you should just be able to put it into that file

#

or you import it from wherever you have that
depending what translator even really is

fresh sierra
#

like put in the class and access without self

#

but that not a big deal whatever

sage tendon
#

i mean why lol

#

yea

vestal folio
#
changelog_embed = discord.Embed(title="Changelog von Planetbot V1.0.0 vom 27.01.24")
changelog_embed.add_field(name="🟢",value="/gutenmorgen",inline=True)
changelog_embed.add_field(name="🟢",value="/gutenacht",inline=True)
changelog_embed.add_field(name="🟢",value="/hello",inline=True)
changelog_embed.add_field(name="🟢",value="/countdown",inline=True)
changelog_embed.add_field(name="🟢",value="/cat",inline=True)
changelog_embed.add_field(name="🟢",value="/hype",inline=True)
changelog_embed.add_field(name="🟢",value="/roll",inline=True)
changelog_embed.add_field(name="🟢",value="/coinflip",inline=True)
changelog_embed.add_field(name="🟢",value="/iq",inline=True)
changelog_embed.add_field(name="🟢",value="/say",inline=True)
changelog_embed.add_field(name="🟢",value="/everyone",inline=True)
changelog_embed.add_field(name="🟢",value="/i_love_trains",inline=True)
changelog_embed.add_field(name="🟢",value="/hack",inline=True)
changelog_embed.add_field(name="🟢",value="/eightball",inline=True)
changelog_embed.add_field(name="🟢",value="/bob",inline=True)
changelog_embed.add_field(name="🟢",value="/entwickler",inline=True)
changelog_embed.add_field(name="🟢",value="/userinfo",inline=True)
changelog_embed.add_field(name="🟢",value="/botinfo",inline=True)
changelog_embed.add_field(name="🟢",value="/serverinfo",inline=True)
changelog_embed.add_field(name="🟢",value="/avatar",inline=True)
changelog_embed.add_field(name="🟢",value="/servericon",inline=True)
changelog_embed.add_field(name="Legende:",value="Hinzugefügt:🟢, Entfernt:🔴, Änderungen:🛠️\n",inline=False)```
#

das wird das größte embed

#

im gesamtem Bot

#

muss alle alten Changelog teile einfügen

#

da ich in v1 alles aus einem Altem Projekt eigefügt hab sind diese natürlich Lang

sage tendon
#

müssen das wirklich alles eigene felder sein

vestal folio
sage tendon
#

wäre es nicht besser einfach ein feld zu haben mit newlines
würde genauso aussehen eigentlich

vestal folio
#

ich find das so ganz gut

sage tendon
#

na dann

errant trout
sage tendon
#

ist kürzer

#

und damit erwischt du auf jeden fall jeden command

#

und du schreibst nicht 90% das gleiche 20 mal
nennt sich DRY, don't repeat yourself

vestal folio
#

ääähm kannst du mir Helfen?

#
Ignoring exception in command ban:
Traceback (most recent call last):
  File "C:\Users\leonf\PycharmProjects\Planetbot\cogs\moderation.py", line 63, in ban
    await ctx.respond(embed=ban_message_server)
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\interactions.py", line 585, in respond
    return await self.response.send_message(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\interactions.py", line 918, in send_message
    await self._locked_response(
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\interactions.py", line 1243, in _locked_response
    await coro
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\webhook\async_.py", line 220, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction```
#
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 131, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 1009, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "C:\Users\leonf\PycharmProjects\Planetbot\cogs\moderation.py", line 65, in ban
    await ctx.respond(f"Es gab ein Problem beim Bannen von {member.mention}.")
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\interactions.py", line 585, in respond
    return await self.response.send_message(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\interactions.py", line 918, in send_message
    await self._locked_response(
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\interactions.py", line 1243, in _locked_response
    await coro
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\webhook\async_.py", line 220, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

The above exception was the direct cause of the following exception:
#
Traceback (most recent call last):
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\bot.py", line 1130, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 376, in invoke
    await injected(ctx)
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 139, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction```
#

mein Ban Befehl wirft Fehler

#
    @slash_command(name="unban",description="Entbannt einen User")
    async def unban(self,ctx,member: discord.Member,*,reason="Keine Begründung angegeben"):#
        if not ctx.guild.me.guild_permissions.ban_members:
            await ctx.respond("Du hast keine Rechte dafür")
            return
        if reason : reason
        if member == ctx.author:
            ban_error = discord.Embed(title="Fehler",
                                      description="Du Bist doch nicht Gebannt wenn du hier Schreibst Witzbold!!!",
                                      color=discord.Colour.dark_red())
            await ctx.respond(embed=ban_error)
        else:
            await member.unban(reason=reason)
            unban_message = discord.Embed(title="User Entbannt", color=discord.Colour.dark_red())
            unban_message.add_field(name="Moderator", value=f"{ctx.author}")
            unban_message.add_field(name="Entbangrund:", value=f"{reason}")
            await ctx.respond```
sage tendon
#

wie bekommst du überhaupt ein member wenn der user nicht mehr im server ist

#

außerdem ist dein error im ban command so weit ich das sehe

#

und du hast den unban geschickt

vestal folio
vestal folio
sage tendon
#

also ich weiß nicht aber

vestal folio
#

unban hab ich noch nicht getestet

sage tendon
#

das sieht mir nicht nach ban aus

vestal folio
#

direkt unterm unban befehl

sage tendon
vestal folio
#

ach

sage tendon
#

du musst schon den ban command schicken nh

vestal folio
#

hab den falschen geschickt

#

sorry

#

mein Fehler

sage tendon
#

außerdem macht if reason : reason absolut gar nichts wenn ich nicht ganz dumm bin

vestal folio
#

äääh und bei unban nutze ich die user id

#

sollte ja eigendlich gehen oder?

#
    @slash_command(name="ban", description="Bant einen User vom Server")
    @commands.has_permissions(ban_members=True)
    async def ban(self, ctx, member: discord.Member, *, reason="Keine Begründung Angegeben"):
        if not ctx.guild.me.guild_permissions.ban_members:
            await ctx.respond("Ich habe keine Berechtigung, Mitglieder zu bannen.")
            return
        if member == ctx.author:
            ban_error = discord.Embed(title="Fehler",
                                      description="Du kannst dich nicht Selbst vom Server Bannen was hast du überhaupt davon?",
                                      color=discord.Colour.dark_red())
            await ctx.respond(embed=ban_error)
            return
        if ctx.guild.me.top_role <= member.top_role:
            await ctx.respond("Ich kann kein Mitglied bannen, das eine höhere oder gleiche Rolle als ich hat.")
            return
        try:
            ban_message_user = discord.Embed(title="Du wurdest Gebannt", color=discord.Colour.dark_red())
            ban_message_user.add_field(name="Moderator", value=f"{ctx.author}")
            ban_message_user.add_field(name="Bangrund:", value=f"{reason}")
            await member.send(embed=ban_message_user)
        except:
            await ctx.respond(f"Ich kann {member.mention} keine private Nachricht senden, kann aber trotzdem bannen.")
        try:
            await member.ban(reason=reason)
            ban_message_server = discord.Embed(title="User Gebannt", color=discord.Colour.dark_red())
            ban_message_server.add_field(name="Name:", value=f"{member}")
            ban_message_server.add_field(name="ID:", value=f"{member.id}")
            ban_message_server.add_field(name="Bangrund:", value=f"{reason}")
            ban_message_server.add_field(name="Moderator", value=f"{ctx.author}")
            await ctx.respond(embed=ban_message_server)
        except:
            ```
vestal folio
sage tendon
vestal folio
sage tendon
vestal folio
#

erst ban Befehl

vestal folio
sage tendon
vestal folio
sage tendon
vestal folio
sage tendon
#

wo? 😂

#

du hast nicht den ganzen command geschickt, außer dein ban command bannt nicht

#

außerdem ist das unnötig wenn du eh schon den permissions check drinhast

#

du brauchst btw kein , *, bei slash commands

#

:>

sage tendon
vestal folio
sage tendon
#

ah ich weiß

#

du returnst hier nicht

vestal folio
#

ja es finden sich immer wieder alte übereste

sage tendon
#

achso ne musst du nicht

vestal folio
sage tendon
#

aber weiß nicht ob man zwei mal responden kann

#

oder antwortet der bot gar nicht

vestal folio
#

und der User kriegt ne naricht

#

per pn

#

nur ich kriege keinen output

sage tendon
#

also application did not respond im chat?

vestal folio
#

Jezt geht es

#

häääääääääääääääääääääääääääääääääääh

#

lol

sage tendon
#

dauert das so ~3s bis zur Antwort?

vestal folio
#
ban_message_server = discord.Embed(title="User Gebannt", color=discord.Colour.dark_red())
            ban_message_server.add_field(name="Name:", value=f"{member}")
            ban_message_server.add_field(name="ID:", value=f"{member.id}")
            ban_message_server.add_field(name="Bangrund:", value=f"{reason}")
            ban_message_server.add_field(name="Moderator", value=f"{ctx.author}")
            await member.ban(reason=reason)
            await ctx.respond(embed=ban_message_server)```
#

könnte es daran liegen das ich member.ban nach da unten gesezt hab?

#

neee

#

das ist grade voll Verwirrend

sage tendon
vestal folio
sage tendon
vestal folio
#

ich Kapiers net warums Plötzlich klappt

#

wo soll ich defer hinsetzen?

sage tendon
#

erste Zeile

vestal folio
#

ok

#

setze es einfach sicherheitshalber rein

#

schadet nicht

sage tendon
#

wenn's damit sicher geht

vestal folio
#

bin echt verwirt darüber und weiß nicht mal wie ich das hingekriegt hab

vestal folio
sage tendon
#

mit discord.User, und dann ctx.guild.unban(user,...)

vestal folio
# sage tendon mit discord.User, und dann ctx.guild.unban(user,...)
    @slash_command(name="unban",description="Entbannt einen User")
    async def unban(self,ctx,member: discord.User,reason="Keine Begründung angegeben"):#
        if not ctx.guild.me.guild_permissions.ban_members:
            await ctx.respond("Du hast keine Rechte dafür")
            return
        if member == ctx.author:
            ban_error = discord.Embed(title="Fehler",
                                      description="Du Bist doch nicht Gebannt wenn du hier Schreibst Witzbold!!!",
                                      color=discord.Colour.dark_red())
            await ctx.respond(embed=ban_error)
        else:
            await ctx.guild.unban(member,reason=reason)
            unban_message = discord.Embed(title="User Entbannt", color=discord.Colour.dark_red())
            unban_message.add_field(name="Moderator", value=f"{ctx.author}")
            unban_message.add_field(name="Entbangrund:", value=f"{reason}")
            unban_message.add_field(name="User:",value=member)
            await ctx.respond```
#
Ignoring exception in command unban:
Traceback (most recent call last):
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 131, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 1009, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "C:\Users\leonf\PycharmProjects\Planetbot\cogs\moderation.py", line 27, in unban
    await ctx.respond
TypeError: object method can't be used in 'await' expression

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

Traceback (most recent call last):
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\bot.py", line 1130, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 376, in invoke
    await injected(ctx)
  File "C:\Users\leonf\AppData\Local\pypoetry\Cache\virtualenvs\planetbot-1aVSNs0I-py3.12\Lib\site-packages\discord\commands\core.py", line 139, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: object method can't be used in 'await' expression
sage tendon
sage tendon
vestal folio
#

warum kopiert der das so dämlich

vestal folio
#

vieleicht sollte ich text ausgeben hahahaha

#

aber unban klappt

#

ich sehe es ja im audit log

vestal folio
#

bei changelogs

vestal folio
#

wie kann ich paginator im select menü nutzen?

fresh sierra
#
        name = localizations.get("name")
        if name is not None:
            if locale == default_locale:
                command.name = name
                pass

            if command.name_localizations is discord.MISSING:
                command.name_localizations = {locale: name}
            else:
                command.name_localizations[locale] = name
#

why the command.name, complelty fuck the command.name_localizations ?

#

is there a way to use name_localization but if for example i havent put the german translation or else, it put another one that i choose per default ?

sage tendon
#

I think the default is just the standard name

fresh sierra
sage tendon
#

Yea because it probably is None then

errant trout
sage tendon
#

im still really confused on your entire bot regarding languages and translation

errant trout
#

basically they're trying VERY hard to make it user customizable *via bot commands*, while discord doesn't really account for that

fresh sierra
fresh sierra
#

and when i add the command.name = the localization stop working

errant trout
#

this is before you start the bot, right?

#

or at least before syncing

fresh sierra
#

yes

errant trout
#

have you considered using a json with the i18n extension

fresh sierra
fresh sierra
#

i have 3 yaml

#

with the translation for each one

#

french, english

#

and i wanna have some default for german for example for it swtich to english

#

with that code :

    def localize_command(self, command: discord.ApplicationCommand | discord.SlashCommandGroup, locale: str, localizations: dict):
        if isinstance(command, discord.SlashCommandGroup):
            for cmd in command.walk_commands():
                self.localize_command(cmd, locale, localizations.get(cmd.name, {}))

        name = localizations.get("name")
        if name is not None:
            if locale == default_locale:
                command.name = name

            if command.name_localizations is discord.MISSING:
                command.name_localizations = {locale: name}
            else:
                command.name_localizations[locale] = name
#

while with that code :
with that code :

    def localize_command(self, command: discord.ApplicationCommand | discord.SlashCommandGroup, locale: str, localizations: dict):
        if isinstance(command, discord.SlashCommandGroup):
            for cmd in command.walk_commands():
                self.localize_command(cmd, locale, localizations.get(cmd.name, {}))

        name = localizations.get("name")
        if name is not None:
            if locale == default_locale:
                #command.name = name
                pass

            if command.name_localizations is discord.MISSING:
                command.name_localizations = {locale: name}
            else:
                command.name_localizations[locale] = name
#

so that pretty strange, its like editing the name of a command remove the localized from it

sage tendon
#

doesnt discord's own command localisation completely handle this??

errant trout
fresh sierra
errant trout
#

what happens when you switch your client lang to french then

fresh sierra
sage tendon
errant trout
fresh sierra
errant trout
#

(they are using built-in localizations, in this case)

fresh sierra
#

with the french client

sage tendon
errant trout
#

right, so it's working; your FIRST example is broken, not the 2nd

errant trout
#

they're loading from a yaml file and applying TLs through that

fresh sierra
#

because its the first one to be load

#
    def localize_commands(self):
        self.setup_lang()
        languages_data = {
            "fr": self.french_data,
            "en-US": self.english_data,
            "en-GB": self.english_data
        }
        for locale, localizations in languages_data.items():
            for cmd_name, cmd_localizations in localizations.items():
                if cmd := discord.utils.get(self.bot._pending_application_commands, qualified_name=cmd_name):
                    self.localize_command(cmd, locale, cmd_localizations)   ```
sage tendon
#

ok i dont think i understand lol
good luck though, ill be out

fresh sierra
#

it mean time 400 commandes i will need to add 3/4 translations

#

and if i add one translation i will have to edit 400 commandes

sage tendon
#

400 commands
bro's building THE bot

fresh sierra
#

its an example

#

just explaning that i will have to do a lot of thing everytime

little cobalt
#

how many sub commands do you got?

fresh sierra
#

or i do something like that who will automatically do everything for me each time

fresh sierra
errant trout
fresh sierra
#

but my prefix bot has around 300

sage tendon
#

but can't you just pass a variable / file (loaded to be a dict) to the name_localisations parameter? then you only need to edit the file with your translations like you already have (?)

fresh sierra
#

cos normally it will localizad command before sync it

#

then it should add the name and also add localization

sage tendon
errant trout
#

they wrote their own implementation using yaml, not json

fresh sierra
fresh sierra
#

so its basically a json

errant trout
#

well json would work with multiple if you want

fresh sierra
#

like without the command.name = name the localization works perfectly fine

sage tendon
fresh sierra
fresh sierra
errant trout
#

could you perhaps show a sample of your own json, including sub/group commands

sage tendon
#

i mean you can just have your main translation file in whatever format with all the translations

and then for the name_localisations parameter you put a function that is like get_translation("commandname") and that function returns a dict of the format pycord wants, for that exact command, with all languages you have

#

or is that not possible

fresh sierra
#

so this :

                    
    def localize_command(self, command: discord.ApplicationCommand | discord.SlashCommandGroup, locale: str, localizations: dict):
        if isinstance(command, discord.SlashCommandGroup):
            for cmd in command.walk_commands():
                self.localize_command(cmd, locale, localizations.get(cmd.name, {}))
        print(localization)
        name = localizations.get("name")
        if name is not None:
            if locale == default_locale:
                command.name = name

            if command.name_localizations is discord.MISSING:
                command.name_localizations = {locale: name}
            else:
                command.name_localizations[locale] = name
#

will give :

#

{'name': 'mode', 'description': "Active ou désactive le système d'expérience.", 'options': {'mode': {'name': 'mode', 'description': "Sélectionnez pour activer ou désactiver le système d'expérience."}}, 'success': "Le système d'expérience est désormais {mode}."}

#

for example

errant trout
#

what does it look like for your test_english subcommand?

sage tendon
fresh sierra
errant trout
#

well, you could but then you're doing it in every decorator

fresh sierra
sage tendon
#

yea, but only once
you dont ever touch that again

fresh sierra
#

so it work

errant trout
#

yeah but being just "once" doesn't matter

fresh sierra
#
test_english
{'name': 'test_english', 'description': 'Test command in english.', 'embed': {'title': 'Test', 'description': 'This is a test of the command in english.'}, 'options': {'kind': {'name': 'kind', 'description': 'Sélectionnez le kind de ressource to add.'}}}
#

i think i might have an idea why now

#

when it edit the name, when then it try to get the command by the name it not longer the name test by default but test_english and it cannot find test_english as key since its a value

#

i will keep looking at that to check

fresh sierra
#

yeap excatly it was that, i solved it by creating a function after that put all the default value

#

however i will have a suggestion

#
    @subcommand(f"{translator.bot.name}")
    @commands.slash_command()
    @discord.option(parameter_name="kind", name=translator.bot.test.options.kind.name, choices=["xp", "level"], required=True)
    async def test(self, ctx: discord.ApplicationContext, kind: str):
        translator = get_translator(ctx)
        embed = discord.Embed(title=translator.bot.test.embed.title, description=translator.bot.test.embed.description)
        await add_embed(embed)
        await ctx.respond(embed=embed)
#

so when a parameter name is adding, make the name optional, because it mean that i will still need to put the name= even if its add like for the slash_command after

#

like make the name default value parameter name ;)

#

because for the moment it mean that i have to do that :

 @discord.option(parameter_name="kind", name="kind", choices=["xp", "level"], required=True)
#

to then have that :

#

however, thanks you @errant trout and @sage tendon for your help at this really late time. I appreciate !

errant trout
#

name is already optional

#

because it uses the function name

fresh sierra
errant trout
#

it is

fresh sierra
#

i got an error if i dont pass it wait

errant trout
#

oh you're using decorator i see

fresh sierra
#
2024-04-13 22:11:52 [WARNING] : Failed to load extension Slashs.Bot.test: Extension 'Slashs.Bot.test' raised an error: TypeError: option() missing 1 required positional argument: 'name'
#

i shouldnt ?

sage tendon
#

yea the option name is required positionally

#

if decorator

errant trout
#

it's fine, it wouldn't change much anyway

fresh sierra
#

so it something who will change in the pycord or i need to continue to do

 @discord.option(parameter_name="kind", name="kind", choices=["xp", "level"], required=True)
sage tendon
#

parameter name is unneeded

fresh sierra
sage tendon
#

well, yea

#

but yours is literally the same

fresh sierra
#

It’s edit like for the name and description

#

In the other part of the code

#

Maybe since it’s edit in another part it will work without

sage tendon
#

name localisations dont change the name parameter which dictates with parameter in the function it binds to

#

if you use the localisations parameter

fresh sierra
#

i will try and see

sage tendon
#

why

fresh sierra
#

and i dont have german translation

#

it will put by default something

sage tendon
#

cry_cat your solution to this is so messy

#

just use the localisations parameter, dont change the actual option name

#

wont that change it for literally every server?

fresh sierra
errant trout
#

it's likely we won't change the behavior because your method is very much outside the norm

fresh sierra
#

    @subcommand(f"{translator.bot.name}")
    @commands.slash_command()
    @discord.option(name="kind", choices=["xp", "level"], required=True)
    async def test(self, ctx: discord.ApplicationContext, kind: str):
        translator = get_translator(ctx)
        embed = discord.Embed(title=translator.bot.test.embed.title, description=translator.bot.test.embed.description)
        await add_embed(embed)
        await ctx.respond(embed=embed)

#

since now i use something outside it work

errant trout
#

if you wish to make your own modifications to the library files, you're free to do so

fresh sierra
#

but before it was giving me an issue because i was editing

fresh sierra
#

i dont need the name parameter

#

even if i edit the name of the option if its in another part than the decorator it work

fresh sierra
fresh sierra
#

and this inclue also automatic translation to english and french using name_localization, and if its from another. like german, since it also edit the command.name etc it will put by default english

sage tendon
fresh sierra
sage tendon
#

nah i give up i finna completely quit at trying to understand your way, i legitimately do not understand it lmfao

fresh sierra
#

thats why i do like that

sage tendon
#

which you could also achieve by simply calling a function for the localisation parameter that gets the right dict for the option in question

fresh sierra
#

?

sage tendon
#

no

#

name_localizations=get_localization("commandname")
as i said before

fresh sierra
#

yes but that mean i need for each command each description and each option to do that

errant trout
#

i guess the point is that through iteration you can do that in a few lines, which is what the i18n extension and luma's method try to achieve

sage tendon
#

I mean, if you want to localise your entire bot, thats what you gotta do no matter your approach to passing it to pycord

#

you need to localise everything

#

lol

little cobalt
sage tendon
errant trout
fresh sierra
sage tendon
#

🤨

fresh sierra
#

but im trying to improve myself and so use the less lib that i can

little cobalt
#

I know and the issue is that name_localizations has to use lower case and it starts with a B instead of a b

errant trout
#

yeah what you're doing is fairly similar, i suppose with your own variation

sage tendon
#

but why not just use that then

little cobalt
errant trout
#

discord's official docs also show uppercase though

sage tendon
#

since when are command names limited to lowercase

errant trout
#

always have been (slash)

#

oh wait i misread

#

ok yeah the command name in that example should be lowercase

sage tendon
#

oh
guess i never thought about that then

fresh sierra
#
    @subcommand(f"{translator.xp.name} {translator.xp.setup.name}")
    @commands.slash_command()
    @discord.option(name="kind", choices=["add", "remove", "edit"], required=True)
    @discord.option(name="channel", type=discord.TextChannel, required=True)
    @discord.option(name="rate", type=float, default=1.0, required=False)
    async def channel_rate(self, ctx: discord.ApplicationContext, kind: str, channel: discord.TextChannel, rate: float):

this will be like that ?

    @subcommand(f"{translator.xp.name} {translator.xp.setup.name}")
    @commands.slash_command(name_localizations=get_localization("channel_rate"), description_localization=get_localization("commandname"))
    @discord.option(name_localizations=get_localization("kind", choices=["add", "remove", "edit"], required=True)
    @discord.option(name="channel", type=discord.TextChannel, required=True)
    @discord.option(name="rate", type=float, default=1.0, required=False)
    async def channel_rate(self, ctx: discord.ApplicationContext, kind: str, channel: discord.TextChannel, rate: float):
little cobalt
#

command name has to be lower case ;3

fresh sierra
little cobalt
#

its also client side @fresh sierra so you cannot create a custome one

errant trout
#

we've already gone through the whole client/bot tl stuff

little cobalt
#

alright ;3

fresh sierra
sage tendon
#

we're going in a very big, very confusing circle

errant trout
#

nice

fresh sierra
#

but finally i did it

#

and its thanks to you also ;)

sage tendon
fresh sierra
#

the bottom one was a try to understand what you were meaning

vapid carbon
#

Hi

#

@bot.slash_command(name='war_plan', description='Generate the war plan for current war')
async def warplan(ctx):
    from game import war_plan
    from helpers import generate_war_plan_embed

    await ctx.defer()
    is_plan_generated, plan_response = await war_plan()

    if is_plan_generated:
        embed = await generate_war_plan_embed(embed=discord.Embed(), plan=plan_response)

        await ctx.respond('', embed=embed)
    else:
        await ctx.respond(f"Please add {', '.join(plan_response)} to the sheet", ephemeral=True)```
#

How can i send an ephemeral message in case plan is not generated?

sage tendon
#

defer ephemerally

#

but then you need to not respond, but ctx.send to respond non-ephemerally

vapid carbon
#

Oh

#

Okay let me try that

vapid carbon
sage tendon
#

yes

sage tendon
#

okay I remembered incorrectly, I thought ctx.send was a shortcut for ctx.channel.send

#

then you have to use that

vapid carbon
#

hmmm seems like, it creates a small issue

#

the original command does not get a response so its still waiting for one

oblique sable
#

Hey quick question how to attach a video prview next to a message?
I know if you send links to direct video it will directly show the video through discord (and for sure proxy it)
I was wondering how to do that with pycord

sage tendon
#

yea you have to respond to that, just say like "sent" or something

vapid carbon
#

okay makes sense

oblique sable
#

yeah but without sending it

#

since i have an embed

vapid carbon
#

what if i say emphemeral=False in the response?

sage tendon
#

add the video as a file to the message?

sage tendon
oblique sable
#

not a file since it is too heavy

#

links get previewed but the link also has to be in the message to be previewed

#

was wondering if there was a parameter to specify so it gets previewed but withuot having to be sent as a message

#

for example here

vapid carbon
#

okay and how long after do the emphemeral msgs disappear by themselves?

oblique sable
#

it sent the info about the video, but im wondering on how to send the info without having the link appear

#

my closest result is this

[-](https://www.youtube.com/watch?v=TkwXa7Cvfr8)

#

or with invisible char

oblique sable
#

doesnt work nvm

vapid carbon
sage tendon
vapid carbon
#

ah

#

okay not a big issue as such

#

thank you so much for the help!

sage tendon
#

i mean it'll be gone after a few messages anyway

#

mp

oblique sable
#

thanks for helping

sage tendon
#

you could try one thing

#

specify the embed type as video and then pass the URL via the URL parameter

oblique sable
#

hmm would this embed the video directly into the embed?

sage tendon
#

no idea

oblique sable
#

i dont think thats possible

#

read somewhere that only images and gifs are allowed

sage tendon
#

it should tho

#

well, in discords official API docs, video embeds are a thing

oblique sable
#

oh

sage tendon
#

so shrug

oblique sable
#

lemme try that!

sage tendon
#

oh I just read discord considers embed types deprecated and the embed attributes implicitly dictate the type now lmao
well if passing the video as a URL doesn't embed it then, then I don't know

oblique sable
#

oh

#

any idea where i could read about this documentation?

sage tendon
#

well I just checked the pycord docs on Embed

errant trout
#

only websites are able to, which is why video embeds exist

oblique sable
#

I tried setting embed.video attribute and got an error

lofty parcel
#

you might wanna read nelo's messages again

glad spoke
#

Does Pycord have a native way to check the session start limit?

fresh sierra
vestal folio
#

wie kann ich paginator im select menü nutzen?

glad spoke
fresh sierra
glad spoke
#

Weird.

fresh sierra
#

but if your question is how to add paganitor is a select menu, paginator has an attribute custom view where you can pass ur select menu

vestal folio
#

How?

#

I have by my Menü Not ctx.interaction

sage tendon
dense summit
#

Hey there, i just got back to my bot and im trying to register a new slash command group although even if i reload discord it doesn't want to show up.

My cog: https://paste.pythondiscord.com/NSQA

sage tendon
#

why do you have an empty line between the decorators

#

that might be it

#

also, just fyi, in the command, you never respond to the actual interaction

dense summit
sage tendon
#

hardcode your test server's ID in the guild_ids parameter to make sure it doesnt register in the wrong / no server

dense summit
#

Unfortunately it didn't fix it

sage tendon
#

make sure to restart discord

dense summit
#

I just got back to pycord and im really confused im pretty sure im making some stupid mistake

dense summit
sage tendon
#

try just make it a regular slash command first to see if it shows up at all

#

also why is literally every string a variable lmao

dense summit
#

As normal slash command it shows up

sage tendon
#

it shouldnt show ctx as parameter though..

dense summit
sage tendon
#

no, just change it in the cog

#

to make sure teh cog isnt the problem somehow

dense summit
sage tendon
#

yea

dense summit
#

The problem is the cog then

sage tendon
#

are you loading the cog in your main file?

dense summit
#

omfg, im sorry..

#

i forgot to load the extension

#

thanks, where i can find an example of modal?

sage tendon
#

the docs / guide

errant trout
glad spoke
errant trout
#

yeah i guess we never bothered because that's for clustering

#

we do have the types, they're just never used

#

could probably include it for completion

rare condor
#

Does someone have a hint about paginator having a diferent select dropdown for each page

sage tendon
#

you can give pages a custom_view

sage tendon
#

nur immer "häh" zu sagen bringt uns beiden wenig

vestal folio
#

ich verstehe net wie man das nuzt

sage tendon
#

probier es aus

vestal folio
#

hääääh

#

das ist komisch

#
   @discord.ui.select(
        placeholder="Wähle den Changelog",  # the placeholder text that will be displayed if nothing is selected
        min_values=1,  # the minimum number of values that must be selected by the users
        max_values=1,  # the maximum number of values that can be selected by the users
        options=[  # the list of options from which users can choose, a required field
            discord.SelectOption(
                label="Startseite",
                description="Hauptseite des Menüs"
            ),
            discord.SelectOption(
                label="1.0.0",
                description=""
            ),
            discord.SelectOption(
                label="2.0.0",
                description=""
            )
        ]
    )
    async def select_callback(self, select, interaction):  # the function called when the user is done selecting options
        if select.values[0] == "Startseite":
            await interaction.edit(embed=help_embed_default)
        elif select.values[0] == "1.0.0":
            await interaction.edit(embed=help_allgemein_embed)
        elif select.values[0] == "2.0.0":
            pages = [
                Page(embeds=[changelog_embed])
            ]
            paginator = Paginator(pages=pages, author_check=True, disable_on_timeout=True, show_disabled=False,
                                  timeout=100)
            page = await paginator.respond(interaction)
            await interaction.edit(page)```
sage tendon
#

sag mir nicht du benutzt dafür chatgpt

vestal folio
vestal folio
sage tendon
#

einfach custom_view= bei der page

vestal folio
#

custom=view=page?

sage tendon
#

dein view.

vestal folio
sage tendon
#

custom_view=View()

vestal folio
#

vom Select Menü oder was?

vestal folio
#

geht net

vestal folio
# sage tendon custom_view=View()
class Changelog_View(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)
    @discord.ui.select(
        placeholder="Wähle den Changelog",
        min_values=1,
        max_values=1,
        custom_id="changelog",
        options=[
            discord.SelectOption(
                label="Startseite",
                description="Hauptseite des Menüs"
            ),
            discord.SelectOption(
                label="1.0.0",
                description=""
            ),
            discord.SelectOption(
                label="2.0.0",
                description=""
            )
        ]
    )
    async def select_callback(self, select, interaction):
        if select.values[0] == "Startseite":
            await interaction.edit(embed=help_embed_default)
        elif select.values[0] == "1.0.0":
            await interaction.edit(embed=help_allgemein_embed)
        elif select.values[0] == "2.0.0":
            pages = [
                Page(embeds=[changelog_embed])
            ]
            paginator = Paginator(pages=pages, author_check=True, disable_on_timeout=True, show_disabled=False,
                                  timeout=100)
            page = await paginator.respond(custom_view=View())
            await interaction.edit(page)```
sage tendon
#

in der Page.

#

nicht im respond

vestal folio
#

und wie mach ich das jezt mit dem output?

sage tendon
#

Guck dir die Docs an

vestal folio
#

ctx.interaction geht ja nicht

sage tendon
#

was?

#

we aren't SQL support

#

This support channel is typically relatively lenient but SQL has absolutely nothing to do with pycord

sly ember
#

oka

vestal folio
sage tendon
#

kann dir nicht deinen ganzen bot machen

vestal folio
#

ich muss einfach nur verstehen wie

dense summit
#

What would be the best way in a modal to check if x text matches something and if not give an error to the user?

#

I would need to close the modal or i can give an error directly into the modal?

oblique fern
#

Is there a list of breaking changes from 2.4 to 2.5 somewhere?

sage tendon
#

its not a major update so there arent any

#

semver be thanked

#

tho i think there was one change to some bridge stuff that made the bridge options behave a bit differently, not sure if that was intended tho

errant trout
oblique fern
#

Nah, just wondering if there were any major changes I should know about before updating.

errant trout
oblique fern
#

negative, fully slashed out bots only here.

lofty parcel
errant trout
#

then you're safe

oblique fern
#

👍

errant trout
sage tendon
#

generally, for minor updates (1.X.0), there are never breaking changes (on purpose)

#

that's how semantic versioning dictates it

errant trout
#

if there's any breaking changes we (are meant to) very clearly announce it

sage tendon
#

strictly speaking any breaking change would have to wait until 3.0

errant trout
#

nah we plan on making some anyway

sage tendon
#

breach of semantic versioning

errant trout
#

oh no! anyway

oblique fern
#

iirc between 2.2 and 2.3 there were also some 🤷

#

It's no big deal either way, just wanted to know for sure before I updated, that's all 🙂

sage tendon
#

i mean i generally do expect any library i use to strictly keep to semantic versioning shrug
especially so that requirements.txt using ~= work fine

lofty parcel
#

You expect too much from the world

sage tendon
#

not really

#

semver is a standard in software development

oblique fern
sage tendon
#

i mean no one wants to compete with semver tho

oblique fern
#

pragmatic versioning, calver, wendtver, semver-ish, and calendar versioning are a couple 😛

rare condor
# sage tendon you can give pages a custom_view

Yeah but I need to change the select in the view, like the select has 20 options in the first page but 7 on the 2nd (just giving random numbers), how do I get the interaction that happened in the paginator and not in the view, so I can update the view and then update the paginator

sage tendon
#

each page has a custom_view parameter

#

so if the next page is selected it also changes the view accordingly afaik

rare condor
#

wait, when i create pages its just a list of embeds that I pass to the paginator

#

Oh

sage tendon
#

pages have a lot more attributes than that :)

rare condor
#

There is a constructor for a single page

#

tysm

frail laurel
#

How to access VoiceState.channel for a certain user if Member object doesn't have that attribute

sage tendon
#

i didnt even know you could make a paginator without that

sage tendon
#

oh, i misread

rare condor
sage tendon
frail laurel
sage tendon
#

yea i was also wondering why it has no return type shown

#

but from the words alone i would say it just returns a VoiceState object

frail laurel
#

I guess it's a programmer's job to find that by trial and error lol

sage tendon
#

i mean the docs are just better than most i read out there
these are minor things imo, usually the return type is given (and linked)

errant trout
#

it'll hopefully be fixed at some point, but at the moment this is a general issue

lone hound
#

Is there a way to access the ctx.guild's banlist? or just the guild's banlist?

sage tendon
#

as always, docs are your best friend

vestal folio
last mason
#

Hey! I am trying to get a contact me set up. Though I want to initialise myself in the init function of the cog. Though I am running into some issues: see screenshots below. It is not the fact that get_user() is taking a string, giving it an integer gives the same result

errant trout
#

doing it on init means it happens before the bot started, so there's no cache

last mason
#

Hmm so I can't init get_user or just not the print?

errant trout
#

can't do get_user in init (at least on first load, it would work on subsequent loads)

last mason
#

I guess I'd have to event another on_ready to do it the way I want to?

errant trout
#

you can use an on_ready listener, just make sure it doesn't get overridden on subsequent reloads

#

alternatively, you could make it a @property py self._nico = userid ... @property def nico(self): return self.bot.get_user(self._nico)

last mason
#

cool thanks, I'll read into @property in that case

last mason
#

I am running a ping slash command in a cog, which works fine. When I then create a slash command with the same code inside in a different cog (did change the name of the slash command a bit) it doesn't detect it at all. But when I comment out the first ping command, the 2nd one does work

sage tendon
#

show both commands

#

my main question is, why have the same command twice

last mason
#

Wait. Does my way of loading cogs work in pycord? I think it might not 1 sec

#

Wait that shouldn't be the issue cause when I comment out the "ping" command it works in the other cog

sage tendon
#

bot.load_extensions("cogs") is shorter

last mason
#

oh didn't know that was a thing. Yeah its my first time using pycord and first time using slash commands in general

#

so having some issues dogekek

errant trout
#

as long as they're loaded before starting the bot

last mason
#

YesYes It's just weird the slash command in my first loaded cog stops working when there's a slash command in a later cog

sage tendon
#

show the entire cogs

last mason
#
import discord
from discord.ext import commands
from decimal import Decimal

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

    @discord.slash_command()
    async def ping(self, ctx):
        await ctx.respond(f"Pong! {round(Decimal(self.bot.latency*1000),3)}ms")

def setup(bot):
    bot.add_cog(Utilities(bot))
#

oof py fail

#
import discord
from discord.ext import commands
from decimal import Decimal

class Contact(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self._nico = '206447192590909440'
        print(self._nico)
    
    @discord.slash_command()
    async def whois(self, ctx):
        await ctx.respond(f"Pong! {round(Decimal(self.bot.latency*1000),3)}ms")

def setup(bot):
    bot.add_cog(Contact(bot))
sage tendon
#

restart the bot, wait until its started, restart your discord, then check again

errant trout
#

best check is if it shows when you go to guild settings > integrations

last mason
sage tendon
#

i mean discord is just awful with syncing slash commands in real time

#

always restart after adding or changing one

last mason
#

does discord have a force restart hotkey?

sage tendon
#

ctrl+r

last mason
#

cheers

#

@errant trout After setting @property how do I use that? As the def nico is not callable

errant trout
#

.nico

#

property is designed to emulate regular attributes

last mason
#

Hmmm lovely stuff. Got to love my user id not existing kekw

#
import discord
from discord.ext import commands
from var_dump import var_dump

class Contact(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self._nico = 206447192590909440

    
    @property
    def nico(self):
        return self._nico
    
    @discord.slash_command()
    async def whois(self, ctx):
        print(self.bot.get_user(self.nico))

def setup(bot):
    bot.add_cog(Contact(bot))
sage tendon
#

arent IDs strings

errant trout
#

no

last mason
#

same result

sage tendon
#

welp

errant trout
#

what intents do you have

last mason
#

all for testing purposes :)

errant trout
#

(also, my intent was that in property you run get_user so you can simply use self.nico wherever)

sage tendon
last mason
#

(I am stupid and I don't wish to talk about my mistakes)

#

definitely not my main.py right after I said I had all intents

sage tendon
#

line 5 is unnecessary

last mason
#

I know I am tired, deleted it right after the screenshot dogekek

last mason
#

brainstorming here, can a command triggered in DMs to the bot create a channel in my private discord server?

errant trout
#

if you want

grizzled loom
#

sure

errant trout
#

just use get_guild

last mason
#

cheers, great to have people that know this by heart rather than having to find out if its even possible, myself

last mason
errant trout
#

mhm

last mason
#

man properties are useful dogekek

#

cheers

last mason
#

How do I get a category? I need to create the text channel in a certain category but get_category doesn't exist sadly enough

sage tendon
#

its just a channel i think

#

so you can use get_channel

last mason
#

New problem arises party I am trying to find a method that returns all channels in a server (server is defined by an ID)

#

Well mostly I am trying to find out if a channel with a certain name already exists

sage tendon
grizzled loom
#

where do i have the thing..

#

.. ah there it is! : D

grizzled loom
stray pasture
#

I am getting Missing access when trying to register commands, what could be the cause ?

shell radish
#

?tag missing_access

limber wagonBOT
#

If you get a Missing Access (50001) error, you probably forgot to add the applications.commands scope.

To fix that, just re-invite your bot to the guilds you specified guild_ids or debug_guilds for.

stray pasture
shell radish
#

the guild's IDs

stray pasture
shell radish
#

you could be passing in the wrong bot's token, too

stray pasture
#

I see I will check that ! Thank you ! Maybe it is the wrong bot token

glad spoke
#

Still kind of confused here. Why is Option getting depricated within slash context? BridgeOption within slash commands don't seem to make any sense to me. Shouldn't this be the other way around, BridgeOption depricated instead of Option?

sage tendon
#

thats.. not whats happening

#

you need to use bridgeoption for bridge commands

#

which is why that message appears if you import bridge as nelo said

high spire
#

I'm getting this error on some code for the @option decorator for slash commands

#

Could someone explain to me what it means and how I would go about fixing it?

sage tendon
#

show your code, the entire command

high spire
#
import discord
from discord import Option, option
from discord.ext import commands
from discord.commands import slash_command
import json 

with open("contentdata.json","r") as file:
    jsonData = json.load(file)

subjectsdata = jsonData["Subjects"]
print(subjectsdata)

subjects = [''.join(subject.keys()) for subject in subjectsdata]
server = 1226452892899217461
admins = [675238101253226496]
print(subjects)

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

    @discord.ui.button(label="Yes", row=0, style=discord.ButtonStyle.success)
    async def accept_button_callback(self, button, interaction):
        
        await interaction.response.send_message(f"The category has now been created", ephemeral=True)

    @discord.ui.button(label="Abort", row=0, style=discord.ButtonStyle.danger)
    async def deny_button_callback(self, button, interaction):
        
        await interaction.response.send_message(f"You have succesfully aborted the creation of the category", ephemeral=True)```
#
class contentsub(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
    
    @staticmethod 
    def subjectAutocomplete(self: discord.AutocompleteContext):
        return subjects
    
    @slash_command(guild_ids=server, name='contentsubmission', description='Send in your resources to gain access to other resources!')
    @option(name="subject", description="Your selected subject for this content to be submitted in", autocomplete=subjectAutocomplete)
    async def contentsubmission(self, ctx: discord.ApplicationContext, link: Option(description="A google doc link to your content", required = True), subject: Option(description="The respective subject your content belongs in", required = True)):
        if subject not in subjects:
            embed = discord.Embed(
                    title="Content Submission",
                    description=f"Your subject doesn't seem to exist yet. Would you like to create a new category for it?",
                    color=discord.Colour.from_rgb(255,255,255))
            embed.set_author(name='Source', icon_url='https://res.cloudinary.com/drt9lxvky/image/upload/v1712798628/sourcev1.png_uzc8zh.jpg')
            await ctx.respond(embed=embed, view=categorycreation(bot=self.bot))
        
        else: 
            embed = discord.Embed(
                    title="Content Submission",
                    description=f"Thanks for submitting the content. Please make the document view only and add the email: to it",
                    color=discord.Colour.from_rgb(255,255,255))
        embed.set_author(name='Source', icon_url='https://res.cloudinary.com/drt9lxvky/image/upload/v1712798628/sourcev1.png_uzc8zh.jpg')
        ctx.respond(embed=self.embed)

def setup(bot):
    bot.add_cog(contentsub(bot))```
sage tendon
#

dont mix the decorator and the typehint variant

#

use either the option decorator or the typehint, not both, that wont work

high spire
#

right so let's say that I used the decorator for the subject parameter and then the typehint for the link parameter would that be ok?

sage tendon
#

why would you want that

#

just stick with one

high spire
sage tendon
#

yea

little cobalt
#

Mhm, maybe I should put my small command builder online

high spire
#

like for example for typehinting we could do

#

member: discord.Member

sage tendon
#

input_type=

#

but i usually pass name and type positionally in the decorator

#

saves space

high spire
#

i dunno if i'm blind or something

#

but is there like a list of the input types

#

on docs

sage tendon
#

not sure but there's not really that many

little cobalt
#

There is not really a list for it

high spire
#

ah ok

#

im having issues getting my commands to sync

#

could it be because of rich presence?

sage tendon
#

bots cant have rich presence lol

high spire
sage tendon
#

why do you redo that every minute

high spire
sage tendon
#

just do it in your bot definition

little cobalt
#

You should also wait until ready at tasks

high spire
high spire
sage tendon
#

discord.Bot(activity=...)

high spire
high spire
#

and it's preventing my new cmd to be used

sage tendon
#

well, show the complete error

high spire
#

nevermind

#

I managed to fix it one of the guildid global variables weren't defined properly as a list it was a int an not iterable

little cobalt
last mason
#

I'm guessing pycord does not support discord polls yet?

shell radish
#

it's waiting for discord's own PR to merge

sage tendon
#

How come this still allows @ everyone to be mentioned?

fresh sierra
sage tendon
#

to control what the bot can ping in a message

fresh sierra
#

so even if the bot does

#

everyone

#

it will not ping anyone ?

sage tendon
#

yes, but my problem currently is that that will still ping everyone

#

tho i think i know why

#

yea okay i had to explicitly pass everyone=False too

dense summit
sage tendon
#

what line even causes that

#

just blindly judging by the weird error i think its because of your option name sub_name?
try changing that

dense summit
#

the command doesn't want to update, tried to force reload ds and restarted but nothing

sage tendon
#

did you change the name of the option and the function parameter

dense summit
worn sphinx
lone hound
#

is it my library thats outated?

sage tendon
#

well, what version do you have?

#

also i dont think thats a valid optiontype anyway, but not sure

deft kestrel
#

?tag defer

limber wagonBOT
#

dynoError No tag defer found.

sage tendon
#

just ask

lone hound
sage tendon
#

yea that's the latest version
Are you sure you dont have discord.py installed (as well)?

#

yea no you cant access BanEntry, i just tried

#

and really there is no point to ever manually accessing that class

lofty parcel
#

BanEntry can't be an option

deft kestrel
#

how use

#

defer?

sage tendon
#

await ctx.defer()

deft kestrel
#

                    embed = discord.Embed(title="Stworzono Ticket", description=
f"""
:IlusionEmotes67: - Użytkownik: {interaction.user.id}
:IlusionEmotes78: - Otwarto ticket: {option_label}
:IlusionEmotes30: - ID Ticketa: {ticket_id}
""", color=0x982afe)
                    embed.set_thumbnail(url=interaction.user.display_avatar.url)

                    await ticket_channel.send(f"{interaction.user.mention} ∙ <@&1217917143996432495>")
                    await ticket_channel.send(embed=embed, view=CloseButton(self.bot))

                    embed = discord.Embed(description=f"> :IlusionEmotes74: Dziękujemy za utworzenie ticketu! Twój kanał: {ticket_channel.mention}", color=0x982afe)
                    await interaction.response.send_message(embed=embed, ephemeral=True)

                except Exception as e:
                    print(f"Error creating ticket: {e}")
                    embed = discord.Embed(description=f"> :IlusionEmotes74: Dziękujemy za utworzenie ticketu! Twój kanał: {ticket_channel.mention}", color=0x982afe)
                    await interaction.response.send_message(embed=embed, ephemeral=True)

        select.callback = select_option```
#

sometimes i got a error "interaction not found"

#

idk why

#

so i want to use "defer"

#

maybe it will fix the problem

#

but i don't know how

sage tendon
#

did you check which line causes that error
might be related

deft kestrel
#

File "/home/container/.local/lib/python3.10/site-packages/discord/ui/view.py", line 426, in _scheduled_task
await item.callback(interaction)
File "/home/container/KategoriaPrivate/Tickety/nowetickety.py", line 193, in select_option
await interaction.response.send_message(embed=embed, ephemeral=True)
File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 918, in send_message
await self._locked_response(
File "/home/container/.local/lib/python3.10/site-packages/discord/interactions.py", line 1243, in locked_response
await coro
File "/home/container/.local/lib/python3.10/site-packages/discord/webhook/async
.py", line 220, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

#

the thing is, sometimes it works, sometimes it doesn't

sage tendon
#

are you taking long to respond, like, up to 3 seconds?

#

oh that's in a view right?

#

yea views dont work anymore after 15 minutes, that might be why

lapis dock
rugged lodgeBOT
#

Here's the persistent example.

high spire
#

how do I create a role after a button click?

lapis dock
#

I answered in the other thread you were in

high spire
#

would it be using the get_role method

#

i've just read the docs

#

and it says that the create role coroutine returns a "role" object

#

which has alot of attribute like id

#

how would I go about accessing it

#

the function returns it but do I store it as a variable?

lofty parcel
weary meteor
#

is there a way to move channels around in a category? like each channel has a number at the start of it so i wanted to order them from least to greatest

umbral gazelle
#

Why channel purge with high limit is so slow?

sage tendon
#

discord, that's why

scenic rock
#

How often can you edit a message with a persistent view? Had one running for a while but it slowly fell behind on the edits over time.

glad spoke
#

I believe this is a little something that Nelo did the wrong way around, or something is not working as intended.

sage tendon
#

are you importing anything bridge related?

vital bramble
#

How would I update the bot status like online, idle etc. without removing the current activity? Is that possible or do I have to keep track of the current activity myself and pass that to change_presence too, every time?

#

is the current presence stored somewhere in the bot?

solemn finch
#

Any way to establish Cog to Cog communication without going over the bot or am I doomed to do it over the bot?

solemn finch
#

Cog A sends something to API of my backend and needs to tell Cog B to update a scoreboard in a channel

sage tendon
#

just make a function call from one to the other lol

solemn finch
#

okay, glad you confirmed I was overthinking it

sage tendon
#

cog a

async def doStuff()

cog b
//commandcode
coga.doStuff()

sage tendon
#

I'm on phone don't judge my amazing codeblock

sage tendon
shell radish
#

not an excuse /j

sage tendon
#

smh

grizzled loom
shell radish
#

thought the /j wasn’t necessary ig not

#

there

sly ember
#

does anybody know why its not working, no errors

sage tendon
#

this isn't SQL support

#

tho, you never commit

fresh sierra
sly ember
#

ohhh

sage tendon
#

but again, this isn't SQL support, there's plenty of documentation for the mysql library

sly ember
#

used commit but still deoesnt work

sly ember
#

pls 😂

sage tendon
#

no

#

this is pycord

#

has nothing to do with SQL

vague oak
#

Hi, i am trying to execute pycord bod and a while loop at the same time. I was trying multiple aproches but none of them work, this is my broken code for reference:

    Crypt(key=key)

    kokot_thread = threading.Thread(target=import_system.kokot())
    bot_thread = threading.Thread(target=bot.start())

    bot_thread.start()
    kokot_thread.start()

    bot_thread.join()
    kokot_thread.join()```
kokot_thread is just a while loop. In this case, whatever thread runs first will be the one that is working, but never both at the same time
sage tendon
#

what does the while loop do

vague oak
#

just prints stuff and sleeps for 1 second

sage tendon
#

make it a task then

vague oak
#

how? should i use asyncio tasks?

little cobalt
#

with asyncio

vague oak
little cobalt
#

if you use bot.start you have to use asyncio

#

else bot.run()

sage tendon
#

usually bot.run is the very last statement in your main.py

#

so you dont really ever need to wrory about it being async aka bot.start, usually you use bot.run

vague oak
#

am gonna change the token later btw

sage tendon
#

nice token leak

vague oak
#

yeah, theres like nothing on it

sage tendon
#

tasks are i think @bot.task

#

look it up on the docs

#

you can then start that task from e.g. the on_ready to make sure your bot is ready before, well, starting the task

vague oak
#

well the bot isnt the main thing, it should run separatly from the other tasks

#

meaning the start_services function should start bot and some other stuff that does loops

vague oak
#

and i noticed that executing it on other thread doesnt work

#

thats why i came here 😄

#

i am trying something that executes the bot and some other looping functions like at the same times

#

that other functions have no problem being executed on another thread

sage tendon
#

await bot.start :>

vague oak
little cobalt
vague oak
vague oak
#

the problem is that i cant call the bot.start() on anything else than main thread

little cobalt
#

you have to use asyncio

vague oak
#

like how exactly?

little cobalt
#

asyncio.run(the function())

vague oak
#

not for the bot

little cobalt
#
import asyncio
asyncio.run(start_services(key))
#

your async def function

vague oak
#

i already do that

sage tendon
#

it needs to be sync

#

else you could just await it

#

unless im dumb rn

vague oak
#

thats why there needs to be asyncio.run(start_services(key))

vague oak
#

but the problem is somewhere else

#

like when calling bot.start() nothing afther will ever execute

#

and i put my loop function before that

sage tendon
vague oak
#

it will not get to bot.start

grizzled loom
sage tendon
#

lol

vague oak
#

but thats not gonna fix anything, like the start_services can run synchronously just fine, the problem is to get the things inside that function to basically start at the same time

#

these 2 functions are supposed to run at the same time, but whichever i put first will be the one that will execute

#

i tried threading, but that doesnt work with the bot

sage tendon
#

why do you even have a function for that
just put it at the bottom of your file

vague oak
#

but if i do this, the first function starts a loop and the second cant load because it is stuck

sage tendon
#

what for lol

vague oak
sage tendon
#

why dont you let the bot just run

vague oak
sage tendon
#

yea i got that by now

vague oak
#

i found a way to fix it

sage tendon
#

which is

#

👍

rapid oar
#

how would I go about dm'ing audio recordings to the user who invoked the slash command instead of posting it into the channel where the slash command was invoked?

sage tendon
#

ctx.member.send

rapid oar
#

Pops an error

sage tendon
#

that's not a slash command

#

well it is but that's just a function you're calling within the command

rapid oar
#

yea, I'm at a loss on it. Never coded a bot before

sage tendon
#

just pass ctx.member to that function as member and then member.send

#

and remove that *args

vague oak
sage tendon
rapid oar
#

idk lol, I got the code from the pycord site for audio recording

sage tendon
#

ah probably because they sent it to a channel after

#

wait you arent calling it the way I expected initially nvm

#

hm I've never used the recording thing either tbh

rapid oar
#

I passed ctx.member as member and when I invoke the slash command I get this error

sage tendon
#

ctx.author, mb

rapid oar
#

that worked, ty so much

vestal folio
#

Wie lege ich beim Schreiben eines Create Channel Befehl fest in welcher Kategorie dieser erstellt werden soll

sage tendon
#

steht alles in den docs

vestal folio
#

Ich find's net

sage tendon
#

discord.TextChannel
steht alles da :)

vestal folio
#

Wo?

#

Finde nur 100 mal Models

sage tendon
sage tendon
#

wo hast du denn sonst geguckt lol

vestal folio
#

Das ist da auch so erklärt das ich es verstehe super

vestal folio
dense summit
#

What is the right way of putting more images in the same embed? Just using #set.image() over and over?

vestal folio
#

und nach discord.TextChannel heducht

sage tendon
shell radish
sage tendon
#

non-website embeds can have multiple images?

shell radish
#

to add multiple images to a single embed, you need to create multiple embeds

#

and each embed would have to have the same url and name

#

and then you can add images to those embeds

sage tendon
#

does that legit end up being one single embed in chat?

shell radish
#

if i described/remembered correctly, yeah

sage tendon
#

jfc

dense summit
#

Well, tbh im a little bit confused but i'll try

sage tendon
#

you aren't alone on this lmao

shell radish
#

#1117988200921702450 message