#General Help

1 messages ยท Page 15 of 1

errant verge
#

but i only pressed it once

surreal lagoon
#

you can't use interaction.response multiple times

#

use interaction.followup for that

errant verge
#

ohhhh

#

so rn i haveawait interaction.response.edit_message(content = None, embed=embed , view=None)

#

at the end

#

i have to change to interaction.followup

surreal lagoon
#

I think so

#

try it

sudden path
#

Because that's not how it works.

errant verge
#

i think this is what i want but i have to input message_id, how'd i get that from the message the button is?

sudden path
#

What are you trying to do

errant verge
#

i have a command that gives you options for approve and deny

#

it checks if you have a role to be able to use approve and if you do it does a bunch of stuff then it edits the message the button was in to an embed and also removing button

sudden path
#

So what you don't know?

errant verge
#

how would i get the message id from the message the button is in?

#

im using view class

surreal lagoon
#

then use .id on that variable

errant verge
#

i.e.

msg = ctx.send("Button test", view=View())
await msg
surreal lagoon
#
msg = await ctx.send("example")
#

this is better

#

then

msg.id```
errant verge
#

how would i add the button then in this case?

surreal lagoon
#

you add it in the view when you send the message

#

I just didn't write it in there because I'm lazy

sudden path
surreal lagoon
#

yeah that might be what you're looking for

errant verge
#

interaction.original_message()
refers to the original message the bot sends?

sudden path
#

Yes

#

By looking at the docs that might be the answer

errant verge
#
asnyc def button_callback(self, button, interaction):
  await interaction.response.defer()
  # a bunch of stuff...
  msg = await interaction.original_message()
  await interaction.followup.edit_message(msg.id, content=None, view=None)
#

something like this then

#

oh, it still returns error
discord.errors.InteractionResponded: This interaction has already been responded to before

sudden path
#

why are you doing interaction.followup.edit_message

#

If you're trying to edit the original message

#

You just have to do

await interaction.response.edit_message(content=None, view=None)```
errant verge
#

it returns the same error

#

because of interaction.response.defer() i assume?

sudden path
#

Show your code

errant verge
#
class View(discord.ui.View):
  @discord.ui.button(label="Approve", style=discord.ButtonStyle.green)
  async def button_callback(self, button, interaction):
    guild = bot.get_guild(ID)
    role = guild.get_member(interaction.user.id).get_role(ROLEID)
    if role is None:
      await interaction.response.send_message(f"<@{interaction.user.id}>, you don't have perms to interact", ephemeral=True)
    else:
      await interaction.response.defer()
      # long code
      await interaction.response.edit_message(content = None, embed=embed , view=None)
warm jungle
#

is there any way to make a user select a channel from a server? i was thinking using the wait_for but it doesnt seem to work when using slash commands

warm jungle
slender lintel
#

like
/choosechannel channel:general

warm jungle
#

i mean i guess that could work

#

but also is there a way to remove an option when in dms?

slender lintel
#

im not sure what it does in a dm channel

#

cause it jsut returns all textchannels

#

you could make it jsut optional

#

and check if they are in a guild or not

warm jungle
#

o yea yea

#

i was just wondering if there was a more better way already implemented but i dont think so

slender lintel
#

thats what you would do

warm jungle
#

yep

#

thanks for the assistance homie

slender lintel
#

np ๐Ÿ‘

verbal mango
#

why does on ready in all my cogs never get called but other things like on_message does? only the on_ready event in my main file is working

@commands.Cog.listener()
    async def on_ready(self):```
#

i think its because my cogs are being activated from my main on_ready in main file, is there a way to activate the cogs earlier

sudden path
errant verge
#

no it doesn't seem like it

sudden path
verbal mango
errant verge
#

the only problem that i have with the code is that the long code needs the response defer

sudden path
#

Hmm

errant verge
#

i think without it, only part of it is completed

sudden path
#

Weird tbh

verbal mango
errant verge
#

the basic function that i want to be done is

warm jungle
errant verge
#

someone with role A does command but has to wait for someone with role B to approve their command

#

and they do this by pressing button

#

which processes some stuff in google sheets

slender lintel
warm jungle
errant verge
#

i'd also want to know if i can make a dropdown menu kindof for arguments in a slash command

#

similar to how if i have the arg to discord.User

#

or autocomplete the arguments

sudden path
verbal mango
sudden path
#

And I'm pretty sure it's not a couroutine because I use it in my code.

gilded widget
#

it's not, that screenshot is from the discord.py docs and not pycord

steady lotus
#

on extension load and unload

#

is on_ready() called

#

and if not

#

what other method is called

cunning dragon
#

What versions is needed for slash command groups?

slow dome
steady lotus
#

is it possible to register update a command

#

keep the other commands registered

#

but force reregister certain commands

#

bot.register_commands() only registers commands passed

slow dome
#

why would you do that

warm jungle
#

why do only a few slash commands show up in direct messages

steady lotus
rotund dragon
#

how to get the vc text channel from the vc object itself?

steep verge
#

Not sure if itโ€™s fetch able by the api yet

slender lintel
#
Ignoring exception in command test:
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 126, in wrapped
    ret = await coro(arg)
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 852, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "/home/container/cogs/mc.py", line 150, in test
    await ctx.author.add_roles(role)
  File "/home/container/.local/lib/python3.10/site-packages/discord/member.py", line 975, in add_roles
    await req(guild_id, user_id, role.id, reason=reason)
  File "/home/container/.local/lib/python3.10/site-packages/discord/http.py", line 353, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.10/site-packages/discord/bot.py", line 993, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 357, in invoke
    await injected(ctx)
  File "/home/container/.local/lib/python3.10/site-packages/discord/commands/core.py", line 134, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

I can't add roles. The bot has administrator permission

errant verge
#

after using interaction.response.defer() i get a leftover response to the command from my bot that says 'The application did not respond' but i know everything has finished after i clicked my button because i have an embed sent out. how would i go about removing this reply message?

ancient gazelle
#

Hey guys

#

I need a bit of a help, I need to create a channel in a particular category. How do i do that?

errant verge
#
@bot.slash_command(description = "Change teams for user")
@commands.has_role("Captain")
async def team(ctx, player: discord.User, team: str, tmz: str):
    class View(discord.ui.View):
        @discord.ui.button(label="Deny", row = 1, style=discord.ButtonStyle.red)
        async def button_callback(self, button, interaction):
            guild = bot.get_guild(GUILDID)
            role = guild.get_member(interaction.user.id).get_role(ROLEID)
            if role is None:
                await interaction.response.send_message(f"<@{interaction.user.id}>, you don't have perms to interact", ephemeral=True)
            else:
                # buncha stuff 
        @discord.ui.button(label="Approve", row = 1, style=discord.ButtonStyle.green)
        async def button_callback(self, button, interaction):
            guild = bot.get_guild(GUILDID)
            role = guild.get_member(interaction.user.id).get_role(ROLEID)
            if role is None:
                await interaction.response.send_message(f"<@{interaction.user.id}>, you don't have perms to interact", ephemeral=True)
            else:
                # buncha stuff

    embed = discord.Embed(title = "Transaction Request", description = f'<@{ctx.author.id}> requests <@{player.id}> to {team} with timezone {tmz}.')
    await ctx.send(embed=embed, view=View(timeout=None))

maybe my format for the command is not good since i have class inside of the function, but idk how to refer to function argument inside of class, but regarding multiple buttons, with this command right now only the 2nd button gets displayed

#

if i remove the row the same thing happens

frigid lark
slender lintel
#

How to check role on interactiob

#

N

slender lintel
slender lintel
#

Nice

celest moth
#

Can you send a response to another channel upon modal callback

slender lintel
#

Hello

#

Does anyone have a py function that can generate discord timestamps like <t:1654610400:R> ( <t:1654610400:R>) with datetime

fair cradle
#

Yes

#

discord.Attachment

slender lintel
#

ty

rigid wave
#

which best fetch_guilds or bot.guilds?
And what is the difference between them?

fair cradle
#

Yes it is that, as an option

#

Image: discord.Attachment

tender crag
#

is "content moderation" feature supported on pycord? the banned word thingy

haughty narwhal
#

if i have a button which is interactable. How can i do, so that i dont get interaction failed without sending a message response?

slender lintel
sudden path
#

It will fail after 15 minutes.

brittle pond
#

Please help me

#

The bot doesnt detect my command

#

i typed '$test'

worthy basin
#

Did your bot print we have logged in as ...

brittle pond
#

Yes

#

been trying to find out whats wrong for the whole day

#

i even copied the code exactly

worthy basin
#

where did you copy it from?

brittle pond
#

youtube

#

This is the Ultimate Python Guide on Buttons with Discord.py or Pycord. In this video, I talk about how to create buttons in discord.py or pycord and how to respond to button clicks along with everything about Views. After watching this you'll know everything about Buttons and Views in discord.py or pycord.

This video might also apply to other...

โ–ถ Play video
ripe parcel
#

The intent for normal commands

worthy basin
#

I does not appear that you have enabled intents. You need to enable the message content intent to use prefix commands

brittle pond
#

๐Ÿ˜ฎ

#

how?

#

please help me

#

i tried this in discord.py but i just moved to pycord

worthy basin
#
intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix="$", intents=intents)

And also go to the developer panel and enable it

brittle pond
#

$test

#

ooops

worthy basin
#

In the developer panel go to your bot
"bot" tab -> scroll down -> enable the one that says message content

brittle pond
#

wrong channel

rigid wave
#

What is the cause of this error?

2022-06-07 11:56:13,419:ERROR:discord.shard: Attempting a reconnect for shard ID 6 in 2.12s
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/discord/shard.py", line 151, in worker
    await self.ws.poll_event()
  File "/usr/local/lib/python3.8/dist-packages/discord/gateway.py", line 582, in poll_event
    raise ConnectionClosed(self.socket, shard_id=self.shard_id, code=code) from None
discord.errors.ConnectionClosed: Shard ID 6 WebSocket closed with 1000
worthy basin
#

It appears one of your shards went offline

brittle pond
#

hmmm

#

now i get this

worthy basin
#

Can you show your code again?

brittle pond
#

i just hid that bot.run below

worthy basin
# brittle pond

A quick search tells me that you might have to update your pycord version.

brittle pond
#

OMG TY SO MUCH

worthy basin
#

or not, ok!

brittle pond
#

finally

#

๐Ÿ˜—

#

back to coding

worthy basin
#

We are happy to help, just a warning YouTube tutorials can sometimes become out of date. We have some examples on the github and a guide to pycord if you want to look at them

brittle pond
#

Ok I will stick to reading the docs.

slender lintel
#

how do rankcards

rigid wave
worthy basin
rigid wave
#

ok

rich nebula
#
@config.command()
async def channel(self, ctx: discord.ApplicationContext, ch: Option(discord.SlashCommandOptionType.channel)):
  await ctx.respond(ch)

err TypeError: issubclass() arg 1 must be a class

#

Someone knows how to fix it?

zealous brook
#

whats wrong there?

forest saffron
#

hii the button interaction is not working (oddly enough my other buttons work) it always says the interaction failed if im adding it to my view and no errors

slow dome
zealous brook
slow dome
#

b!rtfm pyc discord.enums.ButtonStyle

open bearBOT
zealous brook
#

i never had that error

slow dome
zealous brook
#

lol

forest saffron
#

im dumb xd

slow dome
slow dome
forest saffron
#

sorry do disturb again but the enum thing wasnt the problem the interaction is the problem

#

the button was produced fine but if im clicking it it does nothing

#

odd thing is that my other buttons work xd

slow dome
# forest saffron
super().__init__(
  label="button",
  style=...,
  callback=self.button_callback()
)
forest saffron
#

oh lol

slow dome
#

I think that's how you make a button

tepid anvil
tepid anvil
slow dome
#

if you are completely sure there is nothing wrong with your code, open an issue on github

tepid anvil
#

is there any example to refer too ?

forest saffron
# slow dome I think that's how you make a button

well as i expected this threw an error too. callback is the method and not the attribute (dw just respond later if you have time) i will try to fix it. its like in the docs and my other buttons work idk whats wrong xd

slow dome
#

if it responds, congrats. you set it up correctly

slender lintel
#

can someone help me pls

#

my error:


Ignoring exception in command rank:
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 181, in wrapped
    ret = await coro(args, **kwargs)
  File "/home/container/main.py", line 327, in rank
    users = json.load(f)
  File "/usr/local/lib/python3.9/json/init.py", line 293, in load
    return loads(fp.read(),
  File "/usr/local/lib/python3.9/json/init.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 360, in invoke
    await ctx.command.invoke(ctx)
  File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 927, in invoke
    await injected(ctx.args, **ctx.kwargs)
  File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 190, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: JSONDecodeError: Expecting value: line 1 column 1 (char 0)
#

my code

@bot.command()
async def rank(ctx, member: discord.Member = None):
    with open('users.json', 'r') as f:
        users = json.load(f)

    if not member:
        member = ctx.author

    next_level_xp = (users["level"] + 1) * 100
    current_level_xp = users[f'{ctx.author.id}']["level"]
    xp_need = next_level_xp - current_level_xp
    xp_have = users["experience"] - current_level_xp

    percentage = (xp_need / 100) * xp_have

    background = Editor("0.png")
    profile = await load_image_async(str(member.avatar_url))

    profile = Editor(profile).resize((150, 150)).circle_image()

    poppins = Font().poppins(size=40)
    poppins_small = Font().poppins(size=30)

    square = Canvas((500, 500), "#06FFBF")
    square = Editor(square)
    square.rotate(30, expand=True)

    background.paste(square.image, (600, -250))
    background.paste(profile.image, (30, 30))

    background.rectangle((30, 220), width=650, height=40, fill="white", radius=20)
    background.bar(
        (30, 220),
        max_width=650,
        height=40,
        percentage=percentage,
        fill="#FF56B2",
        radius=20,
    )
    background.text((200, 40), str(member), font=poppins, color="white")

    background.rectangle((200, 100), width=350, height=2, fill="#17F3F6")
    background.text(
        (200, 130),
        f"Level : {users['level']}"
        + f" XP : {users['experience']} / {(users['level'] + 1) * 100}",
        font=poppins_small,
        color="white",
    )

    file = File(fp=background.image_bytes, filename="card.png")
    await ctx.send(file=file)
tepid anvil
#

thanks ser

slow dome
hot vale
#

What I have bad on this?

#

nsfw = channel.is_nsfw().replace('False', 'Nie')

slender lintel
#

Hi, I can do a select menu in modal

hot vale
slender lintel
#

Oho siema

sleek grove
#

how to make a slash command error event

slender lintel
#

!install

robust nebulaBOT
#

Install pycord:

pip uninstall discord.py
pip install py-cord

Install pycord beta:

pip uninstall discord.py
pip install py-cord==2.0.0b7

Install pycord alpha from git:

pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
slender lintel
#

pip install py-cord==2.0.0b7

#

i need but thew c

#

one

#

i did it elired

#

to fix everthing

terse plinth
slender lintel
#

anyone know witch on it is

terse plinth
#

?

slender lintel
#

it was like pip install py-cord==2.0.0c7 or something like that\

terse plinth
#

np

slender lintel
#

idk

#

exactly

terse plinth
#

idk either

slender lintel
#

can u please

#

tell

terse plinth
#

i dont know bruh

slender lintel
#

got

#

python3 -m pip install -U py-cord --pre

#

i needed pre

#

for slash commands

#

and shit like that

stray galleon
#

My bot seems to have stopped reading messages.
โ€ข It is working fine on my test server, but not on my live server. I'm guessing I missed a permission when creating the URL, but if I try to select messages.read in the Discord Developer Portal it asks me for a redirect uri, and I am fairly certain I didn't select that option when inviting the bot to my test server.

slender lintel
#

oh wow its up

#

thats suprising

stray galleon
#

Slash commands work fine! Everything but message.read is behaving correctly.

slender lintel
#

im using a vps tho lmao

slender lintel
#

and it was removed in the pre

stray galleon
#

Same machine, same installation, everything. Just a different server.

slender lintel
#

oh

#

uhh have u tried restarting bot

#

it give errors

#

trace backs?

stray galleon
#

Yes. And I ran it on the test server again. No errors.

slender lintel
#

hmmm

stray galleon
#

The slash commands are working perfectly.

slender lintel
#

hmm idk

#

then

#

is there a delete after

#

atribute?

stray galleon
#

Where?

slender lintel
#

no for me

#

im hosting

#

right noe

#

on a vps

#

p.

#

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

46

User Count

18452

Ping

105.74ms

vocal crane
#

how can i await the user to ping a role instead of sending a message then use the role for further permissions?

stray galleon
#

[My issue turned out to be PEBCAK - the bot's permissions per channel weren't properly calibrated]

sleek grove
#

how can i send a embed from json data

#

{
"content": null,
"embeds": [
{
"title": "kicked.",
"description": "{member.name} was kicked.\nReason ยป {reason}",
"color": 6266528
}
],
"attachments": []
}

errant verge
#

after i use a slash command and interact with a button, there is a leftover reply that says the application did not respond but i see that everything i wanted to happen after clicking the button worked. is this because of interaction.defer()? how would i fix this

slender lintel
#

you guys like it?

#

ik its pretty much a remkake of this bots but i loved it so

#

ya

supple ravineBOT
#

Here's the slash cog groups example.

crimson gale
sleek grove
slender lintel
sleek grove
#

cuz i can copy it from discohook

slender lintel
#

and theres no reason to

sleek grove
slender lintel
#

bro what

crimson gale
#

why use json data when you can just construct the exact embed without json?

slender lintel
#

exactly

sleek grove
#

bruh

slender lintel
#

embed=discord.Embed(title="Moderation", description=""" example

#

then just call it

#

bye doing embed=embed

crimson gale
slender lintel
#

EXAMPLE

#

btw

crimson gale
#

its easy

slender lintel
sleek grove
#

I KNOW HOW TO DO A EMBED

slender lintel
#

then why u need json

#

like tf

sleek grove
#

Ignoring exception in on_member_join
Traceback (most recent call last):
File "pythonProject/venv/lib/python3.10/site-packages/discord/client.py", line 382, in _run_event
await coro(*args, **kwargs)
TypeError: Member.on_member_join() takes 1 positional argument but 2 were given

crimson gale
#

hold

slender lintel
#

theres no reason to

sleek grove
#

help by that error

slender lintel
#

just read the error

#

TypeError: Member.on_member_join() takes 1 positional argument but 2 were given

crimson gale
#

it shouldnt take 2

#

is it in a cog?

sleek grove
crimson gale
#

then you need to add self as the first arg

slender lintel
#

LMAO

#

is it in a cog?

sleek grove
#

@commands.Cog.listener()
async def on_member_join(self):
async def on_member_join(member):
role = get(member.guild.roles, id=896705950688370688)
time.sleep(30)
await member.add_roles(role)
await member.edit(nick=f"ๆง‹ๆˆๅ“ก | {member.name}") @commands.Cog.listener()
async def on_member_join(self):
async def on_member_join(member):
role = get(member.guild.roles, id=896705950688370688)
time.sleep(30)
await member.add_roles(role)
await member.edit(nick=f"ๆง‹ๆˆๅ“ก | {member.name}")

slender lintel
#

@sleek grove

sleek grove
#

?

slender lintel
#

iya just add self

#

to your function

crimson gale
#

add member to the first function def and get rid of the duplicate

slender lintel
crimson gale
#

problem solved

sleek grove
#

@commands.Cog.listener()
async def on_member_join(self, member):
async def on_member_join(member):
role = get(member.guild.roles, id=896705950688370688)
time.sleep(30)
await member.add_roles(role)
await member.edit(nick=f"ๆง‹ๆˆๅ“ก | {member.name}") @commands.Cog.listener()
async def on_member_join(self):
async def on_member_join(member):
role = get(member.guild.roles, id=896705950688370688)
time.sleep(30)
await member.add_roles(role)
await member.edit(nick=f"ๆง‹ๆˆๅ“ก | {member.name}")

languid hollow
#

I got rate limted on replit, I fixed it but I was wondering what was the reason that the bot got rate limited?

sleek grove
#

like this?

slender lintel
#

its so easy to fix

crimson gale
sleek grove
slender lintel
#

so am i but like damn

crimson gale
#

to python as a whole or just pycord?

sleek grove
#

ah

#

oh

slender lintel
#

ik

#

i just read errors and code

#

easy

#

and READ THE DOCS

#

lmao

#

litteraly everying is in the docs

#

and here

#

examples

#

everything

sleek grove
#

bro chill

slender lintel
#

use this

lucid cove
#

is it possible to have mutliple on_message event listeners?

crimson gale
#

yes

lucid cove
#

well it doesnr seem to work

crimson gale
#

not using @bot.event though, theres a different decorator

lucid cove
#

and what i mean by that is

@bot.listen
async on_message(message):
slender lintel
#

bruh wtf

#

i never knew that lmao

slender lintel
#

?tag lp

hearty rainBOT
#
slender lintel
#

hmm

#

bruh

crimson gale
#

"on_message"

slender lintel
#

where

lucid cove
#

huh

slender lintel
#

do i find back ground wallapers like this

#

besides the logo

#

just the wallpaper behind it

crimson gale
#

not here

slender lintel
#

lol

lucid cove
#

i see

#

i had two on_messge functions

#

so why should i do instead

#

do i just name it different;y

crimson gale
#

of course

lucid cove
#

like on_message2(message)

#

aight

#

dumb question tbh

crimson gale
#

youre also missing the crucial part of actually telling the decorator which event to listen to

lucid cove
#

as in?

crimson gale
#

read the documentation

#

you shouldve seen it

lucid cove
#

i see

#

thanks

slender lintel
#

how can i check if member is = to self cancel author.id i have no clie tbh

#

i looked through docs

#

i cant find anythin

crimson gale
#

what?

slender lintel
#

so if a user trys to mute them self how do i say u cant do that

crimson gale
#

just compare the target id to author id

sleek grove
#

How is the dm function in cogs?

slender lintel
crimson gale
#

yes

slender lintel
#

ok'

languid hollow
#

E, once again got rate limited

crimson gale
sleek grove
crimson gale
#

await user.send()

#

also dm them before kicking

#

because if they arent in the server, the bot cant dm them

sleek grove
#

ah

sleek grove
crimson gale
#

why?

sleek grove
#

works

#

thanks

languid hollow
#

I believe the bot can DM them unless their privacy is on that friends can only DM (thought I'm not entirely sure)

crimson gale
#

server presence is also a factor

#

if the user isnt present in a server that both the bot and user share then the bot is unable to dm them

sleek grove
#

yes but if you have activated it it is your own fault

paper harbor
#

How do I edit an interaction?

crimson gale
#

await interaction.edit_original_message()

slender lintel
#
    @client.slash_command(name="help", description="Opens a select menu based on helping.")
    async def menu(self, ctx):
        select = Select(options=[
            discord.SelectOption(label="Moderation", emoji=None, description="Shows all the available moderation commands."),
            discord.SelectOption(label="Fun", emoji=None, description="Shows all the available fun commands.")
        ])

        embed=discord.Embed(title="Moderation", description="""        
`Ban`, Bans a user from the server, (/ban)
`clear`, Clears a selected amount messages from a channel, (/clear)
`Kick`, Kicks a user from the server, (/kick)
`Unban`, Unbans a user from the server, (/unban), copy there id!
        """, color=discord.Color.dark_gold())
        async def menu_callback(interaction):
            await interaction.response.send_message(embed=embed, ephemeral=True)

        select.callback = menu_callback    
        view = View()
        view.add_item(select)

        await ctx.respond("What command do u need help with: ", view=view)



def setup(client):
    client.add_cog(help(client))
#

so i have this but i wanna have it embed another

#

embed

#

based on fun

#

commands

#

but I'm confused how i can so that with the first embed already there

crimson gale
#

you can manipulate the attributes

#

plus an easier method to doing this is to instantiate an embed in the callback and then change the attributes based on the selected option

slender lintel
#

uhh

#

how do i do that

#

@crimson gale

#

?

#

lmao

crimson gale
#

compare select.values[0] to the value of the desired option (label = value if not specified in SelectOption) and then do the desired actions

slender lintel
#
async def on_message(message):
    if bot.user.mentioned_in(message):
        await message.channel.send('Hello! I assume you are wondering who i am? \n I was created by @ignfoolish#0396\n I was created for the server Felbcord and i am useful for moderation and fun commands! ')``` How do i make it reply only on single mention eg
@felbcord utils 
instead of 
@felbcord utils hello
atomic thistle
#

How do I put a local image as the image of an embed?

slender lintel
# crimson gale compare `select.values[0]` to the value of the desired option (label = value if ...
from code import interact
from select import select
import discord
from discord.ui import Select, View
from discord.ext import commands
from discord.commands import SlashCommand

client = commands.Bot()

class help(commands.Cog):
    def __init__(self, client):
        self.client = client
    
    @client.slash_command(name="help", description="Opens a select menu based on helping.")
    async def menu(self, ctx):
        select = Select(options=[
            discord.SelectOption(label="Moderation", emoji=None, description="Shows all the available moderation commands."),       
            discord.SelectOption(label="Fun", emoji=None, description="Shows all the available fun commands.")
        ])


        embed=discord.Embed(title="Moderation", description="""        
`Ban`, Bans a user from the server, (/ban)
`clear`, Clears a selected amount messages from a channel, (/clear)
`Kick`, Kicks a user from the server, (/kick)
`Unban`, Unbans a user from the server, (/unban), copy there id!

        """, color=discord.Color.dark_gold())
        async def menu_callback(interaction):
            await interaction.response.send_message(embed=embed, ephemeral=True)

        select.callback = menu_callback    
        view = View()
        view.add_item(select)

        await ctx.respond("What command do u need help with: ", view=view)

def setup(client):
    client.add_cog(help(client))
#

this all i have

#

i need help

crimson gale
#

this is the exact same code?

slender lintel
#

no

crimson gale
#

where?

slender lintel
#

this orignal code

#

i need help with the mbed part

#

so if u choose fun it only shows info about fun commands

#

vise versa

slender lintel
#

i dont know how

#

to do that

crimson gale
#

i literally told you

slender lintel
#

thats what i need help with

crimson gale
#

what i told you is the solution

slender lintel
#

im so conffused

#

dude

#

this makes no sence

#

im trying

#

dude

crimson gale
#

select.values is the list of chosen options, [0] grabs the first element of that list, that is then compared to a predetermined value to check the chosen option and then do the desired actions

slender lintel
#

ok but how do i use select.values to check if it is what ever usaid

crimson gale
#

compare

slender lintel
#

ik if

crimson gale
#

is equal

slender lintel
#

but like

#

equal to what

#

theres nothing for it to be eqals to

crimson gale
#

yes there is

slender lintel
#

WHAT

#

select.values[1]

crimson gale
#

"Moderation" or "Fun"

slender lintel
#

        embed=discord.Embed(title="Moderation", description="""        
`Ban`, Bans a user from the server, (/ban)
`clear`, Clears a selected amount messages from a channel, (/clear)
`Kick`, Kicks a user from the server, (/kick)
`Unban`, Unbans a user from the server, (/unban), copy there id!

    

        """, color=discord.Color.dark_gold())
        async def menu_callback(interaction):
            await interaction.response.send_message(embed=embed, ephemeral=True)
#

ok but these are connected

#

ig

#

u can say

#

just copy and paste this again

#

and do the same thing

crimson gale
#

youve hardcoded the response to send the embed

#

you cant do that if you want the menu to be able to show a different embed

slender lintel
#

i have this

#

but i keep getting a syteax error

#

for ()

errant verge
#

i was checking my command and it stopped working suddenly saying local variable 'teamc' referenced before assignment so i tried testing it by itself first. my function is:

def test(team):
  if team in ["Red", "Green", "Blue"]:
    teamc = 1
  elif team in ["Apple", "Banana", "Pear"]:
    teamc = 2
  if team in ["Red", "Apple"]:
    start = 1
    end = 5
  elif team in ["Green", "Banana"]:
    start = 7
    end = 11
  elif team in ["Green", "Banana"]:
    start = 13
    end = 17
sage robin
errant verge
#

i tried to print teamc, start, and end but they all result in local variable referenced before assignment

sage robin
slender lintel
#

u have pre installed

sage robin
#

what thing I do not underestand

slender lintel
#

@crimson gale

crimson gale
#

why did you erase all of your progress?

slender lintel
#

i still have iut

crimson gale
#

i did not tell you to do that

slender lintel
#

dude its fine

#

i just need to fix this

sage robin
crimson gale
#

reinstall pycord

sage robin
#

ok

slender lintel
#

how do i fix

crimson gale
slender lintel
#

its installed

crimson gale
#

theres your issue

slender lintel
#

oh

#

wtf

#

@crimson gale

#

ok

#

so i have the main select menu setup

terse plinth
#

dont ping without permission bruh

crimson gale
#

shush

terse plinth
#

?

#

lmao

crimson gale
#

right so you have the callback ready?

slender lintel
#

not quirte yet im working on it right now so for my call back args i just leave it blamk?

crimson gale
#

well you need the interaction

slender lintel
#

ya ik

#
async def menu_callback(interaction):
            await interaction.response.send_message(embed=embed, ephemeral=True)

        select.callback = menu_callback    
#

this

#

but leave the embed=embed aout

#

leave args blank

crimson gale
#

nah leave it there

#

before the response you want to check the selected value

slender lintel
#

oh

sage robin
#

I get the same

slender lintel
#

!install

robust nebulaBOT
#

Install pycord:

pip uninstall discord.py
pip install py-cord

Install pycord beta:

pip uninstall discord.py
pip install py-cord==2.0.0b7

Install pycord alpha from git:

pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
slender lintel
#

wsait

#

wait

crimson gale
#

that i have absolutely no knowledge of

slender lintel
#

its his verion

#

u have pre

#

installed right?

crimson gale
#

regardless of the installed version, that should never appear

sage robin
slender lintel
#

no u need pre

crimson gale
#

except the fact that thats the wrong package

slender lintel
#

it will if its older

#

verion

crimson gale
#

the version doesnt matter right now

#

that package is entirely wrong

slender lintel
#

rebuild it

sage robin
#

How do I update it?

slender lintel
#

pip rebuild py-cord

crimson gale
#

dude

#

do you have eyes?

slender lintel
#

me?

crimson gale
#

pycord and py-cord are two separate packages

slender lintel
#

oh

crimson gale
sage robin
#

which?

crimson gale
#

!install

robust nebulaBOT
#

Install pycord:

pip uninstall discord.py
pip install py-cord

Install pycord beta:

pip uninstall discord.py
pip install py-cord==2.0.0b7

Install pycord alpha from git:

pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
crimson gale
#

pip install py-cord==2.0.0rc1

slender lintel
#

yes

#

that one

#

that should 100% work

#

i actually need that thx

#

its for my host

#

server

#
import discord
from discord.ui import Select, View
from discord.ext import commands
from discord.commands import SlashCommand

client = commands.Bot()

class help(commands.Cog):
    def __init__(self, client):
        self.client = client
    
    @client.slash_command(name="help", description="Opens a select menu based on helping.")
    async def menu(self, ctx):
        select = Select(
            placeholder="Choose your help category:",
            options=[
                discord.SelectOption(
                    label="Moderation",
                    emoji="๐Ÿ”จ",
                    description="Shows all the available moderation commands.",
                ),
                discord.SelectOption(
                    label="Fun",
                    emoji="๐Ÿธ",
                    description="Shows all the available fun commands."
                ),
            ]
        )
 
        if select.values[0] == "Moderation":
            embed=discord.Embed(title="Moderation", description="""        
`Ban`, Bans a user from the server, (/ban)
`clear`, Clears a selected amount messages from a channel, (/clear)
`Kick`, Kicks a user from the server, (/kick)
`Unban`, Unbans a user from the server, (/unban), copy there id!""")

        async def menu_callback(interaction):
            await interaction.response.send_message(embed=embed, ephemeral=True)

        select.callback = menu_callback    
    
        view = View()
        view.add_item(select)
        await ctx.respond("Choose what menu u wanna see: ", view=view)

def setup(client):
    client.add_cog(help(client))
#

so i have this

#

so far

#

@crimson gale

#

is this correct?

crimson gale
#

the check needs to be ran inside the callback

slender lintel
#

oh ok

crimson gale
#

otherwise it is correct

slender lintel
#
        async def menu_callback(interaction):
            await interaction.response.send_message(embed=embed, ephemeral=True)

            if select.values[0] == "Moderation":
                embed=discord.Embed(title="Moderation", description="""        
`Ban`, Bans a user from the server, (/ban)
`clear`, Clears a selected amount messages from a channel, (/clear)
`Kick`, Kicks a user from the server, (/kick)
`Unban`, Unbans a user from the server, (/unban), copy there id!""")

        select.callback = menu_callback    
    
        view = View()
        view.add_item(select)
        await ctx.respond("Choose what menu u wanna see: ", view=view)
#

like this?

crimson gale
#

before the response

slender lintel
#

then do the same thing for fun

slender lintel
#

what do mean

crimson gale
#

await interaction.response.send_message(embed=embed, ephemeral=True)

#

before that line

slender lintel
#

so do i have to do this for my fun command as well

#

?

crimson gale
#

obviously

slender lintel
#

ok

crimson gale
#

you should use elif for the other one to cut out unnecessary comparison

slender lintel
#

ok

terse plinth
#

guys, this is general help. If your topic is this extensive, make a thread on #969574202413838426

crimson gale
#

dont need to be a mini-mod thanks

terse plinth
#

ok moth guy

slender lintel
terse plinth
#

?

#

how so? i believe general help is for small topics?

#

or small errors

slow dome
#

โ€œDonโ€™t post same question in multiple channelsโ€

slow dome
crimson gale
#

also that rule is a bit outdated

#

something like "dont make duplicate posts" is more appropriate

slow dome
#

and โ€œYou can ask for any helpโ€

terse plinth
#

3. To ask for help, create a post in help. Remember that talking unnecessarily or creating useless posts is not allowed.

#

sry, keyboard bugged out

slow dome
#

If you want to debate this, we can take it to DMs

terse plinth
#

nahh

#

lmao

#

just let the mods decide ig

#

idrc

slow dome
#

because this isnโ€™t help

#

lol

slender lintel
terse plinth
#

ok bro, if you want constant help im just saying, easier to make a thread than flood #969580926885580801

terse plinth
#

yea

#

im not obligated to

slender lintel
#

bro stfu your digging a missive hole for your self and you sound stupid

terse plinth
#

. . .

crimson gale
#

leave it at that

terse plinth
#

lmao

#

you maddd

crimson gale
#

youre gonna get yourself in trouble with the mods if you keep that up which is why im saying that as a courtesy

terse plinth
#

mate im being polite, that cupcake dude is shouting at me lmao

crimson gale
#

it goes for the both of you

slender lintel
#

dude ileft cuz of this

#

lmao

#

im done good bye

terse plinth
#

bruh can we calm down, it rly isnt that big of a deal

slender lintel
#

dont @ me

#

cyz

errant verge
#
def pow(team):
    if team in ["Tokyo Fart Sniffers", "Neko Cavaliers", "Miami Jits", "Milan Mafias", "Sao Paulo Macacos", "Sendai Sharks", "Cairo Mambas", "New York Rats"]:
        teamc = 6
    print(teamc)
pow("Tokyo Fart Sniffers")
```i was testing my command but i received an error saying `UnboundLocalError: local variable 'teamc' referenced before assignment` so i took out the function and tested it by itself
#

i'm still getting the same error

crimson gale
#

the condition is not true and thus teamc never gets assigned

terse plinth
#

nice team names btw

errant verge
#

LOL

#

ah ok

#

i had to manually write the names from google sheets so i think i just mistyped

sage robin
#

now nothing comes out

terse plinth
#

could be, but if team isnt in that list, teamc will never be assigned and you will run into that error

#

make sure that you error handle this

crimson gale
errant verge
#

i got the value printed out

#

yea i have an else

#

but idk if i have to have it because i plan on making the team options with drop down OptionChoice

terse plinth
#

then you wont need to

languid hollow
#

unless with the error hander as walmart said ignore what I said

sage robin
#

that comes out

crimson gale
#

then it works just fine

sage robin
#

a line

#

thank you very much for helping me

slender lintel
#

anyone know a reoad command i can use?

#

i need one

#

really badly

#

and well tbh i have no clue on how to code one

dusk sable
#

Hey ya'll, I'm trying to debug something here and figure out why my bot is crasing

I've got some really simple code setup that should just log every message being sent but it crashes with AttributeError: 'TextChannel' object has no attribute 'news'
I looked online and someone said to use the github version instead of the pip version but that didn't work

Here's the full code:

@bot.event
async def on_message(message):
    if message.author.bot:
        return
    print(message)```
For some reason that print statement is just crashing the bot. I've enabled the messages intent but it still crashes
slender lintel
#

oh wait

#

nvm

#

sorry

#

my bad

languid hollow
dusk sable
#

It has administrator perms in the server

dusk sable
#

It should be able to see the whole server

slender lintel
#

its has admin?

dusk sable
#

Ye

ruby berry
#

i've installed the pycord library like it says to do in the github, yet when i run my code it says no module named discord

    import discord
ModuleNotFoundError: No module named 'discord'
import discord
from custommodules import infoclass

version = infoclass().FOW_VERSION

bot = discord.Bot(...
slender lintel
#

are you sure you installed

#

py-cord

#

or pycord

ruby berry
#

i copied it word for word from the repo

#

python3 -m pip install -U py-cord

languid hollow
ruby berry
#

one has a hyphen and one doesn't

slender lintel
slender lintel
#

this is pycord

languid hollow
#

oh so whole different one

slender lintel
#

ye

slender lintel
slender lintel
#

whats wrong with opera

#

its so bad

#

in what way

#

its litteraly found in virus

#

slow, slows down pc, adds and more

#

its just ass

#

much faster than chrome for me

#

nah

#

\

#

chrome so fast for me

#

well i had better experiences with opera

#

so im sticking with this

#

oh

crimson gale
#

everyone has opinions, deal with it

slender lintel
#

bro

#

i never said anything abt

ruby berry
#

can we focus on the task at hand

slender lintel
#

?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

  2. 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 release candidate:
pip install py-cord==2.0.0rc1

slender lintel
#

hm

ruby berry
#

that'll probably be it

#

i had dpy installed previously

slender lintel
#

ah

#

pip install py-cord==2.0.0rc1

ruby berry
#

still no luck

slender lintel
#

unistall pycord

languid hollow
slender lintel
#

reinstasll

#

with pip install py-cord==2.0.0rc1

sleek grove
#

is there a stop the bot funktion?

errant verge
#
if rnames in ['Tokyo Fart Sniffers', 'Balitmore Bughas']:
    await player.remove_roles(['Tokyo Fart Sniffers', 'Balitmore Bughas'])
    await player.add_roles(team)
elif rnames not in ['Tokyo Fart Sniffers', 'Balitmore Bughas']:
    await player.add_roles(team)
#

is this a valid way to remove a members role in a list and add the new one?

languid hollow
#

to stop a function?

sleek grove
#

to stop the bot

ruby berry
tepid anvil
#

Is there a way to enable slash command only to server admin ?

#
**@command.has_permissions(administrator=True)**

async def prepare(ctx: commands.Context):
    await ctx.respond ("What's your favourite colour?", view=PersistentView())```
#

This not working

frigid lark
tepid anvil
#

for the permission itself its not working

#

its just a snippet

#

@command.has_permissions(administrator=True)

@frigid lark is this correct ?

frigid lark
#

yes

tepid anvil
#

ok then let me cross check again

ruby berry
#

this is painful

frigid lark
#

but you also can use ```py
@discord.default_permissions(administrator=True)

so people cannot see the slash command
#

without the permission

#

(you still can see it on mobile)

sick stirrup
#

It will disconnect the bot from discord

tepid anvil
#

like role_name = "xyz " or role_id = 19793824536

frigid lark
#

Im not sure if you can, that is the list what you can use

tepid anvil
sleek grove
#

how to make a slash command alias

keen root
slender lintel
#

its a slash command for a reason it would be a prefix command if it had alias

sleek grove
slender lintel
#

how to use images in embeds?

#

?tag images

hearty rainBOT
#

dynoError No tag images found.

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

46

User Count

18461

Ping

112.40ms

keen root
open bearBOT
sleek grove
#

@discord.slash_command()
async def nick(self, ctx, member: Option(discord.Member, description="gdzhuja"), name: Option(str, description="Why?")):
await member.edit(nick=(f"ๆง‹ๆˆๅ“ก | {name}"))

#

why that code doesnt works

keen root
sleek grove
#

but it works

tepid anvil
#

Is there any way to disable the button after n number of uses

gilded widget
tepid anvil
slender lintel
#

?tag lp

hearty rainBOT
#
slender lintel
#

Hey, why is this not working?

    if BotMissingPermissions is True:
        await ctx.send(f"I can not kick this player..")
    else:
        await ctx.send(f"Good.")
        await member.kick(reason="Test")
#
Ignoring exception in command perms:
Traceback (most recent call last):
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\ext\commands\core.py", line 181, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\main.py", line 28, in perms
    await member.kick(reason="Test")
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\member.py", line 679, in kick
    await self.guild.kick(self, reason=reason)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\guild.py", line 2733, in kick
    await self._state.http.kick(user.id, self.id, reason=reason)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\http.py", line 353, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

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

Traceback (most recent call last):
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\ext\commands\bot.py", line 360, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\ext\commands\core.py", line 927, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\ext\commands\core.py", line 190, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
worthy basin
#

^ BotMissingPermissions is a exception (error) that you can create and catch.
As stickfab said you should use a try/except or built in error handling.

try:
  # Kick member
except commands.BotMissingPermissions:
  # Send message

You might want to look into the error handling as well to keep your code cleaner in the future.

slender lintel
# mild hatch Use a try except
@bot.command()
@commands.has_permissions(ban_members=True)
async def perms(ctx, member: discord.Member):
    try:
        if BotMissingPermissions is True:
            await ctx.send(f"I can not kick this player..")
    except:
        await ctx.send(f"Good.")
        await member.kick(reason="Test")

so?

worthy basin
#

BotMissingPermissions is not an Boolean value it is an exception, view my code in my message

#

@supple ravine

mild hatch
slender lintel
#

is this correct?

worthy basin
#

it should be

worthy basin
slender lintel
# worthy basin it should be

i have a error..

Ignoring exception in command perms:
Traceback (most recent call last):
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\ext\commands\core.py", line 181, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\main.py", line 25, in perms
    await member.kick(reason="Test")
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\member.py", line 679, in kick
    await self.guild.kick(self, reason=reason)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\guild.py", line 2733, in kick
    await self._state.http.kick(user.id, self.id, reason=reason)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\http.py", line 353, in request
    raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

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

Traceback (most recent call last):
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\ext\commands\bot.py", line 360, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\ext\commands\core.py", line 927, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord Teststation\venv\lib\site-packages\discord\ext\commands\core.py", line 190, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
#

When i kick a admin, mod ..

mild hatch
#

Also don't use f-strings if you're not gonna use a variable in the statement

slender lintel
#

yes but that is not an error reason?

mild hatch
#

Just a tip

slender lintel
#

Ok thanks prayadge

worthy basin
#

wait, BotMissingPermissions is for the bot trying to run a command, you need something else give me a seocond to find it

slender lintel
#

Oops I thought that is when the bot has no rights whenyahomiesaysomewildshit

steady lotus
#

is there a way to unregister a command

worthy basin
steady lotus
#

that removes it from the internal list

#

not from discord

slender lintel
steady lotus
#

im doing these all already

#

but it didnt work

#

guess ill try again

worthy basin
#

Im not sure how discord handles unregistering commands. It might take a bit.

#

you could also set force=True in sync commands

slender lintel
#

Because with try he tries something or?

worthy basin
#

You need both the try and except in it, is that what you mean?

slender lintel
#

Yes I want to do it in perms.error as you recommended but how can I try something when there is nothing to try or is there?

worthy basin
#
try:
  # Your code that might give an error
except ERROR: # The Error the the code under the try might give AND should 'ignore'
  # What to do after 'ignoring' the error
slender lintel
#

but member is not possible in perms.error?

#

wdym

#

wait im confused

slender lintel
crimson gale
#

dont bother

#

your current stuff works fine

slender lintel
slender lintel
#

so i have a folder nambed moderation and in my main fille i have this

steady lotus
# worthy basin you could also set `force=True` in sync commands
command_found = self.bot.get_application_command(
                name, guild_ids=[ctx.guild.id]
            )
            if command_found is not None:
                self.bot._application_commands.pop(command_found.id)
                removed = self.bot.remove_application_command(command_found)

            await self.bot.sync_commands(force=True, check_guilds=[ctx.guild.id])
            command_found = self.bot.get_application_command(
                name, guild_ids=[ctx.guild.id]
            )```
#

im doing this

#

im removing > syncing > checking if removed after

#

anyway

#

removed = self.bot.remove_application_command(command_found) is returning None

slender lintel
#

biden sucks

languid hollow
#

to send modals to a certain channel would it be like this?

form = MyForm(title="Apps")
Channel = bot.get_channel(12345)
await Channel.send_modal(form)
#

Since I'm not rlly sure on how to send Modals to a certain channel

sudden path
#

You can only send modals on interactions responses

languid hollow
#

so would it be

await Channel.interaction.response.send_message(embed=[embed])
#

bc I did that and for some reason it didn't send

#

and the interaction comes as failed

sage robin
#

How can I remove this error?

sudden path
#

You can only send modals when replying to interactions, slash commands, buttons, dropdowns...

sudden path
languid hollow
#

I'm not sure if I made it clear, sorry if I didn't

sage robin
sudden path
#

Whst

#

What

#

How would you send a modal to another channel

#

Modals pop-up for the user

languid hollow
#

wait I meant for the embedded

sudden path
languid hollow
#

not the modal mb

sudden path
#

Get the channel

#

Then send

#

b!rtfm pyc channel.send

sage robin
clever lava
#

how to change bot's activity status

#

forgor

sudden path
#

b!rtfm pyc change_presence

languid hollow
# open bear

this is the message I get when i sent it over a different channel

sudden path
#

Code?

languid hollow
#
       User = interaction.user
        embed = discord.Embed(title=User, color=discord.Color.random())
        embed.add_field(name="First Input", value=self.children[0].value, inline=False)
        embed.add_field(name="Second Input", value=self.children[1].value, inline=False)
        await interaction.response.send_message(embeds=[embed])
        channel = bot.get_channel(973303609699758132)
        await channel.send(embed)
sudden path
#

You're not sending it with the embed kwarg

slender lintel
#

Hey I have a question about the docs, how do I find exactly what I want? For example, I was looking for when a bot has no rights to issue an error but then I was told (thanks by the way) that it was something else.

languid hollow
slender lintel
#

?custom

mild hatch
#

since you got Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions you should look for "Forbidden" in the exceptions section on the docs

#

and then do try except error handling with that

slender lintel
#

Ohhh thanks this is amazing

clever lava
#

bruh help

#

ajuda_comandos = [
      OptionChoice(name="/embed", value="Este comando รฉ um comando interativo onde vocรช constrรณi sua prรณpria embed de forma prรกtica."), #  Value must be a string.
      OptionChoice(name="/ajuda", value="Ajuda 2.0?? :eyebrow_raising:"), #  Value must be a string.
      OptionChoice(name="/info", value="`/info` รฉ um comando simples, apenas mostra algumas informaรงรตes bรกsicas sobre o bot")
    ]

@bot.slash_command(guild_ids=testbot, description="Veja todos meus comandos")
async def ajuda(ctx, comando : discord.Option(str, description="Escolha um comando", choices=ajuda_comandos, required=False)):

  if comando == None:
  
    embed=discord.Embed(title="Ajuda geral", description="Mรณdulo de ajuda sobre comandos. Digite `/help <comando>` para obter ajuda sobre um comando especรญfico", color=discord.Color.blurple())
    embed.add_field(name="/info", value="Mostra algumas informaรงรตes sobre o bot", inline=False)
    embed.add_field(name="/ajuda", value="Mostra essa lista", inline=False)
    embed.add_field(name="/embed", value="Criador de embed's dinรขmico", inline=True)


    button = Button(label="Vote em top.gg", url="https://meuurl.com.br")

    view = View(timeout=None)
    view.add_item(button)
    
    await ctx.respond(embed=embed, view=view)

  else:

    embedhelp=discord.Embed(title="Ajuda detalhada", description=choices, color=discord.Color.blurple())
    
    await ctx.respond(embed=embedhelp)
#

im trying to add choices to a command

#

what is going wrong

frigid anvil
#

i have this code
@bot.event async def on_message(message): printer = f'Message from {message.author}: {message.content}' print(printer)
but message.content doesnt print anything

frigid anvil
#

and how would i go about doing that

sudden path
#

?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)
frigid anvil
#

so
intents = discord.Intents.all() bot = discord.Bot(intents=intents)

#

?

#

ok yup, thanks!

mild hatch
#
intents = discord.Intents(messages=True)
bot = discord.Bot(intents=intents)
frigid anvil
#

but i am using all of them tho

#

or i plan to atleast

mild hatch
#

use discord.Intents.all() when you get all the events ready

#

For now, just use the intents you're working with

frigid anvil
#

what can happen if you use all, ill update it, but what makes it bad practice

slender lintel
#

quick question, ctx.defer() makes my bot keep saying "bot is thinking..."

#

how can i disable that?

slender lintel
sage robin
#

help?

#
async def displayedmbed():
   embed = discord.Embed(
    title = 'Title',
    description = 'This is a description.',
    colour = discord.Colour.blue()
   )
 
   embed.set_footer(test='This is a footer.')
   embed.set_image(url='')
   embed.set_thumbnail(url='')
   embed.set_author(name='',
   icon_url='')
   embed.add_field(name='field name', value='Field Value', inline=False)
   embed.add_field(name='field name', value='Field Value', inline=True)
   embed.add_field(name='field name', value='Field Value', inline=True)

   await ctx.respond(embed=embed)```
sudden path
#

Pretty sure the error says it all

#

You're missing ctx on displayedembed()

sage robin
sudden path
#

Any error?...

sage robin
sudden path
#

There you go

sage robin
#

What?

sudden path
#

Read the error

#

You're providing incorrect (unexpected) kwargs. And you're setting blank stuff?

sage robin
#

I don't see anything white

sudden path
sage robin
#

but i don't see it

sudden path
#

Whatever

#

You still got an error on embed.set_footer

sage robin
#

embed.set_footer?

gilded widget
#

change test= to text= in embed.set_footer

frigid anvil
#

user=bot.get_user(member.id) imageurl=user.avatar_url

#

why isnt that working?

gilded widget
#

avatar_url -> avatar.url

frigid anvil
#

thank you

gilded widget
#

also provide errors next time pls

frigid anvil
#

ok

#

I have this code:
user=bot.get_user(member.id) imageurl=user.avatar.url

And i get this error:
exception in on_member_join Traceback (most recent call last): File "E:\Development\python\cc-discord-bot\venv\lib\site-packages\discord\client.py", line 382, in _run_event await coro(*args, **kwargs) File "E:\Development\python\cc-discord-bot\main.py", line 27, in on_member_join imageurl=user.avatar.url AttributeError: 'NoneType' object has no attribute 'url'

gilded widget
frigid anvil
#

thank you

#

also just so you know that url doesnt work, like the #discord.User.avatar doesnt actually exist

sage robin
frigid anvil
#

embed.set_footer(text="This is a footer")

#

you have it set to test instead of text

sage robin
#

so

frigid anvil
#

yeah

#

well you need a r at the end of foote

sage robin
#

without the r at the end?

#
@bot.slash_command(guild_ids=[884611858512887848])
async def displayedmbed(ctx):
   embed = discord.Embed(
    title = 'Title',
    description = 'This is a description.',
    colour = discord.Colour.blue()
   )
   embed.set_foote(text="This is a footer")
   embed.set_image(url='https://cdn.discordapp.com/avatars/479441843864731663/4c1c7d257267fa13c543c8e9d082a2af.png?size=2048')
   embed.set_thumbnail(url='https://cdn.discordapp.com/avatars/479441843864731663/4c1c7d257267fa13c543c8e9d082a2af.png?size=2048')
   embed.set_author(name='Mepicaloscoco',
   icon_url='https://cdn.discordapp.com/avatars/479441843864731663/4c1c7d257267fa13c543c8e9d082a2af.png?size=2048')
   embed.add_field(name='field name', value='Field Value', inline=False)
   embed.add_field(name='field name', value='Field Value', inline=True)
   embed.add_field(name='field name', value='Field Value', inline=True)

   await ctx.respond(embed=embed)```
terse plinth
#

embed.set_foote(text="This is a footer")
Change that line to
embed.set_footer(text="This is a footer")

inland acorn
#

something odd is going on, since when the pycord has been upgraded from b7 to latest one, the verified bot goes down automatically after running about a day or two, thats really weird, script is on and bot is down, tried logging, but n abnormal behaviour | error found
host provider says host was up 100% of the timez

this happened 4 -5 times. pls guide what to do

terse plinth
#

any console output?

inland acorn
#

nop

terse plinth
#

hmmm

#

have you tried running the bot locally?

#

like, on ur computer

#

does the same issue occur?

inland acorn
inland acorn
#

most likely api bug

terse plinth
#

hmmm

#

if you could, that would confirm whether its pycord or the host that is the issue

inland acorn
terse plinth
#

i havent faced any issues like this one

inland acorn
terse plinth
#

which host do you use?

#

ah

inland acorn
#

creavite

inland acorn
terse plinth
#

whats ur pycord version?

inland acorn
#

latest git one

terse plinth
#

Mine is py_cord-2.0.0b5 and i dont face any issues

#

oh

inland acorn
#

2.0.0c smthing

terse plinth
#

!install

robust nebulaBOT
#

Install pycord:

pip uninstall discord.py
pip install py-cord

Install pycord beta:

pip uninstall discord.py
pip install py-cord==2.0.0b7

Install pycord alpha from git:

pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
terse plinth
#

the git version is unstable with many bugs

inland acorn
terse plinth
#

try using beta or just normal pycord

gilded widget
terse plinth
#

?

inland acorn
#

not relly

gilded widget
#

if anything b5 is more unstable lmao

inland acorn
#

yes

terse plinth
#

wait rly

gilded widget
#

rc1 is latest release

inland acorn
#

using that only

terse plinth
#

huh

#

interesting

#

b5 works perfectly for me lol

inland acorn
#

i think its a bug

inland acorn
#

no error

#

even in logs

terse plinth
#
    r34 = discord.SlashCommandGroup(
        name = 'r34',
        description = 'Rule34 related commands',
    )

    blacklist = r34.create_subgroup(
        name = 'blacklist', 
        description = 'Blacklist related commands'
    )

How would i go about setting up a commands.isNSFW() check on the r34 slashcommandgroup?

#

btw the command tree looks a bit like this

r34
 |____latest
 |____random
 |____search
 |
 L____ blacklist
           |____add
           |____remove
           |____enable
           |____disable
#

i need all of these slash commands to trigger only if the channel is nsfw, for legal reasons

frigid anvil
#

ive searched through the documentation for 20 mins, is there any way to delete the message a user sent in on_message

terse plinth
#

just do
await message.delete()

red tendon
#

and also try to install the master branch

inland acorn
inland acorn
inland acorn
terse plinth
#
@client.event
async def on_application_command_error(context:discord.ApplicationContext, error):

    if isinstance(error, commands.NSFWChannelRequired):
        await context.respond('> **Error : Command can only be run on NSFW channels**')

Why does the slash command not respond when used on a non-NSFW channel?

#

command is in a cog in a different file

#

raises NSFWChannelRequired error

#

this seems to catch the error, but doesnt respond

#

it is a slash command btw

frigid anvil
#

i have this code:
await member.timeout_for(duration=60, reason="Swearing")

and get this error:
Traceback (most recent call last): File "E:\Development\python\cc-discord-bot\venv\lib\site-packages\discord\client.py", line 382, in _run_event await coro(*args, **kwargs) File "E:\Development\python\cc-discord-bot\main.py", line 30, in on_message await member.timeout_for(duration=60, reason="Swearing") File "E:\Development\python\cc-discord-bot\venv\lib\site-packages\discord\member.py", line 857, in timeout_for await self.timeout(datetime.datetime.now(datetime.timezone.utc) + duration, reason=reason) TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'int'

errant verge
#
rnames = []
for role in player.roles:
    rnames.append(role.name)

trole = discord.utils.get(ctx.guild.roles, name=team)
if rnames in ['Tokyo Fart Sniffers', 'Baltimore Bughas']:
    await player.remove_roles(['Tokyo Fart Sniffers', 'Baltimore Bughas'])
    await player.add_roles(trole)
elif rnames not in ['Tokyo Fart Sniffers', 'Baltimore Bughas']:
    await player.add_roles(trole)```
currently this part of my command doesn't remove the roles for a player
#

can i not remove roles in the list?

sick stirrup
#

you'll be passing the bot object through setup() method to the class.

terse plinth
#

Or rnames is never going to be in the list of team names

#

So*

craggy flame
#

is there a way to add more slash arguments if the previous option choice argument have been filled (selected)?

forest saffron
#

is it possible to have a listener which is only listening if a command is fired ?

rapid kelp
#
import asyncio
import random as r
from discord.ext import commands

client = commands.Bot(command_prefix=">")


@client.event
async def on_message(msg):
    if msg.author.bot:
        pass
    else:
        await client.process_commands(msg)


#the bot executes this when it is running


@client.event
async def on_ready():
    moderator = client.get_channel(984031180162752525)
    print("running")
    asyncio.sleep(2)
    await moderator.send("I am now online.")


@client.command()
async def math_equations(ctx):
  moderator = client.get_channel(984031180162752525)
  for i in range(1,10):
     moderator.send(str(r.randint(1,10))+"+"+str(r.randint(1,10))+"=")

token = open("number.env", "r")
client.run('token_replaced)```
#

is the one i have (code)

rapid kelp
#

whats wrong?

snow citrus
snow citrus
#

pip install python-dotenv

#

read docs how to use it

rapid kelp
#

ok

#

does it work on replit?