#discord-bots

1 messages ยท Page 1029 of 1

heady sluice
#

even though I went into psql shell on my raspberry to find out all the data is gone

paper sluice
#

pain

heady sluice
#

it had the birthdays of 12 guys in it and some voicechannel storing shit

heady sluice
#

cuz it stucks on connecting to the db

paper sluice
#

i dont even make discord bots, why tf am i here lmao

heady sluice
#

๐Ÿ‘๐Ÿฟ

#

dunno

slate swan
#

no one is gonna do something to it and make it interesting

cloud dawn
#

We are but you ask questions that are way to broad.

slate swan
#

how do i create a command for a discord bot?

white citrus
slate swan
#

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

glad cradle
fossil adder
#

do you guys know how to make a wallet?
like a virtual currency wallet?

fossil adder
#

yeah

glad cradle
#

database

cloud dawn
#

database covers 6/10 questions here.

glad cradle
#

ahhaha

modern fiber
#

Hey, how do I make a bot ping a certain role like out of embed message?

fossil adder
#

wheres the database

fossil adder
#

how do i add a prefix to my commands

cloud dawn
unkempt canyonBOT
#

@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.
cloud dawn
unkempt canyonBOT
#

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...
glad cradle
#
@client.command
async def sus(ctx):
	embed = discord.Embed(title='yes')
	await ctx.send('<@&roleId>', embed=embed)

try this

slate swan
modern fiber
glad cradle
#

@modern fiber

slate swan
#

but it triggers both global and local

glad cradle
modern fiber
#

await channel.send('<@&roleId>', embed=embed)

glad cradle
heady sluice
#

๐Ÿ˜ˆ

glad cradle
#

btw I'm using disnake

cloud dawn
#

Inside the global error handler.

quick roost
#

hi

slate swan
#

ima check

#

this is why i do game dev not discord bot creation

glad cradle
heady sluice
cloud dawn
unkempt canyonBOT
#

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`.
slate swan
slate swan
#

its a generated template

glad cradle
heady sluice
#

and don't use repl

cloud dawn
#

!d discord.ext.commands.cog.Cog

unkempt canyonBOT
#

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.
glad cradle
slate swan
#

uhh

glad cradle
cloud dawn
#

File is cog and then class Cog, I know kinda weird.

regal pulsar
gloomy fog
#

Uh

regal pulsar
slate swan
#

too confusing i find it easier with python game dev

regal pulsar
#

!d discord.ext.commands.Cog

unkempt canyonBOT
#

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.
regal pulsar
#

oh nvm ๐Ÿคฆโ€โ™‚๏ธ

cloud dawn
glad cradle
flint isle
#

Some one recommended dynox to me but they don't have any more slots for hosting. Any alternatives?

sharp rose
#

hi

slate swan
slate swan
# heady sluice and don't use repl

i tried printing commands.Command.qualified_name
heres the output:

<property object at 0x0000021AB0793810>

i added it inside the on_command_error

gloomy fog
#

Does anyone know how to check how many messages a user sent in a certain time?

glad cradle
slate swan
#

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

flint isle
vocal plover
#

you're printing the name attribute of the class, not an instance of the class

slate swan
vocal plover
#

you need an actual command instance from something like get_command()/ctx.command

glad cradle
cloud dawn
unkempt canyonBOT
#

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...
glad cradle
glad cradle
regal pulsar
#

disnake>>

fossil adder
#

how do i make a virtual wallet
(something like dank memers wallet)

gloomy fog
glad cradle
regal pulsar
unkempt canyonBOT
#
Bad argument

Converting to "int" failed for parameter "pep_number".

slate swan
#

too many libraries, makes brain hurt even more

cloud dawn
regal pulsar
#

here's a question

slate swan
gloomy fog
fossil adder
#

how do i make a virtual wallet
(something like dank memers wallet)

cloud dawn
#

I learned nextcord, disnake, discord.py and some slash_interaction.

regal pulsar
#

if i wanted to make a levelling system thats unique per person for each guild their in

regal pulsar
#

how would i go about that

fossil adder
regal pulsar
#

and nosql db wouldnt work

sick birch
glad cradle
fossil adder
regal pulsar
#

i tried with mongo

glad cradle
regal pulsar
cloud dawn
#

While loop the database with insert, good times.

regal pulsar
#

i dont know any sql tho

vocal plover
#

I need to add databases to my tutorial PainChamp

modern fiber
#

how do I add a slowmode on command like delay?

slate swan
cloud dawn
vocal plover
regal pulsar
#

i see

glad cradle
modern fiber
#

cooldown.

cloud dawn
slate swan
slate swan
cloud dawn
#

Why sqlite :(

vocal plover
#

I'll probably use an ORM, so it will automatically support mysql/mariadb, sqlite, and postgres

cloud dawn
#

But mysql async drivers are ewwie

glad cradle
unkempt canyonBOT
#

@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")...
sick birch
cloud dawn
sick birch
#

ORM is much much better

#

Prefer the javascript ones

glad cradle
sick birch
#

well typescript for type safety

glad cradle
#

all ded

modern fiber
#

Let's say 1 minute

glad cradle
#

rate = 60

#

no I'm trolling

#

rate 1

slate swan
#

no~

#

60 is correct

glad cradle
#

per = 60

glad cradle
modern fiber
#

Okay so @disnake.ext.commands.cooldown(rate=600)

glad cradle
#

no

modern fiber
#

for 10 minutes? or

slate swan
#

rate is the number of times you want that command to work
per is the amount of time in seconds

glad cradle
#
@disnake.ext.commands.cooldown(1, 600)

1 command every 10 minutes

modern fiber
#

thanks legend

sick birch
modern fiber
#

do you know how to send a custom emojis in an embed tho?

#

Ive tried 100 times but doesn't work

glad cradle
#

it's not intentional

sick birch
# glad cradle I was wrong

Right, if you're not 100% sure that your answer is correct, please do not give it, thanks for your understanding

glad cradle
#

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='<![IRUSUzeno](https://cdn.discordapp.com/emojis/959014425170423808.webp?size=128 "IRUSUzeno")947985467146657842>')
vocal plover
vocal plover
#

I'm yet to properly try it but if you're using vsc with the python language server it's meant to be amazing

cloud dawn
#

I also am good in giving misinfo.

gloomy fog
#

How do i assign a role

torn sail
#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/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.
gloomy fog
#

Tysm

nimble minnow
#

how do i make my bot react to a msg

slate swan
#

!d discord.Message.add_reaction

unkempt canyonBOT
#

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")...
paper sluice
#

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>)

slate swan
#

Message.add_reaction(Bot.get_emoji(id)) ๐Ÿข

heady sluice
#

you didn't just name it Bot

nimble minnow
#

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("๐ŸŽ‰")```
glad cradle
slate swan
#

as you can see the same with Message

nimble minnow
formal basin
#

Anyone know?

glad cradle
nimble minnow
#

ok, now what?

glad cradle
glad cradle
formal basin
glad cradle
#

do you want a list inside the dict?

formal basin
#

No

nimble minnow
# glad cradle run the command

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'```
glad cradle
#

yes, replace ctx in the parameters with message and replace await message.add_reaction..

#

try this

glad cradle
formal basin
#

Like that

nimble minnow
glad cradle
sick birch
#

!d discord.ext.commands.Command.cooldown

unkempt canyonBOT
slate swan
#

pls help ****

glad cradle
slate swan
glad cradle
unkempt canyonBOT
#

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...
glad cradle
#

guild_messages

#

you can also do discord.Intents.all()

#

@slate swan

slate swan
#

ok

glad cradle
#

send your code

#

send 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?

slate swan
#
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']}"))```
slate swan
#

@glad cradlecan you come dm please?

glad cradle
slate swan
#

yea

#

thx so much

glad cradle
#

np

glad cradle
#

cooldown in an embed?

edgy mantle
#

How do I use on_reaction_remove?

modern fiber
#

Hey, I need help, it says its running bot on heroku but bot isnt online

slate swan
#

how to let my bot check when the user said a channel name after using the command?

modern fiber
#

worked perfectly fine before i restarted dynos like couple minutes ago

fossil adder
#

how do i make my bot say different things everytime i use a command

modern fiber
#

Yeah, it was already hosting before I restarted all dynos for an update

fossil adder
#

for example
me: heybot, do my mom
bot: nah
me: heybot, do my mom
bot: sure

modern fiber
#

now it doesn't seem to come online

glad cradle
#

if you handle the error it should return the cooldown time, for ephemeral interaction things idk bro, I haven't experienced that stuff yet ๐Ÿ˜ฉ

modern fiber
#

Nvm fixed

fossil adder
#

can u help me

glad cradle
fossil adder
#

can u make me the code

#

since im pretty brainless

fossil adder
fossil adder
#

why not

glad cradle
fossil adder
#

i like to be spoonfed

fossil adder
#

i did

#

nothing helped

slate swan
fossil adder
#

i only come here when im hella desperate

glad cradle
#

if u have problem re-ask here @fossil adder

fossil adder
#

google how to make an 8ball in python?
got it, thanks!

glad cradle
slate swan
fossil adder
#

BRO
this is my first day using discord.py
PLEASEEEEE stop ass raping me

tranquil turtle
#

i can help if you want

fossil adder
#

im sorta new

#

the only language that im ever so slightly experienced in is C#

velvet compass
olive osprey
glad cradle
slate swan
#

how to make the money come in if the user has this amount?

#

Eh?

#

second

glad cradle
#

yes

#

speak in English maaaaan

slate swan
#

^+1

slate swan
glad cradle
slate swan
#
@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

glad cradle
slate swan
#

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?

slate swan
#

I see

glad cradle
#

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

left crater
#

cuz thats a slash command

glad cradle
#

but there is something else

#

I think there is bot.wait_for... but I'm not sure

edgy mantle
#

as an event?

glad cradle
edgy mantle
#

thats not an event

edgy mantle
#

@client.event

#

is what i mean

glad cradle
edgy mantle
#
@client.event
  async def on_reaction_remove(reaction, user):
#

that doesnt call

#

theres 0 difference

glad cradle
#

you can assume that all the people that the Bot can see are users, so len(client.users)

glad cradle
edgy mantle
#

Can you help me with this call

glad cradle
edgy mantle
#

Thats not what I mean

#

i wrote the indent by accident

glad cradle
#

then what do you mean

edgy mantle
#

How do I make it call

#

It doesnt call

glad cradle
#

what do you mean with "callable" explain what your command should do

edgy mantle
#

Just work in the first place

#

When someone removes a reaction nothing happens

glad cradle
sick birch
midnight gorge
#

do i install the version 3.8.13 or lastest?

#

lastest means 2.0?

spring flax
#

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?

glad cradle
#

try to print payload.user_id

regal pulsar
#

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

heady sluice
#

call functions please

regal pulsar
heady sluice
#

users.keys()

regal pulsar
#

no i meant to tell him to use a list

#

not a dict

heady sluice
#

okay but

#

it still bothered me

regal pulsar
#

lol

glad cradle
#

if u restart the Bot you lose all

heady sluice
#

๐Ÿ˜ฆ

regal pulsar
glad cradle
regal pulsar
#
with open(โ€œusers.txtโ€, encoding=โ€œutf8โ€) as file:
    users = file.readlines()
slate swan
#

how to make command like when u type .report bot creates private channel where person who typed .report can say their report?

regal pulsar
#

not sure hoe to do the perms thing

slate swan
#

can't run

regal pulsar
#

i mightve made a syntax error somewhere

regal pulsar
#

its like 2:30 am and im on my phone ๐Ÿ’€

slate swan
#

for me is 11 PM night

regal pulsar
#

uk?

slate swan
#

nah serbia

regal pulsar
#

o

#

cool

slate swan
#

yeah

regal pulsar
#

its create_channel

#

not channels mb

slate swan
#

?

regal pulsar
#

ctx.guild.create_channel

slate swan
#

igtg i gonna add u as fr

glad cradle
#

""

slate swan
#

How can I fix this?

#
import discord
from  neuralintents import GenericAssistant

chatbot=GenericAssistant('intents.json')
chatbot.train_model ()
chatbot.save_model()```
glad cradle
#

what's the problem?

rotund pagoda
#

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?

slate swan
#

nvm... i think i just found a fix...

keen mural
#

how would i make it so buttons get disabled after time

#

cuz when i try i cant press buttons

frozen patio
#

Use asyncio.sleep

keen mural
frozen patio
#

But you want them disabled yes?

keen mural
#

yeah if they dont press anything within 10 seconds

#

i want them to be functional at first then after 10 sec disable

frozen patio
keen mural
#

no it makes the whole code sleep

frozen patio
#

Not when I do it inside my commends ๐Ÿค”

frigid rose
slate swan
#

ugh i hate parsing long payloads๐Ÿ˜”

frozen patio
#

I hate typing 100 lines of Java to open a blank Window

slate swan
#

๐Ÿ˜ญ

frozen patio
#

My window is really advanced tho

keen mural
frigid rose
glad cradle
keen mural
#

well i need the code to send stuff when button press

frozen patio
#

If it is pressed

#

Have you tried if statements?

keen mural
#

no

frozen patio
#

Try that

keen mural
#

idk how i would implement that though

slate swan
#

@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

heady sluice
#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

@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...
heady sluice
#

client = discord.Client() โŒ
bot = commands.Bot() โœ…

slate swan
#
    bot = discord.Bot(intents=discord.Intents.all())
AttributeError: module 'discord' has no attribute 'Bot'
``` How can i solve this
hard steeple
slate swan
#

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

hard steeple
#

oh

#

use that

#

wait

#
Prefix = "#your bot prefix"
bot = commands.Bot(command_prefix=Prefix)
#

it worked out?

slate swan
#
    @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?

hard steeple
slate swan
#

i see no reason for it only if youre using it some where else

hard steeple
#

it's just to be more organized

slate swan
slate swan
#

most prefixes are average 1 char

hard steeple
slate swan
#

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...

hard steeple
slate swan
#

just a few until your code base becomes bigger

hard steeple
slate swan
hard steeple
#

I think you would have to print like this here:

slate swan
#

@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

rotund pagoda
#

anyone know if there is a way around the keyword requirements for the discord webhook?

slate swan
#

dang my bot doesnt have any relationships ๐Ÿ˜”

frozen patio
#

Mine doesn't either ๐Ÿ˜”

hard steeple
#
# command
    @commands.command(name="test")
    async def send_hello(self, ctx):
      response = "Hello!"
      await ctx.send(response)
      print (response)
slate swan
#

damn these headers๐Ÿ˜”

slate swan
#

yea

#

that should work, thanks

hard steeple
slate swan
#

jeez discords docs are so bad

#

its giving me a headache

hard steeple
#

'-'

frozen patio
#

Cause it's in JS

slate swan
#

5year olds in this chat

#

sexy

slate swan
#

its just its layout

#

i cant even make properties for my class because i dont know the types and the docs doesnt show types

#

๐Ÿ˜”

slate swan
#

How can I get the username of the bot that i've logged into

hard steeple
slate swan
#

bro

#

my name spaces are colliding again

hard steeple
#

is that

slate swan
#

oki

hard steeple
#

!d discord.Member

unkempt canyonBOT
#

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")...
slate swan
#

oki

hard steeple
#

it's discord.Member

slate swan
#

nah

fading marlin
#

!d discord.ext.commands.Bot.user

unkempt canyonBOT
slate swan
#

!d discord.ClientUser.display_name

unkempt canyonBOT
#

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.
hard steeple
#

or

slate swan
unkempt canyonBOT
slate swan
#

?

hard steeple
#

wtf

slate swan
#

theres 41 packages what do you expect

#

you need to specify the module

hard steeple
slate swan
#

?

hard steeple
#

like that?

slate swan
#

AttributeError: 'Bot' object has no attribute 'slash_command'. Did you mean: 'add_command'? ๐Ÿ†˜

hard steeple
#

oof

slate swan
#

author returns a member object

#

!d discord.Member.mention

unkempt canyonBOT
hard steeple
slate swan
#

thats the deco for disnake

hard steeple
slate swan
#

would this not work?
print(f'logged in as '.format(client))

slate swan
#

the property does return the object but thats not the right path

slate swan
#

!f-strings

unkempt canyonBOT
#

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.

slate swan
#

tho it would work right?

hard steeple
slate swan
#

Idk why it doing that then

#

thats confusing cuz my bot definitely does have a name

hard steeple
#

test

#

use a command

#

and see if the bot put your name

slate swan
#

ok

slate swan
hard steeple
slate swan
#

is there another way for me to print it then
print('this ma name: '.format(client)

hard steeple
#

you wanted the username if I'm not mistaken, right?

hard steeple
#

bro

#

try using discord.Member.mention

#

to see if it will work

slate swan
#

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

hard steeple
#

then

#

use discord.Member.mention

sly hamlet
#

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

hard steeple
#

and test

iron sorrel
slate swan
iron sorrel
#

you are lacking perms

slate swan
#

@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

sly hamlet
#

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

slate swan
#

AttributeError: module 'discord' has no attribute 'Bot' i have this

#

I installed disnake but still same

hard steeple
heady sluice
#

it's commands.Bot

#

!!!!!!!!!!!!!!!!!!!!!!!!

hard steeple
slate swan
#

nvm i ended up just doing ```py
print(f'{bcolors.GREEN}> {bcolors.RESET}Ready - {client.user}')

#

lol

slate swan
frozen patio
#

it's commands.Bot

hard steeple
hard steeple
#

Notepad?

slate swan
#

If im using commands.bot i get this but i have slash commands TypeError: BotBase.init() missing 1 required positional argument: 'command_prefix'

slate swan
heady sluice
#

you need a command prefix

hard steeple
heady sluice
#

that error is basic python

frozen patio
#

Very basic

hard steeple
#

I don't know how to solve it but try to use BotBase.__init__(command_prefix=#your bot prefix)

hard steeple
frozen patio
#

LMAO

slate swan
#

And should i add , intents=discord.Intents.all() after command_prefix= ?

frozen patio
#

yeah, you need to have 2 arguments for that

slate swan
#

name BotBase is not defined

hard steeple
frozen patio
#

just add a prefix but never use it

slate swan
#

If i will add i will get error about slash commands

#

Lemme show u

frozen patio
#

No??

#

You shouldn't

hard steeple
frozen patio
#

Dud you import slash_command

#

did*

slate swan
#

lol the bot is having a wierd conversation with itself

#

i might have messed up

frozen patio
#

XDDDDDDDDDDDD

slate swan
#

if message.author == client.user:
return

#

essential

hard steeple
slate swan
#

i removed it to see

#

what would happen

frozen patio
#

It talked to itself

hard steeple
slate swan
#

yh

slate swan
frozen patio
slate swan
#

And if i do how u said i get this AttributeError: 'Bot' object has no attribute 'slash_command'. Did you mean: 'add_command'?

heady sluice
hard steeple
slate swan
#

what do you guys think?

slate swan
heady sluice
#

you add slash commands to a tree

frozen patio
#

Looks good

slate swan
#

kinda basic which i like

frozen patio
#

Yea

hard steeple
frozen patio
#

Wish I could say the same with a Game Engine

slate swan
#

still have to implement the event and intent systems๐Ÿ˜”

#

whats the sexiest bot on discord

#

bro what

hard steeple
slate swan
#

nah

hard steeple
#

lmao

slate swan
#

aight

#

mee6

slate swan
frozen patio
slate swan
#

๐Ÿ˜ณ

hard steeple
slate swan
frozen patio
slate swan
#

yup

hard steeple
#

jeez, i forgot @slate swan hahaha

frozen patio
#

I want to know how it makes different bot accounts and shit

hard steeple
slate swan
frozen patio
#

For Premium

heady sluice
frozen patio
#

I want to know how to do that ๐Ÿ˜‚

hard steeple
# slate swan What ?

i forgot about you for a second and that you were still having doubts about why your command was giving error

slate swan
#

Ah

frozen patio
slate swan
#

Still don't know how to fix it aPES_Cry

hard steeple
slate swan
#

Wdym

hard steeple
slate swan
#

What do you mean*

hard steeple
frozen patio
#

Have you tried add_command yet

#

for slash

slate swan
#

To change slash_command to add_command ?

#

no

#

the error gets raised because the words are similiar

hard steeple
# slate swan What do you mean*

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

slate swan
#

iiirc all slash commands call add_command and the deco is from disnake and not discord.py

#

No

hard steeple
slate swan
#

notstiles you copied the code right?

hard steeple
#

because I don't know what it is either ;-;

#

@slate swan pls send me all the code

slate swan
#

because it seems like you smacked it in the file and called it a day

slate swan
#

its because youre using the wrong library

#

youre using discord.py when you should be using disnake

slate swan
#

!pypi disnake

unkempt canyonBOT
frozen patio
slate swan
#

nextcord uses the same deco naming?

#

i havent checked

frozen patio
#

it uses @bot.slash_command()

slate swan
#

ah nice

frozen patio
#

Yea

#

And way less typing to make a slash command in nextcord

hard steeple
#

@frozen patio @slate swan you guys seem very smart in python, then can you help me with an error my code is having?

slate swan
#

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

frozen patio
frozen patio
#

I have been getting an expert in Java

slate swan
#

python for life

hard steeple
#

I learned python not even a month ago

hard steeple
frozen patio
#

I learned it 3 months ago

hard steeple
slate swan
#

i started learning python a year ago

frozen patio
#

Tkinter a good lib for games in Py

hard steeple
hard steeple
frozen patio
#

then quart & django for backend websites ๐Ÿ‘€

slate swan
#

kinda young in experience compared to most regulars here

hard steeple
slate swan
frozen patio
#

Yeah I forgot about flask

slate swan
#

i love how flask uses decos

hard steeple
frozen patio
#

I am thinking of making a python interpreter

#

for brainf

slate swan
slate swan
#

most regulars here have 2+ years of experience

#

while im here with 1.2

hard steeple
slate swan
#

compared to regulars yes

frozen patio
#

Compared to others yes

#

But it's pretty solid

slate swan
#

my bot is making me hard

hard steeple
# slate swan What ?
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?

slate swan
#

thats how sexy it is

#

bro what

hard steeple
#

@slate swan send me your bot link to i see it ๐Ÿ˜ณ

slate swan
slate swan
#

your bot can be good but is the source good?

frozen patio
hard steeple
slate swan
#

its the command line ui

pliant gulch
hard steeple
#

@slate swan just ctrl + c and ctrl + v easy

slate swan
#

sexyy

#

im gonna improve it

hard steeple
slate swan
hard steeple
#

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 ?

slate swan
#

i cant right now, sorry

hard steeple
#

I'll leave my question here in case someone sees it and manages to solve it '-

thin bluff
#

hello i have an error and its says </script> at the start

#

what does that mean

hard steeple
#

it's in html?

thin bluff
#

no python

hard steeple
#

Jeez, I haven't seen this in python, only in html

thin bluff
#

i googled it but not sure if its the same thing what i have

hard steeple
#

but send the whole error, it will help me to help you

thin bluff
#

ok

sly hamlet
#
AttributeError: 'Button' object has no attribute 'guild'``` ```py
 interaction.guild.voice_client.resume()
#

So do I just take out guild?

thin bluff
#

can u copy an error?

hard steeple
thin bluff
#

yeah I

#

no like

hard steeple
#

'-'

thin bluff
#

do i send a pic or what?

hard steeple
#

it's because I didn't understand what you meant

hard steeple
thin bluff
#

how?

hard steeple
#

ctrl + c and ctrl + v

thin bluff
#

no

#

it says keyboard interrupt

hard steeple
#

so send a pic

thin bluff
#

ok

thin bluff
slate swan
#

looks like a flask error

#

anyway not suited for this channel

thin bluff
#

what that

slate swan
#

take this to a help channel

thin bluff
#

ok

slate swan
#

Where do you host your bots ?

slate swan
slate swan
hard steeple
thin bluff
#

ok

slate swan
#

if you can afford it

slate swan
# slate swan looks like a flask error

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 ๐Ÿ˜ญ

slate swan
#

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

slate swan
#

isn't that the flask format

#

well thats just html

hard steeple
#

alordz is using javascript to program?

slate swan
#

nah lol

#

its just the error

hard steeple
slate swan
#

in html

#

as you can see the opening and closing tags

hard steeple
#

ah that's why there's this </script> thing, well I had recognized

slate swan
#

yep

hard steeple
#

but the error was not supposed to be in python?

slate swan
#

it's because the error is related to a web request

hard steeple
#

strange

slate swan
#

one that failed server-side, so the server returned an html page with content about the exception

hard steeple
#

for the site to go down right when the person is going to run the code

#

in the case the error

slate swan
#

well the error is handled server-side, but in this case the issue is probably with the client

slate swan
#

interesting problem ngl haha

slate swan
#

usually with flask you just take a look at the response.status variable

pliant gulch
slate swan
#

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

hard steeple
#

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

pliant gulch
# thin bluff

Looking at the "full" screenshot, this is indeed a cloudflare error thing

slate swan
pliant gulch
#

You've been banned from the REST API

slate swan
#

๐Ÿ’€

hard steeple
slate swan
#

probably 'application/json' is set, which means that it returns solely the json data

pliant gulch
slate swan
#

he probably did something bad bad

slate swan
pliant gulch
slate swan
pliant gulch
#

Since they use shared servers

hard steeple
#

anyone who knows html here to try to understand this error? haha

slate swan
hard steeple
slate swan
#

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

hard steeple
pliant gulch
#

Repl.it is fine for what is was designed for

#

which doesn't include hosting discord bots

slate swan
slate swan
#

indeed what i just said

pliant gulch
#

And I am agreeing with you

slate swan
#

epic

#

i cant remember

pliant gulch
#

Before this, discord bots on repl.it was against their ToS

hard steeple
hard steeple
#

calm down, can you host bot 24h on repl.it?

slate swan
#

technically

hard steeple
slate swan
#

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

hard steeple
slate swan
#

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

pliant gulch
#

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

hard steeple
slate swan
#

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

slate swan
#

you never know when someone is gonna get freaky

#

๐Ÿคจ

#

ayo?

hard steeple
#

I'm going to have dinner now, after I have dinner can someone try to help me host my bot on heroku? '-

jade tartan
#

Am i able to talk about pycord in this server?

#

and/or channel

slate swan
#

yep

fossil adder
#

'Morning everybody
new day, new error in my script

slate swan
#

we offer help for most of the python discord api modules

fossil adder
#

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?

jade tartan
#
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"?
fossil adder
#

@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

jade tartan
#
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?
boreal ravine
#

!paste @fossil adder

unkempt canyonBOT
#

Pasting large amounts of code

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

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

jade tartan
fossil adder
#

why wont this work

boreal ravine
#

Whats wrong in it?

fossil adder
#

mine?

jade tartan
fossil adder
#

theres no error

#

but whenever i try withdrawing anything it doesnt work

boreal ravine
fossil adder
#

basically

#

heres an example

boreal ravine
jade tartan
fossil adder
#

me: hiwithdraw (hi is the prefix
bot: dawg, withdraw an amount
me:hiwithdraw 1
bot: (says nothing)
me:hi withdraw -1
bot: says nothing

boreal ravine
boreal ravine
fossil adder
#

what is that

boreal ravine
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. 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.

boreal ravine
#

Click the last hyperlink, and enable the intent inside your application

fossil adder
#

ill add intents

slate swan
#

How can I fix this being here? It's annoying me

sick birch
slate swan
#

didnt think of that one

sick birch
#

If running your code works but vsc still gives an error, then it's probably using the wrong interpreter or pip

slate swan
#

theres no errror in the console

#

and i did pip install it

sick birch
#

Then it's most likely a vsc error

#

It's probably not looking in the right place for your packages

slate swan
#

is there a way for me to stop vsc from showing it

#

its annoying me to have that error

sick birch
#

๐Ÿค” Not that I know of, you may have to disable intellisense altogether which is not favourable

slate swan
#

lol

sick birch
#

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

slate swan
#

alr

sick birch
#

Have you considered using venvs?

slate swan
#

no

sick birch
#

They usually fix most of your package and pip related issues

slate swan
#

its fine ill stick to where i am for now

#

thanks though

sick birch
#

Yup, use venvs when you feel ready

slate swan
#

Stage of developement: brain issues

#

its like my dad

#

like i was born i said hi and that mfer said bye and went away

#

:(

vapid bramble
#

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

jade tartan
#

What part

hybrid fjord
#

why won't this work?

any other alternatives?

#

using dropdowns ^^

boreal ravine
boreal ravine
boreal ravine
hybrid fjord
#

discord_components

boreal ravine
#

What do the pyflakes say?

hybrid fjord
#

"[" was not closed

#

or
"(" was not closed

boreal ravine
#

Make sure you close it

hybrid fjord
#

I'm sure I did. The errors go away when I remove the for i,v line

boreal ravine
#

Try ```py
options = [SelectOption(label=i, value=bugs[i]) for i in bugs]

in the options kwarg

options=options

hybrid fjord
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ValueError: too many
values to unpack (expected 2)

#

i think it's a json error

hybrid fjord
#

In components.0.components.0.options.0.value: Must be 100 or fewer in length.

hybrid fjord
stone beacon
boreal ravine
stone beacon
#

Like, what is components.0.components.0

hybrid fjord
#

honestly

stone beacon
#

Makes it hard to debug sometimes

boreal ravine
#

the first component

stone beacon
#

๐Ÿคฎ

hybrid fjord
boreal ravine
hybrid fjord
#

yes

boreal ravine
#

Anything wrong still?

hybrid fjord
#

pyflakes says no

jade tartan
#

I mean it works tho

boreal ravine
#

Awesome

jade tartan
#

Ohh nvm

stone beacon
#

Can we see the json file rq?

jade tartan
stone beacon
#

Wild guess but I'd say whatever value is is too long

hybrid fjord
#

ah figured it out

stone beacon
#

Well that's lovely

hybrid fjord
#

@boreal ravine's original code had the value as v when it was supposed to be i. no worries though.

thanks guys ok_handbutflipped

stone beacon
#

๐Ÿคฃ

hybrid fjord
#

๐Ÿ˜‚

glad palm
#

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?

jade tartan
#

How do i make it function to where itll give the role?

stone beacon
#

naw

#

files accepts a list of File objects not Attachment objs

#

Rmr attachments are still on discord

#

file objs are local

jade tartan
#

Hello any one

glad palm
#

ohhh ok

stone beacon
#

You can resend the link to the attachments though

glad palm
glad palm
pliant gulch
#

You need to await to_file, then it will work

stone beacon
glad palm
pliant gulch
#

List comp is fine

glad palm
#

ok dope, thanks, yall!

stone beacon
#

But doing that on every on_message will be problematic for you

stone beacon
#

Downloading the same files over and over everytime someone msgs ๐Ÿ‘€

#

wait thin_ice

#

Nvm

glad palm
#

i thought it converted it from the attachment object instance to a file instance

pliant gulch
#

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

slate swan
#

How can I make the code just say "Error" when an error pops up?

glad palm
stone beacon
#

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

glad palm
#

nope, it's pretty much recieve and send

stone beacon
#

ahhh

glad palm
#

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

pliant gulch
#

This is pretty neglible though, I mean the max size of an attachment through discord at a time has to be 8mb >=

stone beacon
#

Nitro users?

glad palm
#

true...

pliant gulch
#

It is also 8mb I though?

glad palm
#

nope, i think it's up to 50

pliant gulch
#

Ah wait no it's 100Mb

glad palm
#

oh lol

pliant gulch
#

That's pretty neglible though to be honest