#discord-bots

1 messages ยท Page 236 of 1

vocal snow
#

How are you syncing the CommandTree?

twilit grotto
#

importing a specific function like that, you dont have to do random.randint, just do randint(1-100)

raw quail
#

hmm.. okay i will look for docs more

raw quail
vivid axle
#

you need to sync the commands right

#

i think

#

that should help

raw quail
#

ohhhhhhh

#

thank you so much! i was looking for that

uneven imp
#

How can I host my bot for free

vivid axle
#

i use diva hosting

slate swan
#

heyy

#

i have to code a bot so where i have to code

#

i am doing coding at replit

#

@quick flare

quick flare
#

idk bout that thinks

tired notch
#

how do i disable a button after clicking this is what i tried so far

class Chooser(View):
    def __init__(self):
        super().__init__()

    @button(label="1", style=discord.ButtonStyle.blurple)
    async def chooser(self, interaction: discord.Interaction, button_object: Button):
        button_object.disabled = True
        button_object.label = "DISABLED"
        await interaction.response.send_message("You picked 1")

    @button(label="2", style=discord.ButtonStyle.red)
    async def chooser2(self, interaction: discord.Interaction, button_object: Button):
        button_object.disabled = True
        button_object.label = "DISABLED"
        await interaction.response.send_message("You picked 2")```
uneven imp
#

Bro

hushed galleon
tired notch
#

whats the difference between the 3

hushed galleon
#

they use different API methods and only work in certain situations

tired notch
#

oh i get it the last one is only if you sended another message right

#

and you want to edit the button on that one

hushed galleon
#

uhh the other way, if you use send_message() then discord's concept of "original response" refers to your new message, rather than the message that your interaction came from

#

also i screwed up edit_original_message yet again, dpy 2.0 changed it to edit_original_response

tired notch
#

oh ok thank you

#

whats defer

hushed galleon
#

!d discord.InteractionResponse.defer

unkempt canyonBOT
#

await defer(*, ephemeral=False, thinking=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Defers the interaction response.

This is typically used when the interaction is acknowledged and a secondary action will be done later.

This is only supported with the following interaction types...
slate swan
hushed galleon
#

you give a response so discord doesnt tell the user that your bot failed to respond, but it doesnt actually send any message

tired notch
#

ok thanks

hushed galleon
unkempt canyonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

potent spear
# slate swan

spot the typo in line 15 too (that'll be your next issue)

slate swan
#

in that line?

potent spear
#

fix your errors one by one... you'll see

#

worry about intents first ^

slate swan
#

what parameter should we give for intents?

#

ah got it

slate swan
#

helo here plzzzz

#

u just need to type

#

discord.Client(intents=discord.Intents.default())

slate swan
#

inside the parenthesis type intents=discord.Intents.default()

potent spear
#

you'll still want to enable the message_content intent too though, there's literally a codeblock of it from the bot^

slate swan
#

isn't it capital C?

#

Client*

potent spear
#

you're just mixing up commands.Bot and discord.Client

vivid axle
slate swan
potent spear
slate swan
#

yea it's lowercase maybe cause u didn't import the modules properly

#

idk i haven't created a discord bot

vocal snow
#

I would really recommend learning python

potent spear
#

you're guessing at this point.
some pointer: you should have some basic python knowledge before starting to make a bot like this

#

line 14, you're just creating a bot, but not storing it in a variable...

vivid axle
potent spear
#

you lack the knowledge between an instance of a class and a class itself

#

hence the Client vs client

slate swan
#

are u telling me?

potent spear
#

you're also creating an intents variable which you're never using

potent spear
slate swan
#

yea i never made a discord bot

#

so i thought he made a mistake in the spelling or something

#

but why is the client thingy undefined

#

import problem?

vocal snow
#

Because it isn't defined anywhere

potent spear
#

because he never defined the client... ๐Ÿง 
or in other words
there's nowhere a line to be seen where a variable named client is defined

vivid axle
#

Lol

slate swan
potent spear
#

I get that you just want to make something asap and worry about what it means later, but having some fundamentals will help loads

vivid axle
#

I said lol

slate swan
#

big brain

potent spear
#

5 mins creating & 2 hours debugging <<< 1 hour creating, 5 mins debugging

#

if you know what you wrote, it's easier to understand issues later

#

I've learned it the bad way too though (learned python while creating a bot, when it was recommended to have intermediate python knowledge before starting out, which I didn't have)
do as I say, not as I do

meager chasm
#

Python's simple syntax results in people taking it for granted and thinking they can mash random code together and it will work fine

potent spear
#

which works, until it doesn't

slate swan
#

if he did copy the things properly it would have worked

#

i searched it up

#

he didn't even copy the code properly

potent spear
#

not through AI I hope

meager chasm
#

It would've worked till he wanted to add his own unique features

slate swan
#

yea right

#

helpppp

#

@pallid turtle

pallid turtle
slate swan
slate swan
slate swan
#

You should learn basics first

slate swan
#

i haven't coded a discord bot yet

#

but what it's saying is

#

u r supposed to pass in a parameter for an argument

#

the argument is intents

#

client = discord.Client(intents=discord.Intents.default())

#

type this

#

U should learn how this whole thing works

#

this is just copying code

potent spear
slate swan
#

i just copied it i haven't really learnt anything about the discord.py module

#

I just know u need to pass in some parameter

vocal snow
# slate swan -_-

Python has a simple syntax but that doesn't mean it's easy. Everyone here has learned the basics, unfortunately there are no shortcuts to that

slate swan
#

umm.... can someone tell me wht should i do next after creating a strt command for my bot????

slate swan
slate swan
#

@slate swan

slate swan
#

am back btwjoe_salute

slate swan
slate swan
glad cradle
#

use your fantasy

slate swan
#

lol

glad cradle
slate swan
slate swan
#

long time no see@slate swan

#
import os

import discord
from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')

client = discord.Client()

@client.event
async def on_ready():
    print(f'{client.user} has connected to Discord!')

client.run(TOKEN)```
#
  File "main.py", line 10, in <module>
    client = discord.Client()
TypeError: Client.__init__() missing 1 required keyword-only argument: 'intents'
๎บง 

#

error

unkempt canyonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

slate swan
slate swan
slate swan
slate swan
slate swan
#

on the link

slate swan
slate swan
slate swan
slate swan
slate swan
little surge
#

Where do I begin coding a bot

slate swan
#

waiting......

slate swan
slate swan
little surge
slate swan
slate swan
#

damn u just copy pasted

slate swan
little surge
slate swan
little surge
#

but

slate swan
#

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

slate swan
slate swan
slate swan
#

under import btw

slate swan
slate swan
slate swan
#

down wait

slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
#

lol he is like me altho@slate swan

#

i guess every ruki is like this

slate swan
unkempt canyonBOT
slate swan
#

so i guess its better to explain it than make you come back here every day and ask for same thing

#

how can i fix my code>

slate swan
slate swan
#

u have to learn python i guess

#

what does the error tell you

#

good question

#

i was going to ask same thing

slate swan
slate swan
#

i guess

slate swan
slate swan
slate swan
slate swan
#

so ?

slate swan
#

look at me i am u just betterjoe_maverick

slate swan
slate swan
#

gotcha

#

yes

slate swan
#

varriable intents is not defined

slate swan
#

then define

#

so you are trying to use varriable that you never created

#

ezzz

slate swan
#
import os

import discord
from dotenv import load_dotenv

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

load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')

client = discord.Client()

@client.event
async def on_ready():
    print(f'{client.user} has connected to Discord!')

client.run(TOKEN)```
#

@slate swan listen today i am here but what if tommorow i wont be here

slate swan
#

u have think it by urself how u gonna do it

slate swan
#

okay but if you got this code already

slate swan
#

you need to pass intents to Client

#

do you know what that means?

#

no

slate swan
slate swan
#

jk

slate swan
#

๐Ÿ˜‚

#

@slate swanbtw which type of bot u r trying to make

meager chasm
#

why bother trying to help people with no intention of learning or doing anything on their own

slate swan
#
something = ... 

my_var = MyClass(something=something) # passing something to MyClass

#

thats what i meant

slate swan
#

now try to do that with intents and Client @slate swan

slate swan
#

except permanent marker๐Ÿ˜‚

slate swan
slate swan
#

can you code some other for example

#

!clients

slate swan
#

!intents

unkempt canyonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

slate swan
#

instead of commands.Bot you have discord.Client

slate swan
slate swan
slate swan
slate swan
slate swan
#

oof tht hurts from inside my heart damn!!! //yert //

#

sigma down

#

lol

#

hey boysss

#

@slate swan@slate swan

#

i did ittt

#

it come online yeeeeeeeeeeeeeee

#

wow nice work

welcome to heaven

slate swan
#

what should i do

#

That's debugging

#

You prolly want to run it normally

#

whts wrong in tht

slate swan
#

tht inline = false didnt helped tho

#

where u went u were here one sec before bruh

slate swan
#

next line is \n

slate swan
#

!embeds

#

f

merry wren
#

yo

#

how do i create a slash commands using discord.py ?

slate swan
#

@slate swanhow can i do it in an embedded system tho??

slate swan
#

where is the docs for embed

steady flume
#

wdym

slate swan
#

ty sir

steady flume
#

someone tell me, how to add 2 views ?

#

for ex
here im editting message and pin one view, but i wanna add other one too

await interaction.response.edit_message(embed=embed2, view=view)
smoky sinew
steady flume
smoky sinew
#

you just put the components in the second view and add them to the first view

merry wren
#

after 3h

#

now lets just wait 3h to check if its really works ๐Ÿ’€

smoky sinew
#

what

uneven imp
#

So why yโ€™all gate keeping how to make a discord bot?

uneven imp
#

The gate keeping is outrageous

smoky sinew
#

what

strong knoll
vocal snow
smoky sinew
#

the gate keepers

vocal snow
#

cant believe they are keeping the gates like that

slate swan
#

yo whys no one responding to my question

smoky sinew
#

this doesn't work

#

reload all the bot extensions instead

slate swan
smoky sinew
#

!d discord.ext.commands.Bot.reload_extension

unkempt canyonBOT
#

await reload_extension(name, *, package=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Atomically reloads an extension.

This replaces the extension with the same extension, only refreshed. This is equivalent to a [`unload_extension()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.unload_extension "discord.ext.commands.Bot.unload_extension") followed by a [`load_extension()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.load_extension "discord.ext.commands.Bot.load_extension") except done in an atomic way. That is, if an operation fails mid-reload then the bot will roll-back to the prior working state.
slate swan
#

and
i want to make a slash commadn that collects data in json
like
{
"1103352234848292975": f"{data}",
new data}

#

@smoky sinew

smoky sinew
#

what data

slate swan
#

like
dark devil is a legit server booster

smoky sinew
#

๐Ÿ’€

slate swan
#

or like
5star rating

#

like that its a vouch bot

#

<@&831776746206265384>

west escarp
#

!pban 725403494177046578

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied ban to @shadow dirge permanently.

formal basin
slate swan
#

any one alive?

slate swan
slate swan
#

i made it but when a user gives feeedback it replaces it

#

understood?

#

no i only understand that you want to create feedback command and it accepts string arg with actual feedback

smoky sinew
#

what do you actually need help with though

#

which parts don't you understand

slate swan
#

^

slate swan
#

thats what you mean?

#

yep

#

then store it as list of feedbacks

#

suppose
xuser: 5/5
when some other guy vouches other guy it replaces xuser and keeps yuser
consider x and y as developer id

slate swan
slate swan
#

show code

#

would anyone be able to send code to make 2 simple button that do different things

slate swan
slate swan
# slate swan how do you store it now

@bot.slash_command(guild_ids=[config["guildID"]], name="vouch", description="Add your vouch here.") async def addcap(ctx, vouch: discord.Option(str, "enter feedback", required = True)): if ctx.author.id not in config["sellerID"]: return await ctx.respond(embed = discord.Embed(title = "**Missing Permission**", description = "You must be a **SELLER** to use this command!", color = 0xc80000)) if ctx.author.id in config["sellerID"]: data = [ { f"{ctx.author.id}": vouch } ] with open("vouc.json", "w")as p: json.dump(data, p) embed1 = discord.Embed(title="**Sucess**", description=f"Sucessfully saved your vouch: ||**{vouch}**||") message = await ctx.send(embed=embed1) await message.add_reaction('โŒ') def check(reaction, user): return user == ctx.author and str(reaction.emoji) == 'โŒ' and reaction.message.id == message.id try: reaction, user = await bot.wait_for('reaction_add', timeout=60.0, check=check) except asyncio.TimeoutError: pass else: await message.delete()
here is it

slate swan
#

yes but

#

so what is it then

#

wdym bro

#

what library do you use

slate swan
#

you dont know what lib you use huh ?

slate swan
slate swan
slate swan
# slate swan

so the number is the user id and the kj is the feedback yes?

#

i copy and paste the basic libs and import the extra libs

slate swan
#

when a new guys vouches it replaces it

slate swan
# slate swan yessssir

then instead of storing it as "kj" you can store it as list ["kj"] and then when there is new feedback it will look like ["kj", "other feedback"]

smoky sinew
#
CREATE TABLE IF NOT EXISTS feedback (
    user_id BIGINT,
    guild_id BIGINT,
    feedback TEXT,
    PRIMARY KEY (user_id, guild_id)
)
slate swan
smoky sinew
#

then just do VARCHAR(4000)

slate swan
#

solid

smoky sinew
#

feedback goes in modal

slate swan
#

like this?

#

Down

slate swan
#

you need to append to list

#

if the list exists

#

smtg like this?

#

try

smoky sinew
#

why are you append member id

slate swan
#

but you want to add feedback

#

i prefer developer id as it never changes unless u change ur acc

#

not id

#

dont you

#

i do

#

but the feedback is for a guy
so it displays the feedback of the guy

smoky sinew
#

not the ID

slate swan
#

yep

#

wait

#

if someone vouches someone else it shouldnt replace the exsisting data

#

ngl im confused

smoky sinew
#

yes that's why you want to use the feedback in a list

#

this would be a lot better in a relational database rather than JSON

#

you could have a sellers table and a reviews table

#

reviews could have columns such as seller_id buyer_id guild_id feedback

slate swan
smoky sinew
#

it depends on the database you're using

slate swan
#

mongodb? or sql?

shrewd apex
#

either

slate swan
#

idk databases lol im a JSON guy

slate swan
smoky sinew
#

mongodb is not a language and sql is a family of databases

#

mongodb is not relational though it's a document database

shrewd apex
slate swan
shrewd apex
#
  • its free if thats a changing factor
smoky sinew
#

just don't use pymongo

slate swan
smoky sinew
#

you don't have to pay

slate swan
#

first db is free

smoky sinew
#

both *sql and mongodb are free if you can host it on the same computer as your bot

shrewd apex
#

trust me if u have upto 512mb of discord bot data u will be making enough money to pay for ur own db

slate swan
shrewd apex
#

512 is a lot

smoky sinew
#

mongodb is only paid if you host it on atlas

slate swan
#

guys this is getting too deep

#

icl i want it be simple as ill be selling this to others and i want to be as user friendly as possible to the dummiest ever

shrewd apex
#

i am imagining json files being sold for some reason๐Ÿ’€

slate swan
slate swan
#

bruh

#

i would sell the other with license and make sum money

#

who would buy JSON

shrewd apex
#

lmao good luck finding clients

slate swan
slate swan
shrewd apex
#

u need mongodb or sql json is mot for db

#

cuz its corruptable

#

if ur using mongo use motor library if u decide sql go with postgres or similar asynchronous drivers

#

(asyncpg)

slate swan
#

aiosqlite GIGACHAD

#

import asyncio

shrewd apex
slate swan
#

ty for da gelp tho

#

all of ya

#

luv ya

slate swan
shrewd apex
#

๐Ÿ˜”

vale wing
shrewd apex
#

fair enough

slate swan
#

btw is there anyone who is expert requests and spoofing(optional)

unkempt canyonBOT
#

5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.

smoky sinew
#

bobux bot

#

๐Ÿ’€

glad cradle
#

I'm a developer of bobux, Pokelore, leaf, I am everyone's friend and enemy

shrewd apex
#

txt files

slate swan
glad cradle
shrewd apex
shrewd apex
glad cradle
shrewd apex
slate swan
shrewd apex
#

;-;

glad cradle
#

sigh sometimes Pokelore makes me cry

slate swan
#

is there a way to disable all the buttons on 1 message with 1 message

shrewd apex
#

u still didn't sort the embed thingy loooli ?

#

I'll do it tmrw ig

shrewd apex
slate swan
slate swan
shrewd apex
#

bro be focused on 1

glad cradle
shrewd apex
shrewd apex
#

I'll do the minigames tmrw

glad cradle
shrewd apex
#

or if u free we could each do one

glad cradle
#

yeah + yes yeas

shrewd apex
unkempt canyonBOT
glad cradle
shrewd apex
#

just pick one

glad cradle
#

ok I'll check it later

#

btw yesterday I worked on two PRs for disnake ๐Ÿ”ฅ๐Ÿ”ฅ

shrewd apex
#

aight just ping me with whichever u pick

shrewd apex
#

make a disnake pr which handles oauth flow

glad cradle
#

and I was trying to fix a quite serious bug regarding sub commands but sigh

slate swan
glad cradle
slate swan
#

what bot tho

#

and what do i do

shrewd apex
#

pokelore definitely

glad cradle
#

ash let's down join Pokelore if that's ok for you

shrewd apex
#

i am all hands up for free help

shrewd apex
smoky sinew
slate swan
#

yes i would like to join if there is something i can do

glad cradle
glad cradle
shrewd apex
smoky sinew
glad cradle
#

yes I saw it

shrewd apex
smoky sinew
#

how disnake work??

slate swan
smoky sinew
#

wait i'm gonna test the branch

slate swan
#

wait i need to reconnect my github to discord cause its actually incorrect now

shrewd apex
#

aight

glad cradle
shrewd apex
#

i added the role

smoky sinew
#
Because leaf-bot depends on disnake-jishaku (^2.6.5) which doesn't match any versions, version solvi
ng failed.
glad cradle
#

what, lemme check

smoky sinew
#

ahh you didn't lock poetry

#

silly goose

shrewd apex
#

lmao

glad cradle
#

it was a draft ducky_sphere ducky_sphere

smoky sinew
#

did you gitignore pyproject.toml or something

glad cradle
#

mh, maybe

#

I remember changing the version of Python to run the Bot

smoky sinew
#

AttributeError: 'LeafBot' object has no attribute 'database'

#

wtf

glad cradle
#

sigh

smoky sinew
#

oh wait

glad cradle
#

it was working when I writed it so you are the problem!

smoky sinew
#

i forgot i loaded a non-existent extension

glad cradle
left dew
#

why does my code throw an except error to a try statement but the bot has already responded to the try statement

merry wren
#

can someone help me, how do i make (send) a button.

smoky sinew
unkempt canyonBOT
#

class discord.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
meager orchid
smoky sinew
#

@glad cradle it's a disnake user!!

polar scroll
#

how can i improve this?

fading marlin
#

Don't do any of that in on_ready. discord.Client has status and activity kwargs that you can use, and use a owner-only message command to sync your tree

smoky sinew
#

and don't sync in on_ready

#

and rename your bot variable to bot rd_dogeheh

#

since you are probably using commands.Bot

latent mirage
#

By doing so you get rid of the risk that someone may call a command before the bot has loaded them

tired notch
#

is there a way to delay button clicks so i dont get rate limited

slate swan
#

anyone got ideas on what commands i should add to my bot or how to improve it

smoky sinew
#

you want to send an API call after Client.run is called

#

before the bot's http session has even initialized

latent mirage
#

Wdym by api call

polar scroll
#

Okok, thanks everyone

smoky sinew
latent mirage
#

Oh yeah, i forgot, discord is technically forcing you have commands interface with their way of integrating commands instead of the bot passively reading chat messages

smoky sinew
#

oh yes building my own command parser is so much fun

slate swan
#

how can i made a discord bot using spotify api to play music?

latent mirage
smoky sinew
#

the only thing i miss about ext.commands is the flags converter but i can still do it with the string converter

kindred crater
#

I recently made a program that was fully function less then 6 hours ago, and after attempting to run it again, discord api is now returning a 403 error, (Forbidden). What I cant seem to understand is why it is throwing that error when not a single bit of code was touched, here's the code.

def sendMessage(token, id, message):
    url = 'https://discord.com/api/v10/channels/{}/messages'.format(id)
    data = {"content": message}
    header = {"authorization": token}

    r = requests.post(url, data, headers=header)
    if r.status_code == 200:
        print(Fore.GREEN + "[Success] Message sent to " + Fore.CYAN + format(id))
    else:
        print(Fore.RED + "[Failed] Could not send message to " + Fore.CYAN + format(id) + Fore.RED + "\n[Error] Error code " + str(r.status_code))
#

after changing the token i now get a 401 error, any ideas on what may be the issue?

sick birch
sick birch
#

Could have something to do with id being a built in

#

perhaps try printing url to see if it's expected?

kindred crater
sick birch
#

print(url)

kindred crater
#

okay yeah

sick birch
#

The only other thing then is to make sure your bot has access to that channel

kindred crater
#

checked that as well

#

which is why im so confused

sick birch
#

Reset your bot token and use the new token, and double check the channel ID

kindred crater
#

i cant seem to fix it.

sick birch
#

How'd you get the bot to own the server?

kindred crater
#

its not running off bot atm

sick birch
#

Then?

kindred crater
#

its just running off a discord acc

sick birch
#

Ah, that's why

#

Those are against discord's terms of service

kindred crater
#

wasnt planning on making it like this long term

#

but if i cant even fix it to work like this prob not gonna mess with it anymore

sick birch
#

It'll work perfectly if you used an actual bot token

kindred crater
#

fixed it

#

back working with regular tokens and bot tokens now

slate swan
#

i am having a problem in

#

visual code

#

@static tinsel

smoky sinew
smoky sinew
unkempt canyonBOT
#

await create_guild(*, name, icon=..., code=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").

Bot accounts in more than 10 guilds are not allowed to create guilds.

Changed in version 2.0: `name` and `icon` parameters are now keyword-only. The `region` parameter has been removed.

Changed in version 2.0: This function will now raise [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.11)") instead of `InvalidArgument`.
shrewd apex
#

discord is ready for that scenario

glad cradle
#

notable contributor, pay respect ducky_sphere ducky_sphere

vocal snow
glad cradle
glad cradle
smoky sinew
#

@glad cradle are you textual user

glad cradle
smoky sinew
glad cradle
#

ah I used it once

pallid stirrup
#

Why it fails to give everyone coins

everyone = ctx.guild.members
for member in everyone:
if member.bot:
continue
add_coins(member.id, amount)
time.sleep(0.05)

vocal snow
#

Member intents enabled?

#

And don't use time.sleep, use asyncio.sleep

pallid stirrup
#

this worked ty

slate swan
#
@bot.listen("on_message")
async def detect_msgs(message: discord.Message) -> None:
    if message.author.bot:
        return

    for user_id, reason in afk_users.items():
        if f"<@!{user_id}>" in message.content or f"<@{user_id}>" in message.content:
    
            embed = discord.Embed(description=f"<@{user_id}> is currently AFK with status: **{reason}**", color=0x808080)
            await message.channel.send(embed=embed)
    
    if message.author.id in afk_users:
        del afk_users[message.author.id]
        embed = discord.Embed(description=f":wave: <@{message.author.id}>: Your AFK status has been **removed**.", color=0x808080)
        await message.channel.send(embed=embed)

How can I make the bot ignore when I originally set my afk status?

vocal snow
#

what do you mean by that?

slate swan
smoky sinew
#

whart

#

i have been summoned by @vocal snow

pallid stirrup
#

Damn, it took bot 15 minutes to give everyone coins

upbeat gust
#

why do you have a delay?

pallid stirrup
upbeat gust
#

That doesnt explain anything

#

why would you need a delay

pallid stirrup
#

Bot would overload because of a little weak monitoring

upbeat gust
#

what?

upbeat gust
#

This should be something you can do with one db operation

#

You're definitely doing something wrong if you need to take 15 minutes to "add coins"

short silo
#

I need some basic knowledge about bot hosting.

I have a bot that uses asyncio.to_thread() for a few io based tasks and other stuff. What kind of host should i choose, for that ? I am doing this for the first time so it maybe a stupid question.

So, most hosts provide a single thread to run on, would that hamper with the bot ? it should, right ? Whats the soln.

smoky sinew
#

you can create unlimited threads in python pretty much

#

how would the host restrict you from doing that

short silo
short silo
vocal snow
#

(these threads aren't physical threads)

short silo
#

I guess time to learn threading

short silo
vivid axle
#

is it possible to ban a user who is outside the guild?

#

like guild.ban(user)

#

or something?

vocal snow
#

yes

#

!d discord.Guild.ban

unkempt canyonBOT
#

await ban(user, *, reason=None, delete_message_days=..., delete_message_seconds=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Bans a user from the guild.

The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

You must have [`ban_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") to do this.
vocal snow
#

it takes any Snowflake

#

so you can pass a discord.Object

vivid axle
#

thank you thumbs_up_cat

slate swan
#

Hey

#

I need source code of bots

vivid axle
#

dont copy people

#

or ur a skid

short silo
vocal snow
#

io bound blocking can be avoided with context switching

#

the executing thread is swapped whenever it has to wait on some io

#

anyways, what are you threading?

short silo
vocal snow
#

ah ok, that would be entirely cpu bound i suppose

vocal snow
#

yeah on something with a single cpu im not sure if thats a good idea

short silo
vocal snow
#

are you looking for a free one?

short silo
#

nope, paid works

vocal snow
#

those are what are generally recommended

#

you could also do a free trial for gcp/aws/azure/, try your code out and then go to a paid one

#

gcp has a forever free tier, i think a dual core machine

eternal shuttle
#

why does this keeps on showing on my terminal everytime i try to run my file on the terminal

#

this is my code

short silo
vocal snow
vocal snow
#

which could have 1 or more threads

eternal shuttle
smoky sinew
eternal shuttle
#

it was the old token

smoky sinew
#

๐Ÿ‘

smoky sinew
short silo
#

what config do i need

smoky sinew
#

what config

#

just run it on one instance

#

!intents

unkempt canyonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

short silo
eternal shuttle
#

how do i fix this

smoky sinew
unkempt canyonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

slate swan
eternal shuttle
#

this thing keeps showing everytime i debug the code

slate swan
#

pip install -U discord.py

unkempt canyonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

smoky sinew
#

just use poetry bro ๐Ÿ‘

slate swan
eternal shuttle
smoky sinew
#

replit uses poetry for you ms_troll

slate swan
smoky sinew
#

actually no just remove client

eternal shuttle
smoky sinew
#

also enable message content in your developer portal @eternal shuttle

meager orchid
smoky sinew
slate swan
smoky sinew
#

nobody used client until slash commands were a thing ๐Ÿ’€

slate swan
#

oh my

#

you need to run it as a command in the terminal

eternal shuttle
#

if i remove client, wouldn't it make the @client.event useless?

slate swan
#

i dont know how you do that in this ide you are using

slate swan
short silo
#

so, some help with amazon ec2, i need to run some cpu bound tasks along with the bot itself i.e 2 threads or more so, does t4g nano works ?

maiden fable
#

That's replit

eternal shuttle
slate swan
#

there is more advanced and more readable idea when creating them using a bot

eternal shuttle
#

what do i do with this

slate swan
smoky sinew
short silo
#

why is your 5th line, pip install discord py

smoky sinew
#

use it??

short silo
#

run it ?

slate swan
#

remove this line from code

#

it should be run into console not python script

smoky sinew
#

you said you were going to comment that out

short silo
#

Put a hash before the pip install

slate swan
#

No, simply remove it from the file as mentioned previously

smoky sinew
#

console

#

as in shell, not REPL

#

you should be using poetry add discord.py instead though

upbeat gust
#

Yeah replit uses poetry

#

Or even just use the packages tab

slate swan
#

check by running the code?

smoky sinew
#

don't use discord_slash

upbeat gust
#

Where did you get this code?

thin raft
slate swan
meager orchid
formal basin
#

How do I give roles with buttons?

smoky sinew
upbeat gust
smoky sinew
formal basin
smoky sinew
unkempt canyonBOT
#

await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s.

You must have [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
upbeat gust
#

Which part do you need help with, that's what I'm asking

formal basin
#

I have no code for it

upbeat gust
meager orchid
upbeat gust
formal basin
smoky sinew
#

just use an example ^^^

#

base your code off that

formal basin
#

What file is the example on?

upbeat gust
#

All of them

smoky sinew
#

all of them lol

upbeat gust
#

Except select or dropdown idr

smoky sinew
#

ok

upbeat gust
#

what error

formal basin
upbeat gust
#

Ok?

smoky sinew
#

!tracebacj

unkempt canyonBOT
#
Traceback

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
        ~~~~^~~
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

upbeat gust
#

Last time I asked someone to show their replit error they Made a screen recording

formal basin
# upbeat gust Ok?

How do I turn this

discord.ui.button(label='Confirm', style=discord.ButtonStyle.green)
async def confirm(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_message('Confirming', ephemeral=True)
self.value = True
self.stop()

Into a normal file

upbeat gust
#

Wdym a normal file

formal basin
#

Like not in a cog

smoky sinew
#

it's not a cog

upbeat gust
#

It's not in a cog though?

smoky sinew
#

just because it's in a class doesn't make it a cog

formal basin
#

Oh

slate swan
#

dont use discord_slash

upbeat gust
#

huh

slate swan
#

no i gave you example of slash commands in discord.py

smoky sinew
#

cool ๐Ÿ‘

timid spade
#

can you know the device info of user?

upbeat gust
#

like what platform they're on?

smoky sinew
steady flume
#

how to remove roles from member by using list type?

#

i mean i have list and wanna remove all of this roles in list

#
languages = [1104125991128944834, 1104126202425397338, 1104126311733141564, 1104126793423781982, 1104126892547780649, 1104127041059700979]
        await interaction.user.remove_roles(languages)
timid spade
timid spade
smoky sinew
glad cradle
# meager orchid I don't get it, but messages respond to messages with a button. Or how should it...

what you're actually doing is ok and actually it works but interactions needs to be responded, otherwise discord will flag it as failed

now there are different types of interactions: interactions that comes from app commands (slash commands), from buttons, from context menus, etc...

you need to use the interaction of the button, you're actually using it to check if the author is the same as who invoked the command

in your case you need to send a response using interaction_ctx

something like
await interaction_ctx.response.send_message(...) or await interaction_ctx.send(...)

#

regarding the first question I did not understand what you mean

meager orchid
white citrus
slate swan
#

Doesn't seem related to Discord bots but rather #databases, not every code that is for your bot is related to discord.py and similar libraries

#

It's a question about aiomysql and how to set it up properly which is to be asked in #databases

slate swan
#

Invalid token

#

and the stickers are superfluous

smoky sinew
#

you've already been told to show your actual traceback

#

but given that it's unauthorized yeah krypton is probably right

north kiln
#

I have a question about building an auto complete choice list by querying to a database
basically it works like a search where the user input a name and I try to display possible options similar to the input from a fixed list in my database. I am currently trying to use a function to return a list after a query then call that function in the autocomplete function, something like

  async def fetch_name(self):
        async with aiosqlite.connect('./db/discord.db') as db:
            async with db.execute(sql) as cursor:
                query = await cursor.fetchall() 
                return query

  @command.autocomplete('name')
  async def autocomplete_name(self, interaction: discord.Interaction, current: str):
       name_list = fetch_name()
       return get_close_matches(current, name_list)  

I am not sure what is the best way to do this because it seems like the bot will keep making connections to the database

smoky sinew
#

lrucache will work in this scenario

north kiln
#

I will look into it

#

I have thought of making a cache but never learn how

glad cradle
smoky sinew
#

yes

fiery hare
#

!intents

unkempt canyonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

formal basin
#

I have made a link blocker but how do I make it so it ignores a link in a certain channel?

upbeat gust
#

check what channel the message is in

upbeat gust
formal basin
upbeat gust
upbeat gust
slate swan
#

"filter" bypassed, ggs

upbeat gust
#

exactly

#

regex will be much better, but still not perfect

formal basin
#

Oh

formal basin
upbeat gust
slate swan
#

What do you think

formal basin
upbeat gust
#

really seems like you are if ur asking whether to use an if statement

formal basin
upbeat gust
#

just check if the channel name or id is the one you want to ignore

formal basin
#

Ok

abstract kindle
#

Hey yo, how can I access my bot instance in a lower file?

@classmethod
def new(cls):
  guild = bot.get_guild(856915776345866240)
```I need to access bot here to retrieve the guild, but I don't have access to `bot` in this file
formal basin
#

It says else: is an invalid syntax

formal basin
slate swan
abstract kindle
upbeat gust
abstract kindle
upbeat gust
#

yes, what's the purpose of this other file?

upbeat gust
#

dpy has extensions and cogs that allow you to split commands into seperate files, maybe thats what you're trying to do

#

otherwise, just pass your bot instance to that func/method as an arg

abstract kindle
abstract kindle
#

Got it

eternal shuttle
#

how do i fix invalid syntax everytime i try to run my code on the terminal?

formal basin
#

I donโ€™t have an error and it doesnโ€™t work

naive briar
eternal shuttle
#

i mean i dont think theres any wrong syntax on my code

naive briar
#

Show it then

eternal shuttle
#

hollon

#

can i send it on ur dm?

naive briar
#

No

eternal shuttle
#

alr holdon

vocal snow
#

!paste

unkempt canyonBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

eternal shuttle
naive briar
#

!e

print(
    "cat"
    "meow"
)
unkempt canyonBOT
#

@naive briar :white_check_mark: Your 3.11 eval job has completed with return code 0.

catmeow
naive briar
#

!traceback

unkempt canyonBOT
#
Traceback

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
        ~~~~^~~
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

eternal shuttle
#

bot = discord.Client()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'discord' is not defined

vocal snow
#

you forgot to import it?

upbeat gust
#

That doesn't match the code you showed

eternal shuttle
#

nah wait

#

wrong one

upbeat gust
#

Also why are you shadowing bot and on_ready?

#

Use discord.Client OR commands.Bot, not both

eternal shuttle
#

oh yeah i forgot to delete the discord.Client

#

!intents

unkempt canyonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

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

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

eternal shuttle
#

ok so i changed my code to this

#

and here's the traceback i got

Traceback (most recent call last):
File "c:\Users\Ryxx\Desktop\Akairo Project\bot.py", line 8, in <module>
client = discord.Client()
TypeError: Client.init() missing 1 required keyword-only argument: 'intents'

vocal snow
#

you do not need both Client and Bot

#

choose one

eternal shuttle
#

what about now?

#

oh i forgot to turn on the intents that's needed on the discord dev portal ๐Ÿ’€

#

all good

fiery hare
polar scroll
#

how can i improve this?

vocal snow
#

Only enable the intents you really need, use setup_hook instead of on_ready, remove unused imports, fix type annotations

magic whale
#

hello

#

can anyone tell me how to delete a message in discord.py?

vocal snow
unkempt canyonBOT
#

await delete(*, delay=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other peopleโ€™s messages, you must have [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages").

Changed in version 1.1: Added the new `delay` keyword-only parameter.
vocal snow
#

You can get a discord.Message object via Messageable.fetch_message or from Context/Interaction/other source depending on your code

magic whale
vocal snow
#

Send your code and error please

magic whale
#
Traceback (most recent call last):
  File "C:\Users\JAPAN COMPUTERS\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ui\view.py", line 425, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\JAPAN COMPUTERS\Desktop\Codestore Bot\main.py", line 299, in no_button_callback
    await discord.Message.delete(confirmation_message)
  File "C:\Users\JAPAN COMPUTERS\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\message.py", line 805, in delete
    await self._state.http.delete_message(self.channel.id, self.id)
          ^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute '_state'
#
async def no_button_callback(interaction , confirmation_message):
    print(confirmation_message)
    print(type(confirmation_message))
    await discord.Message.delete(confirmation_message)



async def buy_button_callback(interaction , message , confirmation_item):
    yes_button = discord.ui.Button(label="Yes" , style=discord.ButtonStyle.green)
    yes_button.callback = partial(yes_button_callback , message=message)
    
    no_button = discord.ui.Button(label="No" , style=discord.ButtonStyle.green)
    
    
    
    view = discord.ui.View()
    view.add_item(yes_button)
    view.add_item(no_button)
    confirmation_message = await interaction.response.send_message("**Are You Sure You Want To Buy This Item?**" , view=view)
    no_button.callback = partial(no_button_callback , confirmation_message=confirmation_message)
vocal snow
#

send_message doesn't return the message, you have to use Interaction.original_response iir

#

!d discord.Interaction.original_response

unkempt canyonBOT
#

await original_response()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Fetches the original interaction response message associated with the interaction.

If the interaction response was a newly created message (i.e. through [`InteractionResponse.send_message()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.send_message "discord.InteractionResponse.send_message") or [`InteractionResponse.defer()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.defer "discord.InteractionResponse.defer"), where `thinking` is `True`) then this returns the message that was sent using that response. Otherwise, this returns the message that triggered the interaction (i.e. through a component).

Repeated calls to this will return a cached value.
vocal snow
#

You call it on an instance of discord.Interaction, not the class

fiery hare
#

guys how can i make kick command for discord bot?

vocal snow
#

You'll need to learn classes to understand more about that, it's a slightly big topic for me to cover here

magic whale
vocal snow
#

Yes

magic whale
# vocal snow Yes
Traceback (most recent call last):
  File "C:\Users\JAPAN COMPUTERS\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ui\view.py", line 425, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\JAPAN COMPUTERS\Desktop\Codestore Bot\main.py", line 315, in buy_button_callback
    confirmation_message = discord.interaction.original_response()
                           ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'discord' has no attribute 'interaction'
``` ![pain](https://cdn.discordapp.com/emojis/910907788581040150.webp?size=128 "pain")
potent spear
twilit grotto
magic whale
vocal snow
#

That is generally what is used, but it's essentially a shortcut for Class.method(instance)

twilit grotto
#

ah

vocal snow
#

(The instance is passed to self)

potent spear
#

seems like he needs to grasp the difference between a class and an instance of it / an object

magic whale
potent spear
#

no

magic whale
potent spear
#

discord.Interaction is a class

#

interaction is a variable in your function, that's the one you need to access

magic whale
potent spear
#

how would you think you'd delete a message in the first place without showing me any code?

potent spear
#

read the last 5 words

magic whale
potent spear
#

why though?
why don't you just get the message object and call the .delete() method on it?

magic whale
potent spear
#

code + full error traceback when you had that error?

magic whale
potent spear
#

if you include everything that's in that message for every question you asked, you'd get loads of answers

opaque elk
#

Someone can help me for vc exp system?

fiery hare
#

PS C:\Discord Bot> & C:/Users/Sakura/AppData/Local/Programs/Python/Python311/python.exe "c:/Discord Bot/warn.py"
Traceback (most recent call last):
File "c:\Discord Bot\warn.py", line 2, in <module>
from discord.ext.commands import commands,has_permissions, MissingPermissions
ImportError: cannot import name 'commands' from 'discord.ext.commands' (C:\Users\Sakura\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\ext\commands__init__.py)

whats wrong, i was creating warn command

#

guys

#

how to install commands with pip?

sullen shoal
#

there's no discord.ext.commands.commands in discord.py

#

also, consider building your bot in the home directory of your system

fiery hare
#

maybe install discord.ext

sullen shoal
fiery hare
#

GUYS HELP HOW TO CREATE WARN COMMAND

slate swan
#

You may have forgotten to disable the all caps

fiery hare
#

is this module even exist?

slate swan
#

whts the matter?

slate swan
fiery hare
random obsidian
#

hello!
how can i make an slash command option , optional?

slate swan
slate swan
fiery hare
slate swan
#

k

#

@fiery harecan i ask which type f bot u r making?

fiery hare
#

moderating and support bot

slate swan
#

oh

fiery hare
#

i already created kick and ban system but i cant understand ticket system

slate swan
#

you learned by reading docs??

fiery hare
slate swan
fiery hare
#

2023-05-08 00:51:53 ERROR discord.client Ignoring exception in on_ready

what the matter

fiery hare
#

it has 212 lines....

slate swan
#

its hard to just tell by looking at error for newbies like me

slate swan
fiery hare
#

oh

#

so you need traceback?

slate swan
#

ya ig

fiery hare
#

Traceback (most recent call last):
File "C:\Users\Sakura\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 441, in _run_event
await coro(*args, **kwargs)
File "c:\Discord Bot\ticket.py", line 92, in on_ready
await tree.sync(guild = discord.Object(id=0))
File "C:\Users\Sakura\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\app_commands\tree.py", line 1069, in sync
data = await self._http.bulk_upsert_guild_commands(self.client.application_id, guild.id, payload=payload)
File "C:\Users\Sakura\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\http.py", line 738, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access

slate swan
#

can u send line 92?

fiery hare
#

ok

vocal snow
slate swan
#

hey zeffo

#

remeber? meh?

fiery hare
#

do i need to change 0 to guild id?

hushed galleon
#

ya, otherwise you'd be trying to sync to some guild that had the ID of 0

slate swan
#

ya ya

fiery hare
#

thxz

slate swan
#

@fiery harebro can i get a help?

fiery hare
slate swan
#

sry for being sticky

fiery hare
#

Sakura bot is mine bot

slate swan
#

gg

fiery hare
slate swan
#

oh

fiery hare
polar scroll
#

is it possible to use discord-py-slash-commands using nextcord?

slate swan
#

k'