#General Help

1 messages · Page 28 of 1

graceful robin
#

maybe its the problem with the version i used

#

py-cord 2.0.0rc1

wide cloak
#

how to get this color?

#

i tried accent_colour but i got nonetype

rare summit
#

hi, i am trying to get the id of user who used an interaction button, but i found only user in the documentation and that gives me only his username (example: Kchulka#4766). is it possible to get id of that user?

wide cloak
rare summit
#

ok that works, thx

wide cloak
icy sluice
#

can I add a reason argument for create_invite() like this?

create_invite(reason="testing reasons")
icy sluice
frigid elm
#

@bot.slash_command(name="apply")
async def apply(ctx):
modal = Apply()
await ctx.send_modal(modal)
it doesnt give any error

#

nvm

frigid elm
#

how do i use this

#

await interaction.response.send_message

#

to send in a specific channel

finite cliff
#

Is there a way to disable button from only client side?

wide cloak
sudden path
wide cloak
icy sluice
#

but thanks anyway 👍

frigid elm
sudden path
#

channel.send

#

Not interaction.channel

frigid elm
#

ohhh okay ty

frigid elm
sudden path
#

You can't send a modal to a specific channel. It must be an interaction

frigid elm
#

oh

#

alright

frigid elm
#

im sorry for the confusion lol

sudden path
#

Then in the modal callback

#

Get the channel and send the message

frigid elm
#

alright

wide cloak
frigid elm
sudden path
#

Yes

frigid elm
#

alright

lament nimbus
#

Is it possible to check if a user doesnt have specific permissions?

#

for example

user.has_permissions(send_message=True)
wide cloak
lament nimbus
#

so. the top part is if they can send msgs

#

then bottom is if they cant?

#

right

wide cloak
#

but you have to change your member obj if you want to use user

#

current member obj is ctx.author

lament nimbus
#

oh i got
AttributeError: 'Permissions' object has no attribute 'send_message'
error

still ingot
#

Hello where, and how do i make it so that the buttons has no timeout/(will not get disabled)

wide cloak
still ingot
#

no i mean like because i cant use the button anymore after like 5mins or so

rare summit
#

that is going to work until you restart the bot

still ingot
#

oh

still ingot
still ingot
#

Hmmm

rare summit
still ingot
#

yes

rare summit
#

this should be it

still ingot
still ingot
#

thank you PepeHeartOwO

rare summit
# still ingot thank you <:PepeHeartOwO:969574372195045406>

the screen shot comes from this video: https://www.youtube.com/watch?v=kNUuYEWGOxA

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
#

i used this a lot to create my buttons

still ingot
#

ye i also look there for some tips like how to add multiple buttons on one embed

#

xD

#

btw how do u reset the timer

rare summit
still ingot
#

k

rare summit
#

like this

rare summit
still ingot
#

btw just wondering cant i just maybe do timeout=None?

rare summit
still ingot
#

hmmm lemme try it

lament nimbus
#

alr turns out guild permissions still says i can send msgs if im muted

#

is there a way to check for a timout?

still ingot
rare summit
#

ok nice

slender lintel
#
msg = await ctx.respond(embed=embed)
    asyncio.sleep(3)
    embed=discord.Embed(title=":game_die: | Minigame: Reactiontime", description=f"Click the button now!!", color=0xffb35c)
    msg.edit_message(embed=embed)```
I am getting an error that Interaction has no attribute 'edit_message' why?
lament nimbus
#

try

await msg.edit(embed=embed)
slender lintel
#

ok

slender lintel
lament nimbus
#

huh

#

usually that works for me . umh idk then

slender lintel
#

Ok

#

U use slash commands too`?

lament nimbus
#

prob why

slender lintel
#

oh i needed to ctx.edit

#

Works now

lament nimbus
#

oh nice

slender lintel
#

Hi, how can I edit a interaction message twice? I edit my button click with interaction.response.edit_message() then wait a couple sec but how do I edit the message again?

frigid elm
#

TypeError: 'NoneType' object is not subscriptable how do i handle this?

#

except TypeError:
print("typeError") i tried this

#

but doesnt work

slender lintel
slender lintel
#

?

frigid elm
#

TypeError: 'NoneType' object is not subscriptable

#

its sttill not handling that

slender lintel
#

Could you send the full code?

#

So I can see where it happens

frigid elm
#

its a little long but its a on_message and on every message it tries to find the author id in the database to check if its afk,if its not afk it throws that error

slender lintel
#

Ok

#

could u send the part of the code where you are getting the erros

frigid elm
#

File "c:\Users\amito\Desktop\tests\main.py", line 529, in on_message
memberafk = results["member"]
TypeError: 'NoneType' object is not subscriptable

#

async def on_message(message):
results = await collectionafk.find_one()
memberafk = results["member"]
reasonn = results["reason"]

slender lintel
#

Is your database a json file?

frigid elm
#

no its mongodb

proven plume
#

Hi, is it possible to send a button or a select menu as a private message?

slender lintel
#

yep

proven plume
#

nice!

#

thanks

frigid elm
#

np

slender lintel
#

I think mee6 does that

#

for their send from messages

frigid elm
#

yep

proven plume
#

and the right way to do it is by the use of the class discord.dmmessage?

hazy tundra
#

i am planning to make a bot that works with an sqlite database. For that task I need to create a few classes that represent groups of data (e.g. the data of a specific discord member). Should I put those classes in a separate python file and import it to the main file? If no, is there a way to put it in separate files while it acts as if it is all one file?

hazy tundra
#

Do they allow separate files?

frigid elm
#

yes

proven plume
#

Hi, I didn't understand how to send a private message, can someone help me pls

#
@bot.command()
@commands.is_owner()
async def ledm(ctx):
    ctx.author.create_dm()
    jaaj = ctx.author.dmchannel.id
    await jaaj.send('yo')
#

I have smth like this atm

#

it's obviously not working

frigid elm
spring wharf
#
Ignoring exception in view <SuggestionButtons timeout=None children=4> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='Upvote' emoji=<PartialEmoji animated=False name='⬆' id=None> row=None>:
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.8/site-packages/discord/ui/view.py", line 371, in _scheduled_task
    await item.callback(interaction)
TypeError: upvote() missing 1 required positional argument: 'interaction'```
#
    @discord.ui.button(label="Upvote", emoji="⬆", style=discord.ButtonStyle.green)
    async def upvote(self, ctx, button: discord.ui.Button, interaction: discord.Interaction):
        msg = await self.bot.db.select("suggestions", ["*"], checks=[["status", 0]], single=True)
        print(msg)
        embed = discord.Embed(title=f"TITLE | Suggestions",
                              description=f"""
EMBED_HERE""", colour=col)
        embed.set_image(
            url="URL_HERE")
        m = ctx.fetch_message(msg[0])
        await m.edit(embed=embed)```
crimson gale
#

why do you have ctx in a button callback?

spring wharf
#

m = ctx.fetch_message(msg[0])

crimson gale
#

remove it

#

ctx is not given to the callback

spring wharf
#

Right

#

Should I just change ctx to interaction?

crimson gale
#

you already have interaction

#

remove ctx

spring wharf
#

No I mean

#

m = interaction.fetch_message(msg[0])

crimson gale
#

that will throw an error

spring wharf
#

Is there any other way I can fetch a message?

crimson gale
#

what message do you need?

spring wharf
#

To fetch this

slender lintel
#

How can I make those Options for my slash commands?

crimson gale
#

though you probably need to use alpha for that

spring wharf
#

I am using --pre

#

2.0.0rc1

#

Are you on about fetching the ID from cache?

crimson gale
#

yeah you can still use self.message but you just need to assign the message attribute after sending the message

#

no

spring wharf
#

It's just they run

#

!suggest <suggestion>

robust nebulaBOT
#

⚠️ Suggestion channel not found.

spring wharf
#

The ID and content gets stored

#

when a player presses upvote

#

I need Upvote to increment by one

crimson gale
#

so whats your database solution to store that info?

spring wharf
#

MySQL

#

Using aiomysql with a custom wrapper

crimson gale
#

mkay cool

spring wharf
#

I just am having issues getting the message

crimson gale
#

you should have these be persistent

spring wharf
#

the buttons?

crimson gale
#

yes

spring wharf
#

I am just new to these buttons so

#

I have no clue

#

😂

crimson gale
#

?tag ex

crimson gale
#

theres an example on persistent views

spring wharf
#

I just wanted to get them working first

crimson gale
#

yep fair

spring wharf
#

So

#

m = IDK..fetch_message(msg[0])

crimson gale
#

well you need the channel instance

#

so interaction.channel

spring wharf
#

channel = interaction.channel(ID)

crimson gale
#

unnecessary

#

channel is not a method

crimson gale
spring wharf
#

oh right

#

Hmm

frigid elm
#
class Apply(Modal):
    def __init__(self, *args,**kwargs): 
        super().__init__(*args,**kwargs)
        self.add_item(InputText(label="test",placeholder="Approximate"))
        

          

    async def callback(self,interaction: discord.Interaction):
        em = discord.Embed(color=discord.Color.from_rgb(13, 99, 143),title="New Application.")
        em.set_thumbnail(url="https://cdn.discordapp.com/attachments/991328804347854948/991329051430113380/14dncpxcxwh61.jpeg")
        em.set_author(name=f"{interaction.user}",icon_url=interaction.user.avatar.url)
        em.set_footer(text="Veno Applications")
        em.add_field(name="__test__",value=f"{self.children[0].value}",inline=False)
       
        accept = Button(
             label="Accept",
             style=discord.ButtonStyle.green,
             emoji=":heavy_check_mark:"
    )
        decline= Button(
             label="Decline",
             style=discord.ButtonStyle.red,
             emoji=":grey_exclamation:"
    )
        view = View()
        view.add_item(accept)
        view.add_item(decline)
        async def acccallback(interaction: discord.Interaction):
            
            await interaction.response.send_message("accept")
        async def deccallback(interaction:discord.Interaction):
            await interaction.response.send_message("decline")
        
        accept.callback = acccallback
        decline.callback = deccallback  
        await interaction.response.send_message("Application submitted! check #✗・results"
        )
        channel = await bot.fetch_channel(992014248102346803)
        await channel.send(embed=em,view=view)```how do i make it so that in the buttons callback it gives a role to the person that used the modals command
unkempt iron
#

Quick question: how to deal with tying commands to a role if it contains an emoji ? Example : " ✅ Community Role" ?

I've tried with the ":emoji_name:", sadly no success

frigid elm
#

get the role by the id

sudden path
open bearBOT
unkempt iron
frigid elm
unkempt iron
# sudden path Why you can't get the ID?

The role is something like "✅Community Role", has to get access like "Mods" and "Admins" have to some commands; however I can't get the ID with \ since role is not pingable, cant copy the ID either with dev mode, and cannot address the role to get a ID back because I cannot get it to work with the emoji

frigid elm
sudden path
#

What user you want to give the role to then

frigid elm
#

or in settings

frigid elm
sudden path
frigid elm
#

basically they do /apply they have a modal and the embed gets sent with 2 buttons that says "accept" and "decline"

sudden path
#

Then you'd need to store such ID to a database

frigid elm
#

if we click accept it should give a role to the person that used the command /apply

sudden path
#

And then use it

frigid elm
#

okay

#

so I add the id of the user once they use the command right?

#

oh wait nvm I'm confused

sudden path
#

Store the ID when they submit the modal

#

Then on the button callback get that ID, get the user and add the roles

frigid elm
#

okay ty

#

after it stores the ID how will it find the right ID?

#

cuz multiple people could apply at the same time and I'll have multiple ids in the database

unkempt iron
#

@permissions.has_any_role("Guides", "Mods", 9686xxxxxxxx)

@permissions.has_any_role("Guides", "Mods", "9686xxxxxxxx")
would suffice then ?

frigid elm
#

the id would be an int

frigid elm
#

but i cant do ctx.author in the callback or am i wrong?

half marsh
#

Depend on how you define the button, under view subclass or local function

half marsh
frigid elm
#

where

half marsh
#

On modal class

frigid elm
#

yh im still confused😭 can you maybe send an example

half marsh
#

im on mobile may take long

#

Hold up

#
def __init__(self, author, *args, **kwargs):
    self.author = author
    ...
#

Then when you send a modal in your command

#

You pass ctx.author

#

To your modal class

#

Under your accept callback you can access self.author.add_roles()

frigid elm
#

ohh

#

alright tysm

unkempt iron
#

Shall I move to all int or all strings instead ? Or am I missing something ?

ancient gazelle
#

This might sound really lame but how can I run something after client.run("token") I know I can use on_ready() but it defies my purpose here. I really need to execute some code after client.run(). Bassically I don't want it to forever loop So that I can execute further commands. Please, any help will be really grateful.

crimson gale
unkempt iron
crimson gale
#

you still need a beta version

#

2.0 still has no stable release

#

2.0.0rc1 is the latest on pip

unkempt iron
frigid elm
#
@bot.bridge_command(name="boosters",description="Displays every booster")
async def boosters(ctx):
    x = 1
    for booster in ctx.guild.premium_subscribers:
        em = discord.Embed(color=discord.Color.from_rgb(13, 99, 143),title="Boosters")
        em.add_field(name=f"A list of every person that has boosted **{ctx.guild}**",value=f"`{x}`: {booster.mention} {booster.premium_since}")
        em.set_footer(text=f"Total boosts: {ctx.guild.premium_subscription_count}")
        x += 1
    await ctx.respond(embed=em)``` how do i make it so that it adds the users to the embed
crimson gale
#

pip install -U py-cord==2.0.0rc1
then you can set sensible defaults. too lazy to fetch the link to an example

unkempt iron
crimson gale
#

the integrations tab in server settings

unkempt iron
#

Thanks for your help much appreciated btw 👍 🌻

crimson gale
#

you can set defaults based on guild permissions though

unkempt iron
white latch
#

Morning fellas

#

I'm trying to set up a pycord bot (2.0.0rc1), but I'm unable to get a cog from working

#

This is how the bot is currently running

import discord

bot = discord.Bot(command_prefix="!")
bot.load_extension("cogs.battle")
bot.run(os.getenv("BOT_TOKEN"))

And this is the cog (cogs/battle.py), which is just a copy paste of the cog example on the docs besides the class name

import discord
from discord.ext import commands

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

    @commands.command() # create a command
    async def hello(self, ctx): # all methods now must have both self and ctx parameters
        await ctx.send('Hello!')

    @commands.command()
    async def goodbye(self, ctx):
        await ctx.send('Goodbye!')

    @discord.slash_command() # we can also add application commands
    async def hello(self, ctx):
        await ctx.respond('Hello!')

    @discord.slash_command()
    async def goodbye(self, ctx):
        await ctx.respond('Goodbye!')

    @discord.user_command()
    async def greet(self, ctx, member: discord.Member):
        await ctx.respond(f'{ctx.author.mention} says hello to {member.mention}!')

def setup(bot):
    bot.add_cog(Battle(bot))

#

Do you see anything wrong? The bot doesn't react to the regular commands, and the slash commands won't appear in the server the bot is in

frigid lark
#

Can you print if the cog is loaded?

#

Or do it with a folder search

white latch
#

The setup() method is being called at the very least

#

So the cog should indeed be loading

frigid lark
#

And you need Intents

white latch
#

I think I've enabled all intents already

#

one second

frigid lark
#

In the code?

white latch
#

Ah no, in the platform

#

I haven't added any intents in the code. That might be the problem then

frigid lark
#

You can add it to the discord.Bot

#

intents=discord.Intents.all()

#

Snd you need the guild id for slash commands

white latch
#

The docs say that if I don't specify the guild ID it will be enabled globally, though

frigid lark
#

Yes

crimson gale
#

and thats something you dont want during development

frigid lark
#

^

warm mountain
#

Hey all. question is there a way to await an async call in an Option?

async def blahFunction(ctx: discord.ApplicationContext, 
    name: Option(str, "Enter Name", choices = get_names(), required = True),
    ):

where get_names() is an async call to an API to get the names. I tried adding this in the on_ready() but it seems like the slash command is created before the on_ready completes so the global array isn't updated in time to get the names?

white latch
#

I'm aware that it's not a good practice, but this bot is just for a single server and I don't expect it to be deployed anywhere else so globally is just a dummy test server and the one where the bot will be, though

#

Adding the intents didn't help, by the way. The bot is still ignoring me.

#

bot = discord.Bot(command_prefix="!", intents=discord.Intents.all())

crimson gale
#

that bot class doesnt support prefixed commands

#

you need the bot class from the commands extension for that support

frigid lark
#

You can use bridge or commands.Bot for anything

white latch
#

That sounds like something that should be changed in the example then

#

Wait a second, how do I invoke the bot in the cog as a decorator when I only have access to the bot instance inside the self arg of the methods?

#

I can't just do @bot.command inside a cog

frigid lark
#

You use the Bot for application commands and not for a prefix command

white latch
#

No?

#

The docs explicitly say that you use the bot for prefixed commands

frigid lark
white latch
#

Yes

#

I'm aware

#

and what I'm saying is that I can't access the instance of commands.Bot inside a cog to put in a decorator because it's passed as part of self in the args of the methods of the cog

frigid lark
white latch
#

Yes

#

I know that's how it should work

#

but then how do I add the decorator inside the cog

#

Because the bot instance is only defined in the main file and not the cog

wide cloak
white latch
#

That's what I originally had

#

And it didn't work

wide cloak
#

thats weird

#

did you tested to restart your vscode?

white latch
#

I restarted the python process

#

vscode shouldn't change anything, it's just a text editor

boreal harness
white latch
#

It just doesn't trigger the bot to do anything

#

But after some extra testing it's not the cog's fault, I've checked and it doesn't seem to do anything even in the main script

#

So the issue must be somewhere else

boreal harness
white latch
#

Yes? I'm manually running the script locally.

#
bot = discord.Bot(command_prefix="!", intents=discord.Intents.all())

@bot.command()
async def ping(ctx):
    await ctx.send("Pong!")

bot.run(os.getenv("BOT_TOKEN"))
#

This minimal bot isn't working for me

#

And yes, I can confirm that the bot token is being parsed correctly

boreal harness
frigid lark
white latch
#

Wrong reaction, it was meant to Zervyrel

frigid lark
#

Use commands.Bot()

white latch
#

Bot isn't callable

#

I've already tried

boreal harness
#

looks like a dependency issue

past gate
#

send output of pip list

#

@slender lintel

#

🤔

white latch
warm mountain
#

Is it possible to update Options - choices after startup of a bot?

past gate
white latch
#

No, I've already uninstalled it to avoid conflicts

past gate
#

shouldn't use that (message towards colin)

white latch
#
Package           Version
----------------- -----------
aiohttp           3.7.4.post0
async-timeout     3.0.1
attrs             21.4.0
chardet           4.0.0
ffmpeg-python     0.2.0
future            0.18.2
greenlet          1.1.2
idna              3.3
imageio-ffmpeg    0.4.7
multidict         6.0.2
numpy             1.23.0
pip               22.0.4
psycopg2          2.9.3
py-cord           2.0.0rc1
python-dotenv     0.20.0
setuptools        58.1.0
SQLAlchemy        1.4.39
typing_extensions 4.3.0
yarl              1.7.2
past gate
#

please format your code into codeblocks

frigid elm
#

ncm fixed

white latch
# frigid lark Use commands.Bot()

At this point you've insisted so much about this that now I genuinely want to see an example that is working for you, because I'm genuinely intrigued

warm mountain
frigid lark
frigid elm
frigid elm
past gate
#

ok

#

so if thats the case why are you defining the embed in a for loop

#

that's just going to make a seperate embed for each user

frigid elm
#

ye i figured

past gate
#

move the set_footer call out of the for loop as well

white latch
#
from discord.ext import commands

from dotenv import load_dotenv

load_dotenv()

bot = commands.Bot(command_prefix="!")

@bot.command()
async def ping(ctx):
    await ctx.send("Pong!")

bot.run(os.getenv("BOT_TOKEN"))

This is still not working

frigid elm
past gate
#

well maybe the add_field call

#

since you want the list to be displayed within the embed

white latch
#

I think I'll just create a different thread at this point

wide cloak
#

is it possible to edit a ephemeral message?

frigid lark
proven plume
#

Hi, I would like to know if it's possible to give to someone a role by a button who are on a private message?

sudden path
spring wharf
#

Is there anyway to get the ID of the message that the button is on?

sage robin
vivid nacelle
#

help yourself. the problem is obvious lol

sage robin
#

code

async def Ping(ctx):
  latency = bot.latency
  trueLatency = * 1000
  await ctx.respond(f"Mi ping es {round(trueLatency)} ms.")```
sudden path
#

Pretty self explanatory

halcyon cairn
#

trueLatency = WHAT multiplied by 1000

sudden path
#

Let them realise

halcyon cairn
#

lol

sudden path
#

He watchin a pycord tutorial lmao

sudden path
#

b!rtfm interaction.original_message

open bearBOT
# sudden path b!rtfm interaction.original_message

I couldn't find a documentation with the name interaction.original_message! Maybe you used to command wrong? Correct Usage: <prefix>rtfm <docs> [<term>] (eg. b!rtfm py cool)
List of Documentations you can search:
python
pycord
discord.py
yarsaw
nextcord
disnake

sudden path
#

b!rtfm pyc interaction.original_message

finite cliff
#

Is there a way to disable button from only client side?

sudden path
#

Only for one user? No

dreamy herald
#

hi, how to store datetime object in database using aiosqlite ?

#

i don't see any mention of it on the documentation of aiosqlite

wide cloak
#

hi

#

can anyone help me?

#

i dont get my attachment in the embed.set_image

#
element.screenshot(f'temp/qr-{n}.png')
embed.set_image(url=f"attachment://qr-{n}.png")
dreamy herald
wide cloak
#

you can put a local file

#

but it already found out how

knotty niche
#

So , I am really embarrassed to ask this but I have been getting this indentation error, and I can't just figure out where I am wrong

gilded widget
#

you need to give a callback function to the select menu, it can't be just a standalone decorator

#
@discord.ui.select(**kwargs)
async def select_callback(self, select: discord.ui.Select, interaction: discord.Interaction) -> None:
    ...  # callback code here
knotty niche
knotty niche
#

I tried this too but doesn't work so, I guess that defining a callback is necessary for the select menu to work otherwise it doesn't work whether you subclass View or use select directly

finite cliff
#

how can i get the content of an embed?

gilded widget
#

read the docs

finite cliff
#

i am but i am not getting

gilded widget
#

should tell you everything you need to know

finite cliff
#

nvm got

#

thanks

#

its was to_dict

slender lintel
#

i want to get message id, but i see this thing

finite cliff
slender lintel
#

But now i've got this error discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'

finite cliff
#

i am making a private thread through a channel and i am getting this error discord.errors.HTTPException: 400 Bad Request (error code: 20035): Guild premium subscription level too low

finite cliff
slender lintel
#

without boost you can create public threads

slender lintel
# finite cliff can you please show your code?
async def suggest(ctx, sugs: Option(str, name='предложение', description='Что вы хотите предложить?')):
    user = ctx.author.id
    use = ctx.author.id
    va = '*нету*'
    la = '*нету*'
    b.add_s(self=b, idea=sugs, user=use, vkans=va, lvans=la)
    ids = b.get_s_id(self=b, ids=user)
    l = b.get_l_id(self=b, ids=user)
    v = b.get_v_id(self=b, ids=user)
    mes = b.get_mark(self=b, ids=user)
    am = b.get_mark_am(self=b, ids=user)

    
    
    m1 = discord.utils.get(bot.emojis, name=f'mk1')
    m2 = discord.utils.get(bot.emojis, name=f'mk2')
    m3 = discord.utils.get(bot.emojis, name=f'mk3')
    m4 = discord.utils.get(bot.emojis, name=f'mk4')
    m5 = discord.utils.get(bot.emojis, name=f'mk5')

    embed = discord.Embed(title=f'Предложение № {ids}', color=discord.Colour.from_rgb(76, 0 ,153))
    embed.add_field(name=f'Идея от {ctx.author}', value=f'> {sugs}', inline=False)
    embed.add_field(name=f'Ответ ВКинулся™#1860', value=f'> {v}', inline=True)
    embed.add_field(name=f'Ответ Lavrik#8298', value=f'> {l}', inline=True)
    embed.add_field(name=f'Оценка участников ({am})', value=f'**{mes}** {m1}', inline=True)
    embed.set_footer(text=ctx.message.id)

    m = await ctx.respond(embed=embed, view=PersistentView())
    
    ```
finite cliff
#

embed.set_footer(text=ctx.message.id)

slender lintel
#

and after i need to edit message?

finite cliff
#

yes

slender lintel
slender lintel
white latch
#

I'm having issues getting a cog to work properly

#

This is the cog:

import discord
from discord.ext import commands

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

    @commands.command() # create a command
    async def hello(self, ctx): # all methods now must have both self and ctx parameters
        print("invoked") 
        await ctx.send('Hello!')

def setup(bot):
    bot.add_cog(Test(bot))

And this is the main script

import discord
from discord.ext import commands
from os import getenv
from dotenv import load_dotenv

load_dotenv()

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

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

bot.load_extension("cogs.test")

@bot.command()
async def command(ctx):
        print("commanded")


bot.run(getenv("EVENTBOT_BOT_TOKEN"))
#

The command "command" works fine, but the command "hello" results in a commandNotFound exception

#

Any idea about what could I be doing wrong?

knotty niche
#

Can someone help me with this error, when I tried to do this with buttons it worked fine

half marsh
white latch
slender lintel
#
@bot.event
async def on_user_update(before, after):
    if before.name != after.name:
        if any(word in after.name.lower() for word in blacklistwords):
                await after.kick(reason=f"{after} | {after.id} Blacklistwort.")
                return print(f"{after} | {after.id} Blacklistwort.")

why do i get this?:

line 287, in on_user_update
await after.kick(reason=f"{after} | {after.id} Blacklistwort.")
AttributeError: 'User' object has no attribute 'kick'

#
@bot.event
async def on_user_update(before, after):
    if before.name != after.name:
        if any(word in after.name.lower() for word in blacklistwords):
                await after.guild.kick(after, reason=f"{after} | {after.id} Blacklistwort.")
                return print(f"{after} | {after.id} Blacklistwort.")
#

i have this now

#

but i cant test because ratelimit

#

is it gonna work?

river mortar
#

Python Help: I have an base image, i want to put some text over it and send it in a embed. How can I do this?

wide cloak
river mortar
wide cloak
#
river mortar
knotty niche
#

What are the benefits of subclassing the view?

crimson coral
#

so you want any([word in...])

crimson coral
#

but it isn't a necessity, ultimately just preference

knotty niche
crimson coral
#

for reusability you can just inspect the examples

supple ravineBOT
#

Here's the button roles example.

crimson coral
#

in that example, each button is doing more or less the same thing; the role given is ultimately just dependant on the custom_id, which is taken from the role passed into the button class

slender lintel
crimson coral
#

because users are users

#

not members

slender lintel
#

i know

crimson coral
#

you can't kick a "user" because a user doesn't belong to a guild

slender lintel
#

should i fetch the member with the user.id?

crimson coral
#

yeah that works

#

but guild.kick which you're currently doing also works

#

you don't need to get the member object if you already have the guild and user

slender lintel
#

but where do i have the guild?

#

i have to fetch the guild too?

crimson coral
#

oh i see now

#

yeah on_user_update only deals with users hm

slender lintel
#

i think the smartest way is to fetch the member

crimson coral
#

just to make sure, are you trying to filter usernames or nicknames?

crimson coral
#

is your bot only in a single guild?

slender lintel
#

on on_user_update i only get usernamens

slender lintel
crimson coral
#

you can just use bot.get_guild(id) for the guild object then

slender lintel
#
guild = bot.get_guild(guild_id)
await guild.kick(after, reason=f"{after} | {after.id} Blacklistwort.")
#

this is my code now

crimson coral
#

yeah

forest saffron
#

my bot wont register any commands anymore. i have the intents enabled and debug guild is correct - any ideas ? and yeah i waited for some time for it t o update but it wont recognize anymore

forest saffron
# frigid lark It can take some minutes

yeah but whats odd is that i am waiting for 30 mins now and in my guild it doesnt register the commands for my other bots too. i gave permission in two different guilds still not working

#

it worked ilke 1 week ago without problems. now there are only the defualt slash commands

frigid lark
#

I had the same problem with some servers, it was really weird

forest saffron
#

ooof ok weird? any fix for thaT?

frigid lark
#

nope

#

they kicked the bot

knotty niche
crimson coral
#

yes, subclassing isn't required

slender lintel
#

so like i went to bed

#

and now i try out my code

#

50 errors

#

and i dont know what they mean

#

i tried finding the invaild form body bt idk where its at

#

prob you have more than 1 command having the same name

grim mist
#

Code ```py
if not discord.opus.is_loaded():
discord.opus.load_opus('./libopus.so')

how do i solve this?```py
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.music' raised an error: OSError: ./libopus.so: ELF file's phentsize not the expected size
hot vale
#

Why if I use the slash command in my bot __ in private message__, the bot will automatically shut down?

steep verge
spring wharf
#

Is there any examples to disable all buttons on that message when pressed?

#

Or remove the buttons

hot vale
#

@spring wharf

spring wharf
#

I am asking for help haha sorry.

sudden path
#

Or, there's a method which disables all buttons

spring wharf
#

Could you link it?

sudden path
#

b!rtfm pyc view.disable_all

open bearBOT
sudden path
#

Uh

#

disable_all_items

#

Or something like that

spring wharf
#
await interaction.response.send_message(embed=embed, ephemeral=True, view=discord.ui.View.disable_all_items(self))```
#

Could anyone help it does not disable the buttons?

sudden path
#

What

#

The hell is that

#

You should run the method in the callback

slender lintel
#

discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Interaction' object has no attribute 'edit'

How can i fix it

sudden path
#

And you have to subclass discord.ui.View you're calling the class itself and passing self?

sudden path
#

Read the docs

stable torrent
slender lintel
stable torrent
#

no one will tho if you are giving them solution peepoBlink

stable torrent
#
# like that
slender lintel
#
async def suggest(ctx, sugs: Option(str, name='предложение', description='Что вы хотите предложить?')):
    user = ctx.author.id
    use = ctx.author.id
    va = '*нету*'
    la = '*нету*'
    b.add_s(self=b, idea=sugs, user=use, vkans=va, lvans=la)
    ids = b.get_s_id(self=b, ids=user)
    l = b.get_l_id(self=b, ids=user)
    v = b.get_v_id(self=b, ids=user)
    mes = b.get_mark(self=b, ids=user)
    am = b.get_mark_am(self=b, ids=user)

    
    
    m1 = discord.utils.get(bot.emojis, name=f'mk1')
    m2 = discord.utils.get(bot.emojis, name=f'mk2')
    m3 = discord.utils.get(bot.emojis, name=f'mk3')
    m4 = discord.utils.get(bot.emojis, name=f'mk4')
    m5 = discord.utils.get(bot.emojis, name=f'mk5')

    embed = discord.Embed(title=f'Предложение № {ids}', color=discord.Colour.from_rgb(76, 0 ,153))
    embed.add_field(name=f'Идея от {ctx.author}', value=f'> {sugs}', inline=False)
    embed.add_field(name=f'Ответ ВКинулся™#1860', value=f'> {v}', inline=True)
    embed.add_field(name=f'Ответ Lavrik#8298', value=f'> {l}', inline=True)
    embed.add_field(name=f'Оценка участников ({am})', value=f'**{mes}** {m1}', inline=True)
    

    m = await ctx.respond(embed=embed, view=PersistentView())

    em = discord.Embed(title=f'Предложение № {ids}', color=discord.Colour.from_rgb(76, 0 ,153))
    em.add_field(name=f'Идея от {ctx.author}', value=f'> {sugs}', inline=False)
    em.add_field(name=f'Ответ ВКинулся™#1860', value=f'> {v}', inline=True)
    em.add_field(name=f'Ответ Lavrik#8298', value=f'> {l}', inline=True)
    em.add_field(name=f'Оценка участников ({am})', value=f'**{mes}** {m1}', inline=True)
    em.set_footer(text=m.id)
    await m.edit_message(embed=em, view=PersistentView())
    
    ```
stable torrent
#

🤔

#

напиши на русском

slender lintel
sudden path
#

Use ctx.edit

slender lintel
stable torrent
#

я там в бане

slender lintel
stable torrent
stable torrent
slender lintel
spring wharf
stable torrent
sudden path
spring wharf
#

Callbacks

#

I have not used them yet

supple ravineBOT
#

Here's the confirm example.

stable torrent
#

когда ты отправляешь сообщение, ты получаешь в ответ объект Интеракшон

spring wharf
#

thanks

stable torrent
#

а он уже содержит .message

#

вроде так должно быть по сути

#

я сейчас еще посмотрю, тут очень запутанно все и я бы лично переписал

#

@slender lintel короче, тут можно даже легче это сделать, у discord.Interaction есть edit_original_message

#

по сути это должно сделать то, что ты хочешь

sudden path
#

Whatever you're saying

#

Ctx.edit works

#

b!rtfm pyc ApplicationContext.edit

open bearBOT
stable torrent
#

yep, thats shortcut

stable torrent
#

it kills me how its completely not intuitive

sudden path
#

Yeah

stable torrent
#

someone should kinda rewrite the code or docs

slender lintel
stable torrent
#

пожалуйста

slender lintel
stable torrent
#

хз, не помню такого

slender lintel
stable torrent
#

я вот тоже не вижу

slender lintel
stable torrent
#

🤨

#

хз

#

создай для этого отдельную ветку на английском

#

я вообще хз что это

frigid elm
#

what are slash cmds called in vogs

#

cogs

stable torrent
#

they are called slash_commands

supple ravineBOT
#

Here's the slash cog example.

frigid elm
#

ohh yh mb

#

very dumb question

stable torrent
#

¯_(ツ)_/¯

slender lintel
stable torrent
slender lintel
#

is there a fast way to get all members who are online?

quartz snow
#

is it possible to get an attached file?

past gate
#

yeah just check the message's attachments attribute

frigid elm
#

im new to cogs and i was wondering if i have py channel = await bot.fetch_channel(992014248102346803) how do i define bot

#

commands.fetch_channel?

crimson coral
#

typically you have self.bot defined in the cog's init

frigid elm
#

ohh ye

tepid anvil
#

@crimson coral how to run unending loops without on_ready () with no timelimt

crimson coral
#

uhhhh

#

that sounds like a really bad idea but what exactly are you trying to do

#

might wanna use tasks instead

frigid elm
#

kinda confusing

crimson coral
#

eh...

#

can you show the code?

frigid elm
#
class Application(commands.Cog):

 class Apply(Modal):
    def __init__(self,bot, *args,**kwargs): 
        self.bot = bot
        super().__init__(*args,**kwargs)
        
        self.add_item(InputText(label="Since when do you edit",placeholder="Approximate"))
       

          

    async def callback(self,bot,interaction: discord.Interaction):
        self.bot = bot
        em = discord.Embed(color=discord.Color.from_rgb(13, 99, 143),title="New Application.")
        em.set_thumbnail(url="https://cdn.discordapp.com/attachments/991328804347854948/991329051430113380/14dncpxcxwh61.jpeg")
        if interaction.user.avatar == None:
            em.set_author(name=f"{interaction.user}")
        else:
            em.set_author(name=f"{interaction.user}",icon_url=interaction.user.avatar.url)
        
        em.set_footer(text="Veno Applications")
        em.add_field(name="`1` __Since when do you edit?__",value=f"{self.children[0].value}",inline=False)
        
         
        await interaction.response.send_message("Application submitted! check #✗・results"
        ,delete_after=10)
        channel = await bot.fetch_channel(992014248102346803)
        await channel.send(embed=em)
         

         


    

        
        
        
 @commands.slash_command(name="apply",debug_guilds=[991441544349499512])


 async def apply(ctx):
            modal = Apply(title="Veno Application Form")
    
            await ctx.send_modal(modal)```i had to get rid of some code or it wouldve been to long
#

@crimson coral

crimson coral
#

wait so what's the error

frigid elm
#

in the command Apply isnt defined

crimson coral
#

what about modal = self.Apply(...)?

#

alternatively just have the apply class outside the cog

frigid elm
#

oh ty

crimson coral
#

you also need to pass bot into the Apply class

crimson gale
#

the latter is more preferable since it can then be reused outside of the cog easily

crimson coral
#

yeah

tepid anvil
crimson coral
#

....

tepid anvil
#

if matches --> do some tasks

crimson coral
#

just use on_member_update for nicknames, or on_user_update for usernames

tepid anvil
crimson coral
#

yes

tepid anvil
#

even new users

tepid anvil
#

new users wont to both

crimson coral
#

?

tepid anvil
#

they simply join

crimson coral
#

what

tepid anvil
#

i want to check the names

crimson coral
#

...so use on_user_update

#

it's an event

tepid anvil
#

for that user need to update their names right ?

crimson coral
#

yes

tepid anvil
#

im saying i want to just check the exiting member name - where they wont change

crimson coral
#

but why would you need an infinite loop for that

past gate
#

Discord Security Analyst? 🤔

tepid anvil
#

to make it simple , i want to continuously loop through every member

crimson coral
#

that's... not simple

#

if you're "scanning all member names continuously" then of course you want to use an event

#

you can do a one time check of all bot.users with a command or something, then do the tracking with on_user_update

tepid anvil
#

for all the bot.users

crimson coral
#

once? sure i guess

#

but you typically shouldn't be using on_ready for that

past gate
#

Yeah on_ready can be fired multiple times during the running of the bot iirc

tepid anvil
crimson coral
#

i've... said it already

#

events are literally the best way to do that

tepid anvil
#

ok

#

Application Command raised an exception: ValueError: no such name

#

@crimson coral what might be the reason

past gate
#

maybe also supply your code

crimson coral
#

^ what code triggered that

tepid anvil
past gate
#

like..

tepid anvil
past gate
tepid anvil
#

lol

past gate
#

just send your code for the command

sudden path
#

Thought you had more than 7 years of experience in programming my man.

vivid nacelle
#

@tepid anvil send your code otherwise we can't help.
Read #help-rules

past gate
#

🤔

main grail
#

why code from documentation is not working?

#

and after fixing that, another code from doc is not working:

vivid nacelle
sudden path
vivid nacelle
#

ah there

#

well

past gate
#

web3

#

yeah ok im out

#

cya

vivid nacelle
#

same

#

i hate web3

past gate
main grail
past gate
#

update pycord

main grail
#

it was just fresh install

past gate
#

we're on 2.x

#

1.7.3 is old

#
# Linux/macOS
python3 -m pip install -U "py-cord[voice]"

# Windows
py -3 -m pip install -U py-cord[voice]```
#

also you might need this

crimson hinge
#

pip install py-cord==2.0.0rc1 ^^

main grail
main grail
frigid lark
past gate
main grail
stable torrent
#

seems to be an issue with example, but, still, what is your pycord version?

#

@main grail

main grail
stable torrent
#

did you change something in code?

#

i'll try to recreate a bug and possibly fix it

#

@main grail to be sure, what python version are you using?

main grail
#

yes

#
from enum import Enum
import discord

intents = discord.Intents.all()
# bot = discord.Client(command_prefix=',', intents=intents, debug_guilds=[957264333509898312])

bot = discord.Bot(command_prefix=',', intents=intents, debug_guilds=[957264333509898312])
connections = {}


class Sinks(Enum):
    mp3 = discord.sinks.MP3Sink()
    wav = discord.sinks.WaveSink()
    pcm = discord.sinks.PCMSink()
    ogg = discord.sinks.OGGSink()
    mka = discord.sinks.MKASink()
    mkv = discord.sinks.MKVSink()
    mp4 = discord.sinks.MP4Sink()
    m4a = discord.sinks.M4ASink()


async def finished_callback(sink, channel: discord.TextChannel, *args):
    recorded_users = [f"<@{user_id}>" for user_id, audio in sink.audio_data.items()]
    await sink.vc.disconnect()
    files = [
        discord.File(audio.file, f"{user_id}.{sink.encoding}")
        for user_id, audio in sink.audio_data.items()
    ]
    await channel.send(
        f"Finished! Recorded audio for {', '.join(recorded_users)}.", files=files
    )


@bot.command()
async def start(ctx: discord.ApplicationContext, sink: Sinks):
    """
    Record your voice!
    """
    voice = ctx.author.voice

    if not voice:
        return await ctx.respond("You're not in a vc right now")

    vc = await voice.channel.connect()
    connections.update({ctx.guild.id: vc})

    vc.start_recording(
        sink.value,
        finished_callback,
        ctx.channel,
    )

    await ctx.respond("The recording has started!")


@bot.command()
async def stop(ctx: discord.ApplicationContext):
    """Stop recording."""
    if ctx.guild.id in connections:
        vc = connections[ctx.guild.id]
        vc.stop_recording()
        del connections[ctx.guild.id]
        await ctx.delete()
    else:
        await ctx.respond("Not recording in this guild.")


@bot.event
async def on_ready():
    print('działam!')
#

3.10.4

stable torrent
#

nvm, its example bug

#

i have it too

#

i'll try to fix it

main grail
#

the same with python 3.9.13

stable torrent
#

@main grail i got it to work

#

say if something isn't working

main grail
#

super, thank you. I will check

stable torrent
#

👍🏻

finite cliff
#
  File "C:\Users\Fammy\Desktop\test\cogs\Button.py", line 36, in closeTradeButton
    await messgae.thread()
AttributeError: 'Message' object has no attribute 'thread'```
#

i want to get the thread created on this message

finite cliff
#

thread is listed as attribute in docs

gilded widget
#

update to the latest master branch on github

#

it was just merged a few days ago

finite cliff
#

ohh

#

can you please tell me cmd?

frigid lark
#

pip install py-cord==2.0.0rc1

finite cliff
#

i have this one

frigid lark
#

oh

gilded widget
#

you need github master

#

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

finite cliff
frigid lark
#

!git

robust nebulaBOT
finite cliff
#

is there any step by step process?

finite cliff
#

here is my list

frigid lark
finite cliff
finite cliff
#

which one should i install?

frigid lark
#

or start cmd

finite cliff
#

next

frigid lark
#

and use this command

#

winget install --id Git.Git -e --source winget

finite cliff
#

oki

#

installing...

frigid lark
finite cliff
#

almost done

#

done

#

now?

frigid lark
#

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

finite cliff
#

oki

errant verge
#

is there a way to role a bunch of people at once in a slash command?

finite cliff
#

mhmm

gilded widget
#

open and close command prompt

#

your PATH hasn't updated there yet so restart it

finite cliff
#

ohh

#

nice its installing

#

installed

#

lemme open vs code again...

#

oki working 😄

#

thanks alot

#

i have one more issue how can i get bot in this?

@discord.ui.button(label="Close Trade",style=discord.ButtonStyle.red,custom_id="closeTradeButton")
    async def closeTradeButton(self,button:discord.Button,interaction:discord.Interaction):```
#

while sub classing View

gilded widget
#

just pass bot as an init argument for the view

finite cliff
#

oki

errant verge
#
@bot.command()
@commands.has_role("Council")
async def addrole(ctx, role: discord.Role, *members: discord.Member):
    rnames = [role.name for role in player.roles]
    for member in members:
        if str(role) in rnames:
            await ctx.respond(f"<@{member.id}> already in {role}")
        else:
            await member.add_roles(discord.utils.get(ctx.guild.roles, name=role))
            await ctx.respond(f":white_check_mark: {role} added to <@{member.id}>")
@addrole.error
async def addrole_error(ctx, error):
    if isinstance(error, commands.MissingRole):
        await ctx.send("You dont have the Council role.", ephemeral = True)
#

im making a command to role multiple people at once

#

but right now it doesn't do anything?

#

no errors or anything

main grail
#
import discord

intents = discord.Intents.all()
# bot = discord.Client(command_prefix=',', intents=intents, debug_guilds=[957264333509898312])

bot = discord.Bot(command_prefix=',', intents=intents, debug_guilds=[957264333509898312])
connections = {}

sinks = {
    "mp3": discord.sinks.MP3Sink(),
    "wav": discord.sinks.WaveSink(),
    "pcm": discord.sinks.PCMSink(),
    "ogg": discord.sinks.OGGSink(),
    "mka": discord.sinks.MKASink(),
    "mkv": discord.sinks.MKVSink(),
    "mp4": discord.sinks.MP4Sink(),
    "m4a": discord.sinks.M4ASink()
}


async def finished_callback(sink, channel: discord.TextChannel, *args):
    recorded_users = [f"<@{user_id}>" for user_id, audio in sink.audio_data.items()]
    await sink.vc.disconnect()
    files = [
        discord.File(audio.file, f"{user_id}.{sink.encoding}")
        for user_id, audio in sink.audio_data.items()
    ]
    await channel.send(
        f"Finished! Recorded audio for {', '.join(recorded_users)}.", files=files
    )


@bot.command()
async def start(ctx: discord.ApplicationContext, sink: discord.Option(str, choices=sinks)):
    """
    Record your voice!
    """
    sink = sinks.get(sink)
    print(sink)
    voice = ctx.author.voice

    if not voice:
        return await ctx.respond("You're not in a vc right now")

    vc = await voice.channel.connect()
    connections.update({ctx.guild.id: vc})

    vc.start_recording(
        sink,
        finished_callback,
        ctx.channel,
    )

    await ctx.respond("The recording has started!")


@bot.command()
async def stop(ctx: discord.ApplicationContext):
    """Stop recording."""
    if ctx.guild.id in connections:
        vc = connections[ctx.guild.id]
        vc.stop_recording()
        del connections[ctx.guild.id]
        await ctx.delete()
    else:
        await ctx.respond("Not recording in this guild.")```
#

after /start

dawn cape
#

How can I check the rights of a person in a specific voice channel?

fathom stone
#

You could iterate over bot.guilds and check the len(guild.members) >= 10

#

@slender lintel

#
for g in bot.guilds:
    if len(guild.members >= 10):
        await guild.leave()
#

Put that in your command

half marsh
#

You cant just copy paste, understand it whats wrong on the code

lament nimbus
half marsh
#

No it dont, the code here is iterating client's guild and store it to var g

#

Also the len function parenthesis are wrong

#

Are there any error?

#

Show codee

#

The parenthesis or the closing ) is wrong

#

This is not iterating it

#

But store it

lament nimbus
#
for g in bot.guilds:
    if len(g.members) <= 10: # if member count is less than 10
        await g.leave() # leave
#

that should work

#

i think

lament nimbus
#

mb i forgot what i was and copied it from my code lol

thin trellis
#

Are there any bugs on the current github version with cogs?
Suddenly my bot loads cogs twice and commands inside cogs will not register / even message commands. My Error handler will say that they do not exsist.

halcyon cairn
thin trellis
# halcyon cairn 1) Version of pycord? 2) command group or stand alone slash commands? 3) Error? ...
  1. Version py-cord==2.0.0rc1 (Bug is on both github latest version and pypi)

  2. Slash commands and prefixed commands

  3. No specific error, they just dont register / added to the bot

if os.path.isdir("./cogs"):
for file in os.listdir("./cogs"):
if file.endswith(".py"):
try:
bot.load_extension(f"cogs.{file[:-3]}")
print(f"{file[:-3]} loaded")
except Exception as e:
print(f'Cog {file[:-3]} failed to load:\n{e}')
continue```
This is how I load cogs normally. Each exsisting cog will load twice for some reason
At least I can sea that each print(f"{file[:-3]} loaded") from a cog shows twice

#

Or could this be any error with my code? Thonk

halcyon cairn
#

Is your code long? Can you post it? If not, things to check:

Are you loading them twice in any other area?
I'm not seeing the point of the first if statement (if os.path.isdir) if you're already defining which directory to use in line 2 ( for file in os.listdir("./cogs"):

slender lintel
#

how can i fix it?

    payload["components"] = [] if view is None else view.to_components()
AttributeError: 'Dropdown' object has no attribute 'to_components'```
slender lintel
past gate
#

Run pip list @slender lintel

#

And send the output here

slender lintel
#

@past gate

#

i think it because i use win 11

past gate
#
dhooks                    1.1.4
discord.py                1.7.3
discord-webhook           0.16.3```
#

uninstall these libs

#
py-cord                   1.7.3```
#

and upgrade pycord

forest saffron
#

is there any example

#

how to create a webhook message in pycord?

frigid lark
#

or you try to search for it on google with discord.py

#

like
discord.py webhook

wicked ferry
#

i cant use options in a cog, why?

#
@discord.slash_command(description="Heirate jemanden")
    async def marry(ctx, user: discord.User):
        embed = discord.Embed(title="Offiziel verheiratet!",
                              description=f'**{ctx.author}** und **{user}** haben gerade geheiratet!:heart_on_fire:',
                              color=0xff0000)
        embed.set_image(url="https://c.tenor.com/K6xMm3nxBg4AAAAC/marriage-marry.gif")
        await ctx.respond(embed=embed)```
snow citrus
frigid lark
#

And use discord.Member

clear plaza
#

I updated Py-Cord and now the bot crashes when I execute a slash command in a direct message.

#

I used "pip install git+https://github.com/Pycord-Development/pycord" to update the py-cord.

past gate
#

did you give it the application.commands scope when inviting it

clear plaza
#

Is this it?

#

I do not need to use the slash command in my direct messages.
Is there any way to disable the slash command in direct messages?

past gate
#

go the developer panel and invite with your bot with the scope selected

clear plaza
past gate
#

a new error?

clear plaza
#

same error

past gate
clear plaza
#

Do I need to set some kind of intent?

past gate
#

latest pycord requires intents yes

clear plaza
#

intents=discord.Intents.default()

#

Is this okay?

past gate
#

do you have the intents enable on the developer portal?

clear plaza
#

Which intent is required?
presence, server member, message content

#

Only server member intent is enabled.

slender lintel
#

#993544558828851250

clear plaza
frigid lark
#

you can change it to
intents=discord.Intents.all()

clear plaza
crude temple
#

I have an old bot that used to work fine but suddenly it doesn't respond to commands or anything. The bot loads up just fine, no error shows up too.

clear plaza
#

My BOT at least seems to work with this.

clear plaza
frigid lark
#

if its really a int or str?

sudden path
#

Are you sure TOKEN points to something

clear plaza
#

My BOT does not seem to be getting permission on direct message.

sudden path
#

What version are you on

clear plaza
#

I installed py-cord from github.

#

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

sudden path
#

Hm

#

This is weird tbh

gilded widget
#

this is definitely a lib bug

errant verge
#
import discord
from discord.ext import commands
from discord.commands import option
import os
from dotenv import load_dotenv



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

bot = commands.Bot(command_prefix='$')

@bot.event
async def on_ready():
    print(f"{bot.user} Ready")

@bot.command()
async def poopin(ctx):
    await ctx.send("farting")

bot.run(os.getenv("TOKEN"))

did i mess something up for it not to give me anything?

#

i dont have any errors or unresponsive messages

#

it does on_ready but thats it

crimson coral
#

and you never passed the intents into bot either

errant verge
#

oh

intents = discord.intents.message_content()
bot = commands.Bot(command_prefix='$', intents=intents)```
#

or is this wrong way

crimson coral
#

ehh nearly... first line is wrong, it's the same as how you set intents.members

#

i.e. intents.message_content = True

errant verge
#

oh right i forgot about that

errant verge
crimson coral
#

allgood

icy sluice
#

I’m randomly getting this error but I haven’t touched any of my code?

crimson coral
#

i mean

#

you tried to use a variable you haven't defined

icy sluice
#

it is defined

sudden path
#

Clearly its not

icy sluice
sudden path
#

You refer to it as self.bot

#

Not bot

icy sluice
#

can I swap em around

#

to lessen the confusion?

sudden path
#

No?

#

It just classes work

icy sluice
#

alri

#

ty

sudden path
#

Basic python.

raven crane
#
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: ValueError: could not find open space for item

I got this error while sending a Modal
how many items can I add in a Modal, is their a limit ?

forest saffron
#

any ideas why deleting the message in the on_message event throws discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message error even though it deletes the message=

sudden path
#

Like 5 items. Or maybe less

steep verge
#

When I make a select menu and use it, the option I select is a default option for me on my client side, how do I remove that so it doesn’t make it a default option on my end but just shows the normal select menu?

sudden path
#

Looks like a Discord issue?

dawn bridge
#

Hello everyone, does anyone know what could be the problem?
WARNING:discord.gateway:Shard ID None heartbeat blocked for more than 10 seconds.

frigid elm
#
@commands.slash_command(name="mute",description="Mutes a user for a specified time")
    @commands.has_permissions(manage_roles=True)
    async def mute(self,ctx,user: discord.Member=None,time=None,*,reason: Option(str,"why",required=False)):
     time = humanfriendly.parse_timespan(time)
     if ctx.author.top_role <= user.top_role:
        e = discord.Embed(color=discord.Color.from_rgb(13, 99, 143),description=f"You can't timeout {user} according to roles hierarchy")
        await ctx.respond(embed=e)
     else:
       await user.timeout(until=discord.utils.utcnow() + datetime.timedelta(seconds=time),reason=reason)
       e = discord.Embed(color=discord.Color.from_rgb(13, 99, 143),description=f"Succesfully muted {user} for reason: `{reason}`")```
 it doesnt give me any error but it doesnt time out the person
deep grail
#

Why is it that after I run a message command, the context menu is no longer visible if I right click on the message?

clear plaza
ionic sable
#

So, I'm coding a League Of Legends Discord Bot and I want to show my best 5 champions (Champion Name - Champion Mastery Points) in a Embed Value like this example [1] [2]

sudden path
#

embed.add_field?

ionic sable
#

This is the code that I have right now

ionic sable
#

I don't want a field for each champion, I want a line of the field value for each champion

sudden path
#

Add to a string?

#

champions = ""
champions = champions + "\nHello World"

ionic sable
#

and then embed.add_field(name = "Best Champions", value = champions)? right?

sudden path
#

Yep!

ionic sable
#

Okay, gonna try that

sudden path
#

That's my best shoot rn

ionic sable
#

I tried that (I don't know if I did it correctly) and the bot only send one of the 5 champions (the last one)

sudden path
#

Because that's what your for loop does

ionic sable
#

Thanks! It worked, now I have another question

#

Do you know how can I do to convert the number (e.i: 92000 to 92k?)

sudden path
ionic sable
#

tysm

halcyon cairn
#

Probably not the place, but just an FYI, there's a hack going around telling you that you've been exposed and asking you to click a link. I can share a screenshot if you like. Would recommend NOT clicking that link. Multiple people in my server caught it within the past hour.

gilded widget
#

absolute low lifes

slow dome
gilded widget
#

true

solar berry
#

Is it a bad idea to store Discord IDs as floats? They take so much less storage than str, and its much faster too. I cant use int bcz it would be very complicated to change things when discord ids go above 64bits (it'll be a couple years but better be ready than sorry)

#

int -> str -> float

#

nvm im stupid, its super innacurate

slender lintel
#

#993544558828851250 pls help

oblique hazel
#

How to process commands in on_message event?
client.process_commands(ctx)
Does not work

azure quest
#

How to make a discord.File object a discord.Attachment?

slender lintel
oblique hazel
azure quest
#

I don't want to send it though.

oblique hazel
#

It returns me that "Bot" object does not have process_commands

azure quest
#

I want a link of the attachment which then downloads the file.

#

But the txt file is created using Python

slender lintel
azure quest
#

Then how can I get a url to download the txt file

slender lintel
#

upload to an external host

azure quest
#

How am I meant to do that with Python though

slender lintel
slender lintel
azure quest
#

Can I not just create an attachment or get a url for the file using discord api

oblique hazel
# slender lintel are you using discord.Bot?

import discord


intents = discord.Intents.all()
activity = discord.Activity(name='Use /rphelp!', type=discord.ActivityType.watching)
client = discord.Bot(intents=intents, command_prefix='>', fetch_offline_members=True, sync_commands=True, activity=activity, debug_guilds=[985044751122313227])```
#

That's my client instance

slender lintel
azure quest
#

But I don't want to send it as a file

#

I want to send it as a link

#

They just take up lots of space

slender lintel
azure quest
#

what

oblique hazel
slender lintel
#

if you dont send the file you cant access the link

azure quest
#

ik

oblique hazel
#

bruh

#

it's simple

azure quest
#

im looking it up file to url and nothing comes up

oblique hazel
#

EZ api

slender lintel
slender lintel
#

only commands.Bot have

oblique hazel
#

So how do I process commands in on_message event ?

#

With client instance that I have now ?

azure quest
#

Idk what rest is or have experience

#

with a whole new api

#

so its not ez

slender lintel
#

theoretically you could create an discord.Context calling the process, but i am not sure if that one will works

oblique hazel
#

bruh

slender lintel
#

i am dumb

#

replace discord.Bot with commands.Bot

#

if this dont work i am out

#

and try ```
cctx = discord.commands.Context()
await cctx.invoke(command_here)

twilit musk
#

discord.errors.ExtensionFailed: Extension 'jishaku' raised an error: AttributeError: module 'discord.ui' has no attribute 'TextInput'

what does this means ?? and how to fix it

azure quest
#

otherwise when u download it, it is just a File ext

solar berry
#

Or you mistyped an import

oblique hazel
#

learn python

#

ty

solar berry
#

Anyone know where the @commands.has_permissions decorator source code is located?

vale eagle
#

I'm on a Macbook and I'm following this tutorial, I have to do node bot.js in terminal however since I moved the file to desktop its giving me an error saying Error: Cannot find module '/Users/bradley/bot.js'

past gate
#

have you seen the discord you're in?

vale eagle
#

?

past gate
#

This is Pycord (a python discord api wrapper) not discord.js

vale eagle
#

O

#

Is there a discord for that

past gate
#

probably

vale eagle
#

Ok

#

Bye bye

lost sparrow
#

so if a timezone object returns none when .tzinfo is called, is it native or offset, i am so confused

crimson gale
#

its naive

slender lintel
#
@xp.command()
    @option(
        'user_id',
        int,
        description='Enter user id'
    )
    async def add(self, ctx, user_id: int, xp: Option(int, 'Enter amout of xp to be added', min_value=1)):
```how?
slender lintel
#

how to make it valid