#Basic Pycord Help (Quick Questions Only)

1 messages ยท Page 16 of 1

proud mason
#

Does running your code take longer than 3 seconds with latency factored in?

slender abyss
#

no its not the case

proud mason
#

Hmm

slender abyss
#

what is the required latency ?

#

heroku gives 19ms

proud mason
#

Uh there is no required latency

#

Slower is better

slender abyss
#

i get 60ms from my host

proud mason
#

You are fine even when it is below 200

slender abyss
#

hmm then why this

#

tbh this is not the only button

proud mason
#

No idea tbh
If you were responding more than once it would have said interaction already responded

#

But that's not the case

slender abyss
#

it all started from here

#

idk what jab is trying to say

proud pagoda
#

Are you running multiple bot instances?

lime lichen
#

is there a place i can see discord.Interaction.data dict keys?

#

im trying to get the command usage

#

or command message content

proud mason
#

Discord docs?

proud mason
lime lichen
solid agate
#

Anyone having trouble with Autocomplete being utterly broken over the last few days?

#

I see the bot adding the right list to the autocomplete, but just erroring out over being a task ๐Ÿค”

slender abyss
#

i thought making the interaction work like this would help it but no

#

now what im thinking to avoid this is that im gonna defer the interaction and just send a normal message in that channel its not like it was ephemeral before

proud pagoda
slender abyss
#

im doing the same right? in the try block

proud pagoda
#

Yeah, but also try replacing the interaction.message.edit

slender abyss
#

okay

lime lichen
#

when i use both min_value and max_value, like shown in the example discord.Option code, the command does not register (and is removed) from my testing server

#

nevermind, i realized my problem

lime lichen
#

can you use tasks with cogs for separate files?

cyan quail
lime lichen
cyan quail
#

im pretty sure most of the task examples already use cogs

lime lichen
#

where is an example?

cyan quail
rare ice
lime lichen
#

just starts in the init ig

#

ok, thanks

young edge
#

what is the exact amount of time until an ephemeral message become invalid (not sure if thats the right word). i cant find a specific number either on the pycord docs nor on the official discord api. according to this dicord faq (https://support.discord.com/hc/en-us/articles/1500000580222-Ephemeral-Messages-FAQ), it just says "These messages disappear when you [...] wait long enough" and "They'll disappear after a little bit of time..."

its 15 minutes

lime lichen
#

does discord.commands.Bot.reload_extention(...) update slash command ui stuff? for example options

hushed ledge
#

One message removed from a suspended account.

naive remnant
#

How can I make a timeout for a command

full basin
#

Timeout for a command?

worn void
#

How can I reply to a dropdown with a button?

#

I'm trying this

    async def select_callback(self, select, interaction): # the function called when the user is done selecting options
        if select.values[0] == "Shoppy":
            await interaction.response.send_message(view=SubStoreMenuShoppy)
        else:
            await interaction.response.send_message(view=SubStoreMenuPatreon)
full basin
#

I think you must have content

#

Can't send a view alone

cyan quail
#

you can

cyan quail
worn void
#
class SubStoreMenuShoppy(discord.ui.View):
  def __init__(self):
    super().__init__(timeout=None)
    PayPalPage = discord.ui.Button(label='Shoppy Link', style=discord.ButtonStyle.gray, url='')
    self.add_item(PayPalPage)
#

@cyan quail

cyan quail
#

you never called it

#

SubStoreMenuShoppy()

worn void
#

ah

#

i tried that im pretty sure

#

AH guess not lmao

#

thanks, it works now

#

How do I make it so it shows the "dismiss message" think so it only shows for you

#

do I just add ephemeral=True?

fierce elm
#

Or application command type specifically

rare ice
#

Why is this happening with motor? And how do I fix it?

hearty mauve
#

My cog file isntworking, anyone know the issue

#
# main.py at the bottom of code:

for file in os.listdir('Cog'): 
    if file.endswith('.py'):
      client.load_extension(f'Cog.' + file[:-3]) 
# Cog/staff.py:

class staff(commands.Cog):
    def __init__(self, client):
         self.client = client

@commands.slash_command(name='mute', description='Mutes <user> for <duration> minutes because of <reason> using discords new timeouts')
@commands.has_guild_permissions(moderate_members=True)
async def mute(self, ctx, member: discord.Member, duration, reason):
    minutes = datetime.timedelta(minutes=int(duration))
    await member.timeout_for(minutes, reason=reason)
muteem=discord.embed(title=f"{member.mention} was muted for {minutes} for {reason}", color=0x2F3136)
await ctx.message.delete()
    await ctx.respond(embed=muteem)

def setup(client):
  client.add_cog(staff(client)))
slender abyss
slender abyss
#

i mean i want to edit the message + send a response

hearty mauve
hearty mauve
slender abyss
#

setup is a function in your cog file

#

you can run that function

#

from main file

slender abyss
hearty mauve
#

Ok

#

So i import in mainpy and use setup in cog file

slender abyss
#

in main file import cog_file_name without.py in the end and then use cog_file.setup(client)

#

if it's in a folder you can use
from cogs import cog_file
cog_file.setup(client)

devout nimbus
worn void
#

How can I get a user object with the pycord dropdown?

young bone
#

Interaction.user?

tulip bobcat
devout nimbus
tulip bobcat
#

i'm not

#

you have your command, and inside set up a select menu, but you never sent the select

chrome skiff
#

Is the "Pause Invites" feature already in pycord?

#

anything like guild.pause_invites or smth?

fervent cradle
#

how can i get Bot Latency And API Latency

fervent cradle
#

Inst that only client ping,

chrome skiff
#

this is the bot latency

chrome skiff
fervent cradle
#
    from ..http import Route, handle_message_parameters, MultipartParameters, HTTPClient, json_or_text
ImportError: cannot import name 'handle_message_parameters' from 'discord.http' (C:\Users\14794\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py)
#

uhhhhh

proud mason
slender abyss
#

Nothing is working

#

However i try to respond to the interaction it says unknown interaction

#

So i thought if i defer the interaction and try sendnig the messgae like a normal mesg it would work

proud mason
slender abyss
#

Nope

#

Does that work?

proud mason
slender abyss
#

Im not responding

proud mason
slender abyss
#

Im just editing like a normal message

proud mason
proud mason
slender abyss
#

If i would have been running two instances then my commands would reply twice wont they

slender abyss
proud mason
slender abyss
#

I see

proud mason
slender abyss
#

Lemme get my laptop

proud mason
#

But token reset is a harmless thing ngl

#

So it's fine to do it

slender abyss
#

this is my current code haven't tested it yet

#

im doing response in the last cuz even if it throws error it not gonna stop anything from running

#

the code before this was

await interaction.response.edit_message(view=self)
await interaction.channel.send(cont)
#

so as i put the reponse above channel.send(...) the line was not executed

slender abyss
proud mason
#

wait i think there is interaction.edit_original_message too
try that

proud mason
#

man this whole interaction thing is a bit weird ngl

#

multiple way to do multiple stuff

slender abyss
#

and the button will get disabled in 5min due to timeout

lime lichen
#

anyone know how long slash commands take to add to guilds?

#

if it depends on the guild count, consider 1100

#

pls @ me idc

slender abyss
tiny wagon
#

what is lock in buttons

tiny wagon
edgy dew
#

Hi, i've used the old Discord package for python for a long time and i wanted to take a big step and use py-cord. I stumbled across the "selectors" and i tried making a role selector. Everything fine so far. I just wanted to know if its possible to deactivate the selector after a user chose a role.

edgy dew
tiny wagon
#

the thing b4 . must be a SelectMenu object

edgy dew
#
async def select_callback(self, select, interaction):
        await interaction.response.send_message(f"Perfect. You chose the role {select.values[0]}")

This is my callback.

For the selector i use a class:

class MyView(discord.ui.View):
  @discord.ui.select(...)
#
await ctx.send("Simplistic - Role Selector", view=helper.MyView())
tiny wagon
#

select.disabled = True
then you need to edit the message with new view as self

#

await interaction.response.edit_message(view=self)

edgy dew
tiny wagon
#

๐Ÿ‘

proud mason
slender abyss
proud mason
#

lol

#

i only came to know about it a while back

slender abyss
#

wait isn't it true by default?

proud mason
#

no idea

#

oh it is

#

hmm nvm then

slender abyss
#

lol

slender abyss
#

i can't even defer it

#

i think i should not give a response

proud mason
#

man

#

wait for someone else

#

or ask in discord support server

#

also what is your discord version btw

slender abyss
slender abyss
#

it auto updates discord on start

proud mason
#

pip list

proud mason
slender abyss
#

pycord version?

proud mason
#

yea

#

sry mb

slender abyss
#

2.0.1

proud mason
#

try 2.1.1

slender abyss
#

it has problems

proud mason
#

oh

slender abyss
#

with slash commands group

#

i tried it i get the same error there also

#

##1593

proud mason
#

hmm

slender abyss
#

20-25 people clicking the button at the same time

#

for some it works maximum get interaction fail

rare ice
#

Why is this happening with motor? And how do I fix it?

silver moat
soft girder
#

I need help PyCord+Pillow not work.Details in private messages.Please help .hehehe

#

๐Ÿ‘† general problem

cerulean drum
slender abyss
soft girder
#

If you can give example.I'll be glad

cold hamlet
#

Why is get_application_command so unreliable?

slender abyss
#

whats is the error?

slender abyss
slender abyss
cold hamlet
slender abyss
#

pycord version?

cold hamlet
#
- Python v3.10.5-final
- py-cord v2.1.1-final
- aiohttp v3.8.1
- system info: Windows 10 10.0.19044

slender abyss
#

i think pycord 2.1.1 has some issues with slash commands groups

#

##1593

prisma flicker
#

it's true

#

try 2.0.1

cold hamlet
#

ok one sec

slender abyss
cold hamlet
#

neither of the first two yields have a value

#

OH

#

I need to specify that the config command is a group via type=discord.SlashCommandGroup

#

That's whacky

hushed ledge
#

One message removed from a suspended account.

#

One message removed from a suspended account.

simple canopy
#

make sure you are running 1 bot instance

hushed ledge
#

One message removed from a suspended account.

night warren
#

how can I create something like this?

hearty mauve
#

Why wont this work

cyan quail
soft girder
#

@cyan quail thx, I did it already

uncut skiff
#

Pip doesn't work

#

Nor does cloning the development version

cyan quail
#

perhaps there's a reason they don't want people installing packages

#

but you could potentially just write a python file to install with pip

uncut skiff
#

Hmm

#

Pip does run and install it

#

But it says no module named discord

#

It probably can't access the library

sleek arch
#

How can I get the user ID from a button click? I need it just to print to console at the moment.

sleek arch
#

I knew it was something with .user

round rivet
#

send help

bronze vector
#

sometimes i have it too

bronze vector
round rivet
#

interaction.user.id

bronze vector
#

see, we all have strokes sometime

round rivet
#

there only took 3 tries

sleek arch
worn void
#

How can I made it so with a / command it gives then 2 options for a value? e.g. transcript:True/False

proud pagoda
worn void
#

I tried messing with discord.Option and couldn't seem to get it to work, do you have any examples?

proud pagoda
#

So something like this:

async def some_command(ctx, choice: discord.Option(bool, "Your choice")):
    ...
proud pagoda
worn void
#

what is bool? the value name?

proud pagoda
#

No, its the type

worn void
#

oh wait yeah

proud pagoda
#

So you could use int for example so that it automatically converts to int and Discord will actually prevent people from entering a non-int on the ui side of things

worn void
#

ah

#

what are true false statements

proud pagoda
worn void
#

i cant remember for some reason

proud pagoda
worn void
#

Like True isnt a str its called something else

proud pagoda
#

bool

worn void
#

oh

#

that would be logical

#

also

#

this should work right?

                    for i in range(5,1,-1):
                        await ctx.respond(f"Ticket closing in {i}...")
                        time.sleep(1)
                    time.sleep(2)
                    await ctx.channel.delete()
proud pagoda
#

I would recommend using await asyncio.sleep() instead of time.sleep as time is thread blocking

#

But other than that it should work

worn void
#

kk

worn void
cinder silo
#

How to check who invited someone?

sleek arch
round rivet
#

uh yeah

#

interaction.guild

sleek arch
#

I couldn't find any of that on the documentation, thankyou

worn void
#

@sleek arch

sleek arch
#

Thankyou :)

fervent cradle
#

Hi, why i can not use global for get the channel?
....(self, ctx, channel: discord.TextChannel):
global channel
i need this for my modal because i want send to the channel what i select.

hushed ledge
#

One message removed from a suspended account.

proud pagoda
#

So something like this:

class MyModal(Modal):
  def __init__(self, channel):
    super().__init__(...)
    self.channel = channel
  
  async def callback(self, interaction):
    ...
proud pagoda
#

Set it to None initally, and then on button clikc, check if person is None and then update the person

prisma flicker
fervent cradle
unreal shoal
#

how do i make it so only the admins can see the command

hushed ledge
hushed ledge
cyan quail
fervent cradle
fervent cradle
cyan quail
#

you can just add an argument to the modal and pass it in, don't use global

#

well in any case, show how you've implemented it currently

fervent cradle
# cyan quail well in any case, show how you've implemented it currently
    @slash_command(description="test")
    async def test(self, ctx, channel: discord.TextChannel):
        modal = modal(title="Modal Test")
        await ctx.send_modal(modal)

class modal(discord.ui.Modal):
    def __init__(self, channel, *args, **kwargs):
        super().__init__(channel, *args, **kwargs)
        self.channel = channel

        self.add_item(discord.ui.InputText(label="sass", placeholder="asas"))

    async def callback(self, interaction: discord.Interaction):
         await self.channel.send(f"bla")
cyan quail
#

and you should call them different things

#

like call the class Modal

#

then do modal = Modal(channel, title="...")

#

oh also take channel out of super().__init__()

fervent cradle
fervent cradle
cyan quail
#

but you don't need global...

rare ice
fervent cradle
cyan quail
#

it should

fervent cradle
# cyan quail it should

then come this error
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: Modal.__init__() missing 1 required positional argument: 'channel'

cyan quail
#

i just said

#

ok look

#

you've defined your modal like this py class Modal(discord.ui.Modal): def __init__(self, channel, *args, **kwargs):meaning the first argument should be channel, and then anything else

#

but you're doing py modal = Modal(title="Modal Test")see the problem?

fervent cradle
#

modal = Modal(channel, title="Modal Test")

cyan quail
#

yes

fervent cradle
#

oh man.. discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'TextChannel' object has no attribute 'row'

cyan quail
#

show your new code

#

oh right

#

remove *args, from both init

fervent cradle
#

okay i have it

fervent cradle
cyan quail
#

can you show your new code

fervent cradle
# cyan quail can you show your new code
    @slash_command(description="test")
    async def test(self, ctx, channel: discord.TextChannel):
        modal = Modal(channel, title="Modal Test")
        await ctx.send_modal(modal)

class Modal(discord.ui.Modal):
    def __init__(self, channel, **kwargs):
        super().__init__(channel, **kwargs)
        self.channel = channel

        self.add_item(discord.ui.InputText(label="sass", placeholder="asas"))

    async def callback(self, interaction: discord.Interaction):
         await self.channelchannel.send(f"bla")

btw when i remove **kwargs then coming a new error

cyan quail
#

don't remove it

fervent cradle
#

okay

cyan quail
#

just checking, you didn't import Modal did you

fervent cradle
#

No why?

cyan quail
#

wait

#

.

cyan quail
fervent cradle
#

ohh

fervent cradle
cyan quail
#

all good

hearty mauve
#
@commands.slash_command(name='mute', description='Mutes <user> for <duration> minutes because of <reason> using discords new timeouts')
@commands.has_guild_permissions(moderate_members=True)
async def mute(self, ctx, member: discord.Member, duration, reason):
  minutes = datetime.timedelta(minutes=int(duration))
  await member.timeout_for(minutes, reason=reason)
muteem=discord.embed(title=f"{member.mention} was muted for {minutes} for {reason}", color=0x2F3136)
  await ctx.respond(embed=muteem)
#

Indentation looks right

#

Ping me if u can fix

full basin
#

There's a space (indent)

#

Before the respond just as the error says

hearty mauve
#

Ik

#

But its fine

#

๐Ÿ’€

#

Read the code @full basin

full basin
#

Copied and pasted your code and there's literally an indent

#

Its not that python just wants to yell about it

hearty mauve
#

Thats what i keep doing

#

What

#

I gotta move the timeout right?

obtuse juncoBOT
#

Why NOT to use Repl as a hosting platform

You should not use Repl.it to host your bot.
It may be a nice option as its "free" but you should use something else considering the major flaws.

  • The machines are super underpowered.
    • This means your bot will lag a lot as it gets bigger.
  • You'll need a web server alongside your bot to prevent it from being shut off.
    • This isn't a trivial task, and eats more of the machines power.
  • Repl.it uses an ephemeral file system.
    • This means any file you saved via your bot will be overwritten when you next launch.

IMPORTATNT

  • They use a shared IP for everything running on the service.
    This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.

Please avoid using repl.it to host your bot. It's not worth the trouble.

If you're looking for free options, consider using AWS/Google Cloud Platform/Azure and its respective free tiers or just pay for an actual VPS.

full basin
#

Do you have a proper IDE? Any decent IDE shows indentation errors.

hearty mauve
cyan quail
#

eh... arguably none of them are, even cheap 1-2$/month hosts are significantly better just because they operate in a very different way from free services

#

but if someone has to use a free service even when we advise not to, we can't really stop them

hearty mauve
#

I litterally cant spend money, im moving to a new house, and i dont have money, luxxy is constantly getting doxxed and railway is sketchy

#

Replit is fine

full basin
#

Railway is way better than replit

hearty mauve
#

But its sketchy

full basin
#

It's not

hearty mauve
#

It is so

cyan quail
#

please avoid... arguing about free hosts here, take it to #general

hearty mauve
#

Some guy tried to make me use his code and get money off of me

#

With railway

#

Replit is fine

prisma flicker
hushed ledge
quick temple
#

How can I get a list of all slash commands (my bot has)

#

I'm looking to get the name of the slash command only

rare ice
prisma flicker
proud pagoda
#

How would I go about restarting a task?

quick temple
#

thx

proud pagoda
rare ice
proud pagoda
#

Thanks

#

Idk why but I thought that wasn't a method for some reason

hushed ledge
#

One message removed from a suspended account.

#

One message removed from a suspended account.

prisma flicker
hushed ledge
#

One message removed from a suspended account.

worldly schooner
#

how can I add on_application_command_error to my cog file where I put all the event listeners (or cog.listeners)? I did it already but its not handling the errors:

@commands.Cog.listener()
async def on_application_command_error(self, ctx: discord.ApplicationContext, error):
        if isinstance(error, commands.CommandError):
            print(error)
            await ctx.message.add_reaction(':x:')
        if isinstance(error, KeyError):
            print(error)
            await ctx.message.add_reaction(':x:')
proud pagoda
#

And also is the error of type CommandError or KeyError?

worldly schooner
#

CommandError

#

mainly

worldly schooner
#

as on_message, on_member_join

proud pagoda
worldly schooner
#

ok lemme try

#

nothing

full basin
#

on_application_command_error doesnt handle prefixed commands errors

#

on_command_error does

proud pagoda
#

yeah

worldly schooner
#

changed to on_command_error, working now

#

thanks everyone for the help

hushed ledge
#

One message removed from a suspended account.

bleak cloud
hushed ledge
slender abyss
#

anyone knows how to host bot on railway?

#
File "/app/mbtrack.py", line 7, in <module>
import matplotlib.pyplot as plt
File "/opt/venv/lib/python3.9/site-packages/matplotlib/__init__.py", line 109, in <module>
from . import _api, _version, cbook, docstring, rcsetup
File "/opt/venv/lib/python3.9/site-packages/matplotlib/rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "/opt/venv/lib/python3.9/site-packages/matplotlib/colors.py", line 56, in <module>
from matplotlib import _api, cbook, scale
File "/opt/venv/lib/python3.9/site-packages/matplotlib/scale.py", line 23, in <module>
from matplotlib.ticker import (
File "/opt/venv/lib/python3.9/site-packages/matplotlib/ticker.py", line 136, in <module>
from matplotlib import transforms as mtransforms
File "/opt/venv/lib/python3.9/site-packages/matplotlib/transforms.py", line 46, in <module>
from matplotlib._path import (
ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory
Traceback (most recent call last):
``` i get this error
tranquil coyote
#

Please help me in my post

fervent cradle
#

you can either deploy via railway cli, or upload your code to a private repository in your github and deploy the repo in railway

#

i am sure the docs must have covered it all

#

Does pycord support the HTTP thing where a bot can have no status?

slender abyss
#

i deploying using private git repo still

fervent cradle
fervent cradle
amber shale
#

how to have timestamp like this in embed footer

full basin
#

embed.timestamp = datetime.datetime.utcnow()

royal spindle
#

how to add slash command permission for an user id?

bleak cloud
#

is it not possible to get contents of automod filters yet?

cyan quail
cyan quail
#

or fetch_auto_moderation_rules if you want all rules

#

not sure if the feature is 100% complete yet, but it should work well enough

bleak cloud
cyan quail
#

the object doesn't appear to be fully implemented, but does it return anything?

sharp smelt
#

Why do I get this when I start my bot? It looks like it happens after the on_ready event. The bot still works

bleak cloud
#

it returned nothing, sadly
probly itโ€™s not finished

sharp smelt
#

2.1.1

cyan quail
#

ohok

#

?tag missing_access

obtuse juncoBOT
cyan quail
#

or you specified a guild_id you don't have access to

sharp smelt
#

ty

cyan quail
bleak cloud
#

i managed to get the data!
it was just that the data i was trying to fetch was a discord-made one, so there was nothing inside the data
sorry, and thanks for the help!

cyan quail
#

all good

amber shale
fervent cradle
#

Hey, why i can not edit my label from the button?
global no
@discord.ui.button(label=no"
global no
no = f"({nein_counter})"

NameError: name 'no' is not defined
btw nein_counter = in json

fervent cradle
#

its possible to add cooldown to buttons?

undone smelt
#

Do we know why discord.User.display_name throws a type error in pylance? It's weird because they're typed correctly in the source

full basin
#

Cause whatever youre doing there makes no sense

full basin
fervent cradle
nocturne canopy
#

what exactly is ctx:commands.Context used for? does it have to go in every command, or only those with arguments?

full basin
#

And the button object has a label attribute

fervent cradle
#

ohh okay

full basin
#

I'm sure you can figure out what to do with that

full basin
#

All commands receive a context.

fervent cradle
#

?

full basin
#

It is what the word says, the command context

full basin
fervent cradle
#

Oh a function

full basin
#

I said its not

fervent cradle
#

ok ty

#

can someone help me with this?
``` await interaction.author.send(embed=discord.Embed(title="Key Generated",description=f"Your Key: {key}",colour=0x42F56C))

#

like if u clicked the button you will receive a dm

#

nvm i replaced author with user

calm plume
#

this question probably has been asked but

#

can i respond to a slash command without sending any message?

silver moat
calm plume
#

i just wanna do something without sending a message so discord doesn't say

#

"Interaction Failed"

silver moat
#

why can't the response be ephemeral?

calm plume
#

ephemeral isn't it hidden?

#

bc i don't want to send a message even if its hidden

silver moat
#

what does your command even do

umbral fox
#

i keep getting this error "ctx is a required argument that is missing.", when i use this command. anything i could do about this ? here is the command code.

calm plume
#

it just a error handler

silver moat
calm plume
dry echo
calm plume
#

and instead do something else

silver moat
#

like what?

calm plume
#

like send a message on a other website (using a other api)

silver moat
#

it's still good for the end-user to display a success or fail

calm plume
#

ik but can i pls just have the code to say to discord not to popup the

#
Interaction Failed
umbral fox
silver moat
#

you can delay it with defer

#

or respond and delete the response

calm plume
#

to see a message just pop up and dissapear

silver moat
#

exactly

dry echo
#

.invoke()

calm plume
#

wait u mean

dry echo
#

ctx.invoke()

calm plume
#
ctx.invoke
dry echo
#

then it doesnt pop up

calm plume
#

wait it requires a command argument

#

and im on a bot.event

#

not bot.command

silver moat
#

wut

dry echo
#

lemme see

calm plume
#

yeh it says

#
TypeError: invoke() missing 1 required positional argument: 'command'
dry echo
#

show the code....

silver moat
#

what even is the point of invoke

calm plume
#
@bot.event
async def on_application_command_error(ctx: discord.ApplicationContext, error: discord.DiscordException):
    await ctx.invoke()
    if isinstance(error, commands.CommandOnCooldown):
         # Other API Related Stuff Unesscarry to Discord
    else:
        raise error
proud pagoda
#

Why are you invoking the command on error?

calm plume
silver moat
#

I still don't understand why you can't respond with a message

proud pagoda
calm plume
#

but i don't want to respond to a message, i wanna use lets say a other api to respond

#

oh wait

silver moat
#

what do you mean another api to respond

calm plume
#

nvm i get what u meant

silver moat
#

you should still send a message eventually to inform the end-user of the result of their command

calm plume
#

like how can i say this

#

when the end user executes the command

#

i wanna end the command and not output anything

umbral fox
silver moat
calm plume
silver moat
#

even saying something like "Success!"

calm plume
#
try:
    await inter.send()
except disnake.errors.HTTPException:
    pass  # We know this isn't valid but that's fine
silver moat
#

would work

sleek arch
#

I have my bot set up to create a new channel with guild.create_text_channel("Name")How can I make it create a private channel, one that I can add users or roles to have permissions with

calm plume
#

overwrites is basically the permissions

sleek arch
sleek arch
calm plume
#

np

calm plume
#

anyways

#

uhh The application did not respond can this tho be disabled without sending a new message

calm plume
#

but i think it adds the menus if ur using pycharm

#

so u can inspect the functions without having to look the docs

#

or ask anything

umbral fox
calm plume
#

well okay

#

but its reccomended to use this instead of plain ctx

#

or for me at least

iron halo
#

i added a cooldown to 1 command like this
@discord.ext.commands.cooldown(1, 1, discord.ext.commands.BucketType.user)
and it worked fine
but now i added it to other commands and it tells me
AttributeError: module 'discord' has no attribute 'ext'

#

and i am confused why it has only decided now that theres no ext

cyan quail
iron halo
#

no

#

the only time i have discord is import discord

cyan quail
iron halo
#

uhhh its 3500 lines

cyan quail
#

bruh

#

the only way that would happen is if you overrode discord somewhere GuraShrug

iron halo
#

ill try go back to when it worked and try again

#

maybe i just copied and pasted wrong

#

yea i went back to it only being on 1 command and it works fine

#

thats so weird

wooden zenith
#

does anyone have any type of example of where when u need a password for a command to work because i have seen my friend use a code where the password is needed for the command to execute if anyone has any info on something like this please let me know

undone smelt
#

Does anyone have a raffle command I could take a peek at? ๐Ÿ‘€

lime lichen
#

code:

member = await ctx.guild.get_member(user.id)

error:

Application Command raised an exception: TypeError: object Member can't be used in 'await' expression
tulip bobcat
#

the error occurs after the member was found, therefore trying to await the object Member that was retrieved by the get_member method

lime lichen
#

@tulip bobcat thanks, mixed up fetch_member and get_member methods

lime lichen
calm plume
#

is it possible to add a sort of custom variable that i can write to the function of a command and access it later by like using ctx?

naive remnant
#

How can I make only members with a specific role that can access a command

quick temple
#

I have an ApplicationCommand object (command from my bot), how can I get a list of all the inputs it takes from the user

dry echo
#

when i use task.loop() and pass a time(hour=8, minute=15) object, does it loop through the task until the minute is over or only once?

cyan quail
night warren
#

'TicketingButton' object has no attribute '_underlying' hm what

cyan quail
cyan quail
cyan quail
dry echo
night warren
#
class TicketingButton(discord.ui.Button):
    def __init__(self, label):
        super().__init__(
            label="Report Player" if label is True else "Open a Ticket",
            style=discord.ButtonStyle.red,
            custom_id="report" if label is True else "ticket",
        )

    async def callback(self, interaction: discord.Interaction):
        bot = variables.bot
        embed = await interaction.response.send_modal(ReportingModal()) if self.label is True else await interaction.response.send_modal(TicketingModal())
        cat = bot.get_channel(1012271308765138954)
        overwrite = discord.PermissionOverwrite(send_messages=True, read_messages=True, read_message_history=True)
        category_overwrites = cat.overwrites```
how do I add arguments to the callback func? I can't add things in the __init__ as that would mess up the parameters I think
cyan quail
cyan quail
#

you can't mess with the callback

dry echo
cyan quail
#

why would it repeat itself

cyan quail
night warren
#
class TicketingButton(discord.ui.Button):
    def __init__(self, label, bot):
        self.label = label
        self.bot = bot
        super().__init__(
            label="Report Player" if label is True else "Open a Ticket",
            style=discord.ButtonStyle.red,
            custom_id="report" if label is True else "ticket",
        )

    async def callback(self, interaction: discord.Interaction):
        embed = await interaction.response.send_modal(ReportingModal()) if self.label is True else await interaction.response.send_modal(TicketingModal())
        cat = self.bot.get_channel(1012271308765138954)
        overwrite = discord.PermissionOverwrite(send_messages=True, read_messages=True, read_message_history=True)
        category_overwrites = cat.overwrites
        category_overwrites[interaction.user] = overwrite
        tn = await funcs.how_many_tickets() + 1
        cursor = await variables.db_connection.cursor()
        new_chan = await cat.create_text_channel(f'{"Reporting" if self.label is True else "Ticket"}-{tn}', overwrites=category_overwrites)
        await cursor.execute(
            "INSERT INTO Ticketing (TicketID, CreatorID, CreatedAt, ChanID, ClosedAt) VALUES (?, ?, ?, ?, null)",
            (tn, interaction.user.id, time.time(), new_chan.id))
        await variables.db_connection.commit()
        await interaction.response.send_message(f"You can find your channel at <#{new_chan.id}>")
        await new_chan.send(embed=embed)```
cyan quail
#

yeah that would work

#

though tbf you generally don't even need to do bot because you can get it from interaction.client

night warren
#
                            guild_ids=[variables.guild_id])  # Create a slash command for the supplied guilds.
    @discord.default_permissions(
        manage_messages=True
    )
    async def postticket(self, ctx):
        view = discord.ui.View(timeout=None)
        view.add_item(TicketingButton(label=True, bot=self.bot))
        view.add_item(TicketingButton(label=False, bot=self.bot))
        chan = self.bot.get_channel(1014263404992675850)
        embed=await funcs.custom_embed("Welcome", "Please select one of the following options")
        await chan.send(embed=embed, view=view)
        await ctx.respond("Done", ephemeral=True)```
cyan quail
#

since you made the arguments positional, you just need TicketingButton(True, self.bot)

night warren
#

**Ignoring exception in command postticket:
Traceback (most recent call last):
File "/Users/marianraul/PycharmProjects/GTAbot/venv/lib/python3.10/site-packages/discord/commands/core.py", line 127, in wrapped
ret = await coro(arg)
File "/Users/marianraul/PycharmProjects/GTAbot/venv/lib/python3.10/site-packages/discord/commands/core.py", line 904, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "/Users/marianraul/PycharmProjects/GTAbot/cogs/ticketing.py", line 94, in postticket
view.add_item(TicketingButton(label=True, bot=self.bot))
File "/Users/marianraul/PycharmProjects/GTAbot/cogs/ticketing.py", line 36, in init
self.label = label
File "/Users/marianraul/PycharmProjects/GTAbot/venv/lib/python3.10/site-packages/discord/ui/button.py", line 189, in label
self._underlying.label = str(value) if value is not None else value
AttributeError: 'TicketingButton' object has no attribute '_underlying'

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

Traceback (most recent call last):
File "/Users/marianraul/PycharmProjects/GTAbot/venv/lib/python3.10/site-packages/discord/bot.py", line 997, in invoke_application_command
await ctx.command.invoke(ctx)
File "/Users/marianraul/PycharmProjects/GTAbot/venv/lib/python3.10/site-packages/discord/commands/core.py", line 359, in invoke
await injected(ctx)
File "/Users/marianraul/PycharmProjects/GTAbot/venv/lib/python3.10/site-packages/discord/commands/core.py", line 135, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'TicketingButton' object has no attribute '_underlying'**

#

this is what I am getting

cyan quail
#

can you move the super init above self.label

#

(also considering the logic you used in super, you should completely remove self.label = ... anyway

night warren
#

it works tysm

meager heron
#

Is there an easy way to set a recurring task to run on a specific day of the month? (i.e. "run on the 1st of the month at midnight")

#

I know I can set the next run datetime, but I wanted to make sure there isn't a more trivial method first

cunning stag
#

I need help, I installed pycord and I want to delete it for a while and when I type pip uninstall py-cord it is deleted but I can't start the regular discord.py bot

#

I thought it was down to the bot script itself, but not a single bot is working, but all of them were working

proud pagoda
#

Try typing pip install discord.py

cunning stag
silver moat
#

type pip freeze and send output

proud pagoda
#

I believe dpy calls them something different so you may have issues using them

cyan quail
#

i guess you could have it run every day

#

and then check the current date

pallid token
#

I've realized that now that I've implemented a select dropdown, the bot takes much much longer to shut down. Is this normal?

#

Event loop seems to only close sometimes.

cunning stag
cunning stag
#

@silver moat ๐Ÿ˜ฆ ๐Ÿ˜‚

rare ice
#

?tag codeblock

obtuse juncoBOT
#

Please put your code in a code block:
```py
Here is your Code
```

That makes reading code in Discord a lot easier:

print("This is an example.")
fervent cradle
#

i realised i put role as interaction user id

hushed ledge
#

One message removed from a suspended account.

full basin
full basin
hushed ledge
full basin
#

Make some attribute and check it before actually running the callback?

bright shard
#

I have a command that essentially stops if 'lose' becomes false, I made a button that pops up along w the embed when you start the command

#

my question is how could I change the value of lose via the button?

hushed ledge
bright shard
#
class Skip(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)

    @discord.ui.button(label='Skip', style=discord.ButtonStyle.primary)
    async def skip(self, button, interaction):
        print('make lost true')```
#

this is my buttons callback and when i just try and lose = true in the callback nothing happens

full basin
full basin
bright shard
#

basically

#

the variable 'lose' is false in the command and when it becomes true, the command stops i currently have it so when you send a message in chat lose becomes true

#

but i want to make it so when you press the button lose becomes true

#

nothing happens when i just put lose = true in the callback though

hushed ledge
full basin
#

Because youre just setting a variable

#

Youre not responding

full basin
hushed ledge
full basin
#

I said override interaction_check

hushed ledge
full basin
#
async def interaction_check(self):
  if self.pressed ...

@discord.ui.button(...)
async def ...```
pallid token
#

I've realized that now that I've implemented a select dropdown, the bot takes much much longer to shut down.
Event loop seems to only close sometimes. Otherwise it just sits there at closing forever. Is this normal?

worn void
#

I had an error I got and cant figure it out:

#

nevermind ๐Ÿ’€

fervent cradle
#

Hi anyone have any idea whats going on with discrod api, my bot is getting temp ban too frequently and the bot is just shutting down even when the code is still running, It has been running for more than an year now never faced this and the bans were never frequent

#

No updates to the code have been done recently

surreal glade
#

also @lilac turret do u know how to make a command with optional arguments

silver moat
#

text command or slash command?

surreal glade
lilac turret
#

I think you use Optional in the type annotation or set the default value to None

surreal glade
#

how do i give it different functions based on what u put

#

this is what i want to do

silver moat
# surreal glade text

assign a default value like

async def cool_command(ctx, optional_arg = "No way!"):
  pass
surreal glade
#

%heat add/set usr amt

#

thats what i want to do

#

add or set

lilac turret
#

I don't think you can do that because of how Python treats default parameters before non-default parameters

#

Actually wait

#

I'm stupid sorry

#

Just check if the first argument is add or set, and if it's not then raise an exception

surreal glade
lilac turret
#

I'm surprised you didn't think about that

surreal glade
#

im surprised i didnt either

#

ooh i can use elifs, my favorite

surreal glade
lilac turret
#

What

silver moat
surreal glade
#

hey man cut me some slack havent worked with python in like a week

surreal glade
#

very much so

lilac turret
surreal glade
#

but i have been doing cpp like stuff with arduinos and ultrasound measurement systems

#

for a while

lilac turret
#

Ah I see

silver moat
#

ok #general ty

lilac turret
#

No and goodbye

silver moat
surreal glade
lilac turret
#

if thing == "other value" or thing == "another value":

#

Pretty straightforward

surreal glade
#

well yes

#

but how

worn void
#

How can I make it so when I restart my bot, the current buttons it has posted in channels still work and dont just say "interaction has not responded"

lilac turret
errant craneBOT
#

Here's the persistent example.

silver moat
#

@worn void ^

worn void
#

ty

surreal glade
# lilac turret Wdym?
@bot.command()
async def heat(add, set, usr: discord.Member, val, ctx):
  if #idk what to put here
worn void
#

what are you trying to do?

surreal glade
#

i would know how with normal base python but this is pycord

lilac turret
worn void
#

Its the same thing

lilac turret
#

Actually on second thought why not use subcommands?

surreal glade
#

actually ik what it is

#

but how do u do it with like

#

text cmds

#

wait ik how

silver moat
#

congrats

surreal glade
signal sandal
#

any idea why i cannot get audio off of pycord

#

bot just will not play audio

#

even if lavalink says it is

lilac turret
#

Any more information? Saying "guys this isn't working" is not helpful

fervent cradle
fierce elm
#

where is the SlashCommandGroup decorator

tiny wagon
#

how to invoke a slash subcommand?
works fine on one word slash commands
await ctx.invoke(self.bot.get_application_command('auction info'))

night warren
#
class TicketingModal(discord.ui.Modal):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
        self.add_item(discord.ui.InputText(label="Reason", style=discord.InputTextStyle.long))

    async def callback(self, interaction: discord.Interaction):
        await self.wait()
        embed = await funcs.custom_embed("Ticket", "A ticket has been opened")
        embed.add_field(name="Reason", value=self.children[0].value)
        return embed```

why won't the code wait for the modal to be completed by the user and why is embed of type interaction?
calm plume
#

question

#

quite quick one

#

does @commands.has_permissions also know when u have the permissions when you are administrator

calm plume
#

so if i have lets say Admin Permissions

#

and the Command needs Kick, Ban Member Enabled, Admin Should bypass it

young bone
#

With Admin you have any permissions

#

You also can delete the server

calm plume
#

bc when i used an if elif and else

#

i had to do

#
if (ctx.author.guild_permissions.kick_members or ctx.author.guild_permissions.ban_members) or ctx.author.guild_permissions.admin
#

thx a lot tho @young bone

#

also before u go one other question

#

is it possible if i can get the required permissions of a command without having to specify them in lets say a Database or json file

dry echo
#

how can i access the callback without using decorator?

class SelectToDoItem(discord.ui.View):
    def __init__(self, bot, entries):
        super().__init__(timeout=None)
        self.entries = entries
        self.select_options = []
        
        for entry in entries:
            self.select_options.append(discord.SelectOption(label=entry[2], value=entry[1], description=entry[3]))
        
        self.add_item(discord.ui.Select(options=self.select_options, placeholder="test", custom_id="select_todo"))
    

    async def select_callback(self, select, interaction):
      ...
tulip bobcat
dry echo
#

like this?

        self.children[0].callback = self.callback
    
    # the function called when the user is done selecting options
    async def callback(self, select, interaction):
        ...
tulip bobcat
#

looks good

dry echo
#

TypeError: SelectToDoItem.callback() missing 1 required positional argument: 'interaction'

tulip bobcat
dry echo
#

nvm i got it self.children[0].values[0]

tulip bobcat
#

interaction.data["values"]

calm plume
#

but one question and thats for the error handling

#

i wanna stop discord from Saying "Application did not Respond" bc i try to send a dm on my Error Handling

#

and the command kinda keeps going, even with the error

tulip bobcat
#

use on_application_error to handle the error

calm plume
#

but lets say i execute a command

#

and the error gets thrown yeh?

#

the bot dms me for the error, like normal

#

but the command just doesn't stop that i executed and then says after 3 seconds "application did not respond"

tulip bobcat
#

the command stops, but you never responded to the command, that's why it fails

#

instead of sending a dm, you could respond to the command

calm plume
#

i would like it to respond by dm

tulip bobcat
#

is it necessary to respond via dm? or do you just donโ€™t want the error to show รบp in the server?

calm plume
#

if possible even turn of the application did not respond completely

calm plume
#

as i will make it configurable

tulip bobcat
calm plume
#

so py-cord should have one trick as well

tulip bobcat
#

oh, in this case I just donโ€™t know about it

calm plume
#

oh ok

#

well thx at least for trying to help

tulip bobcat
#

or send a dummy response

calm plume
#

ik its a fork

#

but bc right there were tricks i could use to make discord stop saying "application did not respond"

amber shale
#

how to dm a member?
use case - want to dm him when a guild has unbanned him

calm plume
#
try:
   ctx.reply()
except HTTPException:
   pass
#

basically stopping discord

#

also what does ctx.response.pong do?

#

like i see docs

#

and says Pongs the ping interaction.

amber shale
#

oh

#

i use ctx.defer if it is taking long time

#

no idea about this

calm plume
#

ok

#

Is it possible if i can contact the Core Developer since they know a lot more bc they are a part of the library

amber shale
#

dont know shoud ask mod

#

then move on to that

#

how to give options to select from?

#

in slash command

full basin
#

It takes a list

amber shale
full basin
#

async def command(ctx, food: discord.Option(str, "Choose your favorite food", choices=["hotdogs", "apples", "banana"])

amber shale
#

oh

#

lets me try it thanks for helping me

coral kindle
grizzled sentinel
grizzled sentinel
coral kindle
#
class View1(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=0)
    @discord.ui.button(emoji='๐Ÿ“ฉ', label='Stworz zamowienie!', style=discord.ButtonStyle.grey, disabled=False)
    async def create_ticket(self, button: discord.ui.Button, interaction: discord.Interaction):
        await interaction.response.send_message(f'Stworzono ticket!', ephemeral=True)
        overwrites = {
            interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False),
            interaction.guild.me: discord.PermissionOverwrite(read_messages=True),
            interaction.user: discord.PermissionOverwrite(read_messages=True)
        }
        await interaction.guild.create_text_channel(name=f'{interaction.user.name}-ticket',
                                                    overwrites=overwrites,
                                                    reason=f'Ticket {interaction.user} (ID: {interaction.user.id})')
        
        channel = discord.utils.get(member.guild.text_channels, name=f"{interaction.user.name}-ticket")
        guild = member.guild
        embed = discord.Embed(title="Stworzono ticket!",
                        description=f"Postฤ™puj zgodnie z poleceniami administracji!", color=0x2f3136)
        await channel.send(embed=embed)

@bot.slash_command(name='ticket')
async def test(ctx):
    await ctx.respond(content=f'Wysล‚ano!', ephemeral=True)
    await ctx.channel.send(view=View1(), embed=discord.Embed(title='Stwรณrz zamรณwienie!',
                                                            description='Jeลผeli juลผ wiesz, co chcesz zamรณwiฤ‡, kliknij guzik na dole!\nNiepotrzebne tickety bฤ™dฤ… odrazu kasowane!', color=0x2F3136))```
grizzled sentinel
coral kindle
#

i didnt

grizzled sentinel
#

does restarting the bot help?

grizzled sentinel
#

I think all you need to do is upgrade to this PR

#

what version are you on now?

#

You should upgrade right away to the above pull (or at least 2.0.1).
2.0.0 has a major security vulnerability. Ability to crash your bot by just running a command or something

#

๐Ÿ‘

#

Groups have been having a lot of issues.
\https://github.com/Pycord-Development/pycord/pull/1605
This is a new version that fixxes some things with cogs.
What are the problems you run into with newer versions?

#

pip install -U git+https://github.com/Pycord-Development/pycord/pull/1605 iirc

#

pip install -U git+https://github.com/Pycord-Development/pycord try this

#

Sorry im not sure about this. You should create a thread and someone with a bit more knolage of the issue might be able to help.

proud mason
#

is it possible to edit a message without using channel.fetch_message ?

#

i want to avoid that api call

#

also does fetch_message return the view too ?

cyan quail
proud mason
#

ohh ic ic

dry echo
#

when i use this edit code i get interaction has failed, because no response, how can i change that?

await interaction.message.edit(embed=embed)
proud mason
#

i think ill use fetch message as i need the view

cyan quail
dry echo
#

why so complicated sadge

cyan quail
#

not really, that's an interaction response

proud mason
cyan quail
#

well it kinda has to be like that

proud mason
#

there is interaction.edit_original_message too ๐Ÿ’€

cyan quail
#

responding to an interaction is different from regular sends/edits

proud mason
#

true

#

but it becomes a bit confusing

cyan quail
#

we can lay it out
interaction.message.edit - Regular message edit, only works if message is cached / interaction.message isn't None
interaction.edit_original_message - Same as above, but more reliable since it can edit directly
interaction.response.edit_message - Responds to an interaction with an edit, only used once

#

in general, all methods under interaction.response can only be used once per interaction

solemn spire
#

can I get users by discriminator?

fervent cradle
#
AttributeError: 'Button' object has no attribute 'user'
#

can someone help me?

white wadi
#

hi guys i wanna make a sqlite database for my bot, should i save user ids as int or string?

fervent cradle
fervent cradle
#

How can I use a converter not in a function definition?
If I have an object, how do I convert it

amber shale
#

how to make buttonrole?

#

can i get some basic idea how that work?

#

what happens when bot restarts..

fervent cradle
wet coral
prisma flicker
fervent cradle
#

For example Member

#

Convert a integer into a member using a converter, but not having it in the command definition

prisma flicker
#

I would use fetch_member or get_member or discord.utils.get(guild.members,id=id)

wet coral
fervent cradle
#
@bot.slash_command(name='embed', description='Build an embed...')
async def embed(ctx):
    
    be_button = Button(emoji='๐Ÿ“„', label='Build', style=discord.ButtonStyle.green)
    async def be_callback(interaction):
        modal = MyModal(title="Modal Triggered from Button")
        await ctx.send_modal(modal)
    view = View()
    be_button.callback = be_callback
    view.add_item(be_button)
    
    await ctx.respond("thinkin' about an embed?", view=view)
#

i have defined my modal somewhere so not to worry about that, but this keeps giving me an interaction responded error, how do i fix it

prisma flicker
#

what do you mean "interaction responded error"

fervent cradle
#

do you know how i can fix this? i am unable to understand i changed, ctx.respond to ctx.send and that didnt work either

prisma flicker
#

is this when you run /embed, click the Build button, or submit the modal?

fervent cradle
wet coral
#

try to replace await ctx.send_modal(modal) with await interaction.send_modal(modal)

prisma flicker
#

I was going to see what I do in my code but that sounds like it should work

cyan quail
#

interaction.response.send_modal

prisma flicker
#

^ yeah I think that's what I do actually

undone smelt
#

Is there no get_role(role_id) ๐Ÿค”

cyan quail
#

guild.get_role

undone smelt
#

Damn I got hit with a read the docs. Gotta happen eventually ig

cyan quail
#

gottem

half olive
#

how to download pycord beta v7?

red marlin
#

How to get members that can see TextChannel?

cyan quail
half olive
cyan quail
#

i mean we have newer versions you can use

half olive
cyan quail
#

well we're currently on 2.1.1

half olive
#

would it affect my work?

cyan quail
#

depends GuraShrug give it a try

#

do you use slash command groups?

half olive
#

nah

cyan quail
#

go for it then

#

don't think there are any other significant bugs

half olive
#

pip install pycord==2.1.1
?

cyan quail
#

yeah

half olive
# cyan quail yeah

help~ 9975pepecryhands

Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement pycord==2.1.1 (from versions: 0.0.1, 0.1.0, 0.1.1)
ERROR: No matching distribution found for pycord==2.1.1```
cyan quail
#

oh oops

#

py-cord==2.1.1

half olive
harsh dust
#

i've just moved to api v10, and changed from commands.Bot to discord.Bot, and this isnt affecting any of the commands from working but on_ready is taking like 4 minutes to load where it used to load within like 10 seconds.

fervent cradle
#

thanks

cyan quail
#

all good

dim flicker
#

Why does python write to me when starting the bot instead of starting it

#
c:\Users\niksy\Desktop\Caramel\bot.py"
Python 
young bone
proud pagoda
dim flicker
proud pagoda
proud pagoda
#

Try using f5 to run it

#

Since your using vs code

dim flicker
severe storm
#

how can i play a mp3 file in a vc?

worn void
#

How can I made mandatory fields and optional fields in a slash command?

quick moon
#

When I switched to pycord, I uninstalled later and went back to discord.py. I made a new bot and switched back to pycord with the correct code from using a slash command example from the guide. Although, the bot isn't turning on and I'm not sure why. If I switched back to discord.py, it would turn on. Does anyone know why? I already tried looking for answers

simple canopy
#

is there any errors?

quick moon
#

There is, but the file crashes before I can even check the error.

simple canopy
#

are you on windows?

quick moon
#

Mhm

simple canopy
#
python3 file_name.py
pause
#

use this script with .bat file

#

place it in same directory with your bot main file

worn void
#

You have to uninstall discord.py, then make sure you imported py-cord I believe

#

Its weird

simple canopy
#

its not, because pycord uses same namespace as dpy

worn void
#

I mean in that context its weird set of steps to install because of that

simple canopy
#

yeah

simple canopy
#

๐Ÿ‘๐Ÿป

worn void
#

So would this work?


@client.slash_command(guild_ids=g, name="bug", description='Reports a bug to the Bot Developer(s).')
async def bug(ctx, bug, image : Option(str, "Any proof of this bug.", required = False, default = ''):
    await ctx.respond(ephemeral=True, "Bug has been re[prted!")
simple canopy
worn void
#

FUCK

#

screw you

simple canopy
worn void
#

lmfao, was wondering if i did it correct hoping youd respond before I can restart my bot

simple canopy
#

i think you did, but if you tried - you would see

worn void
#

and the answer was no

#

It's discord.Option

simple canopy
#

yes it is

worn void
#
    async def bug(ctx, bug, image : discord.Option(str, "Any proof of this bug.", required = False, default = ''):
                                                                                                                 ^
SyntaxError: invalid syntax
#

what, how

#

oh nvm, im stupid

simple canopy
#

you didn't close the bracket

worn void
#

doesnt this just look beautiful

simple canopy
#

it does, but you didn't use emojis

#

๐Ÿ˜”

worn void
#

well

#

Also ik i need to rename the title

simple canopy
#

ok, thats out of topic now

worn void
#

fine ๐Ÿ˜”

simple canopy
quick moon
#

I'm back. It didn't work. I used the script that you gave with the .bat file, but for some reason, it still didn't wanna work.

pallid token
worn void
pallid token
# worn void Elaborate on what you mean? How are you shutting down the bot?

SIGTERM graceful shutdown of the bot. Bot goes through the process of closing loop, cleaning up tasks, etc.

INFO:discord.client:Received signal to terminate bot and event loop.
INFO:discord.client:Cleaning up tasks.
INFO:discord.client:Cleaning up after 5 tasks.
INFO:discord.client:All tasks finished cancelling.
INFO:discord.client:Closing the event loop.
worn void
#

hm not sure

#

maybe theres something internal with the actual dropdown

pallid token
#

It gets to "Closing the event loop." and just sits there for ages.

worn void
#

not sure, im not very graceful and ctrl + c, saying fuck all

severe storm
#

how can i play a mp3 file in a vc?

worn void
#

maybe try

voice.play(discord.FFmpegPCMAudio(executable="C:/path/ffmpeg.exe", source="C:/songpath"))
errant craneBOT
#

Here's the basic voice example.

severe storm
#

thanks, i will look into this

clever nova
#

is it possible to limit the visibility and interaction with a button to a certain role or user?

pallid token
errant craneBOT
#

Here's the button roles example.

cyan quail
prisma flicker
#

Or interaction_check

harsh dust
#

meaning im hosting it completely for free but also the specs of it aren't great

#

but its still manageable

worn void
#

How can I strip a channel for all of its permissions

cyan quail
worn void
cyan quail
#

that's literally what you do

worn void
#

oh ๐Ÿ’€

worn void
#

Could someone help me out?

class TicketClosedButtons(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)
        del_button = discord.ui.button(label="Delete", custom_id="delete_ticket", style=discord.ButtonStyle.danger, emoji="๐Ÿ”’")
        trans_button = discord.ui.button(label="Transcript", custom_id="transcript_ticket", style=discord.ButtonStyle.danger, emoji="๐Ÿ“œ")
        self.add_item(del_button)
        self.add_item(trans_button)
    async def button_callback(self, button, interaction):
        support = discord.utils.get(interaction.guild.roles, name="Staff")
        channel = client.get_channel(transchanid)
        if button.label == "Delete":
            embed=discord.Embed(color=0xff0000)
            embed.add_field(name="Ticket Deletion", value="Ticked will be deleted in a few seconds.", inline=False)
            embed.set_footer(text="Report bugs or suggestions with /bug or /suggest!")
            await interaction.response.send_message(embed=embed)
            await asyncio.sleep(5)
            await interaction.channel.delete()
        else:
            transcript = await chat_exporter.export(interaction.channel)
            transcript_file = discord.File(io.BytesIO(transcript.encode()), filename=f"{interaction.channel.name}.html")
            await channel.send(file=transcript_file)
#

Error:

Ignoring exception in on_ready
Traceback (most recent call last):
  File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "F:\[bots]\MyChemicalCult Bot\bot.py", line 36, in on_ready
    client.add_view(TicketClosedButtons())
  File "F:\[bots]\MyChemicalCult Bot\bot.py", line 136, in __init__
    self.add_item(del_button)
  File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ui\view.py", line 287, in add_item
    raise TypeError(f"expected Item not {item.__class__!r}")
TypeError: expected Item not <class 'function'>
legoscrap-sup
Ignoring exception in view <TicketCommandButtons timeout=180.0 children=1> for item <Button style=<ButtonStyle.danger: 4> url=None disabled=False label='Close' emoji=<PartialEmoji animated=False name='๐Ÿ”’' id=None> row=None>:
Traceback (most recent call last):
  File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ui\view.py", line 396, in _scheduled_task
    await item.callback(interaction)
  File "F:\[bots]\MyChemicalCult Bot\bot.py", line 163, in button_callback
    await interaction.response.send_message(embed=embed, view=TicketClosedButtons())
  File "F:\[bots]\MyChemicalCult Bot\bot.py", line 136, in __init__
    self.add_item(del_button)
  File "C:\Users\Ryanh\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ui\view.py", line 287, in add_item
    raise TypeError(f"expected Item not {item.__class__!r}")
TypeError: expected Item not <class 'function'>```
cyan quail
#

also you didn't actually assign any callbacks

#

and callback doesn't take the button argument if you're not using decorators, you should instead access interaction.custom_id

worn void
#

interaction isnt defined btw

undone smelt
#

"what about the button"
discord.ui.Button I gotcha brother

worn void
undone smelt
#

you mean the type right?

worn void
#

they said to use "interaction.custom_id"

del_button = discord.ui.Button(label="Delete", discord.Interaction.custom_id="delete_ticket", style=discord.ButtonStyle.danger, emoji="๐Ÿ”’")
full basin
#

Why dont you just use the decorator

#

Youre subclassing view after all

meager mica
#

Hey so does anyone know why when I edit a messages view from buttons to dropdown it activeates dropdown before they select an option

#

This is in button callback ```
view = discord.ui.View(Dropdown(self.confirm_interaction))
await self.confirm_interaction.edit_original_message(embed=embed, view=view)

#
class Dropdown(discord.ui.Select):
    def __init__(self, confirm_interaction: discord.Interaction):
        self.confirm_interaction = confirm_interaction
        options = [

        ]
        for i in range(1, 17):
            options.append(
                discord.SelectOption(label=f"Team {i}", value=str(i), description=f"Your preferred team is {i}"))
        super().__init__(
            placeholder="Choose your preferred team",
            min_values=1,
            max_values=1,
            options=options,
        )

    async def callback(self, interaction: discord.Interaction):
        update_set({'user': interaction.user.id}, {'preferred_team': self.values[0]})

        value = self.values.pop()
        embed = discord.Embed(title='Team Selection',
                              description=f'You set your preferred team to:\nTeam **{value.title()}**')
        await self.confirm_interaction.edit_original_message(embed=embed, view=discord.ui.View())
cyan quail
meager mica
#

is it true or not

cyan quail
#

because im WRONG

meager mica
#

oh

cyan quail
#

but uhh

#

can you show a screenshot? not quite sure what the issue is

meager mica
#

when i push button it edit message and takes second or two then says interaction failed and if they select option before that it sends error unknnown interaction

cyan quail
#

oh you should do interaction.response.edit_message instead

meager mica
#

o

cyan quail
#

are you trying to remove the view?