#Basic Pycord Help (Quick Questions Only)

1 messages · Page 14 of 1

wooden zenith
#

yes idk what its called

#

im new to all this coding stuff

#

im tryna help my friend

#

so

#

i might aswell try to learn

dry echo
fervent cradle
#

how do you remove a role from a user when only having their id?

simple canopy
fervent cradle
#

user doesnt have remove _ roles though?

simple canopy
#

you need member

#

from discord.Guild.get_member

fervent cradle
#

member = discord.Guild.get_member(ctx.guild, int(discord_id))

simple canopy
#

you can get a guild object from... well... id, event, or context

meager mica
#

Oh is it get member

prisma flicker
#

I thought buckettype.user meant each user gets their own bucket?

nocturne canopy
#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'group'

it might be a really dumb mistake by me but i know like nothing about python
why did it not format

prisma flicker
#

?tag codeblock

obtuse juncoBOT
#

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

That makes reading code in Discord a lot easier:

print("This is an example.")
nocturne canopy
#

ohh

prisma flicker
#

what is _?

nocturne canopy
#

i read that it takes the value of the last operation. i'm completely misusing it here am i

prisma flicker
#

you should store it in a variable

#

like result = translator.translate(...)

proud pagoda
nocturne canopy
#

this returns the same error

@bot.command()
async def translate(ctx: commands.Context, input: str = "texto de prueba. reemplazar con mensaje basado en contexto." , outlang = "en", inlang = "auto", result = "welp something's wrong"):
    """Translates."""
    result = translator.translate(input, src=inlang, dest=outlang)
    await ctx.send(f"{text} -> {result}")
#

wait the result doesn't go there i'm dumb

#

do i define it inside the body?

prisma flicker
#

why doesn't it go there?

nocturne canopy
#

because the user would be able to pass the content of result as an argument

peak chasm
#

hi, exist the event to create channel ?

prisma flicker
#

right, take off result from the arguments

nocturne canopy
#

in all of these using 'these' and "these" doesn't make a difference, does it?

prisma flicker
#

nope

harsh dust
#

I removed my "on_timeout" function for each view and turns out removing that solved the problem of the images randomly disappearing from the api. kinda odd.
This is the function each view uses:

async def timeout():
  try:
    await msg.edit(view=None)
  except:
    pass

view.on_timeout = timeout
nocturne canopy
#

okay i figured it's something outside my code because the examples in the repo return the same errors

heady skiff
#

On the stable version Is there any way to make slash commands hidden for users who don't have a certain role?

full basin
nocturne canopy
#

OKAY I GOT IT WORKING somewhat. it was a known error with googletrans 3.0, it was fixed in the 4.0 release candidate. now it spews too much data which is good i suppose, just gotta filter out the bits the end user doesn't care about

#
>>> print(translator.translate('bolas de queso'))
Translated(src=es, dest=en, text=Cheese balls, pronunciation=None, extra_data="{'confiden...")

how could i print only the text?

peak chasm
#

how to extrac id the channels in event on_guild_channel_create

nocturne canopy
full basin
#

Oh. Hi. I was also having that issue. 4.0 fixed it?

nocturne canopy
#

yeah, 3.1.0a0 works too

full basin
nocturne canopy
#

if you want to use 4.0 install it as googletrans==4.0.0-rc1

charred shale
#

Does PyCord have anything for creating private messages? I don't mean a direct message in your inbox.
I mean a message in a normal server channel that only a specific user can see.
Sometimes I've seen Discord spit out messages labeled with "only you can see this message" and a dismiss message option.
Is it possible to do that?

nocturne canopy
full basin
cyan quail
#

only available for slash commands and ui components

nocturne canopy
#

another question, if i wanted to send a command like for example .bot translate some text en es that translates from english to spanish, is it only possible if the text (everything before the language arguments) is in quotes?

charred shale
#

Thank you both, Dark and Nelo!

cyan quail
#

allgood

cyan quail
#

e.g. py async def translate(ctx, language, *, text):

nocturne canopy
#

would this work?

async def translate(ctx: commands.Context, input: str, * , outlang = "en", inlang = "auto")
cyan quail
#

no, you should have the input last

nocturne canopy
#

i see. quotes it is.

cyan quail
#

* can only be used for the last argument because otherwise it'd be too ambiguous

#

is it necessary for the languages to be last? it seems like better design for the user to have them before the text

nocturne canopy
#

i'm making it optional to specify the languages, letting the api autodetect the source and translate to english by default

cyan quail
#

hmmm

#

there are various converters you could use to accomplish this

nocturne canopy
#

also planning on making this work on replies

cyan quail
undone smelt
#

is there a way to condense these down into maybe just the group in the /commands menu?

cyan quail
nocturne canopy
#

not sending any arguments and instead doing .bot translate. if it's replying to a message translate that. if not, translate the message right above.

nocturne canopy
#

by the way, is there a way to alias different keywords to a single command?

cyan quail
#

i reckon you'd be most interested in typing.Optional, though it'd need some more work

cyan quail
#

being a list of different names the command can be invoked with

fiery tiger
#

@cyan quail why is that happening thinkCat

#

nvm

#

found why

rare ice
#

@fiery tiger Don’t ping support members randomly.

fiery tiger
#

ok

dawn gyro
#

How could I end a specific asyncio task with self.bot.loop.create_task

fervent cradle
#

im trying to send a message to 1 specific channel in my server I have this

            channel = client.get_channel(rcid) 
            await channel.send(embed=e)

but its not working for some reason

#

I got it to work

rigid sable
#

when I use an application context to access member.activities it returns none but works fine if it's a slash command. Both of them have the same code for the response part. Does anyone know why?

pseudo glen
#
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
#

🤔

pseudo glen
#

line 4

import discord
from discord.ext import commands
#

emmmm

#

i fixed it

#

(delete discord file)

heady skiff
#

Is there a list of input types for options somewhere

#

I'm tryna get the one for like a person input type

round rivet
#

passing most discord models will work, and ext.commands converters are supported

round rivet
heady skiff
#

where is that

round rivet
#

should be in docs

errant craneBOT
#

Couldn't find documentation for discord.SlashCommandOptionType.

heady skiff
#

thank you

#

how do I add that to an option

round rivet
#

pass it as the first parameter to discord.Option

heady skiff
#

so for like mentioning a user you'd put "discord.user" at the start of an option?

heady skiff
#

Ok so I put it as the start and now whenever I do that command it just sends back "This command is outdated, please try again in a few minutes"

#

nvm I think that was something else

tiny wagon
#

can i use bridge_command() in a slash sub command?

waxen whale
#

No we don’t support that

waxen whale
prisma flicker
#

Under what circumstances will a slash command id change?

dim flicker
#
Ignoring exception in on_message
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/discord/client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "/home/discord_bot/cogs/AutoEmoji.py", line 27, in on_message
    await message.add_reaction("![sad](https://cdn.discordapp.com/emojis/956291256781262848.webp?size=128 "sad")")
  File "/usr/local/lib/python3.8/dist-packages/discord/message.py", line 1476, in add_reaction
    await self._state.http.add_reaction(self.channel.id, self.id, emoji)
  File "/usr/local/lib/python3.8/dist-packages/discord/http.py", line 356, in request
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message

Why do I have this error for the third day already? Everything was fine before that. Maybe I should put a delay?

#
from discord.ext import commands
import discord


class AutoEmoji(commands.Cog):

    def __init__(self, bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_message(self, message):
        if message.channel.id == 1005138960487559308:
            await message.add_reaction("![yes](https://cdn.discordapp.com/emojis/956291282165203066.webp?size=128 "yes")")
        if message.channel.id == 1005138960487559308:
            await message.add_reaction("![flat](https://cdn.discordapp.com/emojis/956291270240792676.webp?size=128 "flat")")
        if message.channel.id == 1005138960487559308:
            await message.add_reaction("![sad](https://cdn.discordapp.com/emojis/956291256781262848.webp?size=128 "sad")")
        if message.channel.id == 1005084265156989039:
            await message.add_reaction("![yes](https://cdn.discordapp.com/emojis/956291282165203066.webp?size=128 "yes")")
        if message.channel.id == 1005084265156989039:
            await message.add_reaction("![flat](https://cdn.discordapp.com/emojis/956291270240792676.webp?size=128 "flat")")
        if message.channel.id == 1005084265156989039:
            await message.add_reaction("![sad](https://cdn.discordapp.com/emojis/956291256781262848.webp?size=128 "sad")")
        if message.channel.id == 514580675479863296:
            await message.add_reaction("![yes](https://cdn.discordapp.com/emojis/956291282165203066.webp?size=128 "yes")")
        if message.channel.id == 514580675479863296:
            await message.add_reaction("![sad](https://cdn.discordapp.com/emojis/956291256781262848.webp?size=128 "sad")")


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

code

waxen whale
#

Don’t post your question multiple times. You already asked that in another thread

hushed ledge
#

One message removed from a suspended account.

viral turtle
waxen whale
#

Yes you didn’t get an answer. Wait for it.
Stop arguing with me and stick to the #help-rules. Otherwise you’ll leave this server faster as you expect

round rivet
dim flicker
hushed ledge
viral turtle
#

any idea how I would be able to check if the bots missing permission with out using try and except

hushed ledge
viral turtle
hushed ledge
#

One message removed from a suspended account.

viral turtle
hushed ledge
#

One message removed from a suspended account.

tiny wagon
hushed ledge
viral turtle
hushed ledge
#

One message removed from a suspended account.

viral turtle
hushed ledge
#

One message removed from a suspended account.

viral turtle
waxen whale
hushed ledge
viral turtle
#

try using the code now

hushed ledge
#

One message removed from a suspended account.

tiny wagon
#

hmm

round rivet
#

would add a little check to wait until they're finished syncing to make sure the help command doesn't run before

#

otherwise it's mostly the same

fiery nebula
#

I'm still getting the 50027 error from editing interaction messages, but I think I saw that was fixed? Or am I mistaken

dry echo
#

10 hours ago, which version do you use?

fiery nebula
#

not a version from within 10 hours ago lol mb

dry echo
#

use the dev version

fiery nebula
#

remind me how i do that

dry echo
#

#library-updates first message in there

tiny wagon
#

nvm i make it if not

#

</name:id>

rigid sable
#

when I use an application context to access member.activities it returns none but works fine if it's a slash command. Both of them have the same code for the response part. Does anyone know why?

dusk burrow
#

why isnt there a stickers arguement in the send_message interaction response?

#

whereas in send there is

round rivet
#

sum1 forgor

muted pulsar
#

How do i stop bot from turning links inside a message.content into an embed below the message ?
From what i can tell, difference is message flag being 100 and not 000 but setting it to that value on every message just sounds like a recipe for a bad time later down the line

cursive dew
#

hello does anyone knows how to but a bio to the bot?

round rivet
#

set the application description in the dev portal

round rivet
cursive dew
#

indeed :D ty

round rivet
muted pulsar
round rivet
#

well your other alternative is suppressing embeds with message flags

muted pulsar
#

looking through source code, i might be able to manipulate via

muted pulsar
slate hull
#

it's my first time trying it so i'm sorry if i made a silly mistake

#

can somebody tell me what's wrong in the terminal?

#

I already installed the latest version of python 5 minutes ago

round rivet
#

can you run just python

slate hull
#

and then try to install pycord?

round rivet
#

well see if python works as opposed to python3

slate hull
#

it's opening microsoft store for some reason

round rivet
#

did you add python to path

slate hull
#

yes

cursive dew
#

anyone can help page system, i cant understand doc

round rivet
#

there would have been a little checkbox in the installer

slate hull
#

i pressed on both

round rivet
#

restart your terminal and try again

slate hull
#

ok

muted pulsar
#

python3 is for linux pepegas

#

chad windows users only need to use "python"

round rivet
#

it works on my windows machine

slate hull
#

bruh i was reading the guide

muted pulsar
#

(we're not allowed near hard commands)

slate hull
#

so does anybody know what i should do now?

muted pulsar
#

realistically i'd advise creating a venv

round rivet
#

just keep going through the guide

#

and use python instead of python3

muted pulsar
#

or you can directly install the packages like in the guide and make a main file for the bot

slate hull
#

it worked without the python3

cursive dew
#

Hello @round rivet do you know how pages works ?

round rivet
#

No

slate hull
#

or do i have to make main.py or something myself

round rivet
#

installation installs the library and that's it

muted pulsar
#

actually it also creates venv

round rivet
#

everything else is done yourself

muted pulsar
#

well, it advises to, at least

#

doesn't really matter now tho, lol

cursive dew
muted pulsar
#

apparently you can't directly set flags when sending the message via messangeable.send 💀
still looking for any advice on how to send messages without embeds but without replacing links with <link>

round rivet
#

ig it's not supported in the library

#

if you want you can make a pr to add support for it :p

muted pulsar
#

actually the documentation states that you can only set the supress embeds

#

so the only thing i need

#

i'll try to figure out how to properly add something like supress_embeds, but the implementation is bound to be horrible

slate hull
#

how do I start my bot in the terminal?

nocturne canopy
#

sorry to ask something that's probably been answered but i can't for the life of me find it. how do you get the id of the message that called the bot?

muted pulsar
slate hull
#

it isn't

#

but it didn't start

muted pulsar
#

what's the context

slate hull
#

i tried the hello code from the guide

muted pulsar
#

i'm pretty sure guide is a bit outdated last time i tried it

#

but can't say for sure. drop your codem pls

round rivet
#

and try again

muted pulsar
nocturne canopy
#

i'm using prefixed commands with @bot.command

muted pulsar
round rivet
slate hull
muted pulsar
#

^, had context menu in my mind when answering that

slate hull
#

i just installed dotenv pycord right now

#

i thought the problem is from that but my bot is still not online

round rivet
#

looks like you're missing the bot.run

#

should be at the bottom of your file if you reference the guide

slate hull
#

this is getting too confusing

muted pulsar
#

this is how i set it up, you might prefer this one

slate hull
#

I will switch the project to replit

#

vsc is a pain in the head

muted pulsar
#

@round rivet funnily enough, message.edit has supress option

#

💀

nocturne canopy
#

i use notepad++ only because i like working at night and notepad blinds me lmao

#

i'll write and indent the code myself thank you

nocturne canopy
#

too slow and complicated for monkey brain

young bone
#

It is not slow

nocturne canopy
#

it also doesn't recognize the installed packages for some reason

nocturne canopy
#

i just don't see the need to use vs and vsc if what i have works well enough

round rivet
slate hull
#

i tried disnake too, i have errors there too

#

seems like python isn't my thing

#

thanks for the help

muted pulsar
#

I can't seem to be able to edit attachments in a message - an image, to be exact, can't remove existing files.

#

Is this a problem on the part of my code or a result of File objects being single-use and discord being naughty ?

#

code in question

round rivet
#

I would add a check to that wait_for

muted pulsar
#

check if it contains attachments and get attachment list from that ?

round rivet
#

well firstly check who sent the message and where

#

otherwise ittl take in any message from anywhere

muted pulsar
#

oh, fair

round rivet
#

so what exactly is happening

#

are the attachments changing?

muted pulsar
#

but the message still keeps both the images

#

So either there's something seriously wrong with my code

#

or it's discord limitations

#

and the only one who can reasonably answer it is somebody that understands the discord API and its limitations better than i do

round rivet
#

maybe something wrong with the library

#

although when I PRed it it worked fine

tiny wagon
#

how to change the button label in calllback?

full basin
#

button.label = "something"

tiny wagon
#

not working

full basin
#

then just edit the view

tiny wagon
#

hm

full basin
#

?tag idw

obtuse juncoBOT
#

Saying it doesn't work or asking what's wrong with this code? is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.

tiny wagon
#

how can i use formatted strings in decorators?

muted pulsar
#

just in case you wanted to know the reason

tidal prawn
#

any idea how to fix this in vsc?

#

trying to install pycord using terminal in vsc, this error keeps appearing.

rare ice
nocturne canopy
#

this should return true if the command was sent while replying to a message, right?

if ctx.message.reference is not None:
cold hamlet
#

What does invisible do in deferred responses? the docs don't seem very clear

nocturne canopy
#

messages only reference something if they're replies, crosspost by a followed channel, or pins, but only replies can send a message at the same time, so in theory it should run only on user messages

short grail
#

Does anybody know if it's possible to send a modal using a followup webhook (or similar) instead of using the interaction.response object? Either because it's already been responded to or because of the 3 second timeout

full basin
#

Unless you attach a button in the follow up response

rare ice
short grail
#

Yeah I figured ... sad. Thanks

round rivet
#

therefore making the response 'invisible'

#

because it appears to just stop the loading animation

tidal prawn
#

this is in my appdata

nocturne canopy
rare ice
nocturne canopy
#

and in my example it gets the id of the message the user replied to, right?

cold hamlet
tidal prawn
#

i still cant install pycord on my com smh-

#

this is happening when im trying to install pycord

nocturne canopy
#

use the regular command line outside of python

#

just open cmd and type pip install -U py-cord --pre

tidal prawn
#

still doesnt work

nocturne canopy
#

anyone know if channel.history(limit=3) would return 2 or 3 messages?

#

i'm talking if limit is the maximum or the ceiling

proud pagoda
#

I believe it would be 3

#

that's what it sounds like here

tidal prawn
#

man why does pycord just hate me-

#

its still not working for some reason

proud pagoda
tidal prawn
#

doesnt work?

#

module 'discord' has no attribute 'bot'

proud pagoda
#

bot should be capitalized

neat temple
#

I have a quick question. How do I disable slash commands?

dim flicker
#
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\����\Desktop\���� ��� �����\Caramel\cogs\AutoEmoji.py", line 31, in on_message
    except discord.errors.NotFound(response, message) as e:
NameError: name 'response' is not defined

What's wrong with him?

#
    @commands.Cog.listener()
    async def on_message(self, message):
        await asyncio.sleep(5)
        try:
            if message.channel.id == 1002208210809266247:
                await message.add_reaction("🔱")
            if message.channel.id == 1002208210809266247:
                await message.add_reaction("😢")
        except discord.errors.NotFound(response, message) as e:
            print(e)
neat temple
round rivet
#

no spoonfeed

neat temple
#

The problem was that you dont need to call it as a function

#

Just the type of error raised

nocturne canopy
neat temple
copper dew
#

U could set the command to only load on your private guild, and that way u have access to the cmd, while others dont

nocturne canopy
#

you can disable slash commands for @еveryone but if other roles have the permission you'll have to do the same for those

neat temple
#

Okay thanks!

nocturne canopy
#

actually yeah disabling slash commands from a bot to all servers but one seems like the better option, doesn't stop users from using other bots' slash commands

fervent cradle
#
from discord.ext import commands
from Utils import embeds

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

    @commands.command()
    @commands.has_permissions(administrator=True)
    @commands.guild_only()
    async def clear(self, ctx, amount = 0):
        if amount <= 0:
            await ctx.reply(embed=embeds.default_description("Invalid amount of messages, senpai~"))
            return
        await ctx.channel.purge(limit=amount)
        await ctx.reply(embed=embeds.default_description(f"{amount} messages were deleted with success!"))
    
    @clear.error()
    async def clear_error(error, ctx):
        await ctx.reply(content=error, embed=embeds.default_description("An error has been found, sorry senpai..."))

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

It says the clear command doesn't exist even tho it is being loaded

muted pulsar
#

what's the best approach to making consistent has_persmission checks but also excluding the owner from them ?
since checks are AND operator and not OR, i would need to rewrite has_permissions in the module to include part from is_owner, right ?

fervent cradle
#

Loaded cog Commands.Admin.clear
Loaded cog Commands.Testing.teste

full basin
#

Extensions store errors if they raise some

nocturne canopy
#

is the triple quoted description next to a command's decorator required for it to work or can i remove it?

full basin
#

Add store=False to your load_extension function

nocturne canopy
#
@bot.command()
async def translate(ctx: commands.Context, input = ".", outlang = "en", inlang = "auto"):
    """Translate"""

the Translate part

full basin
#

Ah

#

That's used for functions descriptions. You don't need it, won't affect the command

fervent cradle
#

Is create_group class possible in cogs? 💀

errant craneBOT
#

Here's the slash cog groups example.

fervent cradle
#

ok ty @prisma flicker

solemn spire
#

does on_message trigger before adding a message to cached_messages?

#

also how many messages will the bot cache?

fervent cradle
#

using the on_member_join(member) can I do on_member_join(member, guild) to get server information

solemn spire
#

no

#

you do member.guild

cyan quail
#

by default the message cache is capped at 1000, but you can modify this by setting the max_messages kwarg when creating your bot object

solemn spire
#

ok

naive remnant
#

How can I make the bot get all the IDs of the servers he's in it

nocturne canopy
#

when should i use get_message or fetch_message?

proud pagoda
proud pagoda
slate hull
#

is the pycord guide on the site outdated?

hearty mauve
#

What would i use to make something like this, if i use title and url how would i make it bold lettering

prisma flicker
#

assuming you know the message (should) exist

#

if you're not sure I would just use fetch

fervent cradle
hushed ledge
#

One message removed from a suspended account.

prisma flicker
naive remnant
#

How make an option in Slash command optional

hushed ledge
hearty mauve
#

@prisma flicker possibly

naive remnant
#

[link](paste link here)

hearty mauve
#

What?

#

No like as an embed

naive remnant
#

Yes

prisma flicker
hearty mauve
#

What would i use

naive remnant
#

It will work in an embed

prisma flicker
hearty mauve
prisma flicker
#

#help-rules

hearty mauve
#

I am trying to figure out what parts of the embed do i use

naive remnant
hearty mauve
#

No

naive remnant
#

Ok?

hearty mauve
#

Like i want to make something like that embed

naive remnant
#

A clickable word

hearty mauve
#

Not a link embed

hearty mauve
hushed ledge
naive remnant
#

How make an option in Slash command optional

hearty mauve
#

I want to know how to make my embed look like that because its ovb not a title and desc

hearty mauve
#

Thats a confusing question

prisma flicker
fervent cradle
hearty mauve
#

What parts of the embed do i use to make my embed look like this

prisma flicker
hearty mauve
#

Im confused

#

I cant leave a title empty tho

#

That is ovb not a desc its too bold

#

By bold i mean more color

prisma flicker
#

you can put bold text in the description

#

color?

wooden zenith
#

hey does anyone know how like when you click a button a modal will pop up?

hearty mauve
#

Eh dont worry about it

wooden zenith
#

instead of having to do a diff command

hearty mauve
prisma flicker
#

bruh wdym don't worry about it

hearty mauve
wooden zenith
#

hey does anyone know how like when you click a button a modal will pop up?

hearty mauve
prisma flicker
hearty mauve
#

Oh

#

Ok

wooden zenith
#

yo @ jb

#

@prisma flicker

#

dyk know how like when you click a button a modal will pop up?

prisma flicker
#

s!jsk py py embed = discord.Embed() embed.description="**[Hello](https://google.com)**\n\nHere is some normal text" await _ctx.send(embed=embed)

deft pantherBOT
#

Hello

Here is some normal text

prisma flicker
prisma flicker
prisma flicker
prisma flicker
wooden zenith
#

when i do it everything below it turns orange

#

like all fo the code below where i put that in

prisma flicker
#

I have no idea what you're saying

wooden zenith
#

im so confused rn

proud pagoda
fervent cradle
#

<@id> isn’t pinging me

prisma flicker
#

yes

fervent cradle
#

When I have my bot send it

proud pagoda
prisma flicker
#

yes

proud pagoda
#

Oh alright for a sec I was thinking that Jishaku had made it so you didn't to use dpy

prisma flicker
#

s!jsk py py await _ctx.send(discord.__version__)

deft pantherBOT
#

2.0.1

prisma flicker
#

oh no it's pycord

proud pagoda
#

Huh

prisma flicker
#

sorry I misread what you said

#

?tag codeblock

obtuse juncoBOT
#

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

That makes reading code in Discord a lot easier:

print("This is an example.")
prisma flicker
#

also if you have that much code please use a paste site

#

?tag paste

obtuse juncoBOT
prisma flicker
wooden zenith
prisma flicker
wooden zenith
prisma flicker
#

but I heard newer versions work with pycord now

wooden zenith
#

can u look at it and tell me where i would put this in

prisma flicker
#

why do you have two bots

wooden zenith
#

i dont

prisma flicker
#

line 8 and 10

wooden zenith
#

oh wait

#

my fault i didnt delete it

#

myb i was testing something

prisma flicker
#

it's covered in the docs

proud pagoda
prisma flicker
#

but it still works shrug

#

I think 2.3.2 requires 1.7 though

#

I don't remember, I just know this works 😄

proud pagoda
wooden zenith
errant craneBOT
#

Here's the modal dialogs example.

wooden zenith
#

i have all that

prisma flicker
#

then you have a modal from a button

fiery tiger
#

Sorry i have a question that's a bit out of pycord help support or in general bot supports

#

what's this tax form review about?

#

im using W-8IMY because that's why recommended from the questionnaire

#

do i just use W8IMY pdf file?

#

that's the only thing they make me download

prisma flicker
#

it tells discord how much tax to withhold

#

I have no idea if W-8IMY is the right form, I'm not a lawyer or accountant

fiery tiger
#

😂

nocturne canopy
#
input = await ctx.channel.fetch_message(message.id)
await ctx.send(input.content)

how could i change this such that input alone contains what would be sent?

smoky forge
iron halo
#

i have a slash command that people are only meant to be able to do once, and it works, but when discord lags and you spam the command it lets u do it like 50 times and idk how to get aroundt hat

iron halo
#

not a cooldown

#

just stored in a dict whether they did it or not

cyan quail
#

and im pretty sure you can't even spam it that fast

iron halo
#

its just if ctx.author.id in dict: return do whatever

#

obv indented

#

it never happened before but someone spammed it and managed to do it like 6 times

cyan quail
#

i feel there's something missing here... if it's a simple dict then you wouldn't be running into a race condition like that

iron halo
#

i thought it might be because the command is being ran a 2nd time before it can add them to the dict and not let them do it again

cyan quail
#

like

users = {}
@slash_command(...)
async def command(ctx):
  if users.get(ctx.author.id): return await ctx.respond(...)
  users[ctx.author.id] = ...```there's clearly no room here for it to be abused, unless you're somehow using different dicts every time the command runs
#

like... loading it from a json

iron halo
#

i do load it from a json but not when command is ran

cyan quail
#

i guess that in itself isn't bad

#

what's your actual full code here

iron halo
#

gimme a sec

#

its a bit messy bc i made it ages ago but

#

i cant even send it

#

hold on where can i upload it

cyan quail
#

use hastebin or something i guess

iron halo
#

theres other stuff

#

but it should have been deleted from marketData to not let them do it again

#

but they managed to spam it

cyan quail
#

well your issue is that you delete from marketdata at the end of the command

#

why don't you just add a cooldown to it

iron halo
#

true

#

ill just delete before and cooldown then

#

ty

cyan quail
#

allgood

smoky forge
#

your case would work much better with a cooldown

iron halo
#

yea

#

i think it was bc of that bug on mobile where sometimes when you spam send it sends it like 10 times

#

so it let them do it like 10 other times before it stopped them

smoky forge
#

does it have to be run once per user, once per guild or

iron halo
#

i was just simplifying it bc it was too long to explain once you buy a card you cant buy it again bllah blah blah

smoky forge
#

so per user

iron halo
#

well per card

smoky forge
#

so once a user buys a card the rest of the users can't

iron halo
#

yea

#

but i gave it to them and then stopped them from buying it

#

so i guess if it was ran at the same time it would give it the 2nd time before deleting it the 1st time

delicate jolt
#

Can I use slash commands and normal at the same time?

errant craneBOT
#

Here's the bridge commands example.

delicate jolt
#

ty

young bone
#

o/

delicate jolt
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'is_app'

young bone
#

?

delicate jolt
#

In the example

#

Oh

#

Nevermind

tidal prawn
#

any idea how to fix this?

smoky forge
#

Does it make a difference to run an async database on a different loop as the bot?

smoky forge
obtuse juncoBOT
#
discord.Client # just for events
discord.Bot # events + slash/user/msg commands
commands.Bot # above + prefixed commands
tidal prawn
smoky forge
tidal prawn
#

pycord.

smoky forge
#

could you check

tidal prawn
#

alr lemme try

smoky forge
#

do pip freeze

tidal prawn
#

it gives stufff like this

young bone
#

can you show the pip list?

smoky forge
#

look for py-cord

young bone
#

do pip show py-cord

tidal prawn
young bone
#

and discord?

tidal prawn
#

no such package as discord

#

any idea wats happening-

young bone
#

can you show the pip list?

tidal prawn
#

ok

#

as in the one from pip freeze?

young bone
#

no

#

pip list

tidal prawn
young bone
#

I cannot see py-cord

#

at the screenshots

tidal prawn
#

oh

#

already installed it though-

#

i installed it again, its now here

lilac turret
#

@tidal prawn you appear to be using replit

#

?tag replit

obtuse juncoBOT
lilac turret
#

This might help

prisma flicker
lilac turret
#

Scroll up, someone told them to do that already

short coyote
#

Where might I find guidance on slash commands in cogs?

prisma flicker
errant craneBOT
#

Here's the slash cog example.

young bone
#

@short coyote

prisma flicker
#

they just used the client tag

short coyote
#

Thank ya sir

#

I’ve been able to get slash commands working in the main.py file but not yet in cogs so I appreciate the assistance

wooden zenith
#

Traceback (most recent call last):
File "main.py", line 7, in <module>
bot = discord.Bot(debug_guilds=[1012074059976155137])
AttributeError: module 'discord' has no attribute 'Bot

how to fix

wooden zenith
#

I tried to install it

#

But idk if I did it right agisn

silver moat
#

?tag install

obtuse juncoBOT
#
  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

2a. Install py-cord
python -m pip install py-cord

2b. Update py-cord
python pip install -U 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

fervent cradle
#
@bot.event
async def on_message(message):
    if message.channel.id == SOURCE_CHANNEL:
        if USE_WEBHOOK:
            requests.post(WEBHOOK_URL, json={"content": message.content})
#

what is wrong here? nothing gets sent

prisma flicker
#

do you have message content intent?

fervent cradle
#

yes

#

it can see message content if i print message

prisma flicker
#

can you print(message.channel.id, SOURCE_CHANNEL, message.channel.id == SOURCE_CHANNEL, USE_WEBHOOK)

#

at the top

frosty bramble
#

anyone know what this means?

fervent cradle
#

fsdfsdfds dfssfddfs True True

fervent cradle
#

but they are the same

prisma flicker
frosty bramble
#

so i came here for help

prisma flicker
obtuse juncoBOT
#
prisma flicker
#

try running the post by itself, like just in a python shell

fervent cradle
#

that works

#

thats why im confused

prisma flicker
#

then I don't know what to tell you

#

maybe use aiohttp instead

fervent cradle
# prisma flicker then I don't know what to tell you
@bot.event
async def on_message(message):
    if message.channel.id == SOURCE_CHANNEL:
        if USE_WEBHOOK:
            async with aiohttp.ClientSession() as session:
                async with session.post(WEBHOOK_URL, json={"content": message.content}) as resp:
                    print(resp.status)
#

is this wrong? gives a 401 status code

prisma flicker
#

sounds like you're unauthorized

#

is this a discord webhook?

fervent cradle
#

yes

fervent cradle
#

i cannot add a bot to the destination server

#

only webhook

fervent cradle
#

didnt know it supported that

prisma flicker
#

sweet

tidal prawn
#

it says name commands is not defined

prisma flicker
tidal prawn
#

i already imported discord/

prisma flicker
#

from discord.ext import commands

tidal prawn
#

oh it needs a command prefix how'd u do that

prisma flicker
#

so give it a command prefix

tidal prawn
#

but isnt it supposed to be slash commands

prisma flicker
#

it's both

tidal prawn
#

oh.

#

whats this error-

#
from discord.ext import commands

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

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

@bot.event
async def on_ready():
    print(f"We have logged in as {bot.user}")

bot.run("my token(yes i did change it)")

this is my code

prisma flicker
#

you just leaked your token

#

and that's not the full error

tidal prawn
#

oh

#

its much longer for some reason

tidal prawn
#

has something like this

prisma flicker
#

you're being rate limited

tidal prawn
#

oh.

#

so i gotta wait?

prisma flicker
#

Yep

tidal prawn
#

when will it stop

#

it has been so long, and i ran it, and it still doesnt work

near hollow
#

If that is cloudflare ratelimit then its a ip rate limit, they usually last a bit (few hours I think)

prisma flicker
#

Shared hosts like that are always going to have rate limits

smoky forge
#

?tag norepl

obtuse juncoBOT
#

Why NOT to use Repl as a hosting platform

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

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

IMPORTATNT

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

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

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

fervent cradle
#

is there a way to make a bot say something in the channel it joined in when it joins

fervent cradle
prisma flicker
#

You would be just have to get a channel from the guild and then send a message to it

fervent cradle
#
@bot.event
async def on_message(message):
    if message.channel.id == SOURCE_CHANNEL:
        if USE_WEBHOOK:
            if message.embeds != []:
                await bot.send_webhook(WEBHOOK_URL, content=message.content, embeds=message.embeds, avatar_url=message.author.avatar_url, username=message.author.name)
#

is this code correct?

#

the sending embeds part

prisma flicker
#

I don't think it'll work if embeds or content are None

#

Or maybe only if both are None?

tidal prawn
#

any idea why bot object has no attribute 'slash_command' happens?
im using bot = command.Bot

lilac turret
#

@tidal prawn are you positive that you don't have discord.py installed?

prisma flicker
errant craneBOT
#

Here's the new member example.

fervent cradle
#

How many inputtext fields may a modal have?

tidal prawn
#

and my python isnt working on vsc for some reason

errant craneBOT
#

Here's the slash options example.

gentle flare
#

Hey how can I get a channel with a mention like #channel?

gentle flare
#

But where can I find it. Can you send me the link?

dry echo
smoky forge
#

Does it make a difference to run an async database on a different loop as the bot?

loud holly
#

are there a list of overrides for issuing perms for creating text channels? I'm trying to find it, but 0 luck in finding them

cyan quail
loud holly
#

for the overwrites parameters, are there a list of stuff that I can find so ik what exactly to pass in into the overwrites

cyan quail
#

overwrites is a dict that should map an Object such as Role or User to a PermissionOverwrite object

fervent cradle
#

Do I need the guild indent to check if a user has a specific permission?

loud holly
cyan quail
cyan quail
fervent cradle
#

for ctx.author.guild_permissions.administrator ?

cyan quail
#

idk never tested before

#

give it a try

fervent cradle
#

cause this, without any indents gives None

#
@bot.slash_command(name="blacklist", description="blacklist a user")
async def blacklist(ctx, *, user: Option(discord.User, "blacklist any user", required=True)):
    await ctx.defer()
    await conn.fetch('CREATE TABLE IF NOT EXISTS blacklist_mfs(userid BIGINT NOT NULL PRIMARY KEY, username VARCHAR(50) NOT NULL)')
    check = await conn.fetch(f'SELECT EXISTS(SELECT 1 FROM blacklist_mfs WHERE userid = {user.id})')
    if check == True:
        await ctx.respond('User is already blacklisted!')
    else:
        await conn.fetch(f"INSERT INTO blacklist_mfs(userid, username) VALUES('{user.id}', '{user.name}')")
        await ctx.respond(f'Successfully blacklisted {user}!')
#

hey guys i made a command, but the check doesnt work

#

what is the problem?

#

i cant find any solutions for it anywhere on the net

cyan quail
#

well

#

what does the first conn.fetch actually return

#

and is the second conn.fetch actually applying to the db

fervent cradle
#

reading the discord docs for guild members, it doesnt mention anything about user permissions

cyan quail
#

the problem with it is how cache works

fervent cradle
cyan quail
#

without the intents, members aren't cached so they don't have their permissions set properly

#

you'd have to fetch the member separately

fervent cradle
#

author = await self.client.fetcher.fetch_user(ctx.author.id)

#

is this correct?

fervent cradle
#

try member: discord.Member = ctx.author

round rivet
#

default it to None and implement extra logic inside the command

sinful osprey
#

The following code is a really basic example of the issue I'm having.
Is it intended that the first respond (send_message) does not mention the user, while every respond after that (followup) does? I tried setting allowed_mentions but that doesn't help either.
If I remove the defer it does mention, however that ends up breaking the command because it ends up taking longer to process. ```py
@slash_command(name='test', description='...')
async def _test(self, ctx: discord.ApplicationContext):
await ctx.defer()
await ctx.respond(ctx.author.mention) # doesn't mention
await ctx.respond(ctx.author.mention) # does mention

fervent cradle
#
        for i in self.client.guilds:
            guild = self.client.get_guild(i.id)
            embed.add_field(name=guild.name, value=i.id, inline=False)

guild name is still none. I have no indents (i dont think I need them)

round rivet
#

you'd need guild intents

#

At the very least

fervent cradle
fervent cradle
real warren
#

Does anyone knows how to import commands from files, for example i have in codes.py, a slash command group called codes, and i want to import it into main.py

#

got it

round rivet
real warren
naive remnant
#

My code is working well but I always have unknown interaction

#

Error

fervent cradle
#

Hello
Does anyone know how to show a slash command for specific roles/users

fervent cradle
#

?

cyan quail
fervent cradle
cyan quail
#

server settings > integrations > select your bot

#

you can't do it by code anymore

fervent cradle
cyan quail
#

it now requires a bearer token by discord, meaning authorisation with your user account; it can't be done with just a bot token

fervent cradle
#

I don't mind doing that. How can I?

cyan quail
#

as in, you literally can't do it with a bot

fervent cradle
#

I mean, it says "not synced" so there should be a way to sync with the bot

#

discord.js has it pretty sure

cyan quail
#

the way to sync it is to literally click there and hit sync

fervent cradle
#

i didnt mean that

#

dont mind it
could you tell how to do it (set default hiding setting)

cyan quail
#

look, i'm telling you it's not possible to do via the api

#

oh defaults

fervent cradle
#

like preset it to show for only admins, or only a specific userid

cyan quail
fervent cradle
cyan quail
#

and you can't do it per role or user; this relies on them having a specific discord.Permission

#

remove the decorator > restart > add it back > restart

fervent cradle
#

ah, is there a way to show it on only a specific guild? Does (img) work to do that?

cyan quail
#

guilds_ids is a list of guild ids (integers) to register the command to

fervent cradle
muted pulsar
#

Can't seem to register an extension discord.errors.ExtensionFailed: Extension 'testing' raised an error: AttributeError: 'Bot' object has no attribute 'add_command'

#

were the docs not updated ?

#

or am i not allowed to load the extension before the bot runs ? current setup looks like this

fervent cradle
#
        try:
            ...
        except pycord.RateLimited:
            ...
```Would this work?
cyan quail
#

that example is for using discord.ext.commands.Bot, not discord.Bot

gentle flare
#

Hey I want to make a command where you need to give a channel id.
But I dont want to force the user to enable the developer settings.
I cant find it in the docs. How can I get the channel from this #channel

fervent cradle
#

just take a channel mention and convert it to id?

gentle flare
#

But hoe do I make a channel mention

#

I searched on google but wont find an awnser

fervent cradle
#

.

cyan quail
#

where you need to give a channel id
doesn't that imply you have to have developer settings enabled?
anyway if it's a slash command just use the discord.TextChannel option type

cyan quail
fervent cradle
cyan quail
#

you'd have to check the text of it to see

fervent cradle
muted pulsar
#

as an argument

cyan quail
#

because it isn't really an error, the library warns you and automatically handles ratelimits

fervent cradle
#

i wanna be-able to halt process's if there's a warning

cyan quail
#

i guess you could check bot.is_ws_ratelimited

fervent cradle
#

they do

cyan quail
#

good for them i guess

gentle flare
fervent cradle
#

I just dont wanna be bothered to check error messages
Its also forcing me to use bad practices PogBruh

cyan quail
gentle flare
#

ok thx

cyan quail
#

and no one's forcing you to run into ratelimits

fervent cradle
#

I dident say the ratelimit was forcing me to use bad practice i said the way i have to check for ratelimits is causing / forcing bad practices by not having a built-in method

rugged lantern
#

make your own method then

rotund reef
#

What's wrong here? (in a cog)

    async def verify(self, context: Context):
        guild = self.get_guild(context.guild_id)
loud holly
#
await self.User_Ticket_Channel.set_permissions(interaction.user,overwrites=discord.PermissionOverwrite(send_messages=True))

After a user clicks the claim button, I'm trying to change the channel's permission to allow the user to send messages but it's coming as invalid permission

cyan quail
muted pulsar
#

Do i get it right: if i want to use extensions and cogs, i need to use ext.commands.bot instead of discord.bot, and the former doesn't implicitly convert @bot.command on a function to a slash command ?
So i need to replace every instance of @bot.command to @bot.slash_commands ?

fervent cradle
#

was the event when bot joins server

#

i fogor

prisma flicker
#

on_guild_join

fervent cradle
#

thanks

cyan quail
#

you can use cogs without ext.commands actually

#

but you need ext.commands.Bot for prefix commands

prisma flicker
#

Your ide should have a find/replace tool

#

Or there's always sed

muted pulsar
#

yeah, but i don't like how it looks in the code

prisma flicker
#

If you're in a cog it would be commands.slash_command

muted pulsar
#

@command is so much better than @safe inlet_command

cyan quail
#

GuraShrug it has to be explicit

muted pulsar
#

i was trying to implement cogs as a way to separate functions into several files, but that means i need to pass in ext.commands.bot instead of the one i was using before

prisma flicker
#

There's also bridge

cyan quail
#

no, as i said cogs work without ext.commands.Bot

muted pulsar
#

so i'd need to use the same syntax

prisma flicker
muted pulsar
cyan quail
#

wdym

rotund reef
prisma flicker
#

Either way don't cross post

#

#help-rules

muted pulsar
real warren
#

how to use wait_for in dm?

real warren
prisma flicker
real warren
#

I'm using wait_for but it doesn't work in dm

cyan quail
real warren
# cyan quail can you show the code? it works fine in dms

async def create(ctx):
member = ctx.user
dmChannel = await member.create_dm()
await dmChannel.send("يرجى كتابة اسمك أو اسما مستعارا")
name = await client.wait_for("message", check = lambda message: message.author == ctx.author)

cyan quail
#

try comparing message.author.id and ctx.author.id

#

also you don't need create_dm, you can directly do member.send

real warren
#

can u send me ur code to try it

fervent cradle
muted pulsar
#

this is what i use for my case

real warren
gritty pond
#

How can i save {} variables in json file?

I make it, but i've got this:

fervent cradle
#

how can i make unclickable option after select? whyy

fervent cradle
#

but it also turns off the menu completely

#

🤨

dry echo
#

this one

#

i guess you cant

fervent cradle
fervent cradle
#
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: InvalidSchema: No connection adapters were found for 

what's this?

coral kindle
#

what's the event when user join's tthe guild

fervent cradle
meager mica
#

hey so my modal call back isnt being called heres my code

#
class MyModal(discord.ui.Modal):
    def __init__(self, *args, **kwargs) -> None:
        print('ran')
        super().__init__(
            discord.ui.InputText(
                label="Minecraft username",
                placeholder="",
            ),
            *args,
            **kwargs,
        )
    async def modal_callback(self, interaction: discord.Interaction):
        print("Modal callback:")
        await interaction.response.send_message(content='hi')
``` the ran gets printed but not modal callback
#

when i push submit

#

it gets sent when buton pushedpy @discord.ui.button(label="Join event", style=discord.ButtonStyle.green, disabled=False) async def confirm_callback(self, button: discord.ui.Button, interaction: discord.Interaction): self.database.insert_one(document={'user': interaction.user.id, 'linked': False}) print(f'button clicked by: {interaction.user}') modal=MyModal(title="Link to Minecraft") await interaction.response.send_modal(modal)

proud pagoda
errant craneBOT
#

Here's the new member example.

meager mica
#

oh it matters? i figuredit just picked first func

proud pagoda
#

No, it has to be named callback

meager mica
#

does buttons have to be named confirm_callback

proud pagoda
fervent cradle
#

What's this warning about?

coral kindle
#
@bot.event
async def on_member_join(member: discord.Member, guild_ids=[767773860481073222]):
    print("test")
    guild = member.guild
    member = discord.Member
    #
    role = discord.utils.get(member.guild.roles, id='767773860543987744')
    await member.add_roles(role)
    channel = discord.utils.get(member.guild.text_channels, id='1012417901812269186')
    
    emb = discord.Embed(title=" ", 
                        description=f":7_: {member}")
    await channel.send(embed=emb)```
#

why it doesn't work

#

it does not event print "test" to console

hushed ledge
#

One message removed from a suspended account.

dry echo
coral kindle
#

??

dry echo
#

??

coral kindle
#

How can i fix this

dry echo
#

learn python

coral kindle
#

Im learning

dry echo
#

why do you do member = discord.Member???

fervent cradle
coral kindle
dry echo
#

then your friend dumb

coral kindle
#

yea

fervent cradle
proud pagoda
meager mica
#

o ok

hushed ledge
fervent cradle
#

np

dry echo
#

@coral kindle learn python before doing pycord thanks

coral kindle
cyan quail
#

change the edit message to a regular message edit (interaction.edit_original_message) and then use interaction.response.send_modal

#

probably

#

idk might work in theory

cyan quail
#

hmmm

#

what about self.view.message.edit

#

hmmmmmmmmmmmmmmmmmmmmmmmmmmm idk

#

knew it

#

it probably could but i'd need more context

#

you basically just need some way to get the original message object to your callback

#

because you can still do a regular message edit before responding

#

can you show more of the code

#

just the current class then i suppose?

#

...if possible

#

if anything, i could try work with just how the original message/view is sent

#

too many items in your view

#

need to use ActionRows for more than 5

chrome skiff
#

yeah

cyan quail
#

though tbh at that point i'd prefer to use a dropdown

#

looks neater to me but personal preference i guess

dry echo
cyan quail
#

you can try it, but if im not mistaken this only adds it for respond, not edit_message

#

nono

#

try await self.view.message.edit again

#

but there's a chance it still won't work

#

this that we tried before

#

did you update?

prisma flicker
#

edit is a method

#

you need to pass in content

#

well yeah that's what Nelo was saying

#

message is None

#

yes

#

you can set self.message manually

#

self.message = interaction.original_message() or whatever

wooden zenith
#

Traceback (most recent call last):
File "main.py", line 99, in <module>
bot.run(TOKEN)
File "/home/runner/koolaidman-1/venv/lib/python3.8/site-packages/discord/client.py", line 715, in run
return future.result()
File "/home/runner/koolaidman-1/venv/lib/python3.8/site-packages/discord/client.py", line 694, in runner
await self.start(*args, **kwargs)
File "/home/runner/koolaidman-1/venv/lib/python3.8/site-packages/discord/client.py", line 657, in start
await self.login(token)
File "/home/runner/koolaidman-1/venv/lib/python3.8/site-packages/discord/client.py", line 510, in login
raise TypeError(f"token must be of type str, not {token.class.name}")
TypeError: token must be of type str, not NoneType

#

how to fix

dreamy mauve
#

persistent views are not working for me. even when I pass a message_id argument to add_view()

View Class

class GiveawayView(discord.ui.View):
    def __init__(self, id):
        super().__init__(timeout=None)
        button = discord.ui.Button(label="Enter", style=discord.ButtonStyle.blurple, custom_id=f"persistent_view:{id}")
        
        async def callback(interaction: discord.Interaction):
            modal = GiveawayModal(id)
            await interaction.response.send_modal(modal)
            
            # modal.childre
        
        button.callback = callback
        self.add_item(button)

Adding view on bot start:

@commands.Cog.listener()
    async def on_ready(self):
        giveaways = json.load(open("bot_config/giveaways.json", "r"))
        
        for msg_id in giveaways:
            view = GiveawayView(int(msg_id))
            self.bot.add_view(view, int(msg_id))
prisma flicker
#

add_view just takes in the view

proud pagoda
wooden zenith
proud pagoda
#

Send code then

wooden zenith
#

hold on wait

#

i have somthing else i need help w

#

so i have another bot with a /ban command i created and i want the message to pop up in a embed thing not just like a regualr messgae

#

like the results of the ban

#

so how do i put it in embed

proud pagoda
wooden zenith
#

Yea but like it confuses me where I put the code in so where the results are embed

#

Like do I put a strip of code or sum idk

proud pagoda
#

You can use an online embed builder if your confused on what attrs change what on the embed

fast totem
#

new feature??

fervent cradle
#

why does this not work sometimes in other servers
![database](https://cdn.discordapp.com/emojis/1012353979461677147.webp?size=128 "database")

fierce elm
#

Can someone give me an example on using @before_invoke and @after_invoke to open a sqlalchemy connection?
What I have so far

db.py

async def db_engine():
    engine = create_async_engine(
        f'{dbcfg.proto}://{dbcfg.user}:{dbcfg.password}@{dbcfg.host}/{dbcfg.database}?charset=utf8mb4')
    return engine
tiny wagon
#
original = await interaction.original_message()
embed = original.embeds[0].copy()
embed.set_field_at(1, name='Current bidder',
                   value=f"{interaction.user.mention} ({interaction.user.name}#{interaction.user.discriminator})",
                   inline=True)
embed.set_field_at(2, name='Current bid', value='test', inline=True)

await interaction.followup.send(content=None, embed=embed, view=self)

in button callback, error: unknown webhook

gritty pond
#

How can i save {} variables in json file?

I make it, but i've got this:

dry echo
#

show code

gritty pond
#
    def say(self,name: str, sub_module: Optional[str] = None):
        with open(f'data/lang/{self.lang}.json', 'r') as f:
            config = json.load(f)
        if sub_module is not None:
            return config[f'{self.module}'][f'{sub_module}'][f'{name}']
        else:
            return config[f'{self.module}'][f'{name}']```

and after:

```py
await ctx.respond(f"{lang.say(name='mute')}", ephemeral = True)
#
"mute": "{ctx.author} - admin"
dry echo
#

where do you store the values????

gritty pond
devout nimbus
#

was selfbot support removed from pycord?

round rivet
#

yes

#

we do not support selfbots

vital blade
#

either d.py 2.0 doesnt

round rivet
#

nothing to be sad about

vital blade
#

selfbots are fun sometimes

dry echo
vital blade
#

not rlly

#

i tried 2 times just for educational purposes. streaming status nothing that would abuse discord api

dry echo
round rivet
#

whether you do anything with it or not

vital blade
#

after i used that i figured out

dry echo
#

Ignorantia legis non excusat

grim canopy
#
Traceback (most recent call last):
  File "/home/catto/Documents/Network-Bot-Beta/bot.py", line 9, in <module>
    from _global import (
  File "/home/catto/Documents/Network-Bot-Beta/_global.py", line 17, in <module>
    from cogs.n import NetworkGroup
  File "/home/catto/Documents/Network-Bot-Beta/cogs/n.py", line 19, in <module>
    class Network(commands.Cog):
  File "/home/catto/.local/lib/python3.10/site-packages/discord/cog.py", line 238, in __new__
    new_cls.__cog_commands__ = tuple(c._update_copy(cmd_attrs) for c in new_cls.__cog_commands__)  # type: ignore
  File "/home/catto/.local/lib/python3.10/site-packages/discord/cog.py", line 238, in <genexpr>
    new_cls.__cog_commands__ = tuple(c._update_copy(cmd_attrs) for c in new_cls.__cog_commands__)  # type: ignore
  File "/home/catto/.local/lib/python3.10/site-packages/discord/commands/core.py", line 1263, in _update_copy
    return self.copy()
  File "/home/catto/.local/lib/python3.10/site-packages/discord/commands/core.py", line 1231, in copy
    ret = self.__class__(
TypeError: BridgeSlashGroup.__init__() missing 1 required positional argument: 'callback'
#

I believe this is an error in the package

#
@bridge.bridge_group()
    async def networks(self, ctx):
        ...
dry echo
#

show the full code

grim canopy
#

I just wanna test the bridge and it occurred

prime remnant
#

how to do it in python if you write a message, they didn’t write anything in response, but if you put a question mark like type in this message, write the answer

prime remnant
#

mylist = ["Нет", "Возможно", "Да", "Скорее да", "Скорее нет"]

        elif text == "?":
             send_message(user_id, random.choice(mylist))
#

how to do it in python if you write a message, they didn’t write anything in response, but if you put a question mark like type in this message, write the answer

#

that is, the answer to the message is given if the value is "?" at the end, and if "?" not at the end of the answer did not give

#

how to do it?

fervent cradle
#

Question how would i go about getting the time tell the next cycle on a task loop from inside a command

#

or for that matter any tasks info

fierce elm
#

do variables created in a before_invoke exist during the invoke?

lime lichen
#

is there a way to handle interactions between but runs?

gloomy robin
grizzled sentinel
lime lichen
amber shale
#

why is my bot cant get guild by id?

gloomy robin
amber shale
#

everything provided is correct