#discord-bots
1 messages ยท Page 236 of 1
importing a specific function like that, you dont have to do random.randint, just do randint(1-100)
hmm.. okay i will look for docs more
i haven't try yet i will try it now thank you
oh yeah
you need to sync the commands right
i think
that should help
How can I host my bot for free
i use diva hosting
heyy
i have to code a bot so where i have to code
i am doing coding at replit
@quick flare
idk bout that thinks
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")```
Bro
you'll need to edit the message passing your view to refresh it, i.e. ```py
await interaction.response.edit_message(view=self)
If you already responded with edit_message()/defer():
await interaction.edit_original_message(view=self)
If you responded with send_message():
await interaction.message.edit(view=self)```
whats the difference between the 3
they use different API methods and only work in certain situations
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
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
!d discord.InteractionResponse.defer
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...
you give a response so discord doesnt tell the user that your bot failed to respond, but it doesnt actually send any message
ok thanks
!intents
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.
spot the typo in line 15 too (that'll be your next issue)
whay should i do
in that line?
helo here plzzzz
u just need to type
discord.Client(intents=discord.Intents.default())
wait
inside the parenthesis type intents=discord.Intents.default()
you'll still want to enable the message_content intent too though, there's literally a codeblock of it from the bot^
remove line 13 for now...
you're just mixing up commands.Bot and discord.Client
Not replit ๐ข
no uppercase
?
yea it's lowercase maybe cause u didn't import the modules properly
idk i haven't created a discord bot
I would really recommend learning python
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...

you lack the knowledge between an instance of a class and a class itself
hence the Client vs client
are u telling me?
you're also creating an intents variable which you're never using
no, the replit hoster
but you were guessing a fix for him too though
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?
Because it isn't defined anywhere
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
Lol
ok
and there's no need to be laughing
I get that you just want to make something asap and worry about what it means later, but having some fundamentals will help loads
big brain
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
Python's simple syntax results in people taking it for granted and thinking they can mash random code together and it will work fine
which works, until it doesn't
if he did copy the things properly it would have worked
i searched it up
he didn't even copy the code properly
not through AI I hope
It would've worked till he wanted to add his own unique features
I am not in a position to help you.
oh noo
@slate swanhelp me plzz
-_-
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
this is kind of a solution, not completely
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
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
umm.... can someone tell me wht should i do next after creating a strt command for my bot????
tf u doing bruh
@vocal snow lol sry for ping
@slate swan
mh what
am back btw
heh i typed it tho
like after making a strt command wht should i do next..
use your fantasy
hi
hello
didnt get it
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
go read some docs bruh
!intents
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.
help me
can i ask why u ignoring meh?
what i have to ?
you have to read it at first
where is the link
donno but read this tht would help i guess@slate swan
i reead
@slate swan
now do as it says
wait
Where do I begin coding a bot
waiting......
do you know python basics at least?
start with a hello message i guess
yeah
@little surge
lmao
ight
ye
but
https://discordpy.readthedocs.io/en/stable/intro.html
https://discordpy.readthedocs.io/en/stable/quickstart.html
https://github.com/Rapptz/discord.py/tree/master/examples
i would suggest going through that links and trying to play with the code see what it changes thats how you learn
intents = discord.Intents.default()
intents.members = True
intents.messages = True
intents.message_content = True
ight
this i the true form which i use
where i have to paste
bruhh...... lol i am realting so much from i was like his as strt
upper ?
do you know basic python?
on which line?
lemme explain him
then read the error and then look at your code
i see but did not understand
pls.........
you are not explaining you are giving him solutions thats not how to help
sry
lmao please dont rude
lol he is like me altho@slate swan
i guess every ruki is like this
i am not rude but giving straight solutions isnt going to make you understand it anyway
hm
!docs
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>
u said this same line to me erlier damnn
try to read
u have to learn python i guess
what does the error tell you
good question
i was going to ask same thing
missing 1 intents
not this error

this
should i tell?
yes tell me i have small brain
varriable intents is not defined
yes
then define
so you are trying to use varriable that you never created
ezzz
like what
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
why
this is not the code you send above
u have think it by urself how u gonna do it
...
okay but if you got this code already
i just did by watching tutorials on youtube
you need to pass intents to Client
do you know what that means?
no
i see
๐

@slate swanbtw which type of bot u r trying to make
why bother trying to help people with no intention of learning or doing anything on their own
something = ...
my_var = MyClass(something=something) # passing something to MyClass
thats what i meant
good question, you are a good question
now try to do that with intents and Client @slate swan
am i supposed to learn sql??
i did not understand what you wrote
can you code some other for example
!clients
other example is here which you already saw
!intents
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.
broo this was a damn op joke no one laughed
instead of commands.Bot you have discord.Client
@slate swan sir?
how can i know what you are supposed to do
like i finished the strt command and to store the data of ppl
can u bother to remove these dogs from ur pfp tht makes ur og pfp look bad
just my oppinion
help wen???
oof tht hurts from inside my heart damn!!! //
//
sigma down
lol
hey boysss
@slate swan@slate swan
i did ittt
it come online yeeeeeeeeeeeeeee
wow nice work
welcome to heaven
๐
what should i do
That's debugging
You prolly want to run it normally
whts wrong in tht
hey how can i do emebed message in next line'
tht inline = false didnt helped tho
where u went u were here one sec before bruh
@slate swanhow can i do it in an embedded system tho??
where is the docs for embed
wdym
ty sir
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)
you don't, you combine them
how
what do you mean
you just put the components in the second view and add them to the first view
understand
what
So why yโall gate keeping how to make a discord bot?
what
The gate keeping is outrageous
what
Can anybody help in #1104462430190440488 ?
the gate keeping is horrible bro
cant believe they are keeping the gates like that
yo whys no one responding to my question
can u guide me pls?
!d discord.ext.commands.Bot.reload_extension
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.
and
i want to make a slash commadn that collects data in json
like
{
"1103352234848292975": f"{data}",
new data}
@smoky sinew
what data
๐
!pban 725403494177046578
:incoming_envelope: :ok_hand: applied ban to @shadow dirge permanently.
thanks
Ask your Python question, not if you can ask or if there's an expert who can help.
so
i want to write a slash command
in which the user gives a feedback in str
and it show save the user id and vouch
"user.id": "reveiw", repeat
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
yea
but the problem is it replaces the string when new feedback is given
^
so one user can have many feedbacks
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
do u mind guiding me?
how do you store it now
show code
would anyone be able to send code to make 2 simple button that do different things
look into the examples
https://github.com/Rapptz/discord.py/tree/master/examples/views
wil do
@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
do you use nextcord?
nah
discord.ext and discord
yes but
its not discord.py
so what is it then
wdym bro
what library do you use
discord.py, pycord, nextcord, disnake, hikari, interactions.py ?
i cant lie idk
you dont know what lib you use
?
why do you import os two times
idk habit
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
yessssir
when a new guys vouches it replaces it
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"]
CREATE TABLE IF NOT EXISTS feedback (
user_id BIGINT,
guild_id BIGINT,
feedback TEXT,
PRIMARY KEY (user_id, guild_id)
)

confused what you meant
text 
varchar 
then just do VARCHAR(4000)
feedback goes in modal
no this will still override
you need to append to list
if the list exists
smtg like this?
try
why are you append member id
memberid = developer id
coz people change the usernames and my bot would not work
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
you want to append the feedback
not the ID
yep
wait
if someone vouches someone else it shouldnt replace the exsisting data
ngl im confused
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
so what language would that be again?
it depends on the database you're using
mongodb? or sql?
either
idk databases lol im a JSON guy
both are good your choice
mongodb is not a language and sql is a family of databases
mongodb is not relational though it's a document database
mongodb then
mongodb is based on json documents
- its free if thats a changing factor
just don't use pymongo
i heard its free for 500mb then ive to pay
you don't have to pay
both *sql and mongodb are free if you can host it on the same computer as your bot
trust me if u have upto 512mb of discord bot data u will be making enough money to pay for ur own db
or should i say cluster
512 is a lot
mongodb is only paid if you host it on atlas
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
selling what?
sell? 
i am imagining json files being sold for some reason๐
the bot
data invaltion
bruh
i would sell the other with license and make sum money
who would buy JSON
lmao good luck finding clients
selling bot
ngl i have em
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)
asyncpg >>
never used it tho xdd
๐
Whatever bobux bot uses is automatically >>>
fair enough
btw is there anyone who is expert requests and spoofing(optional)
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
prisma >>
I'm a developer of bobux, Pokelore, leaf, I am everyone's friend and enemy
txt files
wowo i wanna join something
have you ever tried Prisma
hmm reminded me been some time since i worked on lore need to get on it too
nope
wowo i wanna do some real bot that gets really famous
join lore
bro missed ~
;-;
sigh sometimes Pokelore makes me cry
is there a way to disable all the buttons on 1 message with 1 message

u still didn't sort the embed thingy
?
I'll do it tmrw ig
u can press just a button to disable all the other buttons that works for u?
is that a no
how do i make 1 disable button
bro be focused on 1
I was thinking how tf I'm supposed to make the constructor better, let's just leave it like that, I've already replaced all the disnake.Embed(s) though
just set the callback disable all buttons and edit the view
okie
I'll do the minigames tmrw
that is a yeas
or if u free we could each do one
yeah + yes yeas
!d discord.ui.View.children
property children```
The list of children attached to this view.
alright, just share your ideas
its on the task in the issues iirc
just pick one
aight just ping me with whichever u pick
op

make a disnake pr which handles oauth flow
and I was trying to fix a quite serious bug regarding sub commands but sigh

I can make an extension for it, it's out of scope for the base API
ash let's down join Pokelore if that's ok for you
wanna join
developer of leaf ๐
yes i would like to join if there is something i can do
I'm putting all my PRs on the bill
Well I've made a PR ๐ญ
yessir
i merged your PR into disnake branch 
yes I saw it
sent an invite
how disnake work??
im in
wait i'm gonna test the branch
wait i need to reconnect my github to discord cause its actually incorrect now
aight
it's quite similar to discord.py but slash commands are synced automatically
i added the role
Because leaf-bot depends on disnake-jishaku (^2.6.5) which doesn't match any versions, version solvi
ng failed.
and other things
what, lemme check
lmao
it was a draft

did you gitignore pyproject.toml or something
sigh
oh wait
skill issue
it was working when I writed it so you are the problem!
fr
why does my code throw an except error to a try statement but the bot has already responded to the try statement
can someone help me, how do i make (send) a button.
!d discord.ui.View
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.
Hello, what should I do if the button is triggered only once? And how can I remove the interaction error? The code is executed as follows.
Link to the command code: https://paste.pythondiscord.com/ejilacanot
Disnake library
@glad cradle it's a disnake user!!
how can i improve this?
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
client = discord.Client(
...,
activity=discord.Game("Project Alicization"),
status=discord.Status.do_not_disturb
)
and don't sync in on_ready
and rename your bot variable to bot 
since you are probably using commands.Bot
i would suggest you perform command loading in the run function, I'm assuming you are using the Client class
https://discordpy.readthedocs.io/en/stable/api.html#discord.Client.run
By doing so you get rid of the risk that someone may call a command before the bot has loaded them
is there a way to delay button clicks so i dont get rate limited
anyone got ideas on what commands i should add to my bot or how to improve it

you want to send an API call after Client.run is called
before the bot's http session has even initialized
Wdym by api call
Okok, thanks everyone
syncing app commands requires a call to discord's API
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

mfs when they complain at discord for years for forcing them to manually parse message content and when they actually add it everyone starts complaining
oh yes building my own command parser is so much fun
how can i made a discord bot using spotify api to play music?
I was the vocal minority that prefered parsing by hand as it allowed for more interesting interactions such as reaction on key words and the likes
the only thing i miss about ext.commands is the flags converter but i can still do it with the string converter
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?
- header = {"authorization": token}
+ header = {"Authorization": f"Bot {token}"}
401
Could have something to do with id being a built in
perhaps try printing url to see if it's expected?
wdym by that
print(url)
The only other thing then is to make sure your bot has access to that channel
Reset your bot token and use the new token, and double check the channel ID
just tested that, the token its using literally owns the server and it cant send it
i cant seem to fix it.
How'd you get the bot to own the server?
its not running off bot atm
Then?
its just running off a discord acc
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
It'll work perfectly if you used an actual bot token
reinstall
!d discord.Client.create_guild
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`.
imagine ai takes over discord
discord is ready for that scenario
kid I'm also a disnake contributor
notable contributor, pay respect

damn, so now there are like 12 in total?
hey! disnake is famous
you need to respond using the interaction that is coming from the button
@glad cradle are you textual user
what
ah I used it once
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)
ok I'll try
this worked ty
@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?
what do you mean by that?
when I set an afk status, since the bot is reading every message it's like removing the status right after I set it
Damn, it took bot 15 minutes to give everyone coins
what are you even doing to give people coins?
why do you have a delay?
Server too big
Bot would overload because of a little weak monitoring
what?
What does "giving coins" entail?
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"
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.
you can create unlimited threads in python pretty much
how would the host restrict you from doing that
hmm, time to read up
could you recommed an article
(these threads aren't physical threads)
I guess time to learn threading
Great start i would say XD
is it possible to ban a user who is outside the guild?
like guild.ban(user)
or something?
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.
python allows unlimited threads but if its run on a single physical thread, wouldnt anything io based block the entire execution
anything cpu heavy would block the entire execution
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?
i am not 'threading' anything so to say, i am using asyncio.to_thread to convert an ogg file to mp3
ah ok, that would be entirely cpu bound i suppose
indeed
yeah on something with a single cpu im not sure if thats a good idea
could you suggest a host which i could use ?
are you looking for a free one?
nope, paid works
This article lists recommended VPS services and covers the disasdvantages of utilising a free hosting service to run a discord bot.
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
why does this keeps on showing on my terminal everytime i try to run my file on the terminal
this is my code
so, threads in aws ec2 would be instances ?
do not share token bruv
because you're running it in a python REPL not in a shell
quit()
no, im not very experienced with aws but an instance would be a individual vps
which could have 1 or more threads
i changed the token
thx for the token
it was the old token
๐
just one instance
@smoky sinew so....
what config do i need
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.
on t4g nano ?
how do i fix this
!intents
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.
install discord.py
this thing keeps showing everytime i debug the code
pip install -U discord.py
!intents
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.

like this?
replit uses poetry for you 
no
no you have to pass intents into client
actually no just remove client
alright
also enable message content in your developer portal @eternal shuttle
I don't get it, but messages respond to messages with a button. Or how should it be done?
never understood why you would like to use client
nobody used client until slash commands were a thing ๐
if i remove client, wouldn't it make the @client.event useless?
i dont know how you do that in this ide you are using
replace client.event with bot.event
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 ?
That's replit
alright i'll try that
also with bot you dont use on_message event to create commands
there is more advanced and more readable idea when creating them using a bot
alrighty
any1
what do i do with this
you pass proper token
Improper token has been passed.
why is your 5th line, pip install discord py
use it??
run it ?
you said you were going to comment that out
Put a hash before the pip install
No, simply remove it from the file as mentioned previously
console
as in shell, not REPL
you should be using poetry add discord.py instead though
check by running the code?
don't use discord_slash
Where did you get this code?
discord.py already have built in slash commands
Guys, how can you remove the interaction error? I don't understand...
The code itself: https://paste.pythondiscord.com/kuroqejaga
How do I give roles with buttons?
i think snipy already told you
Which part are you having issues with?
<#discord-bots message> @meager orchid
No Iโm asking
!d discord.Member.add_roles
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.
Buttons? Callbacks? Adding roles?
Which part do you need help with, that's what I'm asking
Like making the button then once they press it then it gives them a role
I have no code for it
I know what you want to do
How do you implement this?
So can you help me
What file is the example on?
All of them
all of them lol
ok
what error
I donโt use cogs
Ok?
!tracebacj
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.
Last time I asked someone to show their replit error they Made a screen recording
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
Like not in a cog
it's not a cog
It's not in a cog though?
Oh
dont use discord_slash
huh
no i gave you example of slash commands in discord.py
.
cool ๐
can you know the device info of user?
like what platform they're on?
you can know their statuses on various platforms
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)
yeah
oh okay
await interaction.user.remove_roles(*map(interaction.guild.get_role, languages))
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
thanks a lot!
Ahh, now I get it. Thanks for the help, I got the separate class option and didn't understand it at all. I was already thinking of redoing everything, thank you so much!
you're welcome
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
you've already been told to show your actual traceback
but given that it's unauthorized yeah krypton is probably right
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
make a cache
lrucache will work in this scenario
redis
yes
!intents
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.
I have made a link blocker but how do I make it so it ignores a link in a certain channel?
check what channel the message is in
this is not a very good way to check for links-
How?
Why?
the id or name
because you dont need to have http://
Oh
Would it be in an if statement?
are you new to python?
What do you think
No
really seems like you are if ur asking whether to use an if statement
Yes
Idk what to write
just check if the channel name or id is the one you want to ignore
Ok
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
It says else: is an invalid syntax
It says else is an invalid syntax

I would recommend trying some basic python exercises before jumping into discord bots. Your issue is related to indentation.. You have a return statement in between your if and else
what exactly are you trying to do?
I need to access the bot instance to get a guild channel in one of my files
yes, what's the purpose of this other file?
Thanks
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
No no, this file is related to my database. It's not a cog
Got it
how do i fix invalid syntax everytime i try to run my code on the terminal?
I donโt have an error and it doesnโt work
Correct the syntax? ๐คท
i mean i dont think theres any wrong syntax on my code
Show it then
No
alr holdon
!paste
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.
!e
print(
"cat"
"meow"
)
@naive briar :white_check_mark: Your 3.11 eval job has completed with return code 0.
catmeow
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.
bot = discord.Client()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'discord' is not defined
you forgot to import it?
That doesn't match the code you showed
Also why are you shadowing bot and on_ready?
Use discord.Client OR commands.Bot, not both
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.
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'
what about now?
oh i forgot to turn on the intents that's needed on the discord dev portal ๐
all good
this theme
how can i improve this?
Only enable the intents you really need, use setup_hook instead of on_ready, remove unused imports, fix type annotations
!d discord.Message.delete
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.
You can get a discord.Message object via Messageable.fetch_message or from Context/Interaction/other source depending on your code
thnx alot
when i try it it is giving me an error
Send your code and error please
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)
send_message doesn't return the message, you have to use Interaction.original_response iir
!d discord.Interaction.original_response
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.
You call it on an instance of discord.Interaction, not the class
guys how can i make kick command for discord bot?
You'll need to learn classes to understand more about that, it's a slightly big topic for me to cover here
you mean use interaction instead of Interaction?
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'
``` 
uppercase
use the variable interaction, not the class
there's's probably a parameter in your callback function called interaction or whatever
swear he'd just do confirmation_message.delete() no?
i tried it as well
That is generally what is used, but it's essentially a shortcut for Class.method(instance)
ah
yea
(The instance is passed to self)
seems like he needs to grasp the difference between a class and an instance of it / an object
confirmation_message = discord.interaction.origional_response
like this?
no

discord.Interaction is a class
interaction is a variable in your function, that's the one you need to access
yea but how do i use it to delete the message
how would you think you'd delete a message in the first place without showing me any code?
i have shown the code here
i have used a different method there to try to delete message
why though?
why don't you just get the message object and call the .delete() method on it?
this is very relevant here
it says the message object is Nonetype and it can't delete a nonetype object
code + full error traceback when you had that error?
ah what do you mean? i am not really good at understanding english
if you include everything that's in that message for every question you asked, you'd get loads of answers
Someone can help me for vc exp system?
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?
there's no discord.ext.commands.commands in discord.py
also, consider building your bot in the home directory of your system
maybe install discord.ext
we help when you include your actual issue with python code snippets, error details, traceback of the error, your manual debug logs. Not all are required, but the code snippets are the least
GUYS HELP HOW TO CREATE WARN COMMAND
You may have forgotten to disable the all caps
is this module even exist?
whts the matter?
man u asking for code?
yep i am asking
hello!
how can i make an slash command option , optional?
somehow it is not allowed for us to spoon feed u code
rather u can send code i will see if i can help
I dont wanna create warn command anymore
moderating and support bot
oh
i already created kick and ban system but i cant understand ticket system
ic
you learned by reading docs??
yeah
nice
2023-05-08 00:51:53 ERROR discord.client Ignoring exception in on_ready
what the matter
code?
it has 212 lines....
its hard to just tell by looking at error for newbies like me
the error line
ya ig
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
can u send line 92?
ok
which library are you using?
ya, otherwise you'd be trying to sync to some guild that had the ID of 0
ya ya
thxz
@fiery harebro can i get a help?
I made it
sry for being sticky
Sakura bot is mine bot
ticket system, warn command later
oh
.
nope
is it possible to use discord-py-slash-commands using nextcord?
k'

