#discord-bots

1 messages · Page 85 of 1

slate swan
#

Should I respond with ```py
interaction.response.send_message('Game instance created')

cloud dawn
#

Np :3

slate swan
#

Because even when it creates it, it still says 'did not respond'

errant coral
#

oh i completly didnt see that lol

slate swan
#

but i assume thats because i didnt respond with the interaction

cloud dawn
cloud dawn
errant coral
#

the command worked before and i added perms thing and then it f up so im redoing it lol

cloud dawn
#

Have you ever played land.io on Discord @slate swan? It's like paper.io but in Discord.

cloud dawn
#

Poker?

slate swan
#

Nope

thorn seal
#

my bots activity presence wont change

cloud dawn
slate swan
#

Nope O_o

#

I have not seen anything.

slate swan
#

;O

cloud dawn
#

Pretty awesome.

#

I've made a custom command to generate invite urls.

#

Only bots can generate it.

thorn seal
slate swan
cloud dawn
thorn seal
#

and i need help

cloud dawn
thorn seal
paper sluice
slate swan
#

I am so proud of myself, this is my first python project that I have ever completed.

cloud dawn
slate swan
#

Wow

#

Usually I give up halfway, but this time I was passionate and I did it.

paper sluice
thorn seal
cloud dawn
thorn seal
cloud dawn
#

Here is an example ```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)

#

!d discord.BaseActivity there are more...

unkempt canyonBOT
#

class discord.BaseActivity(**kwargs)```
The base activity that all user-settable activities inherit from. A user-settable activity is one that can be used in [`Client.change_presence()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.change_presence "discord.Client.change_presence").

The following types currently count as user-settable...
cloud dawn
#

I'm pretty sure the Game.. etc. Is self explanatory.

#

@paper sluice Did you ever have this glitch?

#

It's like in my text box of Discord, when I scroll up and down back to the most recent messages.

thorn seal
cloud dawn
thorn seal
slate swan
# cloud dawn Are you using discord.py?

I'm trying to do the same thing:

@Host.event()
async def on_ready():
    await Host.change_presence(status = discord.Status.idle, activity = discord.Game('with the API!'))
#

@Host.event() TypeError: Client.event() missing 1 required positional argument: 'coro'

cloud dawn
#

Could you provide anything more that might help me?

cloud dawn
slate swan
#

Ah im so stupid

thorn seal
cloud dawn
#

And I recommend changing the presence in the setup hook.

unkempt canyonBOT
#

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

A coroutine to be called to setup the bot, by default this is blank.

To perform asynchronous setup after the bot is logged in but before it has connected to the Websocket, overwrite this coroutine.

This is only called once, in [`login()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.login "discord.ext.commands.Bot.login"), and will be called before any events are dispatched, making it a better solution than doing such setup in the [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready") event.

Warning

Since this is called *before* the websocket connection is made therefore anything that waits for the websocket will deadlock, this includes things like [`wait_for()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.wait_for "discord.ext.commands.Bot.wait_for") and [`wait_until_ready()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.wait_until_ready "discord.ext.commands.Bot.wait_until_ready")...
cloud dawn
thorn seal
#

of course

cloud dawn
#

The example I send also didn't work?

thorn seal
#

nope didnt work

cloud dawn
#

hmn

thorn seal
#

i fixed it

cloud dawn
#

What was it?

thorn seal
#

aha i had 2 async def on_ready i beleive

slate swan
#
        # http request obj with regular image to .content
        icon = server.atserver_request(
            url = 'https://aternos.org/panel/img/server-icon.php',
            method = 'GET',
            sendtoken = True
        )

        discord.File(fp=BytesIO(icon.content), filename="image.png")

        status_emoji = status_to_emoji.get(server.status)
        embed = discord.Embed(
            color = discord.Color.blurple(),
            title = 'Information',
        embed.set_thumbnail(
            url = 'attachment://image.png'
        )

This wont display a picture. Why doesnt it and how should I fix it?

#
discord.Object(id=guild_id)
#

np

vocal snow
#

what data are you trying to get

slate swan
#

I wouldnt call myself

:VerifiHaken:︱Verified Dev
🖥︱Coder (Python, SQL)
🪟︱Designer, Web dev (Html, JS, CSS)

If I were you

#

look up the doc lmao

#

y

#

"Dev"

#

be nice!

vocal snow
slate swan
paper sluice
slate swan
paper sluice
#

you didn't close the function call for discord.Embed

vocal snow
slate swan
cloud dawn
slate swan
slate swan
vocal snow
paper sluice
#

code of conduct

cloud dawn
slate swan
#

Okay.

slate swan
cloud dawn
slate swan
#

We need your code to know.

vocal snow
# slate swan ??

you're creating a discord.File, you need to attach it with the file kwarg

#

!d discord.InteractionResponse.send_message

unkempt canyonBOT
#

await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by sending a message.
vocal snow
#

file kwarg here

vocal snow
#

how are you defining guild?

#

and why are you making sets?

slate swan
#

lmao

#

@vocal snow Thanks for your help! The b*tch finally works

#

Where do you define guild?

zenith wagon
#

Hello, I need help I want to make a bot that detects when someone is in the voice channel and then sends a message in text chat I have no idea how to query this with voice channel

slate swan
#

pillow < create html => 2 image

vocal snow
unkempt canyonBOT
#

discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceState "discord.VoiceState").

The following, but not limited to, examples illustrate when this event is called...
vocal snow
#

to detect when someone joins a vc

thorn seal
#
@tree.command(name = "avatar", description = "Get an avatar", guild = discord.Object(id = 823975769747095582))
async def Avatar(interation: discord.Interaction):
    em = discord.Embed(title='Avatar', description=interation.display_avatar)
    interation.response.send_message(embed=em)```
Help?
vocal snow
#

please don't send 1 line screen shots, send the full code with !paste

slate swan
#

Ah I see, add ur guild variable at the top of ur previous code

thorn seal
#

'Interaction' object has no attribute 'display_avatar'

slate swan
thorn seal
slate swan
#

@slate swan What you are doing is this:

paper sluice
#

interation 😶

slate swan
#

you cant display the avatar of interation

#
print(bob)
bob = 5

That wont work because bob is not defined when you print it.
You have to add bob at the top so like:

bob=5
print(bob)
vocal snow
#

the error is saying you're defining it after you're using it's attributes. We can't debug this without seeing the full code.

thorn seal
vocal snow
thorn seal
# vocal snow <@576424345703022617>

RuntimeWarning: coroutine 'InteractionResponse.send_message' was never awaited
interation.response.send_message(embed=em)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

vocal snow
thorn seal
#

oh

#

lmfao

vocal snow
#

and where are you defining total_text_channels

#

you're defining total_channels

thorn seal
vocal snow
#

im asking where you're defining total_text_channels

vocal snow
#

!d discord.Embed.set_image

unkempt canyonBOT
#

set_image(*, url)```
Sets the image for the embed content.

This function returns the class instance to allow for fluent-style chaining.
vocal snow
#

you should use the guild from ctx.guild

#

im guessing you're trying to get the total channels in the guild the command was invoked in

thorn seal
thorn seal
vocal snow
#

this is generally why we recommend learning python before trying out discord.py

#

anyways; ```py
em = discord.Embed(...)
em.set_image(...)

vocal snow
thorn seal
zenith wagon
#

AttributeError: 'VoiceState' object has no attribute 'voice_channel'

#

Why

vocal snow
#

!d discord.VoiceState

thorn seal
#
@tree.command(name = "avatar", description = "Get an avatar", guild = discord.Object(id = 823975769747095582))
async def Avatar(interation: discord.Interaction):
    em = discord.Embed(title='Avatar')
    em.set_image(interation.user.display_avatar)
    await interation.response.send_message(embed=em)```
zenith wagon
#
@client.event
async def on_voice_state_update(before, after, member):
    if before.voice.voice_channel is None and after.voice.voice_channel is not None:
        for channel in before.server.channels:
            if channel.name == 'feff':
                await client.get_channel(884876951427362876).send(f"{member.mention} **ist in der Whitelist Warteschlange.**")```
vocal snow
vocal snow
unkempt canyonBOT
#

The voice channel that the user is currently connected to. None if the user is not currently in a voice channel.

vocal snow
#

just channel, not voice_channel

vocal snow
thorn seal
#

ok

vocal snow
#

!pos-keyword

unkempt canyonBOT
#

Positional vs. Keyword arguments

Functions can take two different kinds of arguments. A positional argument is just the object itself. A keyword argument is a name assigned to an object.

Example

>>> print('Hello', 'world!', sep=', ')
Hello, world!

The first two strings 'Hello' and world!' are positional arguments.
The sep=', ' is a keyword argument.

Note
A keyword argument can be passed positionally in some cases.

def sum(a, b=1):
    return a + b

sum(1, b=5)
sum(1, 5) # same as above

Somtimes this is forced, in the case of the pow() function.

The reverse is also true:

>>> def foo(a, b):
...     print(a, b)
...
>>> foo(a=1, b=2)
1 2
>>> foo(b=1, a=2)
2 1

More info
Keyword only arguments
Positional only arguments
!tags param-arg (Parameters vs. Arguments)

thorn seal
#

got it

zenith wagon
#
@client.event
async def on_voice_state_update(before, after, member):
    if before.voice.channel is None and after.voice.channel is not None:
        for channel in before.server.channels:
            if channel.name == 'feff':
                await client.get_channel(884876951427362876).send(f"{member.mention} **ist in der Whitelist Warteschlange.**")```
#

No error but does not give out a message

paper sluice
#

then your if statement don't work

#

why are you checking if they are None?

vocal snow
zenith wagon
#

intents=discord.Intents.all

vocal snow
#

also; before.guild.channels not before.server.channels

vocal snow
#

well it doesn't

#

you would use ctx.guild.channels

#

and call len() on that

zenith wagon
#
import discord
from discord.ext import commands

client = commands.Bot(command_prefix=".", intents=discord.Intents.all())

@client.event
async def on_ready():
    print("Is Ready")

@client.event
async def on_member_join(member):
   await client.get_channel(1013481921210237060).send(f"{member.mention}** ist am Flughafen gelandet.**")

@client.event
async def on_voice_state_update(before, after, member):
    if before.guild.channels is None and after.server.channels is not None:
        for channel in before.server.channels:
            if channel.name == 'feff':
                await client.get_channel(884876951427362876).send(f"{member.mention} **ist in der Whitelist Warteschlange.**")```
vocal snow
#

!d discord.Guild.channels

unkempt canyonBOT
vocal snow
#

it gives you all channels

zenith wagon
#

Can you please korriegenren can hardly english the difficult for me

dull knot
#

Is there a resource for how I can learn how to implement his types of API in code? So far, I only know about sending Images/Gifs and whatnot lol.

Just answer my question later. After you've finished replying to the rest of their questions lol

vocal snow
#

it doesn't like the error says

#

uhm.. why?

dull knot
proud apex
#

How to get the mentioned member in interaction?

vocal snow
#
len(ctx.guild.channels)
``` why is this hard
vocal snow
#

it'll probably respond with the image bytes, which you can then send as a file

vocal snow
#

you have like a slash command with a parameter that takes a Member?

proud apex
#

Select menu

sick birch
#

How would a user be mentioned in a select menu?

proud apex
#

Not. Like a participant pings a person, and he will already be in the message, he found only interaction.user

winged coral
unkempt canyonBOT
#

coroutine async-with get(url, *, allow_redirects=True, **kwargs)```
Perform a `GET` request.

In order to modify inner `request` parameters, provide kwargs.
sick birch
#

NameError: name 'base_url' is not defined

#

What do you think you can do? If something is not defined, logically, what would be the next step?

#

There you go

#

Same way you'd define any regular variable in python

#

You defined the base URL, so you need to choose what would play best with your code

paper sluice
#

it would be the url of the api you are using

thorn seal
#

how do i mention the author using interation

zenith wagon
#
async def on_voice_state_update(member, before, after):
 if not before.channel and after.channel:
    print(f'{member} has joined the vc')
    await client.get_channel(1020014500335861920).send(f"{member.mention}** wartet im Whitelist Warteraum.**")```
#

How can I set it to 1 language canal so that he does not send the message to all

thorn seal
#

how do i fix this not mentioning

slate swan
#

How do I make a whitelist discord bot does anyone know (Python)

zenith wagon
#

How can I set it to 1 language canal so that he does not send the message to all

slate swan
thorn seal
#

how do i put their username instead?

#

interation.user ?

slate swan
zenith wagon
slate swan
zenith wagon
#

Yes he sends a message as soon as someone in voice chat joint but he should do it only in a voice chat

slate swan
# zenith wagon .
 if not before.channel and after.channel:
    print(f'{member} has joined the vc')
    await client.get_channel(1020014500335861920) ```
primal token
slate swan
#

I get its missing a tab del space whatever but im trying and I cant find the place there suppost to be could someone help please!?

primal token
slate swan
feral frost
#

guys how do i do smth like (ctx.author.id) with interaction and slash commands ?

primal token
unkempt canyonBOT
feral frost
#

ah thanks

primal token
unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

primal token
slate swan
# unkempt canyon

Sorry, I dont understand im new to discord bots and also im not good at english

zenith wagon
#

The bot does just no matter in which voice chat you joint he sends in the message every time I want but that it has worked only in a selected voice chat

#
async def on_voice_state_update(member, before, after):
 if not before.channel and after.channel:
    print(f'{member} has joined the vc')
    await client.get_channel(1020014500335861920).send(f"{member.mention}** wartet im Whitelist Warteraum.**")```
primal token
slate swan
#
 if not before.channel and after.channel:
    print(f'{member} has joined the vc')
    await ctx. message. delete()
    await client.get_channel(1020014500335861920).send(f"{member.mention}** wartet im Whitelist Warteraum.**")
slate swan
primal token
slate swan
#

yes

primal token
#

I believe you, you know python, but not enough.

slate swan
zenith wagon
#

Oh man

#

My code doesent work

paper sluice
slate swan
slate swan
#

and it ruined my code

paper sluice
#

uhm, then you didn't do it properly....

slate swan
#

wait on witch like

primal token
slate swan
slate swan
primal token
paper sluice
# slate swan

those lines of code which you want to execute when the condition is true

meager chasm
#

The troll is back 🍿

primal token
slate swan
primal token
meager chasm
paper sluice
slate swan
# unkempt canyon

That dosen't really help and i only created 1 if statement in that image

primal token
#

I shouldnt even be saying that line, its common sense and your parents shouldve already told you about it

primal token
slate swan
meager chasm
#

This server's moderators don't handle trolls. And it's great, i love seeing them ask basic and stupid python questions and watching innocent helpers wate their time trying to help

#

It's very comedic

paper sluice
#

then enjoy it

meager chasm
#

I am, hence the popcorn emoji

paper sluice
#

don't have to comment

meager chasm
#

🍿

slate swan
paper sluice
slate swan
#

maybe thats why its hard for me to understand what yall are tryna tell me

meager chasm
slate swan
# paper sluice I'm not sure I understand.

So you said to intent or whatever the word is the rest of the lines but the rest of my lines are its just in that area im having the problem but Im confused on how to fix the error ik what to do i just dont know how to do it

#

if that made a bit more sense

keen viper
#

hi

slate swan
#

idk if that made sense to you

slate swan
keen viper
#

Hello

#

How are you.

primal token
slate swan
paper sluice
#

!e

if True:  # stuff under that will always execute
    print('Hi!')
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your 3.11 eval job has completed with return code 0.

Hi!
keen viper
#

Im fine!

meager chasm
primal token
slate swan
meager chasm
#

I remember yesterday some helper was helping them and they asked "is this javascript" 😆 that poor helper

winged coral
#

because it's not an argument in the function

paper sluice
slate swan
keen viper
#

!e

unkempt canyonBOT
#
Missing required argument

code

#
Nah.

No documentation found for the requested symbol.

paper sluice
#

bruh, why did i paste tf

keen viper
#

haha

primal token
paper sluice
#

!d discord.Member.activities

unkempt canyonBOT
#

The activities that the user is currently doing.

Note

Due to a Discord API limitation, a user’s Spotify activity may not appear if they are listening to a song with a title longer than 128 characters. See GH-1738 for more information.

meager chasm
paper sluice
primal token
slate swan
meager chasm
winged coral
paper sluice
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your 3.11 eval job has completed with return code 0.

10
primal token
meager chasm
#

This server staff bother writing essays to trolls it's so funny 🤣

keen viper
#

Bruh

slate swan
#

ye

keen viper
#

btw

slate swan
#

i use daki to host

keen viper
#

i dont code like games

#

i like to make minecraft asian european servers

slate swan
keen viper
#

yeah]

meager chasm
#

Noo you should not give up!!

paper sluice
primal token
keen viper
#

a 12 year old kiddo learns how to code ol

meager chasm
#

You are my source of entertainment

#

Please don't leave 😔

paper sluice
#

you must be a very sad individual, lol

slate swan
#

if i send u the code can u spoonfeed me for like 1 time

keen viper
#

invalid peyton

meager chasm
keen viper
#

do you know how to make like plugins

meager chasm
#

Since you're clearly in love with them... Defending them so much

primal token
keen viper
#

for servers.

paper sluice
sick birch
#

Is there a problem here?

slate swan
paper sluice
slate swan
#

for u to spoon feed me

meager chasm
#

Ayoo yessss

paper sluice
primal token
meager chasm
keen viper
#

like im trying to make a european asian discord server and minecraft server like with alot of gamemodes uk uk.

slate swan
paper sluice
#

what is going on pithink

meager chasm
#

I'll spoonfeed one command for every quarter gallon

sick birch
sick birch
#

Could we get back on topic though

meager chasm
#

This will be fun

keen viper
#

Pour*

meager chasm
#

Yes autocorrect 😊

paper sluice
unkempt canyonBOT
keen viper
#

when you correct a guy

meager chasm
slate swan
keen viper
#

Grammerly*

#

lol

slate swan
sick birch
keen viper
#

fu-

#

nvm

slate swan
keen viper
#

cross do you know a host to host minecraft servers?/

slate swan
#

i know how to host p- site- nvm

sick birch
#

I used to host Minecraft servers, got bored after a while though

meager chasm
keen viper
#

what is the site

#

like 50 is average

#

for a 5 gamemode server

meager chasm
#

50 players is quite a lot

sick birch
#

!ot off topic for this channel

unkempt canyonBOT
keen viper
#

yeah

meager chasm
#

If you're planning on a free hosting site I mean

#

Good hardware requires $ unfortunately

keen viper
#

yup

sick birch
#

@meager chasm @keen viper please move this convo to one of the OTs, thanks

#

Use the async for syntax

#

I don’t believe you can flatten it

keen viper
#

come general endysis like give me a site to host a server

sick birch
#

Again it’s off topic

meager chasm
#

Where did the noid guy go he was smart af he prolly knows a million of them

primal token
#

I'm currently eating a meal while watching the chat, may i stay lurking or do you need something from me? If not please dont refer to me in the conversation.

meager chasm
#

Yes we need you and your massive brain rn

#

@keen viper ask noid your question

primal token
sick birch
#

async iterator syntax?

#

async for

#

Typing code on phone is hard so excuse me here:
async for ban in guild.bans():

slate swan
#

pepe_cry Anyone know how to fix?

little wolf
#

why do i keep on getting this

primal token
little wolf
#

make a bot i put the url in and i keep on getting that

#

I only checked bot

primal token
little wolf
slate swan
#

Na, that's it

little wolf
#

no

slate swan
#

Yuh, its repl so it installs it all for you

#

Hahaha, i know i was just testing something i was using vsc but i wanted to see if it works in repl thats it 😂

little wolf
#

do you know whats wrong?

slate swan
#

Nah tbh idk whats wrong with it

primal token
#

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

primal token
#

this can help your issue ^

slate swan
vague zephyr
#

hey i got a question

#

so i want the bot to react with 👋 to anyone that says hi hello etc

#

i made a tuple and used the if content in greets:

#

but it only works when the message is EXACTLY the words

#

and if i use it with __contains__() it doesn't work

slate swan
#

Is this correct?

async def test(ctx):
    await ctx.send("test!")

The bot is just not sending the test message back

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

mint cipher
#

Hi. My bot has a command .custom. When this command is run, it makes an embed with a few fields. It then adds 10 emojis to it. I want it so that on reaction, the bot edits the embed (the specific field correlated to the emoji with the reaction users name). I then want it to remove the reacted emoji. Any tips on how to go about this? Thanks in advance.

slate swan
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.10)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.10)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
slate swan
#

wait for add_reaction, and edit the message when that emoji is clicked

toxic thicket
#

How to get the mentioned participant in interaction?

mint cipher
vague zephyr
#

but i can't use it with tuples or lists

sick birch
#

you could probably split the user input into words and use set intersection

vague zephyr
#

ok i'll try that

slate swan
#

ignore the download png above

sick birch
sick birch
#

You have avatar.url

#

You need avatar_url

slate swan
#

u right nvm

#

is it possible to bypass 5 edits every 5 seconds

#

sfffff

#

fffffffffff

#

Hey, does anyone know if i can run 2 seperate wait_for()'s? I want my bot to send out a message to some users dms, that would then wait for a reaction to the message, but wouldnt the wait_for not send the 2nd user a message until the first one either completed or timed out?

sick birch
sick birch
slate swan
slate swan
#

Is there a library for slash commands?

sick birch
slate swan
#

could you link me a documentation?

slate swan
#

thanks.

mint cipher
sick birch
slate swan
#

Hey!
When using chat exporter i get this error: https://hastebin.com/zeqecidela.sql

Here is my Code:

@bot.slash_command(description="Saves a Full Ticket Transcript")
async def savetran(ctx):
    if not Staff(ctx):
        return await ctx.respond(
            error=discord.Embed(title="Insufficient perms", description="Unfortunatly, You do not have the Required Permissions to Run This Command", color=0xb626dc), ephemeral=True
        )
    else:
        loading=discord.Embed(color=0xe700ff)
        loading.set_author(name="Loading Chat, Users, Messages, and Time!", icon_url=footericonurl)
        msg = await ctx.send(embed=loading)
        transcript = await chat_exporter.export(ctx.channel)

        if transcript is None:
            return

        transcript_file = discord.File(io.BytesIO(transcript.encode()), filename=f"transcript-{ctx.channel.name}.html")
        await ctx.respond(file=transcript_file)
        await msg.delete()
sick birch
slate swan
sick birch
#

A wait_for will finish the first time anyone reacts to the message, and you can get details of the person who reacted to it as well

#

Seems like this is what you want

slate swan
#

Oooooh i think i get it, so lets say im waiting for 2 seperate reacts, i can have 1 wait for, then save the user that reacted, and have another wait for that checks that if the 2nd reaction isnt the 1st person just unreacting and rereacting?

sick birch
#

And instead waiting for the first user

slate swan
slate swan
#

Oki thankies, ill give it an attempt when i get home

sick birch
sick birch
#

You attach a callback to these buttons so your bot can do whatever you want when a user clicks one of these

slate swan
#

Interesting, got like a link to an example of some code for it o:?

slate swan
#

Okidoki ill check it out ^^

sly hamlet
#

I seem to be having some trouble starting my bot. It says that my cog.fun has already been started while it is true it has been started. It shouldn't be trying to start it again. Any ideas?

#
async def main():
    await bot.load_extension('cogs.botut')
    await bot.load_extension('cogs.fun')
    await bot.load_extension('cogs.nsfw')
    await bot.load_extension('cogs.helpmenu')
    await bot.load_extension('cogs.admin')
    await bot.load_extension('cogs.ut')
    await bot.load_extension('cogs.mute')
    await bot.load_extension('cogs.testmusic')
    asyncio.create_task(sync_commands(bot))
    async with bot:
        await bot.start("")
slate swan
#

@sick birch this is an emergency

sick birch
#

What's up?

slate swan
#
self.tree.copy_global_to(guild = discord.Object(id = 994773768482336828))
        
        await self.tree.sync(guild = discord.Object(id = 994773768482336828))
#

How do i sync it to multiple guilds?

primal token
sick birch
#

You want to make a global command then

#

Remove the copy global to line and don't pass in an ID into the sync function

slate swan
#

Ok

#

so just await self.tree.sync()?

slate swan
sick birch
#

No you need to sync

#

just don't pass in any args there

slate swan
#

ok

autumn vale
#

hi :>

#

can i ask ?

mossy jacinth
#

Hello! I just found out you can make </this:0> with </text:0> is there any way to make it do something tho?

primal token
mossy jacinth
rare jewel
#

how do i make my bot be able to be self-hosted by other users?

rare echo
rare jewel
sick birch
#

but you can also have users download python and your requirements and run it

kind trellis
#

How do I disable a command in 1.7.3?

austere vale
#

does anyone know how to fix this error? ive already used pip install aiosqlite but...

wanton fractal
shrewd apex
#

is it possible to execute sql queries from .sql file using asyncpg

wanton fractal
shrewd apex
#

apparently the execute dosent work

paper sluice
#

does asyncpg have executemany?

#

if so, you can probably use that and do connection.executemany(file.read())

dull terrace
#

still working on this update for my bot, up to 5142 lines of code pepe_cry

maiden fable
#

Imagine deleting message

placid skiff
#

nvm didn't read asyncpg lmao

maiden fable
#

I didn't even completely read it ;-;

placid skiff
robust fulcrum
#

Whats asyncpg?

shrewd apex
shrewd apex
robust fulcrum
#

Ok

pulsar solstice
#

is it possible to make (timeout) command in dsicord.py?

shrewd apex
placid skiff
maiden fable
#

Lmaoo

quick brook
slate swan
#

"on_message.<locals>.check() takes 1 positional argument but 2 were given" What does this mean?

pulsar solstice
#

Btw I am not taking about the classic mute command

naive briar
unkempt canyonBOT
#

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

Applies a time out to a member until the specified date time or for the given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").

You must have the [`moderate_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") permission to use this.

This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.edit "discord.Member.edit").
naive briar
#

Basically, it's just a command that takes member, time, and maybe also reason as arguments, then timeouts the target member with the given time(in seconds in the example)

from datetime import timedelta
...
async def timeout_member(
    ctx, member: discord.Member, time: int, *, reason: str
):
    timeout_for = timedelta(seconds=time)
    await member.timeout(timeout_for, reason=reason)

You can also make your own time converter if you want

robust fulcrum
#

Can anyone here help me make a snake game in discord.py?
Any idea how can I make?

slate swan
#
while temploop:
  def check(reaction, user):
    return reaction.message.id == usermessage.id and reaction.emoji == emoji and user.bot == False

    await client.wait_for('reaction_add', check=check)
    print("Done")
    usersreacted+=1
    if usersreacted == tempnum:
      temploop == False
    else:
       continue
``` would this work?
naive briar
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.10)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.10)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
slate swan
#

erm, whats the issue with it if i may?

#

Hello hi beginner here
I'm currently learning how to create a bot and Python at the same time-ish and I wanted to write a command per the tutorial where it gives you a random quote back, but when I put the .99 call in, the bot does not reply, nor does it give me an error.
What could it be?

@bot.command(name="99")
async def nine_nine(ctx):
    brooklyn_99_quotes = [
        "I'm the human form of the 💯 emoji.", "Bingpot!", (
            'Cool. Cool cool cool cool cool cool cool, '
            'no doubt no doubt no doubt no doubt.'
        ),
    ]

    response = random.choice(brooklyn_99_quotes)
    await ctx.send(response)```
naive briar
#

You can have a look at their example

dull terrace
slate swan
#

Anyone sees anything wrong? ```py
await commands.ColourConverter.convert(ctx, color)

slate swan
dull terrace
slate swan
#
intents = discord.Intents.all()
client = discord.Client(intents=intents)
bot = commands.Bot(command_prefix=".", intents=intents)```
this I assume?
maiden fable
dull terrace
maiden fable
#

What update?

slate swan
#

since I'm still in the learning phase I kinda mess things up so... PES_CringeGrin

dull terrace
#

Content being privileged and enforced

slate swan
dull terrace
#

I see nothing obvious in your code that should stop it working so

#

What's with the tuple in your quote list?

naive briar
slate swan
#

it's to group cool cool cool and no doubt no doubt no doubt together, I presume. (It's what the tutorial had it as)

dull terrace
#

Are you trying to send them together but on separate lines?

slate swan
dull terrace
#
"this is\ntwo lines"```
=
this is
two lines
slate swan
#

it worked fine when I had it as client.event but now I'm trying to make it an actual command

slate swan
paper sluice
naive briar
dull terrace
#

I don't get what that accomplished though hold on

#

!e

print(
    (
        'test'
        'second quote'
    )
)```
unkempt canyonBOT
#

@dull terrace :white_check_mark: Your 3.11 eval job has completed with return code 0.

testsecond quote
slate swan
#

I fixed it. ._.

dull terrace
#

I- why would they do it like that than using one line

#

sorry, it just confused me lol

#

Yeah the problem isn't in the code you showed there I think

robust fulcrum
#

Pls anyone help me!!!!!!
How can I make snake game in dpy?

dull terrace
#

Disabling messages for me disabled on_message() recieving anything while message content is just the message content in other people's messages, about all i know about it

slate swan
#

but anyway this is how it looks

#

also the issue is that at the end I had
client.run(TOKEN) instead of bot.run(TOKEN)

#

big brain random fix (i got lucky)

paper sluice
tidal hawk
#

How do I set a message on Webhook? Returns error - {'message': 'Cannot send an empty message', 'code': 50006}

headers = {"Content-Type": 'application/x-www-form-urlencoded', "content": "test"}
response = requests.post(f"https://discord.com/api/webhooks/{wh_id}/{wh_token}", headers=headers).json()```
naive briar
tidal hawk
#

Oh thanks!
Btw Put returns an error - "Method not allowed" so it still a post method

naive briar
#

Mb 🫠

slate swan
#
data2[str(guild.id)]['users'] = {}
            for user in Sleeper.get_all_members():
                if str(user.id) not in data2[str(guild.id)]:
                    data2[str(user.id)] = {}
                    data2[str(user.id)]['open_tickets'] = 0```
how would i put the user.id database inside of 'users'
naive briar
slate swan
#

ohhh lairghty

#

thank you very much

#

hey guys so i made a command that checks if someone has a role and if they do the command will work. however i cannot use else since what it does is checks for every role and if there is a role with the id i put in then it will send the command, so if i want to make it say something else it would say that for every OTHER role that that user has

#

How could i make it say something different if the user has no role with that id

ashen perch
slate swan
#

ok but it has weird ass names

#

variable names

unkempt canyonBOT
#

Hey @slate swan!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

ashen perch
#

ill try and look at it but cant rn

slate swan
#

i think i found how to fix itr

#

What does this mean?```py
/home/container/bot.py:27: DeprecationWarning: There is no current event loop
bot.loop = asyncio.get_event_loop()

vocal snow
#

there's no event loop running

#

get_event_loop was deprecated in python 3.10

slate swan
naive briar
slate swan
#

Could someoen help me

When I change my bot prefix to / the bot prefix dont work?! but theres no errors

vocal snow
#

Code please

slate swan
vocal snow
#

Full code please

slate swan
#

no

vocal snow
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

slate swan
#

I dont paste 🤣

vocal snow
#

If you can't send your full code I won't be able to help, consider you can't provide a traceback either

vocal snow
#

So you're doing /mines {round_id} and it isn't responding?

slate swan
#

ye

vocal snow
slate swan
#

it does work w over prefixes

vocal snow
#

Do you have an on_message event?

slate swan
#

u dont ened thta

#

for a / command

vocal snow
#

Slash commands are different from message commands with a "/" prefix

#

If you're trying to make slash commands, the process is different

slate swan
#

k so what do id o

vocal snow
slate swan
#

tht has nothing to do awith a / cmd

vocal snow
#

It's an example of creating a slash command

#

You can also check out Ashley's gist (2nd pinned message) if the GitHub example is too verbose

slate swan
#

no its not

#

🤣

vocal snow
#

😆

slate swan
#

stop being aretard

#

wtf is wrong with you @slate swan

#

he is trying to help you

vocal snow
#

Don't worry about it :)

rugged shadow
hollow badger
placid skiff
dull knot
#

Is it a good idea to first learn File writing and creating some Cmds utilizing Read/Writing files to Json format if I would want to eventually learn how to use databases such as MongoDB?

Cuz someone told me to first get myself comfortable with Python Basics (Variables, Iterables, Conditionals, etc) as well as Asynchronous programming before delving further. But It feels that I really need to learn File Writing/Reading else It feels like I won't ever learn lol.

Do u guys think it's a good idea? Or should I stick to just the former?

rugged shadow
#

but don't use json as a db in discord bots

#

use mongodb

slate swan
#

i got pinged, who pinged me?

#

how do i get my .repl.co link?

ashen perch
faint sapphire
#

yo
with their id, its not possible to get the username and tag of a person that isnt in your server?

meager chasm
meager chasm
#

!d discord.Client.fetch_user

unkempt canyonBOT
#

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

Retrieves a [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.

Note

This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.get_user "discord.Client.get_user") instead.

Changed in version 2.0: `user_id` parameter is now positional-only.
faint sapphire
#

i have to use client instead?

meager chasm
#

commands.Bot is subclass of Client, so you can use either

slate swan
#

how do i get my .repl.co link?

faint sapphire
#

use heroku

meager chasm
slate swan
meager chasm
#

i mean free plan

#

or tier whatever u call it

faint sapphire
#

theyll prob have something for students

#

they said somethings coming

slate swan
#

just use digital ocean huh

#

so how do i get my .repl.co link

#

its nowhere

slate swan
#

whichone?

#

webserver url?

#

yeah

#

that

#

it'll appear on the right side when you run your bot

#

well it doesnt

#

what is on your screen currently

#

and are you starting the server

#

well on the left site is the cone, right bottom is output and right top is the website im scraping

#

code*

slate swan
#

you asked for whats on my screen

faint sapphire
#

am i doing something wrong?

meager chasm
naive briar
faint sapphire
#

oh i thought once in front of it was enough

#

ok thanks

#

wow awesome thanks

slate swan
slate swan
slate swan
#

are

#

you starting the webserver?

#

from the main file?

faint sapphire
#

this int really a problem
im just wondering if its unrecommended

i dont want to use prefixes, but the output is always gonna be flooded

slate swan
slate swan
faint sapphire
#

so i put all the commands in a try except thing?

faint sapphire
# slate swan idk

literally just show a screenshot of your screen
or watch a tutorial

slate swan
#

tutorials are shit

slate swan
meager chasm
#

win ROBUX thinkmon

slate swan
#

!d discord.ext.commands.Bot.on_command_error

unkempt canyonBOT
#

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

The default command error handler provided by the bot.

By default this logs to the library logger, however it could be overridden to have a different implementation.

This only fires if you do not specify any listeners for command error.

Changed in version 2.0: `context` and `exception` parameters are now positional-only. Instead of writing to `sys.stderr` this now uses the library logger.
slate swan
faint sapphire
#

thank you

dull knot
slate swan
# faint sapphire thank you
@bot.listen("on_command_error")
async def error_handler(ctx: commands.Context, exc: commands.CommandError) -> None:
  if isinstance(exc, commands.CommandNotFound):
    pass

is an example

#

@slate swan

dull knot
slate swan
slate swan
#

replit changed their UI

dull knot
faint sapphire
slate swan
#

you're tryna scrape

#

the url is behind it

slate swan
#

how do i tab out

slate swan
#

caps

#

ohh

dull knot
faint sapphire
#

why not use aiosqlite

slate swan
#

whats the next step

dull knot
slate swan
#
import sqlite3

conn = sqlite.connect("db_name.db")

''' aiosqlite '''

import aiosqlite

async def main() -> aiosqlite.Connection:
  return await aiosqlite.connect("db_name.db")

that's the difference really

slate swan
#

the url will appear on the black part

#

it was already running

#

should appear

#

hm

#

can I see an ss?

#

of your replit window

#

now it appeared but i got rate limited 💀

#

also what ip is that

faint sapphire
#

good thing u didnt blur the output

slate swan
slate swan
#

what what, it's returning an IP address in the webserver url or what?

#

no

#

how long does being rate limited last

slate swan
#

i did

#

but limits generally last as long as they need to

#

it said reconnecting and now its still giving the error

#

sad

#

it got ratelimited again then

#

how 💀

#

replit.

#

simply don't use replit

#

you won't get ratelimited until you reach a valid point

slate swan
slate swan
#

i dont have a vps tho

#

well then

dull knot
#

New question:

    """Roll Dice"""
    @commands.slash_command(name="dice-roll", description="Rolls the dice from 1 to 6")
    async def Dice_Roll(self, inter, die=7):
        Default_Dice = list(range(1, 7))
        Custom_Dice = list(range(1, die))
        Roll_Embed = disnake.Embed(title=f"", 
                                   description=f":DiceRoll: Dice is rolling...",
                                   color=disnake.Colour.random())
        Default_Dice_Embed = disnake.Embed(title=f"",
                                   description=f":DiceRoll: Dice rolled {random.choice(Default_Dice)}",
                                   color=disnake.Colour.random())

        Default_Dice_Embed.set_footer(text="Set a limit for the dice by providing an argument.")

        Custom_Dice_Embed = disnake.Embed(title=f"",
                                   description=f":DiceRoll: Dice rolled {random.choice(Custom_Dice)}",
                                   color=disnake.Colour.random())

        Custom_Dice_Embed.set_footer(text="Set a limit for the dice by providing an argument.")
        await inter.response.defer()
        
        if die is None:
            await inter.send(embed=Roll_Embed)
            await asyncio.sleep(3)

            await inter.edit_original_message(embed=Default_Dice_Embed)

        else:
            await inter.send(embed=Roll_Embed)
            await asyncio.sleep(3)

            await inter.edit_original_message(embed=Custom_Dice_Embed)

Here's the error I got:

    raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'str' object cannot be interpreted as an integer

I assume I got this error because I used a string as a parameter? And that the argument would be an int? How do I fix this?

slate swan
#

!paste and show the whole traceback in the link

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.

dull knot
#

Wait Lemme

#

Do that.

#
Ignoring exception in slash command 'dice-roll':
Traceback (most recent call last):
  File "C:\Users\Alliah\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\disnake\ext\commands\slash_core.py", line 681, in invoke
    await call_param_func(self.callback, inter, self.cog, **kwargs)
  File "C:\Users\Alliah\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\disnake\ext\commands\params.py", line 827, 
in call_param_func
    return await maybe_coroutine(safe_call, function, **kwargs)
  File "C:\Users\Alliah\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\disnake\utils.py", line 580, in maybe_coroutine
    return await value
  File "c:\Users\Alliah\Desktop\VS Code\Neko-Nyan\Cogs\Fun.py", line 536, in Dice_Roll
    Custom_Dice = list(range(1, die))
TypeError: 'str' object cannot be interpreted as an integer

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

Traceback (most recent call last):
  File "C:\Users\Alliah\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\disnake\ext\commands\interaction_bot_base.py", line 1262, in process_application_commands
    await app_command.invoke(interaction)
  File "C:\Users\Alliah\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\disnake\ext\commands\slash_core.py", line 690, in invoke
    raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'str' object cannot be interpreted as an integer

Full Error ^^^^

#

It sends fine if I don't provide an argument though. Since by default, the list of range would just be from 1-7

If the Parameter is not empty, it would send the code in the else statement.

#

And the parameter inside the variable Custom__Dice_Embed is a string, rather than an int

meager chasm
slate swan
#

nice

dull knot
slate swan
#

it's just a typehint

dull knot
#

Ahh, wait. Yeahh lol. Lemme try that 😆

slate swan
#

unless you're using typing.Optional as a typehint, the args will never become optional unless you assign them a value whereas you're assigning a default value 7

shrewd apex
dull knot
#

Yeah, it works lol. Well, I guess it won't matter much since it's a slash cmd lol. Thanks guys!

shrewd apex
slate swan
#

slash commands are so uwu

shrewd apex
shrewd apex
#

kek ide linter enough

robust fulcrum
#

Guys how can I make a snake game in dpy?
Can anyone help me
I am not able to understand how can I start making

slate swan
#

you can't

robust fulcrum
#

Ok

meager chasm
#

u can but it will be very shit

slate swan
#

^

#

I don't even see a possible way ngl

robust fulcrum
#

Ok

slate swan
#

and the snake would never be eleminated

#

plus the ratelimits

robust fulcrum
#

I want to make a game but idk what to make (i am having dumb game ideas)

meager chasm
#

just make game with pygame, why ur using discord bot 😓

slate swan
#

^

robust fulcrum
meager chasm
#

but if you want game in discord maybe make typeracer or roleplay game

robust fulcrum
#

Roleplay doesn't make sense?

meager chasm
#

like

#

do u know IdleRPG

robust fulcrum
#

RPGs are boring

#

I bored idk what to do

meager chasm
#

have u tried web framework

#

or databases

robust fulcrum
#

I tried but not like it

meager chasm
#

try flask

robust fulcrum
#

I feel js is good for web frameworks

meager chasm
#

js is awesome ye

robust fulcrum
#

I am currently making my personal website using next js

slate swan
#

django isn't bad either

#

but javascript ftw

meager chasm
#

django is great but it will be overkill for simple website

#

and flask is so sexy with its decorators

#

django big fat ugly have to create so many folder and shit

robust fulcrum
#

flask good for apis ig?

meager chasm
#

fastapi for api

slate swan
robust fulcrum
#

Next js also many folders

meager chasm
#

flask u can just make few decorator in single py file and ur done

slate swan
meager chasm
#

what if not smart 😔

robust fulcrum
#

But js have good frameworks like next js

slate swan
#

skill issue

#

very informative

robust fulcrum
#

Anyway we should not discuss it here

slate swan
#

informative too

meager chasm
faint sapphire
#

when using sqlite3
when all u do is selecting and fetching, theres no need to do db.commit() right

#

also theres no need to sanitise the database right, cause they cant do sql injections cause its all strings the arguments

robust fulcrum
meager chasm
unkempt canyonBOT
#

SQL & f-strings
Don't use f-strings (f"") or other forms of "string interpolation" (%, +, .format) to inject data into a SQL query. It is an endless source of bugs and syntax errors. Additionally, in user-facing applications, it presents a major security risk via SQL injection.

Your database library should support "query parameters". A query parameter is a placeholder that you put in the SQL query. When the query is executed, you provide data to the database library, and the library inserts the data into the query for you, safely.

For example, the sqlite3 package supports using ? as a placeholder:

query = "SELECT * FROM stocks WHERE symbol = ?;"
params = ("RHAT",)
db.execute(query, params)

Note: Different database libraries support different placeholder styles, e.g. %s and $1. Consult your library's documentation for details.

See Also
Extended Example with SQLite (search for "Instead, use the DB-API's parameter substitution")
PEP-249 - A specification of how database libraries in Python should work

meager chasm
#

u shuld use placeholder always

faint sapphire
#

i do those, so ig everything is fine

meager chasm
#

otherwise fine

faint sapphire
#

i do

robust fulcrum
#

@meager chasm are you good at website designing?

meager chasm
#

no my artist skill are shit

#

one time i make website for mother and she told me to delete or she would slap me with slipper

paper sluice
#

epic mother moment

faint sapphire
#

with a random server id
is it possible to get the server's name?

vocal snow
#

No

faint sapphire
#

rip

#

its easier for discord to find the name of a server with the id
than the name of a user with the id
but ig it seems too useless to add

faint sapphire
#

cause there are more users than servers

#

so its more work to find the username for a given id
than a server name for a giver id

naive briar
#

Just pass the fp in the File constructor

file = discord.File(fp, "bilboard.png")

You don't need to use seek(0) here

vocal snow
#

you should seek before passing it

#

ig the file pointer would be at the end after creating the BytesIO

naive briar
#

He's just passing data in BytesIO, not by writing it using .write. So I don't think you have to use it

vocal snow
#

true

naive briar
slate swan
#

the spellings of billboard are different in discord.File() and in embed.set_image there's a missing or excessive L

paper sluice
#

fix the spelling mistake

lyric patio
#

any idea why im still getting this error on VS code terminal? ive added python to my paths and the pip.exe is located in the Python\Scripts

#

nevermind, i just did
py -m pip install discord
i think that fixed it

lyric patio
honest shoal
lyric patio
#

oh lmao

errant coral
#

Can I somehow connect so a when the person presses the button it registers and when I do command it shows what button he clicked on? Im trying to not use database.

honest shoal
errant coral
honest shoal
errant coral
honest shoal
open narwhal
#

are there example codes for menu and button usages?

honest shoal
slate swan
errant coral
open narwhal
#

awesome tyvm

honest shoal
#

just 2-3 messages and enough

slate swan
#

wrong server?

errant coral
#

nah im trying to use the python bot for docks

naive briar
#

It looks like the file isn't a png file

errant coral
#

hmm

honest shoal
#

what are you searching for

errant coral
honest shoal
slate swan
#

!d discord.ui.Button.callback gets triggered when the button is clicked

unkempt canyonBOT
#

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

The callback associated with this UI item.

This can be overridden by subclasses.
honest shoal
#

and a channel

slate swan
#

make your button class and and overrided the callback method, do you operations inside it.

errant coral
#

ok

faint sapphire
#

yo, i cant figure out how to pass kwargs to a command through discord messages

limber bison
#

I need help , i am making a multi guild bot , so i need to store prefix for different servers , so where should I store ? In a json file or create a database like MySQL , i confuse because I think json will be faster then DB , is this fact ?

limber bison
#

Is MySQL slow then sqllite ?

#

Or any other reason

sick birch
#

Json is not a database, don’t use it as such

limber bison
#

Right ?

sick birch
faint sapphire
# slate swan !d discord.ui.Button.callback gets triggered when the button is clicked

is this what i have to use if i want to do something like the following:
two ppl, X, Y use the help from person Z
to know externally everything went well, the bot sends a message requiring both X and Y to react
then the bot can store that information

idk if with reaction roles it works cause idk if a bot can read who reacted to a message

sick birch
#

Make sure you implement some sort of caching because get_prefix is called every message

slate swan
#

yes a bot can read who reacted

limber bison
faint sapphire
#

nice

#

is it possible to pass kwargs through messages?

quaint epoch
#

Although there is probably a better solution

hushed galleon
faint sapphire
#

thanks, i saved this
i find it complex for what it is, so for the moment ill go with splitting the *, args based on stuff like Server_ID=

updatemms
Server_ID=
Server_Name=
Server_Nickname=
Owner_ID=
Invite_Link=
Status=

slate swan
#

just make them provide a json like structure and use json.loads at this point

#
users_argument = "{"Server_ID": 1234, "Server_Name": "coolnameuwu"}"

to_json = json.loads(users_argument)
#

i messed up with the quotes but ukwim

faint sapphire
#

when ppl input a random server id
i wanna make sure its the id for a server and not a message or person
bc it isnt server the bot is in, id like to use the output of an error like you arent in that guild

try:
        guild = await bot.fetch_guild(id)
    except Forbidden:
        await ctx.send("I do not have access to that guild or it doesn't exist.")
    else:
        await ctx.send(guild.name)

but i think id get the same thing if the id isnt the id for a server

#

so im just wondering, theres no solution for this yh?

slate swan
#

check the docs*

wispy spade
slate swan
#

Uptimerobot doesn't work

#

On the website it says it's working

#

The link says "I'm alive"

#

But the bot is offline

#

Anyone know why

honest shoal
slate swan
#

?

#

What does that mean

honest shoal
#

icon shows online, but it is under offline members

slate swan
#

My bot shows it's offline

#

No online icon

honest shoal
#

who

#

Uptimerobot?

#

• Ask your question, not if you can ask or if there's an expert who can help.
• Show a code sample as text (rather than a screenshot) and the error message, if you got one.
• Explain what you expect to happen and what actually happens.

#

!pastebin

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.

slate swan
#

Did it work and all of a sudden it stopped working?

honest shoal
#

2nd point

#

that image is really hard to read

#

ok ssl

slate swan
#

I figured out why my bot wasn't working

#

It got rate limited for no reason

onyx ravine
#

ModuleNotFoundError: No module named 'discord_components' how to solve this?

honest shoal
#

@slate swan

honest shoal
#

you no longer need it, dpy is upto date now

wispy spade
#

or if you have some time to spare, you can just rewrite it with dpy 2.0 since it already includes components

honest shoal
untold iron
#

Hey there this might be simple but how can i have variations of the word hello inputted for it to then return Hello! from the bot?

#

I have tried using or but didnt return the "HELLO" just the "hello"

primal token
primal token
#

!e

print(1 or 2)
unkempt canyonBOT
#

@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.

1
untold iron
#

oh, so it doesnt know which one to use so it will always default to the first one?

#

!e print("hello" or "HELLO")

unkempt canyonBOT
#

@untold iron :white_check_mark: Your 3.11 eval job has completed with return code 0.

hello
untold iron
#

!e print("HELLO" or "hello")

unkempt canyonBOT
#

@untold iron :white_check_mark: Your 3.11 eval job has completed with return code 0.

HELLO
untold iron
#

ooo okay got it

#

How can i get the event to check weather the input is HELLO or hello or any other word

faint sapphire
#

yo, im tryna test if a user exist for a given id
if the id is wrong, the fetch_user never yields
idk if theres a timeout parameter, or if i add a coroutine to make one```py
@bot.command()
async def hi(ctx):
resp = await bot.fetch_user(967398843903791114)
await ctx.reply(f"{resp!=None}")

slate swan
#

if message.gsvd("hello") or if message.useyourbrain("hi")@untold iron

#

sorry for the cracked explanation it's 12am here and i can only help like this

honest shoal
#

using .lower()

slate swan
#

if message.content.startswith("Hello") or if message.content.startswith("Hi")

#

@untold iron

untold iron
#

Ty but i dont think u can do or if after a colon

slate swan
#

please keep them in line

honest shoal
untold iron
#

nice i got it

slate swan
#

he only wants input for these two that's his problem if someone types a message out of given choice

untold iron
#

I learnt something new thank u

slate swan
honest shoal
#

hmmmm

untold iron
#

Okay understood, so Or is only used to link two things together based on a condition

slate swan
#

yea sorta

slate swan
#

yeah multiple