#General Help

1 messages · Page 7 of 1

hazy loom
#

Found a workaround

vc = guild.voice_client
if vc is not None:
   return await send_failed_message(ctx, "Bot already connected to a voice channel")

If anyone has any other way to do it please tell me xD

kind mesa
#

That doesnt work the same for Slash Commands

crimson coral
#

you can no longer implement discord-sided role/user checks from the bot, it can only be done via the integrations tab

#

which is why permissions.has_any_role and similar decorators were removed

#

bot.voice_clients

#

working fine for me on rc1, don't think they were changed either

hazy loom
# crimson coral bot.voice_clients

Yeah but I needed to check in one guild regardless of a channel which each voice client didn't have, forgot I have a channel from the bridgeContext so I just got the guild and checked the state of the voice client

crimson coral
#

fair enough i guess

dapper quiver
#
@bot.event
async def on_error(ctx, error):
    if isinstance(error, commands.MissingPermissions):
        print('test')
        embed = discord.Embed(title='Error Handler Module', description='**Why did this happen?**\nThe command you attempted to run is an admin only command and as such will not execute!', colour=discord.Colour.purple())
        await ctx.respond(embed=embed)```
When I run an admin-only command, i still get the error in my terminal and an embed is never sent nor is test printed
opal storm
#

I'm working on a system that whenever it detects that someone has like ads in their status it removes some roles, that's done but now I want to give them back too when they remove their status and the bot wouldn't know who ppl are staff and who aren't so it might just give staff to some random ppl who had ads and then removed it so I want to make it so that whenever the user removes ads it gives back the roles it removed.

opal storm
hazy loom
#

I highly suggest to create a database in order to keep the roles ID they had and just fetch them whenever they remove it

crimson coral
opal storm
#

make it so that if this user has the role or whatever they can run it else bye ybe

opal storm
hazy loom
#

Do you have another way to save what roles they had?

crimson coral
#

^ you need some way to save it externally

opal storm
#

if it is prob a sql db

hazy loom
#

Ofc it's one way

opal storm
#

well I know I have to store that

#

but idk how to

hazy loom
#

But in a database the data will be highly easier to access

opal storm
#

I really suck with dbs.

crimson coral
#

a db would be ideal, but if it's on a small scale then a json will suffice

hazy loom
#

Here are your options:

  1. database with mysql
  2. json file
  3. gspread
#

gspread a google spreadsheets api that will help you to store data

#

Used it and it's great, before I paid for external database

opal storm
#

why can't I go with a SQLite3 file?

hazy loom
#

Actually, you can do it with .db file, i think it's doable

opal storm
#

I mean I'm actually working on making a warning system with PostgresSQL

opal storm
#

Or I can use .sqlite3

#

Same thing, mostly.

hazy loom
#

Or that

crimson coral
hazy loom
#

xDDD

opal storm
#

The thing is, I know like nothing about dbs.

dapper quiver
opal storm
#

so that's why I'm here.

hazy loom
opal storm
#

I've been trying to learn for a month

hazy loom
#

Always learn new things that will help you in the future 🙂

hazy loom
#

It's confusing at first but it's just query with a command executor

opal storm
#

Welp, I really kinda need this done asap and I don't have a month

#

I guess it is

hazy loom
#

Are you building any large-scale bot?

opal storm
#

for now I can just scrap this for now

opal storm
#

For one server, not much

hazy loom
#

For one server

#

Use Json man

opal storm
#

That's why I'm saying I could indeed use json

#

yeahhh

#

but I'm expecting the server to get really big

#

Probably.

hazy loom
#

For now use json

#

Later implement a database system

opal storm
#

(I don't know how to implement this into it)

#

Like I know how to use JSONs but idk what to do

hazy loom
#

I have a great site for it gimme a sec

opal storm
#

I'm saying like what inputs should I do.

#

I know how to do stuff with JSON

#

Like what should I do?

hazy loom
#

Oh lol

#

Well, you want to save the roles they had so I would save the role ids

opal storm
#

Make a list? or in a dict I make a name with the user's id and then the value would be the role ids>?

#

idk what to

#

dude im just gonna scrap this I expected this to be like a 1-2 hour project and ive been doing it all day lmao

hazy loom
#

Like that:

member_id: [
  role_id1
  role_idf2
]
opal storm
#
{ 123456789: [09147981751, 5018250632613]```
#

Like that?

hazy loom
#

Yep

opal storm
#

(Doesn't know how to give the roles back)

hazy loom
#

member.add_role(id) I think

opal storm
#

I know its add_roles but uh, how tf would I do it ;-;

hazy loom
#

bot.get_role

opal storm
#

dude I know how to give it back, if I didn't i'd google it or look at docs

#

OMG but

#

how do i get the value

#

like how do u get values from json from dicts

#

ik u can just do dict_var["thename"]

hazy loom
#

ye

opal storm
#

oh wait json.load

#

im stupid

hazy loom
#

Basically

#

3

opal storm
#

json.load a thing

#

o m g

hazy loom
#

okay my neice is typing stuff brb

opal storm
#

;-;

#

ok ill write out the code and show u till then

hazy loom
#

not joki n

#

oo+f

#

BRB

hazy loom
opal storm
#

yeah just writing some code

#

1s

hazy loom
#

k

dapper quiver
#

I dont really need exact code but the steps I need to take to do this. How do I make a verification bot work the way thinks like carl or verification bot do? With those images and everything

opal storm
#

okay so

#

there will prob be more than one role

#
            with open("roles.json") as f:
                dict = json.load(f)
                values = dict[str(after.id)]
                for i in range(len(values)):
                    ```
#

and im doing this

#

and I should prob define variables with a number or do I just define em and then get it?

#

actually nvm fixed my prob

hazy loom
hazy loom
dapper quiver
#

Not reaction roles, lemme get an ss

hazy loom
#

Yeah that'll help actually

hazy loom
#

Okay nice, great

opal storm
#

Okay got the stuff working, how do I check if the status is nothing? cause its actually a tuple I think

hazy loom
#

Never learned about the status thing, never got the chance to

opal storm
#

it is

#

its a tupole

hazy loom
#

If you say

opal storm
#

docs say so

dapper quiver
opal storm
#

how do I check if theres no more ads in the status?

hazy loom
opal storm
#

I can't just check for a empty tuple as ppl might their status with something else

#

than just keep it empty

#

sooo what do i do

dapper quiver
hazy loom
#

OOOH like reCaptcha?

opal storm
#

yeah

dapper quiver
#

YEQAH

opal storm
#

exactly like it

#

lmao

#

isnt there a bot to do that already?

hazy loom
#

bruh the painting

dapper quiver
opal storm
#

yeah yeah ik

hazy loom
dapper quiver
#

yep

opal storm
#

l m a o

#

so can anyone help me?

hazy loom
opal storm
#

cause I don't know how to do that im stupid

#

can u just check me if there is not a perticular thing in a string

#

like can u help me check if theres no "discord.gg/" in a string

hazy loom
#

Check for status, if there's a status you can check if it contains a link to another discord server which is not yours aka invite link or custom link

opal storm
#

thats simple python

opal storm
#

now I need help if someone has removed the ads from their status

#

cause we can't rely on everyone just removing their status they might change it to smth else

#

like have ads at start, then change it to "hey" or smth

hazy loom
#

Maybe do on status update? if there's an event like that

opal storm
#

yeah I do it on that

#

but how do i check if theres no more ads in a string

hazy loom
#

Same as checked the discord one

#

I assume

opal storm
#

wait I already have the thing where it checks for it

#

so can't i just use an "else" statement

hazy loom
#

Yeah

#

Yep

opal storm
#

like if its in there alr else u got ur roles back

hazy loom
#

Like a pass generator

opal storm
#

h o w do i put stuff inside of it now, ive did the thing where it takes data and gives roles back but how do I put the role ids in the dict?

dapper quiver
hazy loom
dapper quiver
#

the generation is fairly simple but not sure how I put those numbers on my image

hazy loom
dapper quiver
#

ooh thanks

hazy loom
#

Found it

#

# Import the following modules
from captcha.image import ImageCaptcha
 
# Create an image instance of the given size
image = ImageCaptcha(width = 280, height = 90)
 
# Image captcha text
captcha_text = 'GeeksforGeeks' 
 
# generate the image of the given text
data = image.generate(captcha_text) 
 
# write the image on the given file and save it
image.write(captcha_text, 'CAPTCHA.png')
hazy loom
dapper quiver
#

uh lemme see

#

YES

#

INDEED

hazy loom
dapper quiver
#

thanks so much!

hazy loom
#

No problem, ping me if you need anything else

dapper quiver
#

ofc tyvm

opal storm
#

like how to make the list

hazy loom
opal storm
#

like I know what to do manually

#

I need it to do it automatically

#

or I might aswell not make the feature

#

the thing is, not everyone has certain roles

#

most ppl dont have staff roles, so when they do(I have a check if they have staff role or not) I want to add that in too

hazy loom
#

whenever you remove the role and get it's id you just put it inside a list and dump it to the json

opal storm
#

idk how to dump a lot of ids that are from different checks at once.

#

its like

#
  ok yeah time to add this to it
if this user has this special role:
  add this to the db
  whatever...```
hazy loom
#

give the json more options like:

{
  id: {
    staffRoles: [],
    roles: []
    }
}
#

If u have more options you can just put the member_id as it's own dictionary which will indeed help you out

#

remember it's your code

opal storm
#

B R O

#

i have like 4 checks

hazy loom
#

And?

opal storm
#

so make a new thing for each of em?

hazy loom
#
if have_ads():
  role1 = member.remove_role()
  updateRoles(role1)
#

You don't have to do for each role a check

opal storm
#

uhm what if they dont have that role

hazy loom
#

Just one function if it's a stuff role ( yes you'll have to do a list that contains all of them as you decide cuz discord roles has no groups ) and one for regular ( anything not in the list )

opal storm
#

that'd just give an error.

hazy loom
#
if role in ctx.author.roles:
  do stuff
#

Pycord gives you a lot in terms of clean code ( one of the main reasons I switched a few days ago ) and efficiency

obsidian garnet
#

One message removed from a suspended account.

hazy loom
obsidian garnet
#

One message removed from a suspended account.

hazy loom
#

See here

opal storm
obsidian garnet
hazy loom
opal storm
#

They do.

#

I mean if they do

hazy loom
#

So you remove it?

opal storm
#

how tf would I add it to the dbb

#

yes i remove

hazy loom
#

oh

opal storm
#

and add to db but idk how

#
            if activity.name.startswith("https://") or "discord.gg/" in activity.name or ".gg/" in activity.name:
                print("This is the longer if statement, it has detected ad")
                # Check for roles
                if member_role in after.roles:
                    await after.remove_roles(member_role)
                if staff_role in after.roles:
                    await after.remove_roles(staff_role)```
#

how to add the stuff after I remove too?

hazy loom
#
        with open("file.json", 'r') as f:
            loader = json.load(f)
        loader["something"] = [] # data you want to dump instead
        with open("file.json", 'r') as f:
            json.dump(loader, f)
#

I think it'll work cuz when you dump the files it'll overwrite

opal storm
#

dude

#

im not asking for this

#

im aksing how to input the stupid role into it

#

because in each check I have to do that

#

and if theres a value there i dont want to overwrite it

hazy loom
#

.append

#

if not contains: append

opal storm
#

ok so

#

loaded[str(userid)].append(whatever)

hazy loom
#

yep

opal storm
#

i completely forgot about .append

#

im so stupid

#

omgaosjtoiayhstj

hazy loom
#

🙂

hazy loom
#

They'll check it

opal storm
#

OMFG

#

LMFAOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

hazy loom
#

xDDDD

dapper quiver
# hazy loom Then you check if they have the roles

hope im not bothering you!

# Create an image instance of the given size
    image = ImageCaptcha(width=280, height=90)
    captcha_text = random.randint(120000, 999999)
    # Image captcha text
    captcha_text = str(captcha_text)

    # generate the image of the given text
    data = image.generate(captcha_text)

    # write the image on the given file and save it
    image.write(captcha_text, 'captcha/CAPTCHA.png')
    await person.send('Go ahead and type what the captcha sent below has. Do not add any spaces, if your answer is wrong, you will have start the process again!.', file=discord.File("CAPTCHA.png"))
    print(captcha_text)
    msg = await bot.wait_for("message", check=lambda check: check.author.id == ctx.author.id)
    print(msg.content)
    if(msg.content == captcha_text):
        await person.send('Correct! Role should have been added, if you did not get the role, please contact Powerhouse_')
    else:
        await person.send('Incorrect, run /verify again.')```
The check runs even if the message wasnt sent in dms, how can I make a check for that?
hazy loom
#

In discord.py I used wait_for so he can wait for a dm back

#

IDK how to do that in pycord

dapper quiver
#

im also using wait_for but if a message is sent by that user in a non-dm channel, it still registers it as an answer

hazy loom
#

You want it to be sent in a dm or in the channel?

dapper quiver
#

dm

#

the bot dms the user with the verification process

#

but if the user sends a message in a different channel, it still registers that message as an answer

hazy loom
#

Gimme a sec

dapper quiver
#

alr

hazy loom
#
def make_sequence(seq):
    if seq is None:
        return ()
    if isinstance(seq, Sequence) and not isinstance(seq, str):
        return seq
    else:
        return (seq,)

def message_check(channel=None, author=None, content=None, ignore_bot=True, lower=True):
    channel = make_sequence(channel)
    author = make_sequence(author)
    content = make_sequence(content)
    if lower:
        content = tuple(c.lower() for c in content)
    def check(message):
        if ignore_bot and message.author.bot:
            return False
        if channel and message.channel not in channel:
            return False
        if author and message.author not in author:
            return False
        actual_content = message.content.lower() if lower else message.content
        if content and actual_content not in content:
            return False
        return True
    return check
#

This is the functions I did a while back

#

Before pycord was even released

#

So IDK if it'll work now but it used to work

#
'message', check=message_check(channel=ctx.author.dm_channel)
#

And this was inside the wait_for

#

DISCLAIMER: All functions were copied from stackoverflow so I do understand it's purpose 😄

opal storm
# hazy loom xDDDD

I use py values.remove(i) in my for i loop but it gives me: ValueError: list.remove(x): x not in list I tried doing i+1 and even .remove(1) but its the same

#

wait shoot

hazy loom
#

values.contains(x)
values.remove(x)

opal storm
#

i accidently replied

#

I don't use x tho

#

I use i

#

but SOMEHOW it just thinkgs theres x

hazy loom
#

Wait, you remove it by index?

opal storm
#

yeah?

hazy loom
#

If you're looping with a ranged and a list fixed value it'll always be shorter

opal storm
#
                    for i in range(len(values)):
                        print(f"values.remove({i+1})")
                        roleid = values[i]
                        values.remove(1)
                        role = guild.get_role(roleid)
                        await after.add_roles(role)```
#

I tried +1

#

(ofc in the .remove but its in the print statement cuz yes)

hazy loom
#

oh lol

opal storm
#

the remove is 1 now cause Im just testing if it works

hazy loom
#

But u always remove and the range doesn't change

opal storm
#

it does?

hazy loom
#

Use while to prevent any length errors

#

Not sure

opal storm
#

its based on how many stuff is inside the list itself

#
                    values = dict[str(after.id)]
#

i use len(values)

#

so it changes to however much stuff is inside it

#

can u just tell me a way to remove everything from the dict when im giving roles back?

hazy loom
#

I think it's with .clear or .empty

#

Not sure

opal storm
#

its a list

#

not a dict

#

nvm

hazy loom
#

list.clear

opal storm
hazy loom
#

yeah it's with .clear

#

Now I need help, is there a way to get passed arguments from a command in a check using the ctx? ( in slash it's ctx.interaction.data but is there a way to do the same for extcontext )

dapper quiver
hazy loom
#

and message_check \

crimson coral
hazy loom
crimson coral
#

there's also ctx.current_parameter if you need that one specifically in your check

hazy loom
#

Returned empty

crimson coral
#

might be that args and kwargs are only processed after invocation then

hazy loom
#

For interaction there's a perfect and simple way but for ctx there's not

#

Maybe there's no way to do it?

hazy loom
#

thanks tho

hazy loom
#

Is there a way to check error handling for bridgeCommands?

dapper quiver
#
    msg = await bot.wait_for("message", check=lambda check: check.author.id == ctx.author.id)

Soo, how can i add a check for if the msg.content was sent in a dm?

sudden path
#

Ctx.guild == None

unborn cliff
#

whats rc1 for pycord guys

crimson coral
#

release candidate 1

dapper quiver
#

many thanks, that did it for me :D

sudden path
#

Welcome

hazy loom
#

Is there a way to invoke another bridge command?

#

Instead of retyping everything and such

crimson coral
#

one weird hack i like is to grab an existing message, edit message.content to the command I wanna run and then run bot.process_commands on the message but that might not be ideal

#

otherwise you want ctx.invoke(command) with any other args

sudden path
#

Can I set perms for specific subcommands? Or discord limitation

crimson coral
#

though come to think of it im not sure if bridgecontext has invoke

#

uhh i think that is indeed a discord limitation

#

perms are limited to top level iirc

sudden path
#

thanks discord

hazy loom
#

For some reason it tells me I don't have an attribute called client

#

whadohell

#

Thats so strange, if someone knows please help i'm struggling, using BridgeCommands

crimson coral
gilded widget
hazy loom
#

BRUH

hazy loom
#

I promise

#

I'm not stupid

#

I'm tired af

#

😦

gilded widget
#

all good, happens to the best of us lmao

hazy loom
#

xDDDD

daring flint
#

I have a Message Command that calls a Modal. When the Modal is submitted, I need to get the Message it was originally called from.

I tried interaction.original_message() but got an "Unknown Webhook" error.

Is there a better way of keeping track of it? Could I pass the Message into my custom Modal constructor?

(Edit: Yeah, I think that might be the best option; pass in the message to the Modal class; reference as self.message)

thin trellis
#

What am I doing wrong?
I tried to use the new method for slash command options

hazy loom
#

Is there a way to let the interaction wait for command process to be complete?

inner iris
#

What's the difference between discord.Bot and commands.Bot or bot.slash_command, commands.slash_command and discord.slash_command?

frigid lark
#

Can I get the time from a user?

inner iris
#

you mean the timezone?

frigid lark
#

I use datetime.datetime.now() at the moment

midnight cedar
frigid lark
midnight cedar
#

depends on your usecase

#

i usually use utcnow

#

just for consistency between machines

crimson coral
#

not even the tuple version works anymore rip

#

aaaand discord.channel also broken

#

at least discord.abc.GuildChannel still works

crimson coral
#

pretty sure all the slash_command decorators are interchangeable though

inner iris
#

so discord.Bot doesn't allow prefixed commands?

crimson coral
#

yep

inner iris
#

hm. ok

crimson coral
#

also if you're using commands.Bot, you need to specify intents for prefix commands to work

inner iris
#

and is there any other difference besides of that?

crimson coral
#

generally just better command management, there's quite a lot in the commands extension that works best with commands.Bot

earnest sail
#

there seems to be a max limit of choices discord will show when using the autocomplete. What is the size of that limit?

crimson coral
earnest sail
#

thank you

inner iris
#

ok, so ext.commands is probably the better option?

crimson coral
#

though the list of options you return can be any size

#

yeah it's pretty useful

frigid lark
inner iris
#

Why do I have to use ctx.respond? Is there more to it other than just replying to the invocation? And why does it say The application did not respond if I don't respond?

sudden path
slow dome
crimson coral
#

you have to respond to every interaction

inner iris
#

pretty unnecessary isn't it?

#

but if discord says we have to respond, we'll do it xD

crimson coral
#

to some extent yeah, but it has its own benefits

#

and you can just make the response ephemeral

inner iris
#

Can I respond with nothing?

crimson coral
#

has to be a message

inner iris
#

hm

crimson coral
#

every command call, button press, dropdown selection, modal submission, and any other interaction you can perform

#

has to have a message response

inner iris
#

lol

#

wtf why xD

#

doesn't make sense to me but I'm just a dumb little programmer

crimson coral
#

well close enough anyway

#

it sounds strange at first but after actually implementing your stuff it's not that bad lol

inner iris
#

yeah I guess that's right

#

I'm just starting to use the interaction stuff...

#

I like it and also don't

#

but maybe I'll like it more, when I get to know it better.

#

thx for the answer anyway

earnest sail
#

for some reason... my first slash command is not registering

#

how do I enable logs or something so I can see what's going on?

#

it's happening on all of my bots

worthy bobcat
#

will the view deleted when the message was deleted

slender lintel
#

Also does anyone know if it's possible to make the bot ping a role using ctx.respond, I tried using AllowedMentions but it didn't work

slow dome
earnest sapphire
#

anyone here knows python well?

#

I have an issue with my terminal

#

I tried python manage.py makemigrations but its giving me errors stating No migrations to apply.

crude temple
#

Can we have label with more than 45 characters in modals??

#

getting this error

In data.components.0.components.0.label: Must be 45 or fewer in length.
In data.components.1.components.0.label: Must be 45 or fewer in length.
In data.components.2.components.0.label: Must be 45 or fewer in length.
In data.components.3.components.0.label: Must be 45 or fewer in length.
crimson gale
#

api limitation

midnight cedar
warm tundra
#

i just need to get the server name

#

error: Guild object has no attribute guild

frigid lark
warm tundra
#

i don't know why

frigid lark
#

Do you have intents?

#

@warm tundra

warm tundra
#

all are on and enabled

vagrant mortar
#

I have 2 options in a command, with both of them being autocompletes.
Can I influence the autocomplete of option 2, depending on the selected option 1?

So for example this:
Option 1 = A, that would make Option 2 autocomplete from [A, B, C]
Option 1 = B, that would make Option 2 autocomplete from [D, E, F]

jovial tusk
#
@slash_command()
async def send_msg(
        self,
        ctx: ApplicationContext,
        channel: Option(discord.TextChannel)
):
  ...

Im trying to take channel input as a TextChannel, it works on the discord side, but when i run the slash command , i get this error

frigid lark
#

!install

robust nebulaBOT
#

Install pycord:

pip uninstall discord.py
pip install py-cord

Install pycord beta:

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

Install pycord alpha from git:

pip uninstall discord.py
pip install git+https://github.com/Pycord-Development/pycord
frigid lark
# warm tundra ye
@client.command()
async def guild_name(ctx):
    await ctx.send(ctx.guild.name)

this should send the Server name

vagrant mortar
#

How would that work?

#

As from what I can see, you cannot access Option 1's variable, in Option 2.

vagrant mortar
#

Hmmmmmmmmm....

crimson gale
#

A name to value mapping of the options that the user has selected before this option.

vagrant mortar
#

so it would return {"Option 1 variable": "A"} I suppose then?

#

As that would work 🤔

crimson gale
#

yep

#

returns a dict

vagrant mortar
#

cool cool.

#

Must've overlooked, or misread that attribute then... Thanks 🙂

thin trellis
warm tundra
crimson gale
#

intents?

warm tundra
crimson gale
#

what intents are you giving your bot?

warm tundra
crimson gale
#

show me your code

warm tundra
crimson gale
#

doc is the guild object

hollow moth
#

How can I set default permissions (Permissions v2) for a slash command group?

warm tundra
crimson gale
#

in an event there is no context object

#

on_guild_join only provides the Guild object it joined

warm tundra
#

so do i just remove the doc???

crimson gale
#

youre trying to access the guild attribute of a Guild which doesnt exist

#

the argument name has no effect

warm tundra
#

ok...

#

k it worked

#

thanks for your help

hollow moth
#

Is there a limit on the number of items on a modal?

crimson gale
#

4

#

or 5

#

i forgot which of the two

hollow moth
#

Yikes ok thanks

crimson coral
#

yep 5

#

pretty much everything related to UI components is in fives right now

#

5 buttons per row, 5 rows per view, 25 options per dropdown...

plush lintel
#

can anyone teach me how to provide an available file to the pillow package?

vocal crane
#

what are the max options u can pass in a slash command? and what are the max arguments u can put in one option

ornate spade
#

25 and 25

#

iirc

vocal crane
#

Thank you :)

vocal crane
# ornate spade 25 and 25

I still get a error that 'APPLICATION_COMMAND_TOO_LARGE', 'message': 'Command exceeds maximum size (4000)

solar berry
#

Is there a way to get lines from the logs in the console (where the prints go) and send it as a message

upbeat hill
#

how to get a bot to create a new channel in a specific category?

vocal crane
upbeat hill
vocal crane
#

try .create_text_channel('name', category='category')

upbeat hill
vocal crane
#

what is the eroors?

#

errors*

upbeat hill
vocal crane
#

oh

upbeat hill
#

oh?

vocal crane
#

'str' object has no attribute id

#

are u like extracting .id from a string?

#

can i see the code?

upbeat hill
vocal crane
#

am pretty sure if u use the ip u use is without the ' '

#

if u wanna use the ' ' just straight up put the name of the category

upbeat hill
vocal crane
#

ohhh bruh

#

line 1160 you forgot to close ur ()

upbeat hill
vocal crane
upbeat hill
#

its only 88 lines long atm

vocal crane
#

then why

#

let me debug this shit real quick

#

am a noobie but still lol

#

is that the full error?

upbeat hill
#

yep

vocal crane
#

okay give me a moment

upbeat hill
#

class AppealButtonsView(discord.ui.View):
    def __init__(self, channel):
        super().__init__()
        self.channel = channel

    @discord.ui.button(label="KMC", style=discord.ButtonStyle.secondary)
    async def close_callback(self, button, interaction):
        embed = discord.Embed(
            title="**KMC Ban Appeal**",
            description="Please put down the reason why you were banned from the KMC and why you feel you should be unbanned.",
            color=discord.Colour.green()
        )
        await interaction.response.edit_message(view=self)
        await self.channel.send(embed=embed)
        await interaction.guild.create_text_channel(name='ticket', category=940628083592028230)
        

    @discord.ui.button(label="Main Server", style=discord.ButtonStyle.secondary)
    async def button_two_callback(self, button, interaction):
        embed = discord.Embed(
            title="**Main Server Ban Appeal**",
            description="Please put down the reason why you were banned from the 104th and why you feel you should be unbanned.",
            color=discord.Colour.green()
        )
        
        await self.channel.send(embed=embed)

    @discord.ui.button(label="NTR", style=discord.ButtonStyle.secondary)
    async def button_three_callback(self, button, interaction):
        embed = discord.Embed(
            title="**NTR Appeal**",
            description="Please put down the qual you were NTRd from, reason why you were NTRd and why you feel you should be unNTRd.",
            color=discord.Colour.green()
        )
        await self.channel.send(embed=embed)
#
@bot.command()
async def ticket_panel(ctx):
    await ctx.message.delete()
    channel = bot.get_channel(976499170879885312)          # control pannel
    button_channel = bot.get_channel(929759484593721386)   #sends the embeds from the buttons
    embed = discord.Embed(
        title="**Appeals**",
        description="Select an option for which type of appeal you need.",
        color=0xf0f0f0
    )
    view = AppealButtonsView(button_channel)
    await channel.send(embed=embed, view=view)

bot.run(TOKEN)
vocal crane
#

right

upbeat hill
#

thats the code related to this

vocal crane
#

okay thx

slender lintel
#

Hey how i can with buttons open a modal?
i dont find a docs to this..

crimson gale
#

await interaction.response.send_modal

#

i believe it takes a Modal object that is to be sent to the user

#

@slender lintel

#

and yes it takes the Modal object that is to be sent to the user

slender lintel
crimson gale
#

nope

slender lintel
#

so this with number is a example

crimson gale
#

only text fields

brittle sundial
#
@commands.Cog.listener()
    async def on_ready(self):
                
        view = discord.ui.View(timeout=None)
        role = self.bot.db.execute("SELECT * FROM Roles")
  
        for row in role:
            role = self.bot.get_guild(row[1]).get_role(row[0])
            view.add_item(RoleButton(role))

        self.bot.add_view(view)```
brittle sundial
# brittle sundial ```py @commands.Cog.listener() async def on_ready(self): ...
Ignoring exception in command reactionrole:
Traceback (most recent call last):
  File "C:\Users\Ansh\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 126, in wrapped
    ret = await coro(arg)
  File "C:\Users\Ansh\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 856, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "c:\Users\Ansh\Desktop\Coding\Python\Discord stuff\button role\2\buttonrole.py", line 98, in reactionrole
    await self.bot.db.execute(
AttributeError: 'Bot' object has no attribute 'db'

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

Traceback (most recent call last):
  File "C:\Users\Ansh\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 993, in invoke_application_command    await ctx.command.invoke(ctx)
  File "C:\Users\Ansh\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 357, in invoke
    await injected(ctx)
  File "C:\Users\Ansh\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\commands\core.py", line 134, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Bot' object has no attribute 'db'```
slender lintel
crimson gale
#

none

brittle sundial
#

Why am i getting this error. Can someone help please. Thanks.

crimson gale
slender lintel
crimson gale
#

yep

#

you cant limit them in terms of what they can receive

slender lintel
#

mhmm okay thanks despite it

crimson gale
brittle sundial
crimson gale
#

then set it

brittle sundial
upbeat hill
#

how would you make a ticket naming system(e.g. ticket -0001)?

slender lintel
#

i search a number (1799) when is not correct come a error but dont working..

        if 1799 == None:
            await interaction.response.send_message(f"Falscher Code!")
        else:
            await interaction.response.send_message(f"Geschafft! Du hast dich erfolgreich verifiziert!")
crimson coral
#

1799 == None is always gonna be false

slender lintel
crimson coral
#

what are you trying to check

slender lintel
#

if the code is written correctly

upbeat hill
#

any idea why this wont work?

slender lintel
crimson coral
#

still unsure what you're trying to do there

crimson coral
#

also it should be kticket.send, not kticket.id.send

slender lintel
crimson coral
slender lintel
#

i have tryed with variable but not working

crimson coral
#

ahh i think you've misunderstood how it works

slender lintel
#

yeah maybe

crimson coral
#

so you're trying to check if they've entered 1799 in the modal

slender lintel
#

yes

crimson coral
#

you can get what they entered by accessing self.children[0].value

upbeat hill
crimson coral
slender lintel
crimson coral
#

but subclassing a button would be similar to a view

crimson coral
upbeat hill
crimson coral
#

that should work

crimson coral
upbeat hill
crimson coral
#

still not working?

upbeat hill
#

nope

crimson coral
#

can you show the error

slender lintel
crimson coral
slender lintel
#

Oh i have see it xD Im sry

crimson coral
#

all good

upbeat hill
crimson coral
#

oh you made a typo lol

#

reread your code

upbeat hill
crimson coral
#

all good

slender lintel
crimson coral
#

yep

#

so for example, since code is a list you can change it to if self.children[0].value in code

#

which would let you do multiple "correct" codes

slender lintel
crimson coral
#

not == codes, in codes

#

because you are checking if an object is inside the list

upbeat hill
# crimson coral all good

do you by any chance know how to make a ticket counter naming system
(e.g. ticket - 0001 , ticket - 0002)?

crimson coral
#

well you'd just have to save your counter to another file

slender lintel
crimson coral
#

all good

crimson coral
#

pycord also has the built in utility discord.utils.generate_snowflake() that'll generate a discord-style ID which is pretty likely to be completely unique

upbeat hill
upbeat hill
#

thanks

crimson coral
slender lintel
#

last question for to day why does update my modal not the code

crimson coral
#

don't quite understand the question

#

though if i had to guess, you need to restart the bot to update your callback

slender lintel
crimson coral
#

ehhhh

#

it's hard to figure out because discord is pretty weird when it comes to syncing callbacks

slender lintel
#

mmhmm is that not working a random number to generate?

inner iris
#

How can I get the full command that got called by the user? I'm speaking of a slash command of course.

crimson coral
#

if you want the full command including options, what the user entered etc, you should experiment with ctx.interaction.data["options"]

#

since that will include everything

upbeat hill
#

how do you delete a channel after a delay

crimson coral
#

await asyncio.sleep(seconds) if you want the command to stall for a bit

stable tiger
#

delete_after= param in .send or msg.delete() after you did what you want

crimson coral
#

note if it's via a slash command or other interaction and it's lasting more than 3 seconds you should defer

upbeat hill
# crimson coral `await asyncio.sleep(seconds)` if you want the command to stall for a bit

Ignoring exception in view <CloseButtonView timeout=180.0 children=1> for item <Button style=<ButtonStyle.secondary: 2> url=None disabled=False label='Close' emoji=<PartialEmoji animated=False name='🔒' id=None> row=None>:
Traceback (most recent call last):
File "C:\Users\philc\AppData\Roaming\Python\Python310\site-packages\discord\ui\view.py", line 365, in _scheduled_task
await item.callback(interaction)
File "c:\Users\philc\Desktop\ticket bot WIP\ticket bot.py", line 35, in close_callback
await self.channel.delete
TypeError: object method can't be used in 'await' expression

inner iris
#

Do command checks like guild_only or is_owner also work with slash commands or only with the prefixed commands?

inner iris
#

perfect

#

Is there somewhere a good guide on what to change when switching to slash commands?

inner iris
#

That's not really what I need

frigid lark
inner iris
#

Do I have to change more other that using ctx.respond and discord.slash_command?

frigid lark
#

you dont need to use aliases from the prefix commands, only if you would use bridge commands

crimson coral
#

it's a separate function that waits for the amount of seconds you specify

#

then you can delete after that line

crimson coral
#

delete()

upbeat hill
# crimson coral `delete()`

it works but im getting an error:
Ignoring exception in view <CloseButtonView timeout=180.0 children=1> for item <Button style=<ButtonStyle.secondary: 2> url=None disabled=False label='Close' emoji=<PartialEmoji animated=False name='🔒' id=None> row=None>:
Traceback (most recent call last):
File "C:\Users\philc\AppData\Roaming\Python\Python310\site-packages\discord\ui\view.py", line 367, in scheduled_task
await interaction.response.defer()
File "C:\Users\philc\AppData\Roaming\Python\Python310\site-packages\discord\interactions.py", line 471, in defer
await adapter.create_interaction_response(
File "C:\Users\philc\AppData\Roaming\Python\Python310\site-packages\discord\webhook\async
.py", line 192, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

inner iris
crimson coral
#

how is this callback triggered?

upbeat hill
frigid lark
crimson coral
# upbeat hill button

i recommend either:

  1. replace the self.channel.send with await interaction.response.send_message
  2. leave the self.channel.send, but at the start of the callback, you do something like await interaction.response.send_message("Deleting ticket...")
inner iris
crimson coral
#

all good

crimson coral
inner iris
#

How do I register a slash command that works in dm's too?

crimson coral
#

discord treats them as completely different commands

#

which will cause issues with permissions and such

#

generally slash commands don't need aliases because you can just search for the command you need

crimson coral
inner iris
#

oh ok, makes sense

#

and how would I make a global slash command that won't show up in a dm?

crimson coral
#

add the discord.guild_only decorator... i think?

#

@discord.guild_only()

#

i think this might be broken in rc1 though

#

though there's a pr you can apply if you want it working

inner iris
#

No, it's not that urgent, just wanted to know

crimson coral
#

fair enough

inner iris
#

Can I do command checks on command groups? Like defining a whole command group as guild_only instead of doing it for every command in this group.

midnight cedar
unborn cliff
#

whats the cmd for pycord rc ?

sudden path
#

py-cord==2.0.0rc1

unborn cliff
#

oh

glad saffron
#

Hi guys, how do I get the ID of the user who sends a command?

unborn cliff
#

i think

#

?rtfm id

#

?rtm

#

?rtm ID

glad saffron
#

Whenever I used ctx, it says its not defined

#

😧

unborn cliff
#

bc you cant use a parameter definition inside the parameter list

#

its not pythonic

glad saffron
#

Oh

#

Hmm

#

What should I do in this situation?

unborn cliff
#

def foo(var1 , var2= var1)

#

wont work

#

do it inside the function

glad saffron
#

Ahhh okay

#

Thank you!

#

So just do the logic in the code?

unborn cliff
glad saffron
unborn cliff
#

@south ermine

glad saffron
#

Okok thank you!! im gonna try it

unborn cliff
#

I have this. And it still wont wokr :I

unborn cliff
unborn cliff
glad saffron
#

Wait, I dont understand what you mean by that

#

Also I'm sorry but I dont think I'll be able to help you with your issue I am really new to Pycord

unborn cliff
#

this

#

user now has an attribute called default

#

correct ?

glad saffron
#

Uhhhhhhhhhhhhhh

#

Not sure

glad saffron
unborn cliff
#

Within the function where user is instantiated

glad saffron
#

I'm a bit confused but I think i get what you mean

#

actually no i am very confuysed

unborn cliff
#

You have a param called user

glad saffron
#

😅

#

Mhm

stable tiger
#

You can do

foo(ctx, member: discord.Member = None)

And then member = member or ctx.author

unborn cliff
#

they want the id to be the default

glad saffron
#

Okok I think I should explain what I want the thingy to look like

unborn cliff
glad saffron
#

I want there to be an optional thing you can respond with but if you dont do the optional thing, then your ID would be the default but if you answer it then the person you put id's would be the default

#

Okok ill try that

#

would this work?

glad saffron
#

it's still set as a required option

#

😧

#

unless it hasnt updated yet

unborn cliff
#

wait dont have a default inside the Option

glad saffron
#

okok

unborn cliff
glad saffron
#

Its still set to required

#

Maybe I should reinvite the bot to see if its just a bug with discord?

#

Also I tried running it and it gave me this 😅 discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Member' object has no attribute 'default'

unborn cliff
#

Gah pepe_cry

#

I thought it would work mah bad

glad saffron
#

Nonono its fine

#

That looks like it should work

unborn cliff
#

Member /

#

oh

unborn cliff
glad saffron
#

Ughhhhhh

#

Ok this code it works

#

But it's still set as a required option

#

I'm gonna reinvite the bot to see if its just a bug with discord

glad saffron
#

IT WAS

#

YAYYYY

#

its now optional

#

😭

#

thank you for the help!!

#

Hopefully your problem gets resolved too

glad saffron
unborn cliff
unborn cliff
glad saffron
#

Ah

unborn cliff
#

editing directly in the vps

glad saffron
#

it says ubuntu, but youre on windows?

unborn cliff
#

its vps that runs ubuntu

#

its ssh

glad saffron
#

Also your bio has these date thingies how do you do that?

unborn cliff
#

unix timestamp

unborn cliff
#

(vim)

glad saffron
#

Ahhhh okay I see i see 😁

#

Whats the advantage using that over VScode>

unborn cliff
#

its just used to quickly edit stuff without having to replace files in a vps

#

lol

glad saffron
#

i see

dapper quiver
#
@bot.slash_command(name='statuscheck', guild_ids=slash_guilds)
async def statuscheck(ctx):
    await ctx.respond(ctx.author.status)```
For some reason, this always returns offline no matter what my status is, any ideas?
gilded widget
#

yeah, known bug, fixed in ##1365 but it needs testing before merge into master

supple ravineBOT
gilded widget
#

current workaround is to do ctx.guild.get_member(ctx.author)

dapper quiver
gilded widget
#

its not currently in pycord's master branch so you'd have to clone the branch that i have it on

#

should be merged soon if you just wanna use the workaround for now

dapper quiver
#

Alright yeah ill just use the workaround for now

unborn cliff
dapper quiver
#

ty :D

gilded widget
dapper quiver
#

okay so i looked back at your message and turns out its only with application commands

#

so i can use it in on_message

gilded widget
#

yeah, interactions/options are where it occurs, fairly certain it functions fine with prefixed-esque stuff

dapper quiver
#

oh thats even better, saves me a lot of trouble, thanks :D

unborn cliff
#

¯_(ツ)_/¯

gilded widget
#

all good

glad saffron
#

Hi guys, how do I have a bot send a message in a specific channel?

#

I have the ID of that channel but I'm not too sure on how to have it send the message to it

south ermine
unborn cliff
little tapir
glad saffron
#

thankyou 😁

broken wren
#
@tasks.loop(minutes=1)
async def set_rate(bot:discord.Bot):
    global dbu
    by=randint(4,9)
    inc=choice([True, False])
    ch=bot.get_channel(ECRCH)
    msg=await ch.fetch_message(ECRMG)
    names=["ich","wsi","soc","gzi","fsp"]
    cp=[]
    np=[]
    for i in names:
        cur=await dbu.execute("SELECT vale FROM market WHERE cname=?",(i,))
        res=await cur.fetchone()
        cp.append(res[0])
    day=datetime.utcnow().strftime("%A")
    strs=f"Day: {day}, Note: Markets are closed on Sunday"
    if day=="Sunday":
        strs=F"It's {day}, The markets are closed today "
        np=cp
    else:
        if inc is True:
            for i in cp:
                i+=by
                np.append(i)
        else:
            for i in cp:
                i-=by
                np.append(i)
    v=0
    for j in names:
        await dbu.execute("UPDATE market SET vale=? WHERE cname=?",(j,np[v]))
        # print((j,np[v]))
        await dbu.commit()
        v+=1
    
    em=discord.Embed(
        title="Comapny Value List:",
        color=discord.Color.random()
        ).add_field(
            name="🍒 iCherry",
            value=f"{np[0]}"
        ).add_field(
            name="🌿 William Inc.",
            value=f"{np[1]}"
        ).add_field(
            name="🦾 Socialize",
            value=f"{np[2]}"
        ).add_field(
            name="🎮 Gamezionic",
            value=f"{np[3]}"
        ).add_field(
            name="🥾 Footworks Inc.",
            value=f"{np[4]}"
        ).set_footer(
            text=strs
        )
    
    await msg.edit(content=None,embed=em)

my code, it's not updating db,there's a problem in the for loop part.. everything else works fine

tall stag
#

Does any1 know why ctx.content does not display anything?

import discord, urllib.parse, asyncio, random, json
from discord.ext.commands import bot
from discord.ext import commands
from discord.ui import Button, View
from collections import defaultdict

# we will then need to connect our discord account to the discord bot through 
# https://discord.com/developers/applications

token = open('token.txt', 'r').read()
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)

# on bot startup
@client.event
async def on_ready():
    await client.change_presence(activity=discord.Game('random message'))
    print(f'{client.user} has connected to Discord!')

# on bot message
@client.event
async def on_message(ctx):
    print(f"{ctx.channel}: {ctx.author}: {ctx.author.name} {ctx.author.id}: {ctx.content}")

    print(ctx.guild)
    msg = str(ctx.content)
    print('Message Sent:', msg)import discord, urllib.parse, asyncio, random, json
from discord.ext.commands import bot
from discord.ext import commands
from discord.ui import Button, View
from collections import defaultdict

# we will then need to connect our discord account to the discord bot through 
# https://discord.com/developers/applications

token = open('token.txt', 'r').read()
intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)

# on bot startup
@client.event
async def on_ready():
    await client.change_presence(activity=discord.Game('random message'))
    print(f'{client.user} has connected to Discord!')

# on bot message
@client.event
async def on_message(ctx):
    print(f"{ctx.channel}: {ctx.author}: {ctx.author.name} {ctx.author.id}: {ctx.content}")

    print(ctx.guild)
    msg = str(ctx.content)
    print('Message Sent:', msg)
wooden narwhal
#

though i am not good at sql, everything else looks fine to me.

broken wren
#

nope

wooden narwhal
#

maybe query

#

issues?

slender lintel
slender lintel
tall stag
#

ok thank you 🙏 sorry to ask, but what would i need to specify in
this part or write instead of ctx.content to be able to retrieve message contents?

@client.event
async def on_message(ctx):
    print(f"{ctx.channel}: {ctx.author}: {ctx.author.name} {ctx.author.id}: {ctx.content}")
slender lintel
#
@client.event
async def on_message(message):
    print(f"{message.channel}: {message.author}: {ctx.author.name} {message.author.id}: {message}")

The message content is already stored inside the argument you don't need to access it again

broken wren
crimson gale
#

accessing the content attribute of Message requires you have the message_content intent enabled and provided to your bot

stray smelt
#

?tag intents

hearty rainBOT
#
import discord
from discord.ext import commands

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

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

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

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

hello

#

i installed it with "pip install discord.ui" why doesnt it work

viral fossil
#

Hi guys . As my project ad skipper I want to put multiprocessing in my code using Pipes I want to communicate between processes. I don't really have any idea what I am doing. This is part of my final requirements in school. Our teacher never teach us about, multiprocessing, multithreading, parallel and etc. And he want us to put multiprocessing, multithreading, parallel and etc. in our code. My question is am I doing it right? or I am just messing around in my code? Skip add doesn't print in the system when the ad is skipped. it says that Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)

plush lintel
#

how can i make a photo that can be opened in pillow package?

slender lintel
#

Hey how i can Update a Modal?

inner iris
#

Why can't I import CommandPermission from discord.commands? I'm using rc1, is that the problem?

upbeat hill
#

how would you get a bot to read from a json file?

crimson gale
inner iris
crimson gale
#

permissions v2

#

or checks found in the commands extension

inner iris
warm tundra
#

How do I get the value stored in a specific grid in MySQL???

#

I just started learning abt it so don;t know much

#

Also, is there a way to get an audio file from audio

crimson gale
celest moth
#

is it possible to create a file for a command and add it to the main bot file?

inner iris
crimson gale
#

i guess

frank moon
#

how do i add choices to option when i fetch the data from the database with a specific user?

#

or no way?

crimson gale
#

do you mean dynamic slash command option choices?

frank moon
crimson gale
#

is that what you mean?

frank moon
crimson gale
#

youre saying something about pulling info off a database and then providing them as choices to the user

crimson gale
#

?tag ex

crimson gale
#

slash command, autocomplete example

frank moon
#

uh

#

how do i explain

#

like

#

/find <member> <thing>

crimson gale
#

yes

frank moon
#

so it only provide what the member has as a <thing>

crimson gale
#

yes

#

refer to the example and docs

frank moon
#

ok

crimson gale
#

and for the love of god actually read the docs for the applicable context object

#

youll find what you need there

frank moon
#

ok

inland acorn
#

how to pass args in callback function when the button n view is not subclassed

formal bluff
#

I installed this package for 10 times and I still got the same error?

Traceback (most recent call last):
  File "main.py", line 96, in <module>
    @bot.slash_command(name="ping", description = "Check the time i take to reply to you!")
AttributeError: 'Bot' object has no attribute 'slash_command'

pip install -U discord-py-slash-command

crimson gale
#

dont use it with pycord

formal bluff
#

which package should I install?

crimson gale
#

pycord 2.0 supports slash commands

formal bluff
#

I have pycord 2.0?

crimson gale
slender lintel
#

discord-py-slash-command requires discord. Uninstall that and discord.py

formal bluff
#

installed this again; pip install git+https://github.com/Pycord-Development/pycord
now it worked thx

upbeat hill
#

when updating a channel's permissions.
whats the global permmision(@ everyone)?

crimson gale
#

Guild.default_role

little isle
#

Simple question this time: How do I remove a view from a message? Setting view=None raises this error:

return await self.followup.send(*args, **kwargs)  # self.send_followup
  File "/opt/homebrew/lib/python3.10/site-packages/discord/webhook/async_.py", line 1561, in send
    if view is not MISSING and not view.is_finished():
AttributeError: 'NoneType' object has no attribute 'is_finished'
#

The documentation for WebhookMessage says "The updated view to update this message with. If None is passed then the view is removed."

#

Ditto the documentation for Message.edit()

#

Actually, I think my problem is different. This occurs when sending a message with view=None

vale bloom
#

python3 -m pip install py-cord
when typing that I only get this:

dapper quiver
#

In a channel, i want to get the id of the first message only, any ideas on how?

crimson coral
#

eh...

crimson coral
dapper quiver
#

Theres a param which is oldest_first but issue im facing is when i do

 messages = await channel.history(limit=2, oldest_first=True).flatten()
    print(messages)
    print(type(messages))
    msg = bot.get_message(977238207659909126)
    print(msg)```
My last print(msg) is none and print(messages) gives me
```[<Message id=977238207659909126 channel=<TextChannel id=976338556559691876 name='test' position=14 nsfw=False news=False category_id=971116553032585226> type=<MessageType.application_command: 20> author=<Member id=971276352147845190 name='Powered Bot' discriminator='6049' bot=True nick=None guild=<Guild id=971110220568879134 name='Powered Bots' shard_id=0 chunked=True member_count=11>> flags=<MessageFlags value=0>>, <Message id=977238208209362984 channel=<TextChannel id=976338556559691876 name='test' position=14 nsfw=False news=False category_id=971116553032585226> type=<MessageType.default: 0> author=<Member id=971276352147845190 name='Powered Bot' discriminator='6049' bot=True nick=None guild=<Guild id=971110220568879134 name='Powered Bots' shard_id=0 chunked=True member_count=11>> flags=<MessageFlags value=0>>]

crimson coral
#

because get_message reads from a different cache

dapper quiver
#

oh hm, well what should i be doing then>

crimson coral
#

are you sure 977238207659909126 is in that channel?

dapper quiver
#

according to that print, it is

crimson coral
#

wait then

#

just do messages[0]

#

it already got the message object for you

dapper quiver
#

oh alrighty lemme try that

#

well i want to be able to edit that message later too

#

which is why im going thru all this trouble

crimson coral
#

well yeah you have the object

#

so you just work on that

#

note that the more messages in a channel, the more expensive it becomes to use history; it can take a while before returning anything

dapper quiver
#

makes sense

crimson coral
#

oh wait

#

i just realised your way of doing it works way better than what i initially suggested

#

limit=1, oldest_first=True will instantly return the first message

dapper quiver
#

oh my lord

#

i wish i realized

#

thank you :D

crimson coral
#

all good, if anything your test code above was how i found out lol

sturdy estuary
#

guys I Need help with attachments in slash commands

#
@bot.command(description="Post on your profile")
async def post(ctx, image : discord.SlashCommandOptionType.attachment):
    link = image.url()

    async with aiosqlite.connect("main.db") as db:
        async with db.cursor() as cur:
            await cur.execute("INSERT INTO posts (user_id,image_link) VALUES (?,?)",(ctx.author.id,link))

        await db.commit()

    embed = discord.Embed(title="Successfully Posted :")
    embed.set_image(link)
#

discord.SlashCommandOptionType doesnt seem to work

#

it raises this error :

  File "D:\Tomm's Bot Stuff\Instacord\bot.py", line 53, in <module>
    async def post(ctx, image : discord.SlashCommandOptionType.attachment):
  File "C:\Users\My PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\bot.py", line 813, in decorator
    result = command(**kwargs)(func)
  File "C:\Users\My PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\commands\core.py", line 1580, in decorator
    return cls(func, **attrs)
  File "C:\Users\My PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\commands\core.py", line 644, in __init__
    self.options: List[Option] = self._parse_options(params)
  File "C:\Users\My PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\commands\core.py", line 691, in _parse_options
    option = Option(option)
  File "C:\Users\My PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\commands\options.py", line 177, in __init__
    elif issubclass(self._raw_type, Enum) and (doc := inspect.getdoc(self._raw_type)) is not None:
TypeError: issubclass() arg 1 must be a class```
#

Ive reinstalled thrice

crimson coral
#

just do discord.Attachment

#

i can't recall any scenario in which you need SlashCommandOptionType at the moment, the regular classes work just fine

sturdy estuary
#

but ok

crimson coral
#

ah haven't read the guide much

sturdy estuary
#
  File "D:\Tomm's Bot Stuff\Instacord\bot.py", line 53, in <module>
    async def post(ctx, image : discord.attachment):
AttributeError: module 'discord' has no attribute 'attachment'```
#

clearly in pip list

#

why

#

sorry

#

Capital A

upbeat hill
#

is there a fix for this?

frigid lark
upbeat hill
#

okie

#

thanks

frigid lark
#

Im not sure if this works

upbeat hill
upbeat hill
fair cradle
#

How Do i make a for loop in slash autocomplete?

frigid lark
#

You can just use a list?

fair cradle
frigid lark
#

Oh

daring flint
upbeat hill
#

how would you make an incrementor for a ticket system?
(format: 0001, 0002 etc.
0017, 1732)

vocal crane
#

is there a way to have more the 25 options in slash commands?

slender lintel
#

i cant edit the ctx.response messages, i keep getting thrown an error like this : 'Interaction' object has no attribute 'edit_message'

#

i have tried using the normal message.edit and it gave the same error

midnight orbit
#

can .respond() with ephemeral on_message messages?

slender lintel
# crimson coral nope

so would await edit_original_message(embed=new_embed) work? or is edit_original_message meant to be something else?

crimson coral
#

ctx.respond doesn't return a Message, it returns an Interaction

#

so with your naming, you do message.edit_original_message... because message in this case is an Interaction

slender lintel
#

and message is my ctx.respond variable name?

crimson coral
#

well that's what im guessing anyway

slender lintel
#

ight ill test it out, thanks

#

@crimson coral do you know how to make the bot think?

crimson coral
#

uhhh

#

like typing status?

slender lintel
#

is it await ctx.deffer() or something

#

yea, it allows the bot longer to send a message

crimson coral
#

yes await ctx.defer() is used when you know the bot will take more than 3 seconds to respond

slender lintel
#

yeaa ight thanks

#

finally 😂

#

no more interaction failed

wraith finch
#

so I have a command which calls this and after it makes the dataentry the command doesn't do anything else and just stops after making the dataentry when I use the command once again cause there already is a dataentry it doesn't create one and the command words, anybody know what's happening here?

crimson coral
#

nice

south ermine
slender lintel
#

Hey, when i restart the bot then is my button not working, i have tried with on_ready but not working..

    @commands.Cog.listener()
    async def on_ready(self):
        view = discord.ui.View(timeout=None)
        view.add_item(teststation_button())
#

I can't view the slash command

#

using the latest beta version^^

slender lintel
slender lintel
#

yes

supple ravineBOT
#

Here's the persistent example.

crimson coral
slender lintel
#

so only self.bot.add_view more not?

crimson coral
#

self.bot.add_view(view) along with your previous code

#

but again, you should have a general look at the example

slender lintel
# crimson coral `self.bot.add_view(view)` along with your previous code
Ignoring exception in on_ready
Traceback (most recent call last):
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\venv\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\zReaxrYT\PycharmProjects\Discord\extensions\[Teststation].py", line 79, in on_ready
    self.bot.add_view(view)
AttributeError: 'teststation' object has no attribute 'bot'
crimson coral
#

client?

slender lintel
#

no bot

crimson coral
#

where did you define the on_ready

slender lintel
#

in my cog

crimson coral
#

and your cog doesn't have a bot attribute...?

slender lintel
#

no slash commands now

slender lintel
crimson coral
#

can you show your cog's __init__

slender lintel
#

now this command is back

slender lintel
crimson coral
#

.

#

sigh

slender lintel
#

need init?

crimson coral
slender lintel
#

🤔

#

any way around to get the slash command

crimson coral
slender lintel
slender lintel
crimson coral
#

can you show the code for the slash command

slender lintel
#
@slash_command(name="play", description="Plays a music!", guild_ids=guild_ids)
async def play(self, ctx, *, query):
    player = self.bot.lavalink.player_manager.get(ctx.guild.id)

    query = query.strip('<>')


    if not url_rx.match(query):
        query = f'ytmsearch:{query}'

        results = await player.node.get_tracks(query)

the starting

#

using cog btw ^^^

crimson coral
crimson coral
#

(also please consider making a help thread via #969574202413838426)

slender lintel
slender lintel
crimson coral
#

i mean, when are you calling load_extension

#

ohok

slender lintel
#

in the main file?

crimson coral
#

yes

slender lintel
#

before using client.run

crimson coral
#

not in on_ready or anything right?

slender lintel
#

yeah

crimson coral
#

hm

slender lintel
crimson coral
#

did you override on_connect?

slender lintel
#

channel.id does get the channels id right?

crimson coral
#

yeah