#discord-bots
1 messages · Page 85 of 1
Np :3
Because even when it creates it, it still says 'did not respond'
oh i completly didnt see that lol
but i assume thats because i didnt respond with the interaction
👀
You could, also why can only 1 person create a game at a time? Rate limit I guess lol
the command worked before and i added perms thing and then it f up so im redoing it lol
Yup
no I have not.
Poker?
Nope
my bots activity presence wont change
You ever seen the beta Discord activities?
;O
Pretty awesome.
I've made a custom command to generate invite urls.
Only bots can generate it.
..
😮 you are so smart, and handsome too.
What are you doing?
i cant change the discord presence of my bot
and i need help
What have you tried so far?
async def on_ready():
status = 'maintenance underway'
await client.change_presence(status=discord.Status.idle, activity=status)```
I thought those were headphones for a second lol
I am so proud of myself, this is my first python project that I have ever completed.
It is that's my face.
It does turn on?
oh, great!
yes indeed
Ah I see the issue the activity isn't properly formatted.
can you help with that
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...
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...
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.
still not showing
Are you using discord.py?
yes
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'
Could you provide anything more that might help me?
event is without () so @Host.event
Ah im so stupid
not really i mean i can share screen if you want to see?
And I recommend changing the presence in the setup hook.
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")...
Hmm okay, did you restart the bot?
The example I send also didn't work?
nope didnt work
i fixed it
What was it?
aha i had 2 async def on_ready i beleive
# 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
what data are you trying to get
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!
how are you sending it
embed.set_thumbnail(url = 'attachment://image.png')
Look up the docs on attachments
embed = discord.Embed(
color = discord.Color.blurple(),
title = 'Information',
embed.set_thumbnail(
url = 'attachment://image.png'
)
well, this is not correct...
soooo whats the problem?
you didn't close the function call for discord.Embed
I asked how you're sending the embed
I removed some code on my end. Sorry bout that ig
Yeah this isn't really appropriate please follow this servers CoC rule 3
await interaction.response.send_message(embed=embed, ephemeral=True)
What is CoC? Clash of Clans? :p
you need to attach the file
code of conduct
Code of Conduct
Okay.
??
You wouldn't be the first one lol
We need your code to know.
you're creating a discord.File, you need to attach it with the file kwarg
!d discord.InteractionResponse.send_message
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.
file kwarg here
<3
lmao
@vocal snow Thanks for your help! The b*tch finally works
Where do you define guild?
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
pillow < create html => 2 image
!d discord.on_voice_state_update
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...
to detect when someone joins a vc
@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?
please don't send 1 line screen shots, send the full code with !paste
Ah I see, add ur guild variable at the top of ur previous code
'Interaction' object has no attribute 'display_avatar'
interation.user.display_avatar
alr
@slate swan What you are doing is this:
interation 😶
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)
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.
how do i do it then 😭
@thorn seal
RuntimeWarning: coroutine 'InteractionResponse.send_message' was never awaited
interation.response.send_message(embed=em)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
read the error, it's telling you to await send_message
how do i get it to show instead of as a link?
im asking where you're defining total_text_channels
you should use embed.set_image
!d discord.Embed.set_image
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
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
em = discord.Embed(title='Avatar', discord.Embed.set_image(interation.user.display_avatar))
^
SyntaxError: positional argument follows keyword argument
what the heck is this lol
error message 😭
this is generally why we recommend learning python before trying out discord.py
anyways; ```py
em = discord.Embed(...)
em.set_image(...)
and url is a keyword-only param
🤔 Command 'avatar' raised an exception: TypeError: Embed.set_image() takes 1 positional argument but 2 were given
I believe it's just channel
!d discord.VoiceState
code?
@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)```
@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.**")```
please read my message above, url is a keyword-only parameter
in simpler words
!d discord.VoiceState.channel
The voice channel that the user is currently connected to. None if the user is not currently in a voice channel.
just channel, not voice_channel
url=...
ok
!pos-keyword
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)
got it
@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
do you have member intents enabled?
intents=discord.Intents.all
also; before.guild.channels not before.server.channels
discord.Intents.all(); don't forget to call it
well it doesn't
you would use ctx.guild.channels
and call len() on that
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.**")```
@zenith wagon btw
!d discord.Guild.channels
property channels```
A list of channels that belongs to this guild.
it gives you all channels
Can you please korriegenren can hardly english the difficult for me
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
Wait, nvm. they got their support server lol. But if you guys got any resources or references, I'd appreciate that.
How to get the mentioned member in interaction?
len(ctx.guild.channels)
``` why is this hard
you'd want to use aiohttp or httpx to make the http request asynchronously
it'll probably respond with the image bytes, which you can then send as a file
what do you mean by this?
you have like a slash command with a parameter that takes a Member?
How would a user be mentioned in a select menu?
Not. Like a participant pings a person, and he will already be in the message, he found only interaction.user
Noted. Thanks 🙂
?
!d aiohttp.ClientSession.get
coroutine async-with get(url, *, allow_redirects=True, **kwargs)```
Perform a `GET` request.
In order to modify inner `request` parameters, provide kwargs.
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
it would be the url of the api you are using
how do i mention the author using interation
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
how do i fix this not mentioning
How do I make a whitelist discord bot does anyone know (Python)
How can I set it to 1 language canal so that he does not send the message to all
Could you explain more please?
you could make it fetch there username and then do {name} in the embed at the top
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
Sorry, I dont understand are you trying to say when it joins a vc it sends a message?
Yes he sends a message as soon as someone in voice chat joint but he should do it only in a voice chat
.
if not before.channel and after.channel:
print(f'{member} has joined the vc')
await client.get_channel(1020014500335861920) ```
discord.ext.commands.Bot.get_channel isnt a async function, it doesnt return a coroutine upon the calling of the function object, so it would raise an error as None or any channel object arent awaitable objects
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!?
You meed to indent it inside of the if statement
Pls help me
What do you mean!/
guys how do i do smth like (ctx.author.id) with interaction and slash commands ?
!d discord.Interaction.user
The user or member that sent the interaction.
ah thanks
!indents
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
With what exactly?
Sorry, I dont understand im new to discord bots and also im not good at english
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.**")```
I wouldnt recommend making bots with an advanced library as a beginner, if you want to learn the concepts used in the library, which the library depends on those concepts please refer to this:
#discord-bots message
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.**")
i know python %82 of eveyr libary
Oh really? But you dont know how to use indentation?
yes
I believe you, you know python, but not enough.
huh? 
theres actually no helpful video on indentation
just press enter + tab after you write an expression, like def function, or if <condition>:
U weren't really making sense to me if you can try to amke a bit more sense it would help me to help u more
i did that
and it ruined my code
uhm, then you didn't do it properly....
wait on witch like
The embed given already shows how to use indentation and theirs no tutorials as its such a basic concept python depends on?
i dont understand a single thing u just said to me but ill go w it
Please use google translate if its hard to understand because of your knowledge on english.
Wich embed
those lines of code which you want to execute when the condition is true
The troll is back 🍿
No but theres more lines of code at the bottom its not just that i dont wanna execute just that
Lets not joke about someones skill, ok? Dont judge a book by its cover.
Have you gone through their message history? Lmao
yea, then indent those lines which you want to execute
That dosen't really help and i only created 1 if statement in that image
I shouldnt even be saying that line, its common sense and your parents shouldve already told you about it
Ah Ok
I have, but my point still stands, if its a troll lets leave the moderators handle it, ok?
no wait that wouldnt work cause all my over stuff is indent
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
then enjoy it
I am, hence the popcorn emoji
don't have to comment
🍿
Just cause people ask stupid questions about stuff in python dont mean there trolls you underestimate alot of people so people could be asking "Stupid Questions" Cause of health issues/learning issues u ever heard of that?!
I'm not sure I understand.
maybe thats why its hard for me to understand what yall are tryna tell me
Yes very true, please continue asking them questions
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
hi
idk if that made sense to you
Hello HAK
The server does handle them, you just havent seen it and thats the helpers choice to help if you care so much about the helpers time why dont you participate in the conversations and help the user?
Good, wbu
!e
if True: # stuff under that will always execute
print('Hi!')
@paper sluice :white_check_mark: Your 3.11 eval job has completed with return code 0.
Hi!
Im fine!
I'm not here to help trolls, I'm here to watch them troll you, thanks
You yourself seem like a troll because you have no reason to call a beginner a troll, you are just going against your point which is quite funny
Im still picking up the same error sorry for this its fine if u dont wanna help im just struggling to understand what your tryna tell me 😆
I remember yesterday some helper was helping them and they asked "is this javascript" 😆 that poor helper
where is message defined
because it's not an argument in the function
you have another if inside the first one, indent that as well
Bro I ownestly dont know tbf im just tryna make the command only aloud for a certain role
ye what abt that
!e
code
No documentation found for the requested symbol.
bruh, why did i paste tf
haha
And thats why theyre a helper, they help others unconditionally and quite well over others.
!d discord.Member.activities
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.
Then why did they give up and leave after they said that 😂
you indent the code under it, just like you did for the first if
You see how theres like 150 helpers and a help system🤔
may you tell me how im suppost to indent this
Yep i loved the part where a moderator came and told them to learn python 😂
oh wow
!e
if True:
a = 10
if True:
print(a)
@paper sluice :white_check_mark: Your 3.11 eval job has completed with return code 0.
10
You would understand if you weren't so arrogant kek
This server staff bother writing essays to trolls it's so funny 🤣
Bruh
ye
btw
i use daki to host
bro ownestly i might give up on my discord bot this is to hard for my brain to function
yeah]
Noo you should not give up!!
that is why folks who helped you before recommended learning python first
Whats your deal caring about others time? Quite nice of you🤔
a 12 year old kiddo learns how to code ol
you must be a very sad individual, lol
if i send u the code can u spoonfeed me for like 1 time
invalid peyton
Why do you keep replying to me lol, just help the guy
do you know how to make like plugins
Since you're clearly in love with them... Defending them so much
Cant, ryuga is
for servers.
nope, sorry
Is there a problem here?
ill poor milk on my head on vc
what server?
for u to spoon feed me
Ayoo yessss

Quite immature of you😭
You got the milk ready? I'll spoonfeed rn
like im trying to make a european asian discord server and minecraft server like with alot of gamemodes uk uk.
leme get it
what is going on 
I'll spoonfeed one command for every quarter gallon
I don’t know
Could we get back on topic though
He's going to poor milk on his head and I'm going to spoonfeed in return
This will be fun
Pour*
Yes autocorrect 😊
!ot do that here, thank you
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
when you correct a guy
It's spoonfeedjng discord.bot code, so it's relevant here thanks
Free Gramarlly
Grammarly *
They’re all the same, why so many variables?
U dont gotta now
cross do you know a host to host minecraft servers?/
i know how to host p- site- nvm
I used to host Minecraft servers, got bored after a while though
There are many ways, how many players are you planning on having
50 players is quite a lot
!ot off topic for this channel
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
yeah
If you're planning on a free hosting site I mean
Good hardware requires $ unfortunately
yup
@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
come general endysis like give me a site to host a server
Again it’s off topic
Where did the noid guy go he was smart af he prolly knows a million of them
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.
If you need a big brain @sick birch is your guy
async iterator syntax?
async for
Typing code on phone is hard so excuse me here:
async for ban in guild.bans():
…
Anyone know how to fix?
You forgot to add the bot scope in your invite
can you show?
Na, that's it
no
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 😂
do you know whats wrong?
Nah tbh idk whats wrong with it
I've created my bot and when I click my link to add the bot to my server, https://discordapp.com/api/oauth2/authorize?client_id=40287XXXXXX&permissions=2048&scope=bot I get ...
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.
this can help your issue ^
Cheers 👍
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
Is this correct?
async def test(ctx):
await ctx.send("test!")
The bot is just not sending the test message back
That’s what in does
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
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.
!d discord.ext.commands.Bot.wait_for
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**...
wait for add_reaction, and edit the message when that emoji is clicked
How to get the mentioned participant in interaction?
So the wait_for() is within the on_reaction_add(reaction, user)
yes but i'd like it to react when the message contains the word
but i can't use it with tuples or lists
you could probably split the user input into words and use set intersection
ok i'll try that
I think you're on an older version of discord.py, so it's ctx.author.avatar_url
isnt that already in there?
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?
Send all messages out first, then wait for
No and don't attempt to do so
ok
Would i have multiple wait_fors? If so wouldnt i run into the same issue where it only is waiting for one first, then the next?
Is there a library for slash commands?
Well yeah. That's what you want to do, wait for multiple responses
thanks.
Can someone please help me on how I can implement this on this issue: https://discordapp.com/channels/267624335836053506/343944376055103488/1020050232773459998
I'm kind of confusing myself on how I should implement this..
If you click on the docs link, there are examples
Yea but my question is, it sends out 2 seperate dms, then i have waitfor1 (waits until the first one is timed out or completed) then it waits for the next one? Or am i trippin
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()
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Yes, but that's not really a problem because the wait for will complete when any of the users who you sent a DM to respond
Thats the issue im running into then, i want to be able to individually detect when a certain person reacts to it
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
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?
It makes more sense if you stop thinking about each wait_for as waiting for a certain user
And instead waiting for the first user
And then saving that user as a check for the next wait for right? Hope im understanding this right
Yup, you're spot on
Oki thankies, ill give it an attempt when i get home
Though buttons would probably be better for this sort of thing
Whats that
You attach a callback to these buttons so your bot can do whatever you want when a user clicks one of these
Interesting, got like a link to an example of some code for it o:?
Okidoki ill check it out ^^
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("")
@sick birch this is an emergency
What's up?
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?
why not just loop through all the files in that directory?
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
Right?
self.tree.sync()
``` or do I remove that too?
ok
Hello! I just found out you can make </this:0> with </text:0> is there any way to make it do something tho?
Its just a slash command mention lol
yes but is there a way to let it pop up a text like this?
how do i make my bot be able to be self-hosted by other users?
give source and have them input their own token?
thats it? i thought you would need docker or something as ive seen with other bots on github
docker is preferable
but you can also have users download python and your requirements and run it
How do I disable a command in 1.7.3?
docker is best here
does anyone know how to fix this error? ive already used pip install aiosqlite but...
you should probably loop through every extension you have. this can be done by appending it to a list
is it possible to execute sql queries from .sql file using asyncpg
believe you can read over the file and execute via cursor
apparently the execute dosent work
does asyncpg have executemany?
if so, you can probably use that and do connection.executemany(file.read())
still working on this update for my bot, up to 5142 lines of code 
Imagine deleting message
nvm didn't read asyncpg lmao
I didn't even completely read it ;-;
yes it has executemany, so that should work
Whats asyncpg?
mhm it does i mainly wanted to know if it was supported by asyncpg
lib for postgres
Ok
is it possible to make (timeout) command in dsicord.py?
lmfao since black pinged the message still showed up in notifications 🤣

Lmaoo
specifically this: https://github.com/MagicStack/asyncpg
It's a asynchronous driver for postgres
"on_message.<locals>.check() takes 1 positional argument but 2 were given" What does this mean?
!d discord.Member.timeout
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").
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
okay thank you
Can anyone here help me make a snake game in discord.py?
Any idea how can I make?
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?
No
!d discord.ext.commands.Bot.wait_for
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**...
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)```
You don't have to use while loop
You can have a look at their example
Got message content intents enabled?
I do yes
Anyone sees anything wrong? ```py
await commands.ColourConverter.convert(ctx, color)
oh, sorry, i probably should have explained further, im looking for 2 seperate people to react, so i need 2 checks with the same wait for
Have you set intents in your code as well?

intents = discord.Intents.all()
client = discord.Client(intents=intents)
bot = commands.Bot(command_prefix=".", intents=intents)```
this I assume?
It's enabled by default for unverified bots
Is that still true since the update? You'd think they'd change it 
What update?
since I'm still in the learning phase I kinda mess things up so... 
Content being privileged and enforced
Olie? ^ ^^'
probably explained it poorly, sorry
I see nothing obvious in your code that should stop it working so
What's with the tuple in your quote list?
Idk how to explain exactly, but you have to put () after ColourConverter
await commands.ColourConverter().convert(...)
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)
Are you trying to send them together but on separate lines?
I forgor what it is called
So basically every time i write .99 the bot is supposed to respond with one of the quotes in the list
"this is\ntwo lines"```
=
this is
two lines
it worked fine when I had it as client.event but now I'm trying to make it an actual command
i know 
again, just following https://realpython.com/how-to-make-a-discord-bot-python/ best as I can for a complete dummy beginner
creating instance or calling
Thanks 🫠
I don't get what that accomplished though hold on
!e
print(
(
'test'
'second quote'
)
)```
@dull terrace :white_check_mark: Your 3.11 eval job has completed with return code 0.
testsecond quote
I fixed it. ._.
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
Pls anyone help me!!!!!!
How can I make snake game in dpy?
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
it's okay, yeah I found out the problem.
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)
your bot's on crack
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()```
I think you have to put content in data parameter
response = requests.put(..., data={"content": "Beep"}, headers=headers).json()
Oh thanks!
Btw Put returns an error - "Method not allowed" so it still a post method
Mb 🫠
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'
Simply get the users and put the data in it.
data2[str(guild.id)]['users'] = {}
for user in Sleeper.get_all_members():
if str(user.id) not in data2[str(guild.id)]['users']:
data2[str(guild.id)]['users'][str(user.id)] = {}
data2[str(guild.id)]['users'][str(user.id)]['open_tickets'] = 0
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
can you show the code please?
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
ill try and look at it but cant rn
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()
Should ctx still be there?
But I'm on 3.
Yes
nvm i wasn't
Could someoen help me
When I change my bot prefix to / the bot prefix dont work?! but theres no errors
Code please
Full code please
no
!paste
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.
I dont paste 🤣
If you can't send your full code I won't be able to help, consider you can't provide a traceback either
So you're doing /mines {round_id} and it isn't responding?
ye
But it's working with any other prefix?
it does work w over prefixes
Do you have an on_message event?
Slash commands are different from message commands with a "/" prefix
If you're trying to make slash commands, the process is different
k so what do id o
If you're using discord.py; https://github.com/Rapptz/discord.py/blob/master/examples/app_commands/basic.py
tht has nothing to do awith a / cmd
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
😆
Don't worry about it :)
fix your spelling + it is an example of slash commands, how does it have "nothing to do awith a / cmd"
Please be respectful towards other members of this server.
#discord-bots message
Check there if you're having troubles with slash commands
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?
you should learn about reading/writing to files first
but don't use json as a db in discord bots
use mongodb
in the docs i saw that it said cloudflare can be used to host bots although im pretty sure it will only work for java, does anyone know more about cloudflare hosting?
https://discord.com/developers/docs/tutorials/hosting-on-cloudflare-workers here if you wanna see for yourself
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
yo
with their id, its not possible to get the username and tag of a person that isnt in your server?
broo can u ping me when u troll people plss i want to enjoy the drama
it is
!d discord.Client.fetch_user
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.
i use bot commands
so i do bot.fetch use
i have to use client instead?
commands.Bot is subclass of Client, so you can use either
how do i get my .repl.co link?
use heroku
no u cant use cf workers for bot (u can have like slash commands but not gateway events ig)
whats that
heroku is removing their free trial tho
i mean free plan
or tier whatever u call it
wdym
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*
very informative, I asked about replit lmao
you asked for whats on my screen
am i doing something wrong?
its a coro u need to await
You didn't await the fetch_user
smh
wdym bro thats literally what i see on my replit
...
are
you starting the webserver?
from the main file?
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
idk
use a command error handler
...
so i put all the commands in a try except thing?
literally just show a screenshot of your screen
or watch a tutorial
tutorials are shit
it's more of an event, let me pull up the docs
win ROBUX 
!d discord.ext.commands.Bot.on_command_error
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.
its a predictor people buy them a lot
thank you
Any resources I can start with? That's also one of the problems I'm facing lol. Idk how to use MongoDB Kek
@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
Which is why I was thinking of starting with learning File writing/reading through Json files
don't use Mongo either, don't use a no-SQL db
What should I use?
thanks, id have spent so long figuring it out lol
just tab out from the website
you're tryna scrape
the url is behind it
PostgreSQL is usually the most recommended, sqlite would work too
how do i tab out
And how should I start with those? Are there any resources I can start to familiarize myself with using them? Rn, I've got no idea how those work lol.
why not use aiosqlite
you can use -> https://sqlbolt.com/
you can learn about the sync versions of the libraries such as sqlite but use the async bridge for those libraries
for example, the library for SQLite in python is sqlite3 but the async version is aiosqlite
whats the next step
Alright, will check this one out
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
run the bot
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
good thing u didnt blur the output
why
replit's current ip which is running your project
do kill 1 in the shell and it'll reset the IP
what what, it's returning an IP address in the webserver url or what?
no
how long does being rate limited last
you don't need to wait, do kill 1 in the shell, it'll reset the IP
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
then what should i use
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?
!paste and show the whole traceback in the link
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.
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
just typehint die to int
typehint the die argument with int
nice
But that'd be a required argument, right?
Ahh, wait. Yeahh lol. Lemme try that 😆
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
dw typehints dont affect ur code at run time
Yeah, it works lol. Well, I guess it won't matter much since it's a slash cmd lol. Thanks guys!
rip mypy keeps crying over none so i made a habit to avoid it 
slash commands are so uwu

I don't even use mypy so dc
kek ide linter enough
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
you can't
Ok
u can but it will be very shit
Ok
I want to make a game but idk what to make (i am having dumb game ideas)
just make game with pygame, why ur using discord bot 😓
^
Just for fun
but if you want game in discord maybe make typeracer or roleplay game
Roleplay doesn't make sense?
maybe try learning different part of python
have u tried web framework
or databases
try flask
I feel js is good for web frameworks
js is awesome ye
I am currently making my personal website using next js
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
flask good for apis ig?
fastapi for api
I don't see an issue
Next js also many folders
for simple site it is lot of unnecessary work
flask u can just make few decorator in single py file and ur done
just don't make a simple one
what if not smart 😔
But js have good frameworks like next js
Anyway we should not discuss it here
informative too
it dont matter, mods dont care lol
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
I have one problem when i start a new thing
I stop it in the middle and not finish it
yea if ur just retrieving data no need for commit
!sql injection
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
u shuld use placeholder always
i do those, so ig everything is fine
also if ur using in discord bot u shuld use aiosqlite instead of sqlite3
otherwise fine
i do
@meager chasm are you good at website designing?
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
epic mother moment
with a random server id
is it possible to get the server's name?
No
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
Wdym
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
Just pass the fp in the File constructor
file = discord.File(fp, "bilboard.png")
You don't need to use seek(0) here
you should seek before passing it
ig the file pointer would be at the end after creating the BytesIO
He's just passing data in BytesIO, not by writing it using .write. So I don't think you have to use it
true

the spellings of billboard are different in discord.File() and in embed.set_image there's a missing or excessive L
fix the spelling mistake
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
ask at #python-discussion
ah ok, i will next time since i was tryna get pip install discord working to make a discord bot so i decided to go here since it is a discord bot thing ig
np, also it should be discord.py not discord
oh lmao
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.
log somewhere when someone clicks button
you mean like a event or command that checks when someone clicks the button
yeah, you can also make a function and use it inside button function
ok, I tried something like that but couldn't get it to work so I tried to look at youtube. I'm gonna try again
don't look at yt or you will just end up wasting ur time
are there example codes for menu and button usages?
however, the proper way will be just to store them
yeah, check discord.py's repo on GitHub, it has an example folder with all those stuff
okey just saw that i have functions in the buttons alreday
awesome tyvm
even I don't use database, I just use a channel for that lol
just 2-3 messages and enough
wrong server?
nah im trying to use the python bot for docks
It looks like the file isn't a png file
hmm
what are you searching for
docks for making something that logs the click on the button
why will it be there on docs, it's a custom thing
!d discord.ui.Button.callback gets triggered when the button is clicked
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.
and a channel
make your button class and and overrided the callback method, do you operations inside it.
idk. never tryed to make something like that
ok
yo, i cant figure out how to pass kwargs to a command through discord messages
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 ?
just use aiosqlite
Hmm i already using MySQL is this ok to add one more db in bot code ?
Is MySQL slow then sqllite ?
Or any other reason
That’s a false statement
Json is not a database, don’t use it as such
If you’ve already got MySQL store it there
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
Make sure you implement some sort of caching because get_prefix is called every message
yes a bot can read who reacted
Thanks Robin ❤️it means alot
You can use something like argparse for that
Although there is probably a better solution
dpy has a FlagConverter for strict key-value pair syntax, and integrates with other converters nicely
https://discordpy.readthedocs.io/en/stable/ext/commands/commands.html#flagconverter
https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.FlagConverter
its not as powerful as argparse though, and with either option you will need to write your own help/usage text afterwards
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=
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
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?
you can the docs if it raises different errors for both, idts but
check the docs*
yeah not really, Discord doesn't return any specific error for "that ID exists but isn't a guild", just a 403
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
I think there's some issue
icon shows online, but it is under offline members
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
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.
Did it work and all of a sudden it stopped working?
ModuleNotFoundError: No module named 'discord_components' how to solve this?
@slate swan
@honest shoal
I remember there was a library with such name
you no longer need it, dpy is upto date now
that library is unmaintained, so if you really need it, you'd need to install it from the git repo
or if you have some time to spare, you can just rewrite it with dpy 2.0 since it already includes components
give me the repo
this I guess https://github.com/kiki7000/discord.py-components
so it is discord-components not discord_components
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"
Why even use that library?
because or doesnt work like that
!e
print(1 or 2)
@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.
1
oh, so it doesnt know which one to use so it will always default to the first one?
!e print("hello" or "HELLO")
@untold iron :white_check_mark: Your 3.11 eval job has completed with return code 0.
hello
!e print("HELLO" or "hello")
@untold iron :white_check_mark: Your 3.11 eval job has completed with return code 0.
HELLO
ooo okay got it
How can i get the event to check weather the input is HELLO or hello or any other word
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}")
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
make the msg content lower
using .lower()
if message.content.startswith("Hello") or if message.content.startswith("Hi")
@untold iron
please keep them in line
and what if someone types HellO?
he only wants input for these two that's his problem if someone types a message out of given choice
I learnt something new thank u
Yes!!
hmmmm
idk how to do this
Okay understood, so Or is only used to link two things together based on a condition
yea sorta
multiple
yeah multiple
have you tried try/except?