#discord-bots
1 messages ยท Page 1029 of 1
pain
also I can't run my bot
cuz it stucks on connecting to the db
i dont even make discord bots, why tf am i here lmao
no one is gonna do something to it and make it interesting
We are but you ask questions that are way to broad.
how do i create a command for a discord bot?
I did the process_command but he is ignoring the prefix
When i send hello he say to me that i am on blacklist
https://www.toptal.com/developers/hastebin/icekevakib.py
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
hello, i have a global command error handler but now i want to handle an error for a specific command, how can i overwrite the global error handler so it only triggers the error handler on the command and not the global error handler
@client.command()
async def command_name(ctx):
await ctx.send("Hello World!")
do you guys know how to make a wallet?
like a virtual currency wallet?
like economy commands?
yeah
database
database covers 6/10 questions here.
ahhaha
Hey, how do I make a bot ping a certain role like out of embed message?
wheres the database
sm?
So it actually pings
You can't
it doesnt work
how do i add a prefix to my commands
!d discord.ext.commands.Command.error
@error```
A decorator that registers a coroutine as a local error handler.
A local error handler is an [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event limited to
a single command. However, the [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") is still
invoked afterwards as the catch-all.
Changed in version 2.0: `coro` parameter is now positional-only.
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result
anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with
this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality
to manage commands...
@client.command
async def sus(ctx):
embed = discord.Embed(title='yes')
await ctx.send('<@&roleId>', embed=embed)
try this
i created an local command error handler
like this bruh
@modern fiber
but it triggers both global and local
yes
alr ty legend
await channel.send('<@&roleId>', embed=embed)
command()
yes, mb ๐
๐
btw I'm using disnake
You could also check what command it is.
Inside the global error handler.
hi
is it commands.qualified_name or something i forgot it
ima check
this is why i do game dev not discord bot creation
how is game dev any easier
!d discord.ext.commands.Command.qualified_name
property qualified_name```
Retrieves the fully qualified command name.
This is the full parent name with the command name as well.
For example, in `?one two three` the qualified name would be
`one two three`.
idek i dont even have a Bot.py file
ty
its a generated template
then use Cogs
@command_name.error
and don't use repl
He already got a local handler.
!d discord.ext.commands.cog.Cog
class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.
A cog is a collection of commands, listeners, and optional state to
help group commands together. More information on them can be found on
the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.
When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta")
are equally valid here.
Nice assist
uhh
@slate swan
File is cog and then class Cog, I know kinda weird.
oh
Uh
isnt it
......wtf
too confusing i find it easier with python game dev
!d discord.ext.commands.Cog
class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.
A cog is a collection of commands, listeners, and optional state to
help group commands together. More information on them can be found on
the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.
When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta")
are equally valid here.
oh nvm ๐คฆโโ๏ธ
Both suffices.
what kind of Bot are you creating?
Some one recommended dynox to me but they don't have any more slots for hosting. Any alternatives?
hi
just namespaces
i tried printing commands.Command.qualified_name
heres the output:
<property object at 0x0000021AB0793810>
i added it inside the on_command_error
Does anyone know how to check how many messages a user sent in a certain time?
pex all members from users to moderators
i was going to try and make a bot that if you use the command "/funny" on my server then it would auto generate a random but funny message
Could you show the code?
why not just name
Hmm?
you're printing the name attribute of the class, not an instance of the class
i fixed it i just did ctx.command
you need an actual command instance from something like get_command()/ctx.command
that's ez, if you need help contact me in dm, however I recommend using disnake
!d discord.TextChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the destinationโs message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
what is disnake
I'm trolling
yes
another python library
disnake>>
how do i make a virtual wallet
(something like dank memers wallet)
Tysm
it's Updated
its a fork of discord.py
Converting to "int" failed for parameter "pep_number".
too many libraries, makes brain hurt even more
Really depends on what you are trying to do tough. If you just want to check msg count or have some kind of spam filter I recommend using on_message
here's a question
yeah i did ctx.command and i added an if statement but it wont print the h
if isinstance(error, commands.BadArgument):
if ctx.command == "log":
print("h")
return
else:
await ctx.send("Provide a correct argument.")
I just want to know if they sent enough messages to get a role
how do i make a virtual wallet
(something like dank memers wallet)
I learned nextcord, disnake, discord.py and some slash_interaction.
if i wanted to make a levelling system thats unique per person for each guild their in
database
how would i go about that
whats database?
and nosql db wouldnt work
A place to store your data
like global levelling system or guil levelling system?
how do i make one
guild
i tried with mongo
first learn to interact with a database
i know how to use mongo
While loop the database with insert, good times.
i dont know any sql tho
I need to add databases to my tutorial 
yes :(
how do I add a slowmode on command like delay?
it better be sql based or else
Literally it's just SELECT, FROM, WHERE, INSERT INTO, VALUES
of course
i see
delay or commands cooldown?
cooldown.
postgre :)
ily
no sqlite and postgres๐
Why sqlite :(
I'll probably use an ORM, so it will automatically support mysql/mariadb, sqlite, and postgres
But mysql async drivers are ewwie
!d discord.ext.commands.cooldown
@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
A cooldown allows a command to only be used a specific amount
of times in a specific time frame. These cooldowns can be based
either on a per-guild, per-channel, per-user, per-role or global basis.
Denoted by the third argument of `type` which must be of enum
type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType")...
most connectors are ewwie
yes
postgre gut
@modern fiber
well typescript for type safety
all ded
Read the parameters
rate = 60
no I'm trolling
rate 1
per = 60
.
Okay so @disnake.ext.commands.cooldown(rate=600)
no
for 10 minutes? or
rate is the number of times you want that command to work
per is the amount of time in seconds
@disnake.ext.commands.cooldown(1, 600)
1 command every 10 minutes
thanks legend
You've already done that once, please refrain from giving false answers in the future
do you know how to send a custom emojis in an embed tho?
Ive tried 100 times but doesn't work
I was wrong
it's not intentional
Right, if you're not 100% sure that your answer is correct, please do not give it, thanks for your understanding
you can send a custom emoji if the Bot is inside the server of the emoji you want to use
in discord chat send this message
\:emoji:
then copy paste the message in the description or title of your embed
ex.
embed = discord.Embed(title='example', description='<947985467146657842>')
have you seen prisma python
@modern fiber
I'm yet to properly try it but if you're using vsc with the python language server it's meant to be amazing
I also am good in giving misinfo.
How do i assign a role
!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/master/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to
use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list
of roles than the highest role of the member.
Tysm
how do i make my bot react to a msg
!d discord.Message.add_reaction
await add_reaction(emoji, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Adds a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji")...
How do I add a reaction to a message?
There are a few ways to do it, firstly, you need the emoji you want.
For basic (non custom) emojis, this can be either:
The Codepoint \u2705
The Raw Unicode joy
The Name \N{MAN IN BUSINESS SUIT LEVITATING}
For custom emojis, you will need to specify it in a format similar to:
name:id for static emojis, or a:name:id for animated emojis.
Note that you must NOT have the <> in the reaction.
Or an alternative way,
discord.PartialEmoji(is_animated (True or False), name, id)
How can I use to add a reaction?
await message.add_reaction(<your emoji>)
Message.add_reaction(Bot.get_emoji(id)) ๐ข
you didn't just name it Bot
Error im getting:
- raise MissingRequiredArgument(param) discord.ext.commands.errors.MissingRequiredArgument: emoji is a required argument that is missing.```
What im doing:
```py
@bot.command()
async def react(ctx, emoji, /):
await ctx.add_reaction("๐")```
why do you have emoji between the parameters?
im tolking in objects
as you can see the same with Message
idk, im new at this
Anyone know?
remove emoji from the parameters
ok, now what?
a list in json?
run the command
Yeah?
json data structs are similar to dictionaries
do you want a list inside the dict?
No
got a new error
- raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'add_reaction'```
yes, replace ctx in the parameters with message and replace await message.add_reaction..
try this
send an example, do you want a json file like
[1, 2, 3, "o",...]
?
Like that
- raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'add_reaction'``` [same error]
mb, replace message with ctx in the parameters and try with await ctx.message.add_reaction if this doesn't work I can't help you
works, thank you!
!d discord.ext.commands.Command.cooldown
property cooldown```
The cooldown of a command when invoked
or `None` if the command doesnโt have a registered cooldown.
New in version 2.0.
pls help ****
what you're trying to do
!d discord.Intents
class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way.
You can set and retrieve individual bits using the properties as if they
were regular bools.
To construct an object you can pass keyword arguments denoting the flags
to enable or disable...
ok
send your code
send line 1
tempCodeRunnerFile.py line 1
there is a ')'
What do you need this file for?
are you saving the file?
then delete it, it's an empty file
maybe are you creating it in your code?
File "C:\Users\User\Desktop\discord bot\cogs\economy.py", line 19, in balance
await ctx.send(embed=discord.Embed(description=f"User balance {member}: {self.collection.find_one({'_id': ctx.member.id})['balance']}"))
AttributeError: 'Context' object has no attribute 'member'```
@commands.command()
async def balance(self, ctx, member: discord.Member = None):
embed=discord.Embed(description=f"User balance __{ctx.author}__: {self.collection.find_one({'_id': ctx.author.id})['balance']}")
if member is None:
await ctx.send(embed=embed)
else:
await ctx.send(embed=discord.Embed(description=f"User balance {member}: {self.collection.find_one({'_id': ctx.member.id})['balance']}"))```
code:
@glad cradlecan you come dm please?
try to replace ctx.member.id with member.id
ok
np
cooldown in an embed?
How do I use on_reaction_remove?
Hey, I need help, it says its running bot on heroku but bot isnt online
how to let my bot check when the user said a channel name after using the command?
worked perfectly fine before i restarted dynos like couple minutes ago
how do i make my bot say different things everytime i use a command
Yeah, it was already hosting before I restarted all dynos for an update
for example
me: heybot, do my mom
bot: nah
me: heybot, do my mom
bot: sure
now it doesn't seem to come online
if you handle the error it should return the cooldown time, for ephemeral interaction things idk bro, I haven't experienced that stuff yet ๐ฉ
Nvm fixed
can u help me
create a list, then random.choice and booom
ples
Please help me 
why not
can you give to me an example?
i like to be spoonfed
The bot should say "Whats the channel u want the giveaway to be in" and then the user says "channel name" or "#channel-name"
i only come here when im hella desperate
your command is similar to 8ball, so Google this
if u have problem re-ask here @fossil adder
google how to make an 8ball in python?
got it, thanks!
8ball Bot discord.py
for "channel name" it's more complex, but the user can give #channel and <channelId>
Okay but how would that look like?
BRO
this is my first day using discord.py
PLEASEEEEE stop ass raping me
i can help if you want
Hello, please re-read our #code-of-conduct and avoid using language that can be triggering to others.
mk

that's a semi-pain to do, just create a command to set the giveaway channel, no?
^+1
I forgot to change the language
it's ok ahah
@commands.command()
async def pay(self, ctx, member: discord.Member, amount: int):
emb=discord.Embed(description=f"**{ctx.author}** handed over **{amount}**:money: user **{member}**", colour=discord.Color.gold())
embed=discord.Embed(description=f"The number must be greater **0**", colour=discord.Color.gold())
ubalance=self.collection.find_one({"_id": ctx.author.id})["balance"]
mbalance=self.collection.find_one({"_id": member.id})["balance"]
if member
elif amount <= 0:
await ctx.reply(embed=embed)
else:
self.collection.update_one({"_id": ctx.author.id},
{"$set": {"balance": ubalance - amount}})
self.collection.update_one({"_id": member.id},
{"$set": {"balance": mbalance + amount}})
await ctx.reply(embed=emb)```
here is my code
line 2 indentation error async def pay..
What r u using to store data btw?
what do I need to write in if so that it works if the user has this number?
do you know this number?
it's a constant?
anyway there are some errors
on_command_error is an event, not an interaction, moreover Ephemeral messages can only be used with Slash commands or interactions (like buttons)
I'm not sure on the answer
I know something but I should try them
cuz thats a slash command
sure
but there is something else
I think there is bot.wait_for... but I'm not sure
as an event?
idk man, if u want contact me in dm, we can try this together
thats not an event
@slate swan
if u use client.wait_for you need to remove the on from the event name
@client.event
async def on_reaction_remove(reaction, user):
that doesnt call
theres 0 difference
you can assume that all the people that the Bot can see are users, so len(client.users)
if u use Bot then len(bot.users)
Can you help me with this call
line 2 indentation error
@client.event
async def...
then what do you mean
what do you mean with "callable" explain what your command should do
show your full code
Yeah we're using it in an internal project. I'm more accustomed to the typescript ones haha
for something like this.
async def on_channel_message(self, message):
async with self.bot.db.execute("SELECT ...") as cursor:
result = await cursor.fetchone()
if not result:
return
else:
await message.delete()โ
I know this isn't good, but what's the best way to do it. Would it be to make a dict of channel ID?
what do you need to do?
try to print payload.user_id
create a global list called users
then write an async function to check if the user is already logged
and pass the func in each command
like
async def check(user):
if user.id not in users:
#add user.id to list
then len(users) for the number
call functions please
hmm?
users.keys()
lol
if u restart the Bot you lose all
๐ฆ
then write it to a txt
store the data in a database or in a file
with open(โusers.txtโ, encoding=โutf8โ) as file:
users = file.readlines()
how to make command like when u type .report bot creates private channel where person who typed .report can say their report?
@bot.command()
async def report(ctx):
await ctx.guild.create_channels(name=fโticket-{str(random.randint(1,10000))}โ)
not sure hoe to do the perms thing
i mightve made a syntax error somewhere
yeah in this code
its like 2:30 am and im on my phone ๐
for me is 11 PM night
uk?
nah serbia
yeah
?
ctx.guild.create_channel
How can I fix this?
import discord
from neuralintents import GenericAssistant
chatbot=GenericAssistant('intents.json')
chatbot.train_model ()
chatbot.save_model()```
what's the problem?
I am trying to write a script that parses a org file into json and sends that json to a discord webhook, how would I convert the file into json, and then load it in the payload for the requests url?
to be honest I'm not too sure. I tried running the code multiple times and it gives me this error:
nvm... i think i just found a fix...
how would i make it so buttons get disabled after time
cuz when i try i cant press buttons
Use asyncio.sleep
buttons dont work then
But you want them disabled yes?
yeah if they dont press anything within 10 seconds
i want them to be functional at first then after 10 sec disable
And this won't work at all?
Not when I do it inside my commends ๐ค
maby import time than time.sleep(10)
ugh i hate parsing long payloads๐
I hate typing 100 lines of Java to open a blank Window
๐ญ
My window is really advanced tho
it still makes buttons not work
is shoud make the code stop for 10 seconds but i dont know i ain no python expert
i don't think discord.py has implemented it
well i need the code to send stuff when button press
no
Try that
idk how i would implement that though
@client.listen()
async def on_message(message):
if message.channel.id == 972153184816619611:
await message.add_reaction("โ
")
'Client' object has no attribute 'listen'
worked a day ago
need answer asap pls
this is all the code?
!d discord.ext.commands.Bot.listen
@listen(name=None)```
A decorator that registers another function as an external
event listener. Basically this allows you to listen to multiple
events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")
The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)").
Example...
client = discord.Client() โ
bot = commands.Bot() โ
bot = discord.Bot(intents=discord.Intents.all())
AttributeError: module 'discord' has no attribute 'Bot'
``` How can i solve this
try using bot = commands.Bot
if its discord.py it would be commands.Bot() if you imported commands
but the namespace is correct if youre on pycord which i doubt you are
bot = commands.Bot(intents=discord.Intents.all())
TypeError: BotBase.init() missing 1 required positional argument: 'command_prefix' getting this now
oh
use that
wait
Prefix = "#your bot prefix"
bot = commands.Bot(command_prefix=Prefix)
it worked out?
variable naming and why the useless variable?
@bot.slash_command(guild_ids=[settings["guildID"]], name="whitelist", description="Whitelist a person to use the bot.")
AttributeError: 'Bot' object has no attribute 'slash_command'. Did you mean: 'add_command'?
``` getting another one
its just a string i really dont see why a variable should be created?
are you using disnake?
I use it like this just to be more organized
i see no reason for it only if youre using it some where else
no
it's just to be more organized
No
bro its a string?
most prefixes are average 1 char
yes but whatever and I use it just to be more organized (because it is more organized in my opinion)
its a waste of bytes
how can I log all the messages that the bot sends? so like ```
sender: $help
botname: here is a list of commands: etc...
sender: $say hello
botname: hello
etc etc etc...
but it's very few bytes so it doesn't matter much
just a few until your code base becomes bigger
like print the message it sends?
yeah
I think you would have to print like this here:
@bot.slash_command(guild_ids=[settings["guildID"]], name="whitelist", description="Whitelist a person to use the bot.")
AttributeError: 'Bot' object has no attribute 'slash_command'. Did you mean: 'add_command'? Any idea ? i tried to change but idk
anyone know if there is a way around the keyword requirements for the discord webhook?
dang my bot doesnt have any relationships ๐
Mine doesn't either ๐
# command
@commands.command(name="test")
async def send_hello(self, ctx):
response = "Hello!"
await ctx.send(response)
print (response)
damn these headers๐
is this what you want?
you're welcome
'-'
Cause it's in JS
nah its not that
its just its layout
i cant even make properties for my class because i dont know the types and the docs doesnt show types
๐
F
How can I get the username of the bot that i've logged into
I will send the code
is that
oki
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User")...
oki
it's discord.Member
nah
!d discord.ext.commands.Bot.user
property user```
Represents the connected client. `None` if not logged in.
!d discord.ClientUser.display_name
property display_name```
Returns the userโs display name.
For regular users this is just their username, but
if they have a guild specific nickname then that
is returned instead.
or
The userโs username.
?
wtf
i?
?
like that?
AttributeError: 'Bot' object has no attribute 'slash_command'. Did you mean: 'add_command'? ๐
oof
property mention```
Returns a string that allows you to mention the member.
bro i can't help you because i don't know what is slash
what do you mean, it was the same thing I put '-'
not quite
would this not work?
print(f'logged in as '.format(client))
Yes
the property does return the object but thats not the right path
you should use f strings
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
if there was no error, i believe so
ok
Jeez... that wasn't what you wanted, right?
is there another way for me to print it then
print('this ma name: '.format(client)
you wanted the username if I'm not mistaken, right?
no i dont rlly care about the message the bot sends
i just want the console to log stuff and i want it to display in the console the username of the bot
what is up with this?? ```py
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<sync_commands() done, defined at C:\Users\culan\Desktop\3.0.0 echo\echo.py:30> exception=Forbidden('403 Forbidden (error code: 50001): Missing Access')>
Traceback (most recent call last):
File "C:\Users\culan\Desktop\3.0.0 echo\echo.py", line 34, in sync_commands
await bot.tree.sync(guild=guild)
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\app_commands\tree.py", line 922, in sync
data = await self._http.bulk_upsert_guild_commands(self.client.application_id, guild.id, payload=payload)
File "C:\Users\culan\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 496, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
and test
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
it has to be an instance
you are lacking perms
@hard steeple it should be discord.Bot because i have slash commands and commands.Bot doesn't have slash comm. and idk how can i should fix it
Well I guess I'm forever going to see that message cuz there's no way I'm going to be able to get almost 500 servers to switch over to slash command
try disnake
AttributeError: module 'discord' has no attribute 'Bot' i have this
I installed disnake but still same
so use discord.Bot and, if gave an error, send me the error
but it is giving error in his
Yes
nvm i ended up just doing ```py
print(f'{bcolors.GREEN}> {bcolors.RESET}Ready - {client.user}')
lol
I did but i have this AttributeError: module 'discord' has no attribute 'Bot'
it's commands.Bot
but it is giving error in his
man what's the program you use to program?
Notepad?
If im using commands.bot i get this but i have slash commands TypeError: BotBase.init() missing 1 required positional argument: 'command_prefix'
yeah xD why
you need a command prefix
just to know
that error is basic python
Very basic
I don't know how to solve it but try to use BotBase.__init__(command_prefix=#your bot prefix)
now i'm randomly talking what to do lmao
LMAO
And should i add , intents=discord.Intents.all() after command_prefix= ?
yep
yeah, you need to have 2 arguments for that
name BotBase is not defined
:/
just add a prefix but never use it
yes it gets an error
XDDDDDDDDDDDD
lmao
It talked to itself
haha
yh
Yes pip install discord-py-slash-command
Ah you are using discord.py
And if i do how u said i get this AttributeError: 'Bot' object has no attribute 'slash_command'. Did you mean: 'add_command'?

discord-py-slash-command is not discord.py
in dpy it's bot.tree
wtf, if he's using discord.py why isn't the commands.Bot business working?
what do you guys think?
What ?
you add slash commands to a tree
kinda basic which i like
Yea
for me it's ok
Wish I could say the same with a Game Engine
still have to implement the event and intent systems๐
whats the sexiest bot on discord
bro what
Loritta
nah
lmao
And what that does mean
LMAO
๐ณ
hahaha yes

Mee6 is a bad bot, unless you pay money
yup
jeez, i forgot @slate swan hahaha
I want to know how it makes different bot accounts and shit
hey he is nice
What ?
For Premium
they made it complicated
I want to know how to do that ๐
shards
i forgot about you for a second and that you were still having doubts about why your command was giving error
Ah
So it actually doesn't make bot accounts on the dev portal?
Still don't know how to fix it 
but @slate swan what is the add_command?
Wdym
what?
What do you mean*
oh
To change slash_command to add_command ?
no
the error gets raised because the words are similiar
it's because in the error it has written Did you mean: 'add_command'? so I wanted to know if you knew what add_command means
iiirc all slash commands call add_command and the deco is from disnake and not discord.py
No
there complicates
notstiles you copied the code right?
because it seems like you smacked it in the file and called it a day
A friend gived me to try solving it but idk
its because youre using the wrong library
youre using discord.py when you should be using disnake
hahaha
!pypi disnake
Or nextcord*
it uses @bot.slash_command()
ah nice
@frozen patio @slate swan you guys seem very smart in python, then can you help me with an error my code is having?
sure
I added these two
import disnake from disnake.ext import commands
and i get raise TypeError(f"intents parameter must be Intent not {type(intents)!r}") TypeError: intents parameter must be Intent not <class 'discord.flags.Intents'>
the error quite says it all no?
you passed the Intent class yes but from discord and not disnake
I can try, I haven't coded in Python for a month ๐
me too '-'
I have been getting an expert in Java
python for life
I learned python not even a month ago
nice
I learned it 3 months ago
GG
i started learning python a year ago
Tkinter a good lib for games in Py
wow
and the pygame?
then quart & django for backend websites ๐
kinda young in experience compared to most regulars here
this is all the code you are using?
flask or fast api are good as well
Yeah I forgot about flask
i love how flask uses decos
yes but i'm getting it
nah nah i ment myself haha
What ?
most regulars here have 2+ years of experience
while im here with 1.2
is one year too little?
compared to regulars yes
my bot is making me hard
import disnake
from disnake.ext import commands
and i get raise TypeError(f"intents parameter must be Intent not {type(intents)!r}")
TypeError: intents parameter must be Intent not <class 'discord.flags.Intents'>
this is all the code you're using?
haha
@slate swan send me your bot link to i see it ๐ณ
No i import disnake and the one below and i get those errors

your bot can be good but is the source good?
LMAO
but send me all the code pls just to get a better idea of โโwhat you're doing
4 years nearing 5 ๐ณ
@slate swan just ctrl + c and ctrl + v easy
nice
see๐ญ
since no one is in doubt for now (apart from NotStiles who still hasn't sent his code) can you try to help me @slate swan ?
i cant right now, sorry
ok, no problem
I'll leave my question here in case someone sees it and manages to solve it '-
it's in html?
no python
Jeez, I haven't seen this in python, only in html
i googled it but not sure if its the same thing what i have
but send the whole error, it will help me to help you
ok
AttributeError: 'Button' object has no attribute 'guild'``` ```py
interaction.guild.voice_client.resume()
So do I just take out guild?
can u copy an error?
i?
'-'
do i send a pic or what?
it's because I didn't understand what you meant
just copy the code
how?
ctrl + c and ctrl + v
so send a pic
here
what that
take this to a help channel
ok
i own an in-house server
Nice
i don't know what is it, sorry
ok
no no its probably not a flask error flask handles their errors its just hes ratelimited sometimes dpy doesnt catch the error and it just yeets you html ๐ญ
legit? bruh
yeah ive only seen it happen in replit idk if its a dpy issue or a replit issue
i guess the api just took a dump somewhere
probably just replit ๐ญ
maybe it was caused by replit?
like the connection dropped
nah if it did nothing would be raised
the last line though
isn't that the flask format
well thats just html
alordz is using javascript to program?
oh, so just the error is in javascript?
ah that's why there's this </script> thing, well I had recognized
yep
but the error was not supposed to be in python?
it's because the error is related to a web request
one that failed server-side, so the server returned an html page with content about the exception
this must be very rare to happen
for the site to go down right when the person is going to run the code
in the case the error
well the error is handled server-side, but in this case the issue is probably with the client
wouldn't it just return a 4k http code?
interesting problem ngl haha
it's still html
usually with flask you just take a look at the response.status variable
Most likely a cloud flare error. Most often given when discord API has banned your IP address from using the API
but that's because flask parsed the html in the response
nah nah i ment some apis just return a payload of an exception which they return a http status code which wouls be related to the 4000 codes which are server sided
hey @slate swan, can you help me in my code? it's dont giving error but he has not running
I do not know how to explain
Looking at the "full" screenshot, this is indeed a cloudflare error thing
dpy doesnt handle cloudfare bans?
You've been banned from the REST API
๐
content types
jeez
probably 'application/json' is set, which means that it returns solely the json data
ยฏ_(ใ)_/ยฏ
he probably did something bad bad
considering he's using replit i'm not surprised
again, it's probably just someone using replit to be mean
Since they use shared servers
anyone who knows html here to try to understand this error? haha
right right i forgot he's using replit
he is using repl.it? omg
which error?
repl.it usually gets a lot of shit for what it is
but it's not even that bad, it just has that fame because people erroneously use it for hosting discord bots
the error of alordz
Repl.it is fine for what is was designed for
which doesn't include hosting discord bots
that is uh
And I am agreeing with you
didnt they say you could host discord bots or was it heroku?
epic
i cant remember
Before this, discord bots on repl.it was against their ToS
speaking of hosting bots, I'm really sad because I couldn't host my '-' so I'm going crazy asking someone for help
yeah
technically
I think I'll use it to host since heroku is not working '-'
replit is a network of machines that run containers, which are basically tiny versions of the linux kernel with only necessary packages to function
sometimes, when one container is using too much resources, or it just fails in a way that compromises others
the hypervisor shuts down part of the grid
so if one falls, do they all fall?
nah
so while technically replit would keep a container running 24/7
but most of the times they'll have to shut down at one point
they've introduced like a paid plan
with a thing that keeps your containers alive
just a matter of time
but that's just replit automatically restarting them after they go down
most people use flask or keep_alive to keep the container alive
The big caveat with repl.it for discord bot's is, they share servers between users. Therefor, if the user your server is shared with get's ratelimited, so do you. Same with API Bans
but is it a considerable time or is it a short time?
idk
depends
that's because replit monitors incoming traffic in the 80 port
because when a container hosting a website is offline and someone accesses the page it has to turn on automatically
oh, i understood
it's essentially random lol
you never know when someone is gonna get freaky
๐คจ
ayo?

I'm going to have dinner now, after I have dinner can someone try to help me host my bot on heroku? '-
yep
'Morning everybody
new day, new error in my script
we offer help for most of the python discord api modules
im trying to make a withdraw and deposit command but its not working and i cant find the mistake that i made
does anyone mind reviewing my code and seeing if i made any mistakes?
async def button(ctx, member=discord.):
await ctx.send(
"Please click this button to recieve the Member role to get verified to the server.",
components=[
Button(style=ButtonStyle.red, label="Verify")
],
)
res = await client.wait_for("button+_click")
if res.channel == ctx.channel:
await res.respond(
type=InteractionType.ChannelMessageWithSource,
content=f"{res.component.label} has been clicked!"
)
role = discord.utils.get(client.get_guild(ctx.guild.id).roles, id ="971970467789418576")
await member.add_roles(role)
``` Do i need to define "InteractionType"?
Yes
@client.command()
async def withdraw(ctx,amount = None):
await open_account(ctx.author)
if amount == None:
await ctx.send("Dawg, CHOOSE AN AMOUNT OF MONEY TO WITHDRAW")
return
bal = await update_bank(ctx.author)
amount = int(amount)
if amount>bal[1]:
await ctx.send("Your too broke to withdraw that much")
return
if amount<0:
await ctx.send("Dont try outsmarting this bot :/")
return
await update_bank(ctx.author,amount)
await update_bank(ctx.author,-1*amount,"Bank")
await ctx.send(f"you just withdrew {amount}!")
why wont this work
async def button(ctx, InteractionType, member=discord.Member):
await ctx.send(
"Please click this button to recieve the Member role to get verified to the server.",
components=[
Button(style=ButtonStyle.red, label="Verify")
],
)
res = await client.wait_for("button+_click")
if res.channel == ctx.channel:
await res.respond(
type=InteractionType.ChannelMessageWithSource,
content=f"{res.component.label} has been clicked!"
)
role = discord.utils.get(client.get_guild(ctx.guild.id).roles, id ="971970467789418576")
await member.add_roles(role)
``` So thats correct?
!paste @fossil adder
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.
Please a pastebin and no
Whats wrong in it?
mine?
Error?
Saying "won't work" isn't helping
Do you have a global error handler?
https://paste.pythondiscord.com/moquxerare @boreal ravine
me: hiwithdraw (hi is the prefix
bot: dawg, withdraw an amount
me:hiwithdraw 1
bot: (says nothing)
me:hi withdraw -1
bot: says nothing
I said it's not correct earlier
Does your bot have message intents
what is that
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot 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
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
Click the last hyperlink, and enable the intent inside your application
ill add intents
How can I fix this being here? It's annoying me
You can resolve it by fixing it
didnt think of that one
If running your code works but vsc still gives an error, then it's probably using the wrong interpreter or pip
Then it's most likely a vsc error
It's probably not looking in the right place for your packages
๐ค Not that I know of, you may have to disable intellisense altogether which is not favourable
lol
It indicates that there is an issue, so the best course forward would be to configure vsc to look in the right path for your packages for a better developer experience
alr
Have you considered using venvs?
no
They usually fix most of your package and pip related issues
Yup, use venvs when you feel ready
Stage of developement: brain issues
its like my dad
like i was born i said hi and that mfer said bye and went away
:(
how can i go about seeing if a bot has sent x message in x amount of time?
i.e:
if bot has already said 1234 in the last 2 minutes and conditions are met dont say 1234 again
InteractionType
Save the message content/author and when the message got created then check if the conditions are met
Which library is this?
discord_components
What do the pyflakes say?
Make sure you close it
I'm sure I did. The errors go away when I remove the for i,v line
Try ```py
options = [SelectOption(label=i, value=bugs[i]) for i in bugs]
in the options kwarg
options=options
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: too many
values to unpack (expected 2)
i think it's a json error
*bugs.items()
It's a dict
In components.0.components.0.options.0.value: Must be 100 or fewer in length.
yeah just realised
That's what's causing this error at least
yes
new error
I so dislike this error message
Like, what is components.0.components.0
honestly
Makes it hard to debug sometimes
the first component
๐คฎ
never mind
Is json defined?
yes
Anything wrong still?
pyflakes says no
Awesome
Ohh nvm
well
Can we see the json file rq?
It doesnโt
Wild guess but I'd say whatever value is is too long
ah figured it out
Well that's lovely
@boreal ravine's original code had the value as v when it was supposed to be i. no worries though.
thanks guys 
๐คฃ
๐
hey i got a bot that has a feature where it needs to repeat a message verbatim, including attachments. it's triggered by the on_message() client event
will await somewhere.send(message.content,files=message.attachments) work?
How do i make it function to where itll give the role?
naw
files accepts a list of File objects not Attachment objs
Rmr attachments are still on discord
file objs are local
Hello any one
ohhh ok
You can resend the link to the attachments though
ok would [i.to_file() for i in message.attachments] work?
ooo that might work
You need to await to_file, then it will work
await i.to_file(0 then yup
can i use list comprehension or do i have to make a loop?
List comp is fine
ok dope, thanks, yall!
But doing that on every on_message will be problematic for you
how so?
oh it does that?
i thought it converted it from the attachment object instance to a file instance
KInd of, it doesn't exactly download the file. But what it does is sends a request then reads the bytes, then stores it inside of a BytesIO object
How can I make the code just say "Error" when an error pops up?
yep i just looked at the code ๐
so my final thing is await somewhere.send(message.content,files=[await i.to_file() for i in message.attachments])
If you're gonna reuse those file objs repeatedly it's best you just store them in a list on first run or something
If it's fixed files u can do that
nope, it's pretty much recieve and send
ahhh
if you've ever heard of omegle, i'm making a discord server that's essentially that. anonymous channels where it's just u and the bot and you're paired with someone that the bot relays messages between
This is pretty neglible though, I mean the max size of an attachment through discord at a time has to be 8mb >=
Nitro users?
true...
It is also 8mb I though?
nope, i think it's up to 50
Ah wait no it's 100Mb
oh lol
That's pretty neglible though to be honest

