#General Help

1 messages Β· Page 4 of 1

slender lintel
#

Hey i have a question why is the error there? i want to send the error message when the button not working is.

Task exception was never retrieved
future: <Task finished name='discord-ui-view-timeout-eba966217995ff9d5294171db33fb5bc' coro=<testbutton.on_timeout() done, defined at C:\Users\zReaxrYT\PycharmProjects\Discord\extensions\Buttons.py:49> exception=AttributeError("'testbutton' object has no attribute 'ctx'")>
Traceback (most recent call last):
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\extensions\Buttons.py", line 50, in on_timeout
    await self.ctx.send("Timeout..")
AttributeError: 'testbutton' object has no attribute 'ctx'

Code:

    async def on_timeout(self) -> None:
        await self.ctx.send("Timeout..")

I know the error but how i can send the error?

sharp summit
#

I'm making a Discord Bot which sends messages to multiple servers, in some of them there is slowmode enabled. At first the bot sent messages to all servers but second time there was slowmode enabled and it waited for slowmode to end. I wanna make it ignore the channel where slowmode timeout is going on and my bot shouldn't have to wait for it....any help would be appreciated

#

Please someone help me

slate stirrup
#

Where can I find the source code of @supple ravine

midnight cedar
#

p.source

supple ravineBOT
midnight cedar
#

@slate stirrup

slate stirrup
#

Tnx

slender lintel
frigid lark
#

how can I get the channel name by the ID?

stable anvil
stable anvil
frigid lark
stable anvil
#

Check whether the channel ID is correct

frigid lark
#

it is correct

stable anvil
#

Send your code

frigid lark
#
@client.slash_command()
async def test(ctx, id):
    channel = ctx.guild.get_channel(id)
    await ctx.respond(channel.name)
stable anvil
frigid lark
#

yes

stable anvil
#

try with bot.get_channel(id)

frigid lark
#

I already tried it, same error

stable anvil
#

umm not sure which object the program isn't returning.

Try to print ctx.guild.id

frigid lark
#

I can send it and print but not the stuff with the channel.name

stable anvil
#

Okay so try with an api call it might raise an error

guild = ctx.guild
channel = await guild.fetch_channel(id)
opaque marsh
#
Ignoring exception in on_connect
Traceback (most recent call last):
  File "PycharmProjects\da_pycord_botto\venv\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "PycharmProjects\da_pycord_botto\venv\lib\site-packages\discord\bot.py", line 1025, in on_connect
    await self.sync_commands()
  File "PycharmProjects\da_pycord_botto\venv\lib\site-packages\discord\bot.py", line 685, in sync_commands
    await self.http.bulk_upsert_command_permissions(self.user.id, guild_id, guild_cmd_perms)
  File "PycharmProjects\da_pycord_botto\venv\lib\site-packages\discord\http.py", line 357, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed

Why tf am I getting this error

frigid lark
#

but I did it with client.fetch_channel(id)

stable anvil
slender lintel
# stable anvil Umm not like that. Add it to the class and pass the `ctx` whenever you're creati...

Still not..
Error:

Task exception was never retrieved
future: <Task finished name='discord-ui-view-timeout-c88aa2be5d4b98efde0c02c6745b8b7f' coro=<testbutton.on_timeout() done, defined at C:\Users\Amarz\PycharmProjects\Discord\extensions\Buttons.py:21> exception=AttributeError("'testbutton' object has no attribute 'ctx'")>
Traceback (most recent call last):
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\extensions\Buttons.py", line 22, in on_timeout
    await self.ctx.send(f"Timeout.")
AttributeError: 'testbutton' object has no attribute 'ctx'
slender lintel
#

you need to pass ctx when adding the view

stable anvil
slender lintel
slender lintel
stable anvil
#

How are you creating an object of testbutton?

slender lintel
#

how are you adding the view?

slender lintel
slender lintel
#

hmm should work

#

are you sure you restarted the bot or reloaded the cog

slender lintel
slender lintel
stable anvil
#

Restart your bot and see if it works

slender lintel
#

but what should i create?

stable anvil
#

An object of the button class in other words how you are using it. You've shared the ss above, it seems right. Try restarting

slender lintel
#

okay

#

so is also correct?

frigid lark
stable anvil
slender lintel
#

no its not working..

stable anvil
#

The same error again?

plush narwhal
#

so i am trying to get guild id when a slash command is run but nothing is happening but it works with prefix any way to fix?

slender lintel
#

show code + error

plush narwhal
plush narwhal
# slender lintel show code + error

it's working...

@commands.cooldown(5,60,commands.BucketType.user)
async def help(ctx):
  print(ctx.message.guild.id)``` just removed message ctx.message.guild.id
#

sorry to waste time

slender lintel
#

np

slate stirrup
#

What's the color thing like x0078

#

How do I know what color

plush narwhal
#

Like for black it's #000000 and for white it's #ffffff

slate stirrup
#

Okay tnx

#

And how do I make a menu (select menu) never expires

slender lintel
tidal beacon
#

does anyone know the proper formatting of recursively adding list items to embed fields?

small nova
#

hello! is it possible to make slash commands dynamic? lets say, in a multilingual bot a command that is /buy in english and /comprar in spanish ?

sudden path
#

It's recommended to use aiohttp for api requests on async?

sudden path
potent spruce
#

no

#

I want to use replit to host my discord bot but I need to install this version: py-cord==2.0.0b7. How can I do this?

slate stirrup
#

p.install

supple ravineBOT
#
CommandNotFound

Command "install" is not found

slate stirrup
#

?tag install

hearty rainBOT
#
  1. Uninstall discord.py or any other forks of discord.py you might have with the namespace discord.
python -m pip uninstall discord.py discord -y
  1. Install py-cord
python -m pip install py-cord

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

Updating the module to Alpha (unstable):

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

Updating to beta:

pip install py-cord==2.0.0b7
slate stirrup
#

@potent spruce type pip install pycord==2.0.0b7

potent spruce
#

onto what

slate stirrup
#

Shell

potent spruce
#

alr

plush narwhal
#

any way to customize the message when bot takes long to response
bot is thinking...

crimson coral
#

uhh nope

plush narwhal
#

sadge

rose stratus
#

can someone help me

slate stirrup
slate stirrup
rose stratus
#

no py cord

tidal beacon
#

does anyone know how to format links in embeds? basically I want to take a link and make it show as a word but still be a hyperlink

slate stirrup
plush narwhal
#

Any way to make a slash commands viewable to only 1 user?

plush narwhal
exotic cape
#

pycord 1.0.0 is the fake one or old

py-cord is this library

#

you do pip install py-cord==2.0.0b7

crimson coral
rose stratus
full umbra
#

Have command permissions v2 been implemented into pycord yet? If so, what do I need to do to support them past updating pycord.

mint yoke
#

I'm switching over to pycord from discord.py, ive uninstalled discord.py and installed py-cord, following the instructions.

I'm trying to port over some commands as slash commands in cogs, and I have the import line from discord.commands import CommandPermission, SlashCommandGroup but then I get an error "No module named discord.commands"

#

tried searching to see if anyone else had this issue, but I couldn't find anything in the first page or so of results, so i figured id ask.

#

oh snap, my bad, i see someone else has the same issue literally right above me.

mint yoke
exotic cape
mint yoke
#

and yes, it does the same thing if i have the from discord.ext import commands higher than discord.commands

#

and doing

from discord.ext.commands import CommandPermission, SlashCommandGroup also fails

#

(that one was more of a last ditch effort, I figured it wouldn't work since every part of the documentation says to do from discord.commands for those imports)

exotic cape
#

wait

#
intents = discord.Intents().default()
intents.presences = True
intents.members = True

bot = discord.Bot(intents=intents)

misc = bot.create_group(name='misc', description='misc commands', guild_ids=Whitelisted_Guilds)

the commands looks like this


@misc.command(name="say")
   async def say(ctx, message):
       await ctx.respond(f'{message}')

i am using this one

mint yoke
#

I should note im using cogs

exotic cape
#

wait

#
import discord
from discord.ext import commands
from variables import Whitelisted_Guilds


intents = discord.Intents().default()
intents.presences = True
intents.members = True

bot = discord.Bot(intents=intents)

misc = bot.create_group(name='misc', description='misc commands', guild_ids=Whitelisted_Guilds)

class Misc(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
    
    @commands.Cog.listener()
    async def on_ready(self):
        print(f"{__name__} Loaded")

    @misc.command(name="say")
    async def say(ctx, message):
        await ctx.respond(f'{message}')
def setup(bot):
    bot.add_cog(Misc(bot))
    bot.add_application_command(misc)
#

here's mine

#

the command looks like /misc say [message[]

mint yoke
#

ohhh so you redefine the intents and bot in each cog?

#

or do you keep all the cogs in the main file?

stable tiger
#

No, you don’t redefine intents/bot, cogs just use bot instance you loaded them with

And people usually put cogs into many files

exotic cape
#

ohh you could do that

#

but i did redefine it in mine

exotic cape
mint yoke
#

okay, let me try something real quick

mint yoke
exotic cape
dark zodiac
#

I've got a question about channel permissions management, I see that there's a set_permissions method but not a get_permissions method, since my use case is only adding one role to a channel with a certain permission set overwriting the whole thing would delete all the other roles

can anyone provide some clarification?

exotic cape
#

maybe you are looking for this?

#

@dark zodiac

dark zodiac
exotic cape
#

ohhh

mint yoke
#

I figured out what the issue is with importing discord.commands

only works on the betas. makes a lot of sense

exotic cape
#

this one

#

check this maybe it has what youa re looking for

dark zodiac
exotic cape
#

yes

mint yoke
dark zodiac
exotic cape
mint yoke
#

it did help though :P

exotic cape
#

okay then

mint yoke
#

somewhat

exotic cape
mint yoke
#

it happened to be the next roadblock yea haha

exotic cape
#

ohhh hahaha nice

exotic cape
#

you could do it in another function like validation?

#

other than that i don't know

dark zodiac
exotic cape
#

ahhh

crude spade
#

I'm trying to set up a bot and I'm having an issue following the guide/documentation.
My issue is that when I try to import from discord.commands I get an error that the module doesn't exist.
However, I can tell that I have py-cord installed because running pip freeze gives me

aiohttp==3.7.4.post0
async-timeout==3.0.1
attrs==21.4.0
chardet==4.0.0
idna==3.3
multidict==6.0.2
py-cord==1.7.3
typing_extensions==4.2.0
yarl==1.7.2
crude spade
#

What is the latest version?

exotic cape
#

py-cord==2.0.0b7

crude spade
#

it says 1.7.3 is the newest version for me

#

this could be an issue on my end as I'm using a docker container

dark zodiac
#

you're using pip

#

they haven't updated pypi

#

dunno why but you have to manually install it from github through pip

crude spade
#

ok
I got it working

#

thank you for the help

dark zodiac
#

no worries

#

I'm still trying to figure out how channels work lol

exotic cape
#
@test.command(name="role perm")
async def role_perm(ctx, role:discord.Role):
    add_react = role.permissions.add_reactions
    await ctx.respond(add_react)
#

it returned false

#

to the role

#

meaning the role i put in the /test role_perm [role[] has no add_reactions permission

#

this is one step closer yea?

dark zodiac
#

I can see which roles have permissions under a specific channel, under the channel.overwrites object

exotic cape
#

also the previous documentation would help too

dark zodiac
#

and I can see what permissions each have

exotic cape
#

ohhh that's more complicated than i imagined

midnight cedar
#

what are you trying to do

exotic cape
#

checking a role if it has permissions in a specific channel

midnight cedar
#

you can use channel.permissions_for(role)

exotic cape
#

ohhhh

midnight cedar
#

mashes channel overwrites and guild permissions together and returns a discord.Permissions

dark zodiac
midnight cedar
dark zodiac
#

if I can do it for one I can just loop through the rest

dark zodiac
midnight cedar
#

you can use channel.set_permissions

#

will replace existing overwrites for that role/user

dark zodiac
#

won't that remove all other role based permissions

midnight cedar
dark zodiac
#

oh that's much better

bleak vault
#

!rtfm discord.Role.permissions

robust nebulaBOT
dark zodiac
#

let me check the docs on that function

bleak vault
#

oh god

#

there

bleak vault
#

oh

me forgetting the question\

#

πŸ’€

exotic cape
midnight cedar
crude spade
#

OK, now I have a new error. When I try to use the debug_guilds parameter to test slash commands, I get a 403 error.
I invited the bot to my private server with Administrator privileges

midnight cedar
#

edit it, and pass that to set_permissions

midnight cedar
crude spade
midnight cedar
#

in your application on the dev portal

crude spade
#

OH

midnight cedar
#

oauth2 section

crude spade
#

God I'm so stupid

bleak vault
crude spade
#

It's literally in the guide and I missed it

midnight cedar
#

gg

bleak vault
#

url generator in the oauth2 section

crude spade
#

now I get

discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed
midnight cedar
#

update to the master branch

#

on github

#

pip install -U git+https://github.com/pycord-development/pycord

exotic cape
midnight cedar
#

what

exotic cape
#

it is confusing right?

midnight cedar
#

you get roles fromguild.get_role or guild.roles

#

or member.roles

exotic cape
#

ohhh

#

wait let me try

crude spade
midnight cedar
#

try adding the --force flag to force reinstall

#

pip install --force git+https://github.com/pycord-development/pycord

crude spade
#

ok, now it doesn't error, but the slash command doesn't show up in my server

exotic cape
crude spade
exotic cape
#
  1. go to server settings > integrations > your bot > your command
  2. change a perm > save
  3. change it back > save
#

4.check if the command is there now

tribal vapor
#

question in relation to ports. what port do bots use by default? and what port does it use if the first one is already in use (hosting multiple bots on the same machine)?

old plover
crude spade
exotic cape
crude spade
# old plover what

you probably want to set this to True to avoid any weird concurrency issues

old plover
exotic cape
#

nothing hahaha

exotic cape
#

you need to re-invite your bot

#

with those checked in the developers dashboard

crude spade
#

And I just reinvited it and it still doesn't work

midnight cedar
#

you dont need open ports to create a connection, you need them to receive them

#

and you can have multiple connections on one port

tribal vapor
#

I ask merely for the chance of needing a firewall rule for incoming connections on a server

#

by default I assumed 443

midnight cedar
#

you shouldn't need one

tribal vapor
#

cool

midnight cedar
#

if it doesnt work try allowing 443 yeah

tribal vapor
#

so I'm still chasing this dumb issue then

midnight cedar
#

default https port

midnight cedar
#

it's a 2 way connection

tribal vapor
#

basically I've been chasing on why my bot doesn't work any- oh?

#

well like you said multiple connections on one port

#

anyways.

#

since im here I'll say what's been happening

#

basically I've been chasing on why my bot doesn't work anymore since upgrading to the 2.0 library

midnight cedar
#

what part isn't working

#

is there a traceback

tribal vapor
#

no idea as according to the log it's getting commands and sending them but discord isn't delivering them

#

like the only thing that was changed was the upgrading py-cord to 2.0.0-whatever

midnight cedar
#

it's being recieved and a response is sent?

tribal vapor
#

yea

#

but isn't coming into my discord server

#

but works fine on the older lib????

midnight cedar
#

does it work again if you downgrade

tribal vapor
#

yea

#

I've gone back and forth a couple of times to make sure

midnight cedar
#

odd

tribal vapor
#

ikr

midnight cedar
#

idk what could be causing that

tribal vapor
#

which is why I've started to wonder if it's a firewall in vultr

midnight cedar
#

permissions v2 couldn't have broken it

#

nothing related to sending/receiving stuff has changed

tribal vapor
#

like is my scope wrong?? it has both bot and applications.commands

#

and it has administrator for perms since I wanted to rule that out right away

pale depot
#
import random, time, os
horses = [1,1,1,1,1]
in_race = True

def horseCalculator(h1):
  global in_race
  if h1 == 1:
    horse = "🎌 - - - - - 🐎"
  elif h1 == 2:
    horse = "🎌 - - - - 🐎"
  elif h1 == 3:
    horse = "🎌 - - - 🐎"
  elif h1 == 4:
    horse = "🎌 - - 🐎"
  elif h1 == 5:
    horse = "🎌 - 🐎"
  elif h1 == 6:
    horse = "🎌 🐎"
    in_race = False
  print(horse)

while in_race:
  time.sleep(0.1)
  horse_selection = random.randint(0,4)
  os.system("clear")
  for h1 in horses:
    horseCalculator(h1)
  horses[horse_selection]+=1```
Dumb question but I made this horse game lol.. I'm not sure how I can print out which number horse won.
#

I would like to make it a betting game and I'm not sure how to go about printing out which one won

cedar eagle
#

ignoring all the bad practice in the code, the first thing that comes to mind is at the end of your while loop add

if not in_race:
  print(horse_selection+1)

since this was the last horse to be picked before the loop will be broken next iteration

pale depot
#

That came off way opposite as to how I intended it..

#

What I mean is.. why couldn't I print it out in the function*

cedar eagle
pale depot
#

but look it prints out 3

#

when horse #1 won?

cedar eagle
#

since this isn't exactly about Py-cord itself I'll dm you

pale depot
#

ok

bleak vault
#

aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discord.com:443 ssl:default [None] yelp i think i've been ratelimited

#

yep its def ratelimit i just restarted and it wurks

cedar eagle
#

@pale depot sorry, can't help if I can't dm you

bleak vault
pulsar pier
#

how to clear slash commands(I create a bot before and now my new bot have old bot commands, but I doesn't have it at code of new bot)

slender lintel
#

Im trying to make a bunch of buttons depending on how many players are queued in a list-

button1 = None
button2 = None
button3 = None
button4 = None
button5 = None
button6 = None
buttonlist = [button1,button2,button3,button4,button5,button6]
view = View()

for player,button in zip(trrS[guild]["valid"],buttonlist):
  button = Button(label=str(player) , style=discord.ButtonStyle.green)
  async def trr_interaction(interaction):
    await interaction.response.send_message(f"Clicked on {player}")
  button.callback = trr_interaction
  view.add_item(button)

This works fine but how do i get who clicked a button?
Ping me if you can help me

slender lintel
#

pls someone sad

plush narwhal
#

Is there a way to chnage options based on input like in a slash commands if a person chooses yes then the option will change in next parameter and if he chooses no then next parameter won't be shown

crimson gale
#

no

slender lintel
#

thanks

twilit cobalt
#

how to disable button after certain amount of time

stiff nebula
#

Is there a fix now to the command registration issue that only a single command appears? None of my commands are getting registered

snow citrus
#

can anyone help pls?

discord.errors.ExtensionFailed: Extension 'cogs.apex' raised an error: AttributeError: module 'discord.ext' has no attribute 'bridge'

(can't import ext.pages on heroku)

old plover
#

pip install py-cord~=2.0.0b7

#

Oh that won't have bridge

snow citrus
#

i reseted my app with requirements.txt in it

git+https://github.com/pycord-development/pycord
gaunt cairn
snow citrus
#

discord is not even installed

floral stag
snow citrus
#

okay, discord.py

exotic cape
stiff nebula
exotic cape
#

also if you happen to change a command and it did not change

ex.

/test to /test [say[]
a command to a command with parameter

you just need to remove the command from the code run the bot then return the command code and run the bot again
(either cut it then paste it back or copy the code block and erase it then paste it back)

stiff nebula
exotic cape
#

anyone here know any resources or examples on how to handle discord application command errors?
one for checking if DM is closed and for common application command errors

surreal nimbus
#

why am I getting this error when starting bot? discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed

exotic cape
#

also is your py-cord's version is it latest?

surreal nimbus
exotic cape
#

ohh

#

use b7

surreal nimbus
#

ok

exotic cape
#

update it and see if the error still persists

surreal nimbus
#

nope

#

still the same error

exotic cape
#

hmmmm

#

can you send the full traceback?

surreal nimbus
#
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\bot.py", line 1147, in on_connect
    await self.sync_commands()
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\bot.py", line 770, in sync_commands
    await self._bot.http.bulk_upsert_command_permissions(self._bot.user.id, guild_id, guild_cmd_perms)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 359, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed```
exotic cape
#

are you using async def on_connect():

#

or async def on_ready():

surreal nimbus
#

I have on_ready event

exotic cape
#

how about how you run the bot? bot.run(token) ?

surreal nimbus
#

I have a bot class, then I make the instance of the class and do bot.run

exotic cape
crimson gale
surreal nimbus
#

oh, ok

crimson gale
#

it started appearing as a result of discord deprecating permissions v1 without notice

surreal nimbus
#

oh

exotic cape
#

ohhh

#

the master is pip install git+https://github.com/Pycord-Development/pycord

surreal nimbus
#

ok, ty

surreal nimbus
#

I removed a command from a group and now the other commands do not work, discord says, that the other commands are outdated

slate stirrup
#

Hello how do I delete this

#

And make a costum one

surreal nimbus
#

it's simple, either disable the default help command or make a new one

surreal nimbus
#

wdym

#

how

#

oh it updated by itself

exotic cape
#

update the code to the latest one

#

so it's fine now?

surreal nimbus
#

but I don't recommend it

#

just override it

ornate spade
inland acorn
#

how to close the modal? it worked fine until i redirected the response to some other channel; i am getting the response but now modal isnt closing automatically

ornate spade
#

you probably arent responding to the interaction

inland acorn
#

i said so, redirected the response

#

by fetching channel

crimson gale
#

you still need to respond to the interaction

#

you cant just not respond

inland acorn
crimson gale
#

theres the issue

#

youre not responding to the interaction

inland acorn
#

did respond like this

#

edit message also not working

crimson gale
#

that has to be in the callback

inland acorn
#

@crimson gale whats the use of stop()?

#

it is needed?

crimson gale
#

no but you should still call it just incase

#

stop() makes the Modal stop listening for further interactions

inland acorn
crimson gale
#

ig

ripe pagoda
#

wouldn’t it be interaction.stop() @inland acorn

inland acorn
#

uhh why its not editting now!!

#

says unknown message

exotic cape
#

after updating to master i suddenly got these errors

button() is the name of the command

exotic cape
#

anyone having Application CommandInvokeError: TypeError: command_name() missing 1 required positional argument: 'ctx' error after updating to the latest master?

ripe pagoda
#

give your code

exotic cape
# ripe pagoda give your code
bot = discord.Bot(intents=intents)
test = bot.create_group(name='test', description='test commands', guild_ids=Whitelisted_Guilds)

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

    @commands.Cog.listener()
    async def on_ready(self):
        print(f"{__name__} Loaded")

    @test.command()
    async def button(self, ctx):
        embed = Embed(title='Report or Suggest Something', description='Click a button below to submit a report or a suggestion', color=discord.Color.blue())
        await ctx.send(embed=embed, view=MyView())

def setup(bot):
    bot.add_cog(Test(bot))
    bot.add_application_command(test)
ripe pagoda
#

yeah

#

why are you trying to redefine button

#

just rename the function

exotic cape
#

nope the same thing happens even on hello command

#

the name is not the problem

ripe pagoda
#

what hello command

#

@exotic cape

exotic cape
ripe pagoda
#

what?

exotic cape
#
@test.command()
async def hello(self, ctx):
    await ctx.respond('hello')
#

@ripe pagoda

ripe pagoda
#

and that errors?

exotic cape
#

yep

ripe pagoda
#

well

#

whats the error

exotic cape
#

that happened when i uninstalled py-cord and reinstalled it to update to the latest master

ripe pagoda
#

okay

exotic cape
#

Application CommandInvokeError: TypeError: command_name() missing 1 required positional argument: 'ctx'

ripe pagoda
#

is it in a cog?

exotic cape
#

let me do a clean install of all the venv first

#

yesh in a cog

ripe pagoda
#

okay

exotic cape
#

yup same error

#

command hello() missing positional argument: 'ctx' or 'interaction'

ripe pagoda
#

stop doing @test.command

#

try just doing @discord.command

little tapir
#

how to edit an interaction msg from slash cmd

half marsh
inland acorn
half marsh
#

just checked myself

exotic cape
exotic cape
half marsh
#

yes

#

i check it myself

#

it it throw the same error

#

as you

exotic cape
half marsh
inland acorn
#

in place of create_group

exotic cape
exotic cape
#

basically the same

#

thanks for the help everyone

clever lava
#

help

#

please

#

heeelp

#

what is wrong with my ticket system

#

i want to make a ticket system with persistent views buttons

#

it doesnt show up any error

exotic cape
#

did you add your view to the main file's on_ready?

clever lava
#

i think i didnt

#

should i?

exotic cape
#

then set the timeout to None

clever lava
#

wait

#

where do i put this exactly

exotic cape
#

yeap so that even if the bot restarts the button won't fail to interact

clever lava
#

oh i think thats the insue

exotic cape
#

wait it is in the examples in the docs iirc

clever lava
#

ok ill see

exotic cape
#

try this

#

i am afk so i can't give you an example of mine

clever lava
#

then i came here

exotic cape
#

ohhh wait

#

i am infront of my laptop now

clever lava
#

i think i need to define ctx in @discord.ui

#
@discord.ui.button(label="Criar ticket", style=discord.ButtonStyle.green, emoji="πŸ“©", custom_id="persistent_view:green")
    async def green(self, button: discord.ui.Button, interaction: discord.Interaction):
#

like here

#

the third line

exotic cape
#

main.py


@bot3.event
async def on_ready():
    activity = discord.Game(name='RG DEVELOPMENT', type=1)
    await bot3.change_presence(status=discord.Status.online, activity=activity)
    bot3.add_view(MyView()) # Registers a View for persistent listening
    bot3.add_view(MessageView()) # Registers a View for persistent listening
    print(f'Logged in as {bot3.user}')

you should have that bot.add_view() here in the main.py

clever lava
#

hmm

#

oh i have this

exotic cape
#

ohh wait the time out part

#

ohhh you have it too

clever lava
#

yos :)

exotic cape
#

so what was the problem again?

#
  1. your button is not being persistent? returning interaction failed?
clever lava
#

one moment

#

seems like the button is persistent

#

it doesnt show up "this interactiopn failed"

exotic cape
#

ohhh

clever lava
#

it just do nothing

exotic cape
#

then the problem is in your callback

clever lava
#

yess wtf

#

i get confused with big codes bruh

exotic cape
clever lava
#

yes

exotic cape
#

ohhh try to add comments if you are having a hard time in that part

#

or even add doc strings if you want to define each argument so you would be able to view then on another file when you hover using vs code

clever lava
#

nice

#

tysm

exotic cape
#

np

clever lava
#

oh...

#

still without respond

#

should i define the response in the command or in the PersistentView class ?

exotic cape
#
 button2.callback = botao_callback
  
  await ctx.respond("Mensagem enviada!", ephemeral=True)
  await ctx.send(embed=embed, view=PersistentView())

try to tab this i think it is in the wrong indentation?

#

or am i wrong?

clever lava
#

HMM

exotic cape
#

what i see from what you sent is, it is in the same level as the async def callback

#

but it should be inside it right? that should be the button's response if i am correct?

clever lava
#

ohhh

exotic cape
#

should be at the same level as the if and else

#

did it work?

clever lava
#

uh

#

not really

exotic cape
#

hmmm

clever lava
#
  File "main.py", line 472
    await ctx.respond("Mensagem enviada!", ephemeral=True)
    ^
IndentationError: unexpected indent
#

this is after the fix

#

i think the error is actually even before the line 472

exotic cape
#

hmmm

#

found the problem

#

you are using interaction in the call back but your calls are ctx

clever lava
#

oh man

exotic cape
#

should be interaction.response.send_message()

exotic cape
clever lava
#

still not respond

exotic cape
#

hmmm

clever lava
exotic cape
#

what's the error now?

clever lava
#

NONE

#

😭

#

same as before

#

nothing on console neither on discord

#

wtf is even happening

exotic cape
#

hmmm

#

let me know the feature

  1. an embed with description
  2. a button below to create a ticket
#

what happens after the button is clicked?

clever lava
#

you got the point

#

nothing

#

literally nothing

exotic cape
#

the next one should be creating a ticket channel right?

clever lava
#

yes

exotic cape
#

wait try to make the button able to respond as a text first

clever lava
#

k

exotic cape
#

first clear all of it but leave one view

#

i see you have several of them

#

let me write a code for you from another exmplae i can't seem to find it though

clever lava
#

hm

#

OH

#

IM SO DUMB

#

i was coding in the wrong callback

#

in the close button

exotic cape
#

ohhh hahaha

clever lava
#

not the one for open tickets

#

fadkbabsdkj

exotic cape
#

wait so it now works?

#

i just scanned the code too and did not read it too much 🀣

clever lava
#

bruh

#

holdon

exotic cape
#

also i can't understand the language too hahaha

exotic cape
#

or is it working fine now?

clever lava
#

no

#

im screaming

exotic cape
#
import discord

intents = discord.Intents.default()
intents.members = True

bot = discord.Bot(intents=intents)

@bot.event
async def on_ready():
    bot.add_view(MyView())

class MyView(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None) # timeout of the view must be set to None

    @discord.ui.button(label="A button", custom_id="button-1", style=discord.ButtonStyle.primary, emoji="😎") # the button has a custom_id set
    async def button_callback(self, button, interaction: discord.Interaction):
        await interaction.response.send_message("Button was pressed", ephemeral=True)

@bot.slash_commands()
async def create_ticket(interaction):
    message = 'Click the button below to open a ticket'
    embed = discord.Embed(title='Create Ticket', description=message)
    await interaction.response.send_message(embed=embed, view=MyView())

bot.run(token)
#

try this

#

i think this should work

clever lava
#

one moment

pastel wadi
#
async def classic(self, ctx, characterName : discord.Option(input_type=str, description="Enter the name of the character for this statblock", name="Character Name", required=False) = ""):
``` is there anything missing i this `discord.Option` declaration?
As I get this weird `TypeError: Option.__init__() missing 1 required positional argument: 'input_type'` error, even though input type is in fact present
exotic cape
#

argument option=[discord.Option()]

#

try it

clever lava
#

i dont know what the fck is happenning with this bot it just does not respond after all that

clever lava
#

yes

exotic cape
#

ohhh

#

wait let me try

pastel wadi
plush narwhal
#

why am i getting this error

exotic cape
#

btw what version is your your py-cord?

plush narwhal
exotic cape
#

!replit

robust nebulaBOT
exotic cape
#

@plush narwhal

clever lava
exotic cape
clever lava
#

ye

exotic cape
#

try updating it to the latest

#

or master

#

maybe that's the problem

clever lava
#

k

exotic cape
#

!install

robust nebulaBOT
#

Install pycord:

pip install py-cord```
Install pycord beta:
```pip uninstall discord.py
pip install py-cord==2.0.0b5```
Install pycord alpha from git:
```pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord```
pastel wadi
# exotic cape that should be in the decorator iirc

Even still, it doesn't work with the same message

@statblock.command(
        name="classic", 
        description="Generates a statblocks according to the 4d6^3 (keep highest 3)",
        option=[
            discord.Option(input_type=str, description="Enter the name of the character for this statblock", name="Character Name", required=False)
        ]
    )
    @commands.cooldown(3,180, commands.BucketType.user)
    async def classic(self, ctx, characterName = ""):
exotic cape
#

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

#

this one

plush narwhal
plush narwhal
exotic cape
#

btw what does it say on the traceback?

plush narwhal
#

this is what it says

exotic cape
clever lava
#

oh no i installed the master ver and its having conflicts with other commands

exotic cape
#

yeah my bot got messed up a while ago when i updated too hahaha

clever lava
#

ah

exotic cape
#

ohhh right it would have them since you were using b5

crimson gale
clever lava
exotic cape
#

you need to do it eventually

clever lava
#

i want to die

exotic cape
#

anyway you would still need it since discord made some changes suddenly and libraries had to adapt

#

previous permissions won't work either iirc

clever lava
#

ah

#

this is why permissions decorator is not as before

exotic cape
#

yep

clever lava
#

it just dont even show up the commands

exotic cape
#

you could only change then in the server settings > integrations > your bot

#

also if you encounter a not showing commands or only 1 command showing

  1. go to server settings > integrations > your bot > your command
  2. edit a perm > save it -> should show Not Synced
  3. return the perm back > save it -> should say Synced again

if you encounter the (edited the command and added a parameter but does not change in discord commands)

  1. remove the code block from the code > save it > restart the bot
  2. return the code block >save it > restart the bot
slender lintel
#

p.help

supple ravineBOT
#
Pycord Manager

The ultimate open source server management bot. Use the menu below to navigate through the command list.

Server Count

42

User Count

13998

Ping

113.63ms

pastel wadi
crimson gale
#

wdym?

pastel wadi
#

An error message containing only validation error

#
@statblock.command(
        name="classic", 
        description="Generates a statblocks according to the 4d6^3 (keep highest 3)",
        option=[
            discord.Option(str, "Enter the name of the character for this statblock", "Character Name", required=False)
        ]
    )

in that way

slender lintel
#

Okay so, I wanna migrate from 2.0.0b4 to 2.0.0b7, what all changes I need to make in my code?

plush narwhal
#

So... why is this happening i deleted discord.py and used master version of pycord

#

It was happening on other repl code and when i deleted that it spread to another code which was working perfectly

plush narwhal
#

Well ignore it i think i found the solution

#

Sorry for disturbance JJKYujiSorry

clever lava
#

how does work permission decorator in pycord v7

#

heeeeeeeeeeeeeeeeeeelp

#

pleeease

slow dome
#

your other option for decorators are discord.ext.commands decorators

clever lava
#

im hating this update

#

im gettin mad

lament stag
#

hi may u elaborate more

hard veldt
#

p.help

supple ravineBOT
#
Pycord Manager

The ultimate open source server management bot. Use the menu below to navigate through the command list.

Server Count

42

User Count

14009

Ping

105.72ms

inland acorn
#

how can i fix the loading image issue when source image is deleted?
copied that source image link and added in embed; then deleted that source image

violet night
#
    @slash_command(guild_ids=[532672466255085598])
    async def register(self, ctx, username):
        await ctx.respond("Registering!")
        new_user = Account(ctx.author.id, username)
        self.registry.append(new_user)

I've got this as a cog command for my bot, despite the guild ID being entered, the command is still taking an hour or so to be registered, as if it was a global command. Does anyone know why this might be happening?

random kayak
violet night
fair cradle
#

Has someone an example with an persistent view?

#

Bit with a variable like the member id who clicked the Button aß custom id

steep lark
fair cradle
#

Thats all i have, but idk how to put the member in the on_ready...

heavy cradle
#

how do I pass a variable to the @button decorator? I want label= value of self.correct_answer

crimson gale
#

you cant access self in a decorator because its outside of the function

#

i think you can just access the variable name directly and itll work?

half marsh
fair cradle
wraith folio
#

is it possible to use buttons inside of modals?

fair cradle
#

No

plush narwhal
#

Is there a way to get emoji as input in slash command

stray smelt
wraith folio
#

damn cryloaf

wooden coyote
#

what is a "sink" instance in VoiceClient?

wintry ledge
#

slash command cooldown?

#

nvm i figured it out

fair cradle
#
@bot.event
async def on_ready():
    bot.add_view(MyView())  # in this brackets i have to put member ig, but from where do i get the member object?

class MyView(discord.ui.View):
    def __init__(self, member):
        self.member = member
        super().__init__(timeout=None)

    @discord.ui.button(label='A button', custom_id="button-1", style=discord.ButtonStyle.primary, emoji='😎')
    async def button_callback(self, button, interaction):
        await interaction.response.send_message(f'Button was pressed by {self.member.name}', ephemeral=True)

@bot.command()
async def button(ctx, member):
    await ctx.send(f'Press the button! Is Persistent: {MyView.is_persistent(MyView())}', view=MyView(member))
#

Does Somebody know? πŸ₯²

exotic cape
# heavy cradle nope

aside from using decorators for buttons, you could also use the button class iirc

exotic cape
fair cradle
#

but the view should be refreshed when the button ic clicked

#

@exotic cape

exotic cape
fair cradle
#

doesnt work too, because when i restart the bot, i cant define member in the on_ready

lament stag
#

how can i get the value of the page on the button click in paginator. so i may use it on other button view?

exotic cape
crimson gale
#

basically remove the member argument from the init method

#

and use interaction.user to get the person that pressed the button

fair cradle
#

but i dont want the person pressed the button, i want the person that executet the command

#

where the button is send

crimson gale
#

then youre complicating your view for no apparent reason

#

because you'd need to store the user id somewhere and then generate new views based on that

slender lintel
#
File "C:\Users\Shubham\Desktop\Bot\testing.py", line 40, in callback
    self.stop()
AttributeError: 'Testing_Modal' object has no attribute 'stop' ```
#

Am using, 2.0.0b4

ornate fog
fair cradle
#

yes, and how do i load that?

ornate fog
#

Depending on how you save your data.
If you choose to use a sqlite use aiosqlite if psql then asyncpg
There are many options

#

motor for mongodb

#

if you like json style records

fair cradle
#

because i want to refresh a rank pillow image, and after a few minutes the refresh button stops working...

ornate fog
fair cradle
#

jo

ornate fog
#

For the server the view is in ?

fair cradle
#

yes

ornate fog
#

then just do interaction.guild_id and you good

#

no need to save anything

#

Except your xp ranks ofc

#

And make the view percistant

exotic cape
fair cradle
#

yea..

#

what should i use to send embed when interaction is responsed?

exotic cape
#

btw why do you need member on the myview in on_ready?

fair cradle
#

and if you refresh it

#

it should refresh the same members image

exotic cape
#

basically your requirements are

a rank embed with a button
if the button is clicked, the rank should refresh

#

is this correct?

fair cradle
#

jo

exotic cape
#

wait you want only one rank card then if a user clicked it it would change to their rank card?

ornate fog
#

there is no need to save that

exotic cape
#

you should be able to do that in the callback function if i am correct

ornate fog
#

yes

fair cradle
ornate fog
exotic cape
#

???

#

i am confused now hahaha

ornate fog
exotic cape
#

i mean why do you need view?

#

if you have view means you have components

#

if you have components means you have callbacks

#

let us say you do /rank
rank card ⬇️

| |
| |

[Refresh Button]

in the / command you would have a view and some button components
then you need a callback to call when the button is pressed

-if the button is pressed, the callback function of that button would be called
-in the callback you could get the user who interacted with the button and pass that data to the embed
-in the callback you could edit the original message using interaction.response.edit_message if i am correct

#

@fair cradle

#

oh i don't know how you could edit that pillow image though but the same concept when using buttons you could do things in the callback

wooden coyote
#

I can't find "discord.create_group()" or "commands.create_group()" in a Cog

worthy basin
#

For slash or prefix commands?

exotic cape
wooden coyote
worthy basin
#

discord.commands.SlashCommandGroup

exotic cape
#

should be discord.Bot().create_group() where bot = discord.Bot()
making it bot.create_group()

exotic cape
worthy basin
#

I thought create group was for prefix command I could be wrong tho.

exotic cape
worthy basin
exotic cape
exotic cape
worthy basin
#

Yeah, that is better... I will look into why the example I sent does not use this

exotic cape
#

i see so subgroups are used that way hahaha thanks for the resources

slender lintel
#

Message commands are not visible on android app but they are visible on pc

#

is that a discord limitation or it's just for me?

worthy basin
#

Im going to guess that is discord being weird or you having an outdated version

random kayak
#

It really depends on your use case and what works for you

slender lintel
worthy basin
uneven flax
#

why do i hve this everytie i run my bot ?

exotic cape
exotic cape
#

ohhh nvm i might be wrong

surreal nimbus
#

how do I make a custom height/width for an embed's thumbnail?

exotic cape
uneven flax
#

it was ironic

exotic cape
#

ohh hahaha

uneven flax
exotic cape
#

yep i saw

#

what veraion are you using?

uneven flax
wooden coyote
#

"405 Method Not Allowed" - This is relating to slash commands

surreal nimbus
exotic cape
#

ohhh

surreal nimbus
#

idk how to access the property though

uneven flax
#

it stoped showing 405 method

#

..

surreal nimbus
#

everything is ok

wooden coyote
#

well for some reason, it aint appearing on slash commands

#

"discord.ext.commands.errors.CommandNotFound: Command "record" is not found"

inland acorn
#

how can i fix the loading image issue when source image is deleted?
copied that source image link and added in embed; then deleted that source image

jovial tusk
#

Umm, im getting this error when I use my slash command

class JobCog(BaseCog):

    @slash_command(
        name="new_job",
        description="To create a new job"
    )
    async def new_job(
        ctx: ApplicationContext,
        name: Option(str, description="Name of the job"),
        ytlink: Option(str, description="Youtube link"),
    ):
        print(name)
        await ctx.respond(f"Name: {name}\nYT: {ytlink}")
#

also base cog just contains this...

def __init__(self, bot) -> None:
        self.bot: __Bot = bot```
slow dome
jovial tusk
#

i thought i had it in

#

ima try that out

exotic cape
jovial tusk
#

i should NOT be coding at 2AM

exotic cape
#

options=[discord.Options(), discord.Options()] is the arg iirc

slow dome
exotic cape
#

hmmm

exotic cape
jovial tusk
#

hmm, waiting for discord to update the slash command, idk why it takes a lot of time

i think adding guild_ids=[] while testing helps right??

exotic cape
#

if you encounter a not showing commands or only 1 command showing

  1. go to server settings > integrations > your bot > your command
  2. edit a perm > save it -> should show Not Synced
  3. return the perm back > save it -> should say Synced again

if you encounter the (edited the command and added a parameter but does not change in discord commands)

  1. remove the code block from the code > save it > restart the bot
  2. return the code block >save it > restart the bot
#

@jovial tusktry this

jovial tusk
jovial tusk
# exotic cape yeah add guild_ids=[] too

hmm, how do i add guild_ids across all cogs??

i thought of doing this...

class BaseCog(Cog):

    __slots__ = 'bot',

    def __init__(self, bot) -> None:
        self.bot: __Bot = bot

    @staticmethod
    def cslash_command(**kwargs):
        def decorator(func):
            async def main_func(self, *ar):
                kwargs["guild_ids"] = self.bot.servers
                return await func(self, *ar)
            return (slash_command(**kwargs))(main_func)
        return decorator

but when i start the bot, i get options like "ar" on discord side, ig its checking the main_fun args and sending it thru the discord api

jovial tusk
crimson coral
#

either manually add guild_ids to all commands or set debug_guilds when defining your bot

jovial tusk
#

debug_guilds

#

ima check that out

#

wait how do i set that?

jovial tusk
crimson coral
#

wherever you're defining Bot

jovial tusk
#

hmm

crimson coral
#

if you subclassed it, shouldn't be too hard on that end either

exotic cape
#

anyway what it do is i pass a variable with the list of guild ids

jovial tusk
exotic cape
#

like

whitelisted_guilds = []

then

@bot.slash_command(guild_ids=whitelisted_guilds)

crimson coral
#

that should probably work

#

i think it needs to be in the super actually

jovial tusk
#

hmm

#

kk!

exotic cape
#

but what nelo is suggesting might be better

jovial tusk
#

yup ill do that

#

Thanks a lot guys :D

slender lintel
#

why isn't my bot responding to regular commands

#

only responds too /cmds

#

the help command wont even load

slow dome
#

?tag intents

hearty rainBOT
#
import discord
from discord.ext import commands

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

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

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

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

i already enabled that

slender lintel
#

How can i check which button pressed ?
My code:

import discord
from discord.ext import commands
from discord.ui import Button, View

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

    @commands.command(name="ban",aliases=["yasakla","engelle"])
    async def ban(self,ctx,kullanΔ±cΔ± = None):
        if kullanΔ±cΔ± is None:
            await ctx.reply("`kullanΔ±cΔ±` argΓΌmanΔ± eksik.")
        elif kullanΔ±cΔ±.bot:
            evet = Button(label="Evet",style=discord.ButtonStyle.green,emoji="βœ”",custom_id="evet")
            hayır = Button(label="Hayır",style=discord.ButtonStyle.red,emoji="❌",custom_id="hayır")
            view = View()
            view.add_item(evet)
            view.add_item(hayΔ±r)
            await ctx.reply("Yasaklamaya çalıştığın kullanıcı bir bot yinede devam etmek ister misin ?",view=view)


strong totem
#

i made a server clock

#
import time
from discord.ext import commands, tasks


class Server(commands.Cog):
  def __init__(self, bot):
    self.bot = bot
    
  @commands.command()
  async def done(self, ctx):
    self.my_update.start(ctx, ctx.guild.member_count)
    await ctx.reply(f'Time system is up\nTime - {time.strftime("%H:%M")}')
        

  @tasks.loop(seconds=60)
  async def my_update(self, ctx, members):
    await ctx.reply(f'Time - {time.strftime("%H:%M")}')
    time_channel = self.bot.get_channel(973227126440476702)
    member_channel = self.bot.get_channel(972845929411543070)
    await member_channel.edit(name=f"Server Members - {members - 1}") 
    await time_channel.edit(name=f'Time - {time.strftime("%H:%M")}')

def setup(bot):
  bot.add_cog(Server(bot))```
#

code

#

dont know why it is responsing randomly

crimson coral
#

the start of your task has ctx.reply right there

slender lintel
#
  File "c:\Users\zCurq\Desktop\HizmetΓ§i Bot\app.py", line 2, in <module>
    import discord,os
#
from dotenv import load_dotenv
import discord,os
from discord.ext import commands

load_dotenv()

bot = commands.Bot(command_prefix="*",intents = discord.Intents.all(),status=discord.Status.dnd,activity=discord.Game(name="*yardΔ±m"),help_command=None)

for modules in os.listdir("./modules"):
    if modules.endswith(".py"):
        bot.load_extension(f"modules.{modules[:-3]}")

@bot.event
async def on_ready():
    print(f"{bot.user.name} hazΔ±r !")

@bot.event
async def on_message(message):
    if message.content == "sa" or message.content == "Sa":
        await message.channel.send(f"AleykΓΌmselam, {message.author.mention}")
    await bot.process_commands(message)

bot.run(os.environ['token'])
crimson coral
#

uhhh

crimson coral
slender lintel
#
Traceback (most recent call last):
  File "c:\Users\zCurq\Desktop\HizmetΓ§i Bot\app.py", line 2, in <module>
    import discord , os
  File "C:\Users\zCurq\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\__init__.py", line 20, in <module>
    from .client import Client, AppInfo, ChannelPermissions
  File "C:\Users\zCurq\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 38, in <module>    from .state import ConnectionState
  File "C:\Users\zCurq\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\state.py", line 36, in <module> 
    from . import utils, compat
  File "C:\Users\zCurq\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\compat.py", line 32
    create_task = asyncio.async
                          ^
SyntaxError: invalid syntax
crimson coral
#

what version of pycord do you have installed

slender lintel
#

2.0.0b7

finite cliff
#

Hyy i want to make a reload command so that i don't have to restart my server everytime when i have done some changes

crimson coral
#

you sure? i think that's incredibly old code

slender lintel
#

Yeah

crimson coral
#

if im not mistaken that's a discord.py 0.16.12 error

slender lintel
#

Requirement already satisfied: py-cord in c:\users\zcurq\appdata\local\programs\python\python39\lib\site-packages (2.0.0b7)

crimson coral
#

can you do pip list

slender lintel
#

I found

crimson coral
#

completely uninstall those and py-cord, then reinstall py-cord

slender lintel
#

It works

#

Thanks !

crimson coral
#

all good

wide cloak
#

hi i get an error and i dont know how to fix

@discord.ui.button(label='Ja', style=discord.ButtonStyle.green, emoji="βœ…", custom_id='closeja')
async def closeja(self, button: discord.ui.Button, interaction: discord.Interaction):
            guild = interaction.user.guild
            team = guild.get_role(serverteam)

        #if team in interaction.user.roles:

            mycursor.execute("SELECT * FROM Tickets WHERE TicketChannelID=%s", (interaction.channel.id,))
            data = mycursor.fetchone()
            
            user = await guild.fetch_member(data[3])

            if user:
                await interaction.channel.set_permissions(user, view_channel=False)


                em = discord.Embed(description=f'Das Ticket wurde von {interaction.user.mention} geschlossen!', timestamp=datetime.now(), colour=colour().main)
                em.set_author(name=interaction.user.name, icon_url=interaction.user.display_avatar.url)

                em2 = discord.Embed(description=f'Dein Ticket wurde von {interaction.user.mention} geschlossen!', timestamp=datetime.now(), colour=colour().main)
                em2.set_author(name=interaction.user.name, icon_url=interaction.user.display_avatar.url)

                message = await interaction.channel.send(embed=em, view=Closed())

                log = bot.get_channel(log_id)
                em=discord.Embed(title="Log - Close", description=f"{interaction.user.mention} hat Ticket {interaction.channel.mention}({interaction.channel.name}) von {user.mention}({user.id}) geclosed!", timestamp=datetime.now(), color=colour().main)
                em.set_author(name=f"{interaction.user.name}#{interaction.user.discriminator}", url="", icon_url=interaction.user.display_avatar.url)
                em.set_footer(text=f"{interaction.user.id}")
                await log.send(embed=em)
                # manchmal error nach hier
                mycursor.execute("INSERT INTO ReopenMSG (reopen, TicketChannelID) VALUES (%s,%s)", (message.id, interaction.channel.id,))
                db.commit()


                try:
                    await user.send(embed=em2)
                except:
                    pass
                
                mycursor.execute("SELECT closenein FROM CloseMSG Where TicketChannelID=%s", (interaction.channel.id,))
                data = mycursor.fetchone()

                message2 = await interaction.channel.fetch_message(data[0])

                mycursor.execute("DELETE FROM CloseMSG WHERE TicketChannelID=%s", (interaction.channel.id,))
                db.commit()

                await message2.delete()
        
        #else:
            #await interaction.response.send_message(f"{emoji().error} Nur das Severteam, kann Tickets schließen!", ephemeral=True)

error:

Ignoring exception in view <Close timeout=None children=2> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='Ja' emoji=<PartialEmoji animated=False name='βœ…' id=None> row=None>:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/discord/ui/view.py", line 373, in _scheduled_task
    await interaction.response.defer()
  File "/usr/local/lib/python3.9/site-packages/discord/interactions.py", line 492, in defer
    await adapter.create_interaction_response(
  File "/usr/local/lib/python3.9/site-packages/discord/webhook/async_.py", line 211, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
strong totem
crimson coral
#

well

#

you were asking "why is it randomly replying"

#

i'm not sure what your actual issue is

strong totem
#

i want it to change time every minute

crimson coral
#

oh wait

#

are you trying to do this on channel names?

strong totem
#

ye

#

voice channel

crimson coral
#

yeahhhh not happening, the channel name ratelimit is twice per 10 minutes

strong totem
#

pycord limit?

crimson coral
#

no, discord

#

and to be honest... anyone using discord is gonna have a clock somewhere on their screen

strong totem
#

problem is most of the members are from different location

strong totem
crimson coral
#

if you want a clock like that it has to be message based

strong totem
#

i got one idea 5 channel, it will update and made public, other ones will be private

crimson coral
wide cloak
#

started like 2 day ago

crimson coral
#

can you try deferring at the start of the callback?

paper harbor
#

Is there a certain amount of slash commands which you can have globally until discord needs an hour of registering the commands?

crimson coral
#

uhh all global commands take an hour to register/update

wide cloak
crimson coral
paper harbor
crimson coral
#

i mean... that's always been the rule, not sure how you were getting around it but that's definitely not the norm

paper harbor
#

oh, ok

slender lintel
#

hey! embeds havent been working after i installed pycord

#

any idea?

frosty slate
slender lintel
#

im using slash commands

#

so for example

#

/whitelist @user

#

it says the application does not respond

#

but when i use a command that doesnt involve embeds they work

slow dome
#

are you going to show the code?

slender lintel
#

yeah im currently dragging pycord to the top of my servers so i can answer quickly lol

#

alright

#

do you think its an import?

#

right

#

there

#

so ive been using the code without embeds this whole time

slow dome
#

you are returning which ends the function right there and ctx.send is never called

slender lintel
#

ah

slow dome
#

and it’s ctx.respond() with slash commands

slender lintel
#

look tho

#

OHH

#

ctx.respond

frosty slate
#

yep

slender lintel
#

thats it

#

thanks so much

#

nvm...

#

im so confused

slow dome
#

what does return do?

slender lintel
#

@slow dome

#

eh

#

i dont find anything wrong

#

its just

#

so annoying

slow dome
#

do you know python

slender lintel
#

i do

#

not perfectly

slow dome
#

and what does return do?

slender lintel
#

return?

#

πŸ’€

#

i used that exact same thing

slow dome
#

exactly, return ends the function there and does nothing after

slender lintel
#

without embeds

#

it worked perfectly

slow dome
#

it would not. show your code

#

because that's not how python works

#

if you put a print("hello world") after the return, it would not print

slender lintel
#

this is the original code

#

it worked perfectly

#

now i just made it send embeds instead of normal messages

slow dome
#

because the return returns what await ctx.respond returns, which is an interaction

slender lintel
#

ah

#

mmm

slow dome
#

if you did want to return what await ctx.send returns, then use

  return await ctx.send()
slender lintel
#

i want it to send an embed

#

not a message

slow dome
#

embeds are part of messages

slender lintel
#

right

#

fixed

slow dome
#

ok, so what's the code now

#

ok, now when you are checking whether the user is an Admin, the same logic error exists.

slender lintel
#

so i would remove the return there too?

slow dome
#

well, you should move it below await ctx.respond

#

because I'm assuming you don't want the rest of the command to run if the user is not an admin

slender lintel
#

yes

#

alright

#

let me test it out

#

ahhh

#

i see

#

thanks

#

:)

slow dome
#

your welcome

wide cloak
crimson coral
#

oh wait

crimson coral
#

if i had to recommend, i'd say put an ephemeral response at the very end of the callback that says that it closed successfully (outside the if)

wide cloak
#

because the are one other error

crimson coral
#

inside the callback

slender lintel
#

how would i make it edit an embed

#

message.edit

#

?

tidal beacon
#

I am having an issue with slash command option decorators, this is how I have mine declared, and this is the error that i am getting

tidal beacon
slender lintel
#

embed1=discord.Embed(title="nitroboostinglevel | Fault", description=f"icons_online | Started Boosting...", color=0xde5bbb)

message = await ctx.respond(embed=embed1)

embed2 = discord.Embed(title="![nitroboostinglevel](https://cdn.discordapp.com/emojis/973623946123563159.webp?size=128 "nitroboostinglevel") | Fault", description=f"![icons_online](https://cdn.discordapp.com/emojis/973623983549321256.webp?size=128 "icons_online") | *Finished Boosting...*", color=0xde5bbb)

await message.edit(embed=embed2)
tidal beacon
crimson coral
slender lintel
crimson coral
#

ctx.respond doesn't actually return a message, but instead an interaction

slender lintel
#

@crimson coral

crimson coral
#

? you can

slender lintel
#

oh

tidal beacon
#

do you have to use ctx.edit instead of msg.edit?

crimson coral
#

well because message in that code isn't actually a message, it's an interaction

#

ctx.edit is equivalent to ctx.interaction.edit_original_message iirc

#

though i guess you could do message.edit_original_message if you really wanted

tidal beacon
#

ok that makes sense

tidal beacon
#

this one works fine

#

but the one above doesn't

crimson coral
#

wait

#

you typehinted wrong apensive

#

unless im misreading, commands.Context is for prefix commands

#

(personally i don't really see the need to typehint the vast majority of the time, considering the library handles all the registration for with the decorators, but if want to then you need discord.ApplicationContext)

slender lintel
#

SOMEONE PLEASE TELL ME

#

do i need to import something to use create_dm

crimson coral
#

no

#

though... you don't need it unless you very specifically need something like a user's DMChannel ID

#

because you can just do user.send

slender lintel
#

so how could i do something like this:

#
@bot.command()
async def customrole(ctx, name):
    owner = ctx.guild.owner
    member = ctx.message.author
    direct_message = await owner.create_dm()
    await direct_message.send(f"{member}, wants to create a custom role called {name}.")
#

i want it to send a dm to me telling me something

crimson coral
#

await owner.send

slender lintel
#

ok

crimson coral
#

looks fine

tidal beacon
crimson coral
#

hmm hold on

tidal beacon
#

o wiat

crimson coral
#

oh wait