#discord-bots

1 messages · Page 873 of 1

spring flax
#

apex mobile?

#

nevermind that's ot

maiden fable
junior falcon
#
Traceback (most recent call last):
  File "C:\Users\Federico\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ui\view.py", line 371, in _scheduled_task
    await item.callback(interaction)
  File "c:\Users\Federico\Desktop\AquariusMC Bot\AquariusMC Tickets\bot.py", line 62, in button_callback
    ticket_channel = await interaction.guild.create_text_channel(name=f"{ctx.author.name}", overwrites=overwrites, category=TICKET_CATEGORY)
  File "C:\Users\Federico\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\guild.py", line 1170, in create_text_channel
    data = await self._create_channel(
  File "C:\Users\Federico\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\guild.py", line 1051, in _create_channel
    "id": target.id,
AttributeError: 'property' object has no attribute 'id'```
maiden fable
#

tf is target now istg dpy internals

manic wing
#

i think its because TICKET_CATEGORY is not a category

maiden fable
#

could be

junior falcon
#
TICKET_CATEGORY = bot.get_channel(TICKET_CATEGORY_ID)```
manic wing
#

nope not that

maiden fable
#

@junior falcon can u show the whole command?

manic wing
#

what are overwrites?

#

print(overwrites)

unkempt canyonBOT
#

Hey @junior falcon!

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

junior falcon
slate swan
#

@maiden fable hunter hunter

maiden fable
#

hm?

slate swan
maiden fable
#

go on

manic wing
#

whats SEE_TICKETS

junior falcon
manic wing
#

you need to pass role object

maiden fable
#

or a discord.Object

manic wing
#

hence the error - do ctx.guild.get_role(id)

honest vessel
#

@manic wing👋🏻

manic wing
honest vessel
#

tbh i think the green background is wrong color for the syntax highlight hard to see

#

a dark color would be good

#

anyone here who is owner of website? maybe can fix a darktheme n light theme?

silk kelp
# honest vessel

why is the name the same as what its defined as, does that change anything?

honest vessel
#

not my code - i just complained on how bad it is to read even

#

only change font made a big diffrence

cold sonnet
#

maybe TICKET_CATEGORY being undefined

boreal ravine
#

@manic wing

manic wing
#

what

junior falcon
#

I really dont get whats wrong with my code

boreal ravine
manic wing
#

what

junior falcon
honest vessel
#

@junior falconwhats error?

honest vessel
#

nah u just didnt use english 😛 it was ur language canale and it was declared on function so that was my bad

junior falcon
#

yh

dry junco
#

How does embed work on bot?
Like how do i set it up to send messages as embed?

maiden fable
#

send method has an embed kwarg

honest vessel
#

@junior falcontbh dont know man :S

maiden fable
#

!d discord.TextChannel.send

unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
honest vessel
#

i dont know if this matter but

overwrites = {
        discord.Guild.default_role: discord.PermissionOverwrite(view_channel=False),
        ctx.author: discord.PermissionOverwrite(view_channel=True),
        discord.Guild.me: discord.PermissionOverwrite(view_channel=True),
        SEE_TICKETS: discord.PermissionOverwrite(view_channel=True), }
``` you ending with ,
dry junco
#

Mhm

honest vessel
#

!e
d = {"h":"b", "c":"b",}
print(d)

unkempt canyonBOT
#

@honest vessel :white_check_mark: Your eval job has completed with return code 0.

{'h': 'b', 'c': 'b'}
honest vessel
#

i guess dosnt matter

junior falcon
#

Same error

honest vessel
#

ofc, but here is i think ur error is about

#
TICKET_CATEGORY = discord.utils.get(GUILD.categories, name=TICKET_CATEGORY_NAME)
#
ticket_channel = await TICKET_CATEGORY.create_text_channel(f"{ctx.author.name}-{ctx.author.discriminator}", overwrites=overwrites)

junior falcon
#

if i print this it return the right category

honest vessel
#

you dont want await TICKET_CATEGORY.create_text_channel()

#

you want ctx.guild.create_text_channel("name of channel", category=TICKET_CATEGORY)

#

something like that

maiden fable
#

weird, it should have been there

honest vessel
#

i mean his create_text_channel dosnt know what guild

#

and create_text_channel has a category

#

krwarg

nimble plume
#

Use ticket create embed channel category as category

junior falcon
#

thank you so much

#

one more thing

#

how i get the avatar of a member?

#

ctx.author.avatar?

maiden fable
#

!d discord.Member.avatar

unkempt canyonBOT
#

property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.avatar "discord.User.avatar")
maiden fable
#

yea haha

nimble plume
#

Yes

livid jacinth
#

How can i stop that the bot spam the message into the channel?
I tryed that the bot send a message to an channel if a specific person comes online. But if the person comes online the bot spam the message permanently.

@bot.event
async def on_member_update(before, after):
    if str(after.status) == "online" and after.id == MYID:
        channel = bot.get_channel (941209391917568000) 
        await channel.send("idk")
        pass
mint grail
#

what command is it using discord py, for making the bot send a message without a member using a a command if that makes sense. I have an auto update code and i want the bot to send a message every 10 minutes. I just need help on how i can make the bot send a message?

nimble plume
#

Wait

slim ibex
whole brook
#

Hello everyone, I'm looking for someone who can finish me a discord bot, I don't know anything and the person who does it for me is absent, I pay for it, I give the details in pm

unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

honest vessel
mint grail
livid jacinth
slim ibex
honest vessel
mint grail
slim ibex
#

!d discord.ext.commands.Context.invoke

unkempt canyonBOT
#

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

Calls a command with the arguments given.

This is useful if you want to just call the callback that a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") holds internally.

Note

This does not handle converters, checks, cooldowns, pre-invoke, or after-invoke hooks in any matter. It calls the internal callback directly as-if it was a regular function.

You must take care in passing the proper arguments when using this function.
whole brook
#

sorry i just got here i didn't see, if someone can help me

quaint epoch
honest vessel
#

@slim ibexthanks wasnt that complex

quaint epoch
#

discord.js is good to run on node

nimble plume
#

..

honest vessel
#

@slim ibexthe invoke

nimble plume
slim ibex
#

what about it? I’m so confused 💀

honest vessel
quaint epoch
slim ibex
#

oh lol

quaint epoch
nimble plume
#

Ok

nimble plume
quaint epoch
#

btw, await ctx.send() returns a message obj right?

honest vessel
#

imagine talking about js in a python server 🙃

quaint epoch
honest vessel
#

maybe u working for a js fork and here to recruit

nimble plume
#

!ot

unkempt canyonBOT
nimble plume
#

0

quaint epoch
nimble plume
#

Ok

livid jacinth
#

How can i stop that the bot spam the message into the channel?
I tryed that the bot send a message to an channel if a specific person comes online. But if the person comes online the bot spam the message permanently.

@bot.event
async def on_member_update(before, after):
    if str(after.status) == "online" and after.id == MYID:
        channel = bot.get_channel (941209391917568000) 
        await channel.send("idk")
        pass

or does anyone know an other way to let send my bot a message if a specific person comes online?

honest vessel
#

@nimble plumerelax or i call mod on u

nimble plume
honest vessel
nimble plume
unkempt canyonBOT
#

property status: discord.enums.Status```
The member’s overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") instead.
silk kelp
nimble plume
#

Im not a spammer 🥺

honest vessel
grim robin
#

is there a limit on how often you can call chan.edit()?

honest vessel
slim ibex
honest vessel
nimble plume
#

Not me

honest vessel
grim robin
#

I'm not making too many at the same time, I'm trying to update a single channel's name to show the number of people in it and after the 3rd call of .edit() it stops refreshing the name, as if .edit() is stuck on a loop or something, making commands like chan.delete() unable to work as well. (each call of edit has at least 3-4 secs from the previous if not more)

honest vessel
#

channels dosnt update that often its cached - therefor u try edit but wont see a change - untill some time went by

slate swan
#

whats the scope of bot variables

final iron
#

Doesn't even have to be in the file

slate swan
#

ok

#

and any idea how to delete a bot variable

#

hey im trying to sdit the message when click the reaction edit the numbers of the clicks

final iron
honest vessel
#

!e
myvar = "monkey"
del myvar
print(myvar)

unkempt canyonBOT
#

@honest vessel :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 3, in <module>
003 | NameError: name 'myvar' is not defined
slate swan
#

so in my cog, i am subclassing ui View, will bot variables be accesible there

slate swan
slate swan
#

someone knows why?

junior falcon
slate swan
#

so in my cog, i am subclassing ui View, will bot variables be accesible there

#

hey there! how to host my bot for free for ever

#

???

left crater
#

raspberry pi

manic wing
stiff nexus
#

how to get the author in on_raw_message_edit?

manic wing
#

!d discord.on_raw_message_edit

unkempt canyonBOT
#

discord.on_raw_message_edit(payload)```
Called when a message is edited. Unlike [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), this is called regardless of the state of the internal message cache.

If the message is found in the message cache, it can be accessed via [`RawMessageUpdateEvent.cached_message`](https://discordpy.readthedocs.io/en/master/api.html#discord.RawMessageUpdateEvent.cached_message "discord.RawMessageUpdateEvent.cached_message"). The cached message represents the message before it has been edited. For example, if the content of a message is modified and triggers the [`on_raw_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_message_edit "discord.on_raw_message_edit") coroutine, the [`RawMessageUpdateEvent.cached_message`](https://discordpy.readthedocs.io/en/master/api.html#discord.RawMessageUpdateEvent.cached_message "discord.RawMessageUpdateEvent.cached_message") will return a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") object that represents the message before the content was modified.

Due to the inherently raw nature of this event, the data parameter coincides with the raw data given by the [gateway](https://discord.com/developers/docs/topics/gateway#message-update).
manic wing
#

you would have to get/fetch the message from the message id possibly

honest vessel
#

!e
print(whoisurfather)

unkempt canyonBOT
#

@honest vessel :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'whoisurfather' is not defined
honest vessel
#

where can i get this ? ^ python execution as this one usees

#

is Pythonbot public?

#

or can i download same lib he uses?

manic wing
#

!src e

unkempt canyonBOT
#
Command: eval

Run Python code and get the results.

Source Code
honest vessel
#

ty bro

slate swan
unkempt canyonBOT
final iron
slate swan
#

how to @ a user

maiden fable
#

!d discord.User.mention

unkempt canyonBOT
#

property mention: str```
Returns a string that allows you to mention the given user.
slate swan
#

forgot havent done this in ages lmao

ornate linden
#

another problem with my ascii art, it either escapes the ``` or has leftover backslashes

#

i guess i could .replace ``` with ''' but id really prefer not to

modern fiber
#

Any clue why it doesn't ban the person?

#
# ---- Ban Command
@client.command(description="Bans an user.") #ban
@commands.has_permissions(ban_members=True)
async def ban (ctx, user:disnake.User=None, *, reason=None):
 try:
    if (user == None):
         await ctx.channel.send("You have to specify an user!")
         return
    if (reason == None):
        await ctx.channel.send("You have to specify a reason!")
        return
    if (user == ctx.message.author or user == None):
        await ctx.send("You cannot ban yourself!")

    message = f"You have been banned from **{ctx.guild.name}** for **{reason}**! You may be able to appeal your ban at ///
    await user.send(message)
    await ctx.guild.ban(user, reason=reason)
    await ctx.channel.send(f"{user} is succesfully banned for {reason}! Jeez.")
    channel = disnake.utils.get(ctx.guild.channels, name="protech-logs")
    await channel.send(f"{user} has been **banned** by {ctx.author} for a reason: **{reason}**")
 except:
    await ctx.send(f"I cannot ban {user}! *(I am unable to ban a bot / an owner).*")```
#

Here is the code.

ornate linden
#

if any error occurs in any of that it defaults to the error you're getting

#

try putting just the ctx.guild.ban inside the try:except

ornate linden
#

the line await ctx.guild.ban(user, reason=reason) is what actually bans the user

modern fiber
#

Yeah, right

ornate linden
#

so why have all of the other user.send, ctx.channel.send, etc in a try: block?

#

it's probably an error on await user.send() because they've blocked the bot or smth

#

and because it's erroring there it never makes it to the await ctx.guild.ban

#

also your variable message is never closed

modern fiber
#

Why does it need to be?

#

It works fine-

modern fiber
ornate linden
#

move the try:except so ctx.guild.ban is the only thing in it

#

close your message variable

#

try:except is suppressing syntax errors

silk kelp
ornate linden
#

also @modern fiber you can have the bot see if the user you're trying to ban is the guild owner/a bot

#

iirc member.is_bot() and member.is_guild_owner()

modern fiber
#

So I should just do that instead of the current error I got? Will it fix?

ornate linden
#

sorry?

slim ibex
# modern fiber ```py # ---- Ban Command @client.command(description="Bans an user.") #ban @comm...

there are some issues with this:

  1. Bare Except (you can except CommandInvokeError
  2. Python doesn’t require parenthesis for if and elif blocks
  3. Don’t use client, use commands.Bot (I assume you are using discord.Client because of @client.command)
  4. sending the message to the user will fail if they have DMs closed
  5. user.ban
  6. typehint to discord.Member
  7. ctx.send instead of ctx.channel.send
  8. why if user == ctx.message.author or user == None?
ornate linden
#

thx @slim ibex

slim ibex
#

I would typehint to disnake.Member instead of user also

ornate linden
#

also there's a return missing on your third if statement

modern fiber
#

Should I do it like this?

ornate linden
#

if it's in the except block it will only run if the ban fails

slate swan
modern fiber
silk kelp
modern fiber
#

else:
user.is_bot()
await ctx.send("bla bla bla")

#

?

silk kelp
modern fiber
#

Okay, thanks

modern fiber
#

or should I use "or"?

slim ibex
#

no there can’t be multiple else

slate swan
unkempt canyonBOT
slim ibex
#

and please read up on what or actually does

modern fiber
silk kelp
ornate linden
modern fiber
silk kelp
#
if user.is_owner or user.is_bot:
junior falcon
#
                discord.SelectOption(label="Supporto Store / Acquisti", description="Per problemi riguardanti allo store e i pagamenti.", emoji=":money_with_wings:"),
                discord.SelectOption(label="Segnala Un Player", description="Se desideri segnalare un giocatore.", emoji=":pencil:"),
                discord.SelectOption(label="Segnala Un Bug", description="Se desideri segnalare un bug.", emoji=":paintbrush:"),
                discord.SelectOption(label="Appella un Ban", description="Per fare una richiesta di unban/unmute.", emoji=":envelope:"),
                discord.SelectOption(label="Altro", description="Se nessuna delle opzioni precedenti è il tuo problema.", emoji=":grey_exclamation:")```
Getting this error:

discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0.options.0.emoji.name: Invalid emoji
In components.0.components.0.options.1.emoji.name: Invalid emoji
In components.0.components.0.options.2.emoji.name: Invalid emoji
In components.0.components.0.options.3.emoji.name: Invalid emoji
In components.0.components.0.options.4.emoji.name: Invalid emoji
In components.0.components.0.options.5.emoji.name: Invalid emoji

What format i should use?
ornate linden
modern fiber
#

mk ty

ornate linden
#

if is bot:
if is owner:
if is user:

silk kelp
junior falcon
#

but some emoji with backslash return the text

ornate linden
silk kelp
junior falcon
#

oke thanks

slate swan
silk kelp
silk kelp
modern fiber
modern fiber
# slim ibex <@!655735547297529876> ^^
@client.command(description="Bans an user.") #ban
@commands.has_permissions(ban_members=True)
async def ban (ctx, user:disnake.User=None, *, reason=None):
 try:
    if (user == None):
         await ctx.channel.send("You have to specify an user!")
         return
    if (reason == None):
        await ctx.channel.send("You have to specify a reason!")
        return
    if (user == ctx.message.author or user == None):
        await ctx.send("You cannot ban yourself!")

    message = f"You have been banned from **{ctx.guild.name}** for **{reason}**!"
    await user.send(message)
    await ctx.guild.ban(user, reason=reason)
    await ctx.channel.send(f"{user} is succesfully banned for {reason}! Jeez.")
    channel = disnake.utils.get(ctx.guild.channels, name="protech-logs")
    await channel.send(f"{user} has been **banned** by {ctx.author} for a reason: **{reason}**")
    else:
    if user.is_bot():
     await ctx.send("yeah")
    if user.is_guild_owner():
     await ctx.send(f"I cannot ban {user}! *(I am unable to ban a bot / an owner).*")```
#

Can you help me connect those two "if" statements? My brain kinda stopped working.

silk kelp
modern fiber
silk kelp
silk kelp
last moss
#

haven't been here in a while lol

#
@bot.command(name="join")
async def soundFXCommand(ctx):
    if ctx.author.voice:

        channel = ctx.author.voice.channel
        voice= await channel.connect()     
        
        choice = random.randint(1,3)
        source = FFmpegPCMAudio(executable="C:/Users/pc/Documents/Projects/ffmpeg/ffmpeg/bin/ffmpeg.exe", source='greetings/greeting_{choice}.mp3')

        player = voice.play(source)
        print("played")
    else:
        await ctx.send("You aren't in a voice channel!")
#

This is my code to play something but nothing is played, eventhough "played" is printed

kindred oracle
#

Hello guys. I have been working on my bot for a while now and I was wondering if I can make my bot send a message whenever I type something in my console. Is it possible to do so? I didn't find any implementations that worked for me so far.

silk kelp
last moss
#

oh shit

silk kelp
#

xd

slate swan
#

lmao

silk kelp
#

best emoji

modern fiber
slate swan
modern fiber
#

What's wrong with my else statement?

#

@silk kelp

silk kelp
#

so it doesnt try to ban the owner

slate swan
#

why not use the bot property instead of a method?

silk kelp
modern fiber
modern fiber
silk kelp
#

aswell as all the code inside of it, just indent it once it should work

silk kelp
slate swan
#

i dont even know why people make simple things complex

silk kelp
modern fiber
slate swan
slim ibex
#

a ban command shouldn’t be this complicated. You can extract certain things into separate methods so you don’t have this one large command that is hard to track

cold sonnet
#

ctx.channel.send

slate swan
#

So i'm building a role selector bot. Is there a way to create a user timeout per use. What i mean by that is something that prevents the same person clicking a ton of roles over and over causing the bot to lag or freeze?

slim ibex
silk kelp
silk kelp
modern fiber
silk kelp
modern fiber
#

What's wrong with else statement?

slate swan
spring flax
#

How do i see if a user is on timeout?

slim ibex
#

@modern fiber your code is over complicated and hard to read. I recommend you refactor it and it will be way easier to write and understand

maiden fable
unkempt canyonBOT
#
Certainly not.

No documentation found for the requested symbol.

maiden fable
#

Hmm lemme see

modern fiber
maiden fable
#

heh?

slate swan
maiden fable
unkempt canyonBOT
slate swan
spring flax
#

Huh

maiden fable
#

@slate swan have u ever made an antispam?

last moss
#

Wait how do you check if the bot is in a voice channel

spring flax
#

Wonder how that came up lol

maiden fable
unkempt canyonBOT
#

property voice: Optional[discord.member.VoiceState]```
Returns the member’s current voice state.
last moss
#

and if so how do you return the voice object

maiden fable
#

ctx.guild.me.voice

slate swan
#

is there a way to prevent command spam

last moss
#

tok

silk kelp
slim ibex
silk kelp
maiden fable
unkempt canyonBOT
#

@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.

A command can only have a single cooldown.
slate swan
#

does that work per user or just as a whole

slim ibex
#

you can make it work for users or the whole guild

silk kelp
maiden fable
#

depends on the BucketType

maiden fable
slate swan
#

thank you i'll check that out!

#

def want user

maiden fable
modern fiber
silk kelp
maiden fable
slate swan
#

oh that makes sense

silk kelp
maiden fable
maiden fable
slim ibex
maiden fable
modern fiber
slate swan
#

is there a way to add that to @client.event?

maiden fable
#

ot but I just came to know today that I suck at Valo and Apex both (but I suck more at Valo lmao)

slate swan
#

prob not i can see how that would be confusing

silk kelp
silk kelp
#

ofc i can make it better, thats just a small snippet

slim ibex
#

@modern fiber let me give you some suggestions:

  1. Extract this into separate functions
  2. Follow PEP8 (ex: no parenthesis in if statements
  3. Read disnake docs
  4. It seems like you know some Python, but maybe learn a bit more before continuing
silk kelp
#

i just need to make a command.before_invoke which im really confused on its syntax @maiden fable

kindred oracle
#

Hey

maiden fable
slim ibex
maiden fable
slim ibex
#

🗿

kindred oracle
#

Anyone ever managed to make a bot send a message throught the console?

spring flax
#

What are unique things one can put in a userinfo command? Like things not seen often

kindred oracle
#

I have been trying for a half an hour and if anyone could help I would appreciate it.

slim ibex
#

what do you mean send a message through the console

kindred oracle
#

from the console to the channel

silk kelp
spring flax
maiden fable
last moss
#

🤔 I did voice= await channel.connect() to get the voice object but how would I get this object if I already was in a vc

spring flax
#
@bot.command()
async def example(ctx):
    await ctx.send("example")

@kindred oracle

kindred oracle
# spring flax What are you doing right now?

Long story short my bot is in a server which I abadoned a long time ago and I would like to talk with them first of all. For now I just made a logger and asked for an invite for me to join.

last moss
#

ctx.voiceclient?

slate swan
last moss
#

ok thanks

slate swan
#

!d discord.VoiceClient.is_connected

unkempt canyonBOT
slate swan
#

will check if its in a channel already or not

maiden fable
#

nvm it is voice_client

slate swan
maiden fable
#

I thought u meant ctx.voiceclient is a thing lol

slate swan
#

!d discord.ext.commands.Context.voice_client

unkempt canyonBOT
#

property voice_client: Optional[VoiceProtocol]```
A shortcut to [`Guild.voice_client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.voice_client "discord.Guild.voice_client"), if applicable.
maiden fable
#

I mean, they said ctx.voiceclient and u said yeah, soooooo

silk kelp
# maiden fable code
@commands.command()
@commands.before_invoke()
async def mycommand(self, ctx):
  print("i want to die")
slate swan
maiden fable
#
@bot.command()
async def cmd(...):
    . . .


@cmd.before_invoke()
async def before_cmd(...):
    . . . 
slate swan
maiden fable
#

and then get bullied by PEP8 followers

slate swan
maiden fable
#

PEP8 officers 👀

livid jacinth
#

How can i stop that the bot spam the message into the channel?
I tryed that the bot send a message to an channel if a specific person comes online. But if the person comes online the bot spam the message permanently.

@bot.event
async def on_member_update(before, after):
    if str(after.status) == "online" and after.id == MYID:
        channel = bot.get_channel (941209391917568000) 
        await channel.send("idk")
        pass

or does anyone know an other way to let send my bot a message if a specific person comes online?

livid jacinth
#

Yes i dont know how. I dont know the problem

maiden fable
slate swan
#

can you show MYID var though

maiden fable
#

Its his/her ID

livid jacinth
#

Yes

slate swan
#

data types

maiden fable
#

@livid jacinth is it an int?

livid jacinth
livid jacinth
maiden fable
#

the variable MYID

slate swan
#

uh did you put the id in quotes

echo lagoon
#

Is it an int or str?

maiden fable
#

also, @livid jacinth show yr on_message event

slate swan
#

i'll leave, help god here to help es_pepe_Toilet

maiden fable
#

lmao why tho

slate swan
#

why not

livid jacinth
#

No i just have one on_message event

maiden fable
#

show

maiden fable
livid jacinth
# maiden fable show
@bot.event
async def on_message(message):
    if message.content == ('prefix'):
        with open("prefixes.json", "r") as f:
            prefixes = json.load(f)
        
        pre = prefixes[str(message.guild.id)]

        embed=discord.Embed(color=0xffffff)
        embed.add_field(name="Serverprefix:", value=f'**The server prefix is "{pre}"**')

        await message.channel.send(embed=embed)
        await message.add_reaction('📧')
tidal hawk
#

very creative username, you have

slate swan
maiden fable
livid jacinth
maiden fable
slate swan
#

which isn gonna solve the problem

echo lagoon
#

^

#

Ya know what - ima just run the damn code myself - see if I get the same results

livid jacinth
#
@bot.event
async def on_message(message):
    if message.content == ('prefix'):
        if message.author == bot.user:
            return
        with open("prefixes.json", "r") as f:
            prefixes = json.load(f)
        
        pre = prefixes[str(message.guild.id)]

        embed=discord.Embed(color=0xffffff)
        embed.add_field(name="Serverprefix:", value=f'**The server prefix is "{pre}"**')

        await message.channel.send(embed=embed)
        await message.add_reaction('📧')
``` So?
maiden fable
#

hmmm idk someone else advised to do it but they most probably missed the message so I am just telling them to do so lol

slate swan
#

did you put the id in quotes or not @livid jacinth Pepeangry

maiden fable
#

lmao ash do be pissed

slate swan
maiden fable
#

the emoji says otherwise but okay 👀

slate swan
modern fiber
#

It doesn't send any output..? @slim ibex

# ---- Ban Command
@client.command(description="Bans an user.") #ban
@commands.has_permissions(ban_members=True)
async def ban(ctx, user:disnake.User=None, *, reason=None):
    if (user == None):
         await ctx.channel.send("You have to specify an user!")
         return
    elif (reason == None):
        await ctx.channel.send("You have to specify a reason!")
        return
    elif (user == ctx.message.author or user == None):
        await ctx.send("You cannot ban yourself!")
        return
    elif user.bot:
       await ctx.channel.send("yeah")
       return
    elif ctx.guild.owner.id == user.id:
      await ctx.channel.send(f"I cannot ban {user}! *(I am unable to ban a bot / an owner).*")
      return
    message = f"You have been banned from **{ctx.guild.name}** for **{reason}**!"
    await user.send(message)
    await user.ban(user, reason=reason)
    await ctx.send(f"{user} is succesfully banned for {reason}! Jeez.")
    channel = disnake.utils.get(ctx.guild.channels, name="protech-logs")
    await channel.send(f"{user} has been **banned** by {ctx.author} for a reason: **{reason}**")```
slate swan
#

so in my cog, i am subclassing ui View, will bot variables be accesible there

#

also, pretty sure you ca use a presence event if you are above dpy 2.0 or on forks or api wrappers

maiden fable
#

or api wrappers?

#

wym by that 👀

livid jacinth
#

No it did't worked

slate swan
livid jacinth
#

The bot spam the message again

novel geyser
#

Got a question. I'm trying to make a system where if someone tags the channel in their argument, it sends a message in that channel but I'm not sure how to do that

slate swan
manic wing
#

whats an api

maiden fable
#

bruh

slate swan
slim ibex
unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
maiden fable
novel geyser
livid jacinth
maiden fable
#

wait where u sending 123 in code?

slate swan
maiden fable
#

u r sending idk according to the code

slate swan
maiden fable
livid jacinth
#

just the message

maiden fable
#

stop playing with us rn and stick to one code please lemon_pensive

echo lagoon
#

huh, dunno wtf i did wrong, im not getting any events ; - ;

maiden fable
#

lmao

echo lagoon
maiden fable
#

u need members intent iirc

echo lagoon
#

i do have intents enabled

maiden fable
#

Ah wait

echo lagoon
maiden fable
#

u using dpy 2.0?

echo lagoon
maiden fable
#

!d discord.on_presence_update if u r using 2.0

unkempt canyonBOT
#

discord.on_presence_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their presence.

This is called when one or more of the following things change:

• status

• activity

This requires [`Intents.presences`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.presences "discord.Intents.presences") and [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled...
echo lagoon
maiden fable
#

....?

echo lagoon
#

ow wait

maiden fable
#

Thanks for killing my remaining brain cells

slate swan
#

why even enable intents explicity when you can have them all fLOOsh

echo lagoon
#

is that different naming for method?

maiden fable
#

yea...

echo lagoon
#

my bad, thx

maiden fable
#

on_presence_update smh

echo lagoon
#

well, he aint wrong

#

it do be spamming it

maiden fable
#

I think I will just go away from here 😔

slate swan
#

presence event?

echo lagoon
#

i feel, you'd have to add a couple mins cooldown before its invoked again

maiden fable
echo lagoon
maiden fable
#

@slate swan can u try reproducing this bug with disnake/any other fork please? I cannot really open VSC rn

slate swan
#

im on phone myself

echo lagoon
#

dpy2.0. . hol up ill try asking in dpy disc

maiden fable
#

😔

#

Seems like I will have to open VSC

slate swan
maiden fable
#

Yea most probably its a dpy bug which was fixed in disnake but who knows

#

Lemme ask

echo lagoon
#

unless its an api bug ;-;

#

doubt that tho

maiden fable
#

It shouldn't be

slate swan
#

imma head out, good luck both

echo lagoon
#

thx, anyhow the best i can say is adding some form of timer, giving it a 30 second refresh ig

maiden fable
#

Yea await asyncio.sleep seems like a viable option

slate swan
#

spamming idk every 30 sec

maiden fable
#

BTW imagine if messages were sent through the gateway 😔

velvet tinsel
slate swan
maiden fable
#

I think I will just go from here before all my brain cells die, trying to understand what u just said cz I am a bit too sleepy lmao

maiden fable
velvet tinsel
#

before you know it you'll be using pop in dictionaries

tacit horizon
#

give me tiktakto code with button ._.

maiden fable
#

see the dpy repo

velvet tinsel
maiden fable
#

it has a ttt example

livid jacinth
tacit horizon
echo lagoon
#

gimme 2 seconds and ill give you a fixed up version . . .

velvet tinsel
slate swan
velvet tinsel
tacit horizon
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'ActionRow' object has no attribute 'label'
what is that

modest plover
#

For using postgresql with a Discord bot, what's a good enough free cloud host?

slate swan
#

heroku? maybe

maiden fable
#

Well the pass keyword is just a dummy keyword just for the sake of completing the syntax to prevent getting any syntax errors, so it is useless there, but doesn't really affect anything

maiden fable
modest plover
#

Mhm

echo lagoon
#

welp, shouldnt make a difference if theres a pass at the end tho

slate swan
maiden fable
#

yea

velvet tinsel
modest plover
#

It's like 1000 hours a month

velvet tinsel
#

it's like a space before the opening bracket in print statements

maiden fable
maiden fable
echo lagoon
#

fml, my syntax highlighting just gone whack ; - ;

maiden fable
#

1000 hours are like 40 days lmao

slate swan
modest plover
#

I'm looking at the thing and it says 550-1000 Dyno hours per month

modest plover
#

Oo, that deta thing seems good, would I be able to use it for hosting a db?

maiden fable
#

They have their own DB, like postgres is one, mongo is another and stuff

modest plover
#

I'd use SQLite3 but I forgot I need to access the db on my pc too

maiden fable
slate swan
maiden fable
#

I tried to run a discord bot on there, well the only reason it didn't work was cz the website dies as soon as someone logs off off it, soooooooo

slate swan
#

how do i get bot.commands as a list rather than a set

#

lol

modest plover
#

So do I use base for the db?

maiden fable
maiden fable
slate swan
#

ahh my basics

maiden fable
#

its fine

slate swan
#

thnx

slate swan
#

anyways, im going to study now, bye

maiden fable
#

cya

#

@slate swan that works?

slate swan
#

i didn't try it yet

maiden fable
#

Ah okay

slate swan
#

but yeah it has to work i just couldn't recall it

echo lagoon
#

oh nvm, i just didnt wait long enough for my presence to change . -.

#

right all done

#

right i understand your not currently using a cog, so heres my implamentation:

where in the initializer im setting self.last_invoked = datetime.now()

#

what this does, is it waits 30 seconds before being able to invoke the command again

maiden fable
#

why not just add await asyncio.sleep(30) tho

echo lagoon
maiden fable
#

Hahaha

modest plover
echo lagoon
#

~~right guess ill just show both implamentations:
my one which is over engineered and dumb: ~~ the working method

last_invoked = datetime.datetime.now()
@bot.event
async def on_member_update(before, after):
    global last_invoked
    if (datetime.datetime.now() - last_invoked).total_seconds() > 30 and str(after.status) == "online" and after.id == MYID:
        last_invoked = datetime.datetime.now()
        channel = bot.get_channel (941209391917568000) 
        await channel.send("idk")

~~the preferred cleaner method: ~~ dont work on testing, asyncio only stops that scope,

@bot.event
async def on_member_update(before, after):
    if str(after.status) == "online" and after.id == MYID:
        channel = bot.get_channel (941209391917568000) 
        await channel.send("idk")
        await asyncio.sleep(30)
modest plover
#

Oh, nvm, it got filtered as spam lmao

maiden fable
#

Oh hahaha

echo lagoon
#

It'll just pause the current invoked instance of the command iirc

#

Lemme test

livid jacinth
echo lagoon
#

welp, just change the datetime call to datetime.datetime.now() instead

modest plover
#

Why does datetime have to be like that lmao

echo lagoon
echo lagoon
# echo lagoon Lemme test

yup i was right, asyncio.sleep does nothing, gotta use a var outside of the scope for it to work (aka my not so dumb method)

livid jacinth
echo lagoon
echo lagoon
livid jacinth
#

I dont get an error but the bot dont send an message

echo lagoon
#

huh strange. . lemme give it a try on another bot instance that dont use cogs

kindred oracle
#

Hey is there an official documentation?

#

nevermind

#

Although i have a question still. Should I be able to make a discord bot just from the documentation?

left crater
#

yeah

#

there are plenty of example and stuff

slate swan
#

how to access bot stuff in ui View subclass like bot.commands etc...

viral wolf
#

Is there a way to write a bot more efficiently than just a bunch of if message startswith blank then message send?

potent spear
slate swan
kindred oracle
#

Oh thanks a lot. But I meant if I should be able to write it by the docs and without any other help. I was reading one when I was trying to achieve something but I got lost pretty fast and had to google stuff.

viral wolf
potent spear
potent spear
kindred oracle
#

It helped me with like what atteibutes a guild a member or a role has etc, but writing the code is a bit different

kindred oracle
#

Oh okay

#

well thanks and happy coding

#

👋

echo lagoon
potent spear
#

.

echo lagoon
#

i only used commands.bot

potent spear
#

same thing as with commands.Bot

echo lagoon
#

ah thx,

potent spear
#

commands.Bot is a subclass of discord.Client

slate swan
#

how to access bot stuff in ui View subclass like bot.commands etc...

livid jacinth
echo lagoon
#

wait, you are using commands.bot

#

thought you were using discord.client . - .

livid jacinth
#

No i using discord.bot

echo lagoon
#

ye it working just fine

#

got it to finally show up ; - ; had to wait 30 sec before changing my presence again . _ .

#
import datetime
bot.last_invoked = datetime.datetime.now()
@bot.event
async def on_member_update(before, after):
    print(";-;")
    if (datetime.datetime.now() - bot.last_invoked).total_seconds() > 30 and str(after.status) == "online" and after.id ==  ~ change to your ID ~ :
        bot.last_invoked = datetime.datetime.now()
        channel = bot.get_channel ( ~ change to channel ID ~ ) 
        await channel.send(". - .")
#

ofcourse you will need to change both your ID and chennel ID for it to work

potent spear
#

use a botvar instead at least

echo lagoon
potent spear
#

client.last_invoked would be great

echo lagoon
echo lagoon
#

apparantly it do, huh

potent spear
echo lagoon
#

i see, didnt realize its accessible inside the scope too,

modest plover
#

I'm trying to make a config command, how do I make it so that the bot listens for an answer to a command?
For example

/config
Bot : Welcome to the config menu
Please state the welcome channel:
User : #welcome

The code I have atm is:

import disnake
from disnake.ext import commands
from deta import Deta
import os
from dotenv import load_dotenv

load_dotenv()
project_key = os.environ["project_key"]

deta = Deta(project_key)
config_db = deta.Base("Config")

class Config(commands.Cog):
    """Saves a config to the Deta database."""

    def __init__(self, bot: commands.Bot):
    	self.bot = bot

    @command.slash_command()
    async def config(self, inter)

def setup(bot):
    bot.add_cog(Config(bot))
    print(" | Loaded Extension: Config")
    print(" | ")
#

I'm using Disnake btw

potent spear
modest plover
#

How do I use that?

potent spear
#

examples are stated in the docs

echo lagoon
modest plover
#

Ah, yeah found it

#

Thanks Sniper! :))

potent spear
#

gl hf

modest plover
#

GL maybe, HF fuck no

echo lagoon
#

👍 that good!!

honest vessel
#

(logbot)

slate swan
#
class HelpMenu(View):

    def __init__(self, bot):
        self.bot = bot
        super().__init__()

    options = [opt(label="Fun"),opt(label="Utility")]
    @select(placeholder="Choose a category", custom_id="help", min_values=1, max_values=1, options=options)
    async def callback(self, select, interaction):
        if select.values[0] == "Fun":
            embed = Embed(title="Fun Commands!", description = "Have fun with these commands", color = interaction.user.color)
            for i in list(self.bot.commands):
                if i.brief == "fun":
                    embed.add_field(name=i.name, value=i.description)
                self.bot.message.edit_message(embed=embed, view=self)```

this doesnt seem to add fields to the embed
potent spear
honest vessel
#

any errors?

#

or perhaps print select

#

from start

slate swan
potent spear
honest vessel
#

fuck debbuging

slate swan
#

oki

honest vessel
#

just do print(select)

#

or print(help(select))

#

@potent speardont u abuse print when coding?

#

i do

#

print("can u see me?!")

potent spear
honest vessel
#

same

#

😄 but noneed

#

aintworkingfor a corp

#

use this code on ur own risk

honest vessel
#

you khnowyour own childmy spaceisfuzzed

#

bye

royal jasper
#

i want the bot removes the reactions of a specific channel whenever someone tries to react in it... but this code are not working

@client.event
async def on_reaction_add(reaction, user):
    
    if user == client.user:
        return

    ticket = '📩'
    channel = reaction.message.channel
    canal = client.get_channel(948352556596351030)

    if reaction.emoji == ticket and channel == canal:
        await reaction.message.remove_reaction(ticket, reaction.message.author)
livid jacinth
#

!d status

unkempt canyonBOT
#

Rich can display a status message with a ‘spinner’ animation that won’t interfere with regular console output. Run the following command for a demo of this feature:

python -m rich.status
```  To display a status message, call [`status()`](https://rich.readthedocs.io/en/stable/reference/console.html#rich.console.Console.status "rich.console.Console.status") with the status message (which may be a string, Text, or other renderable). The result is a context manager which starts and stop the status display around a block of code. Here’s an example:

```py
with console.status("Working..."):
    do_work()
```  You can change the spinner animation via the `spinner` parameter...
potent spear
#
    if reaction.message.channel.id == 948352556596351030 and str(reaction.emoji) == ticket:
        await reaction.message.remove_reaction(ticket, reaction.message.author)```
left crater
potent spear
left crater
#

i was just suggesting something

livid jacinth
#

@echo lagoon do you know how i can trigger the event by an activity like playing a game or something?

slate swan
#

i fixed it anyways

modest plover
#

Can I use wait_for in Disnake more than once?

sick birch
#

Of course

modest plover
#

How?

#

I need it to wait for a message about 6 or 7 times for each config req

sick birch
#
await wait_for(...)
await wait_for(...)
```?
modest plover
#

Oh- ok ty

sick birch
#

say you have a list of questions, you can iterate through that and wait for a response

modest plover
#

How would I do that?

sick birch
#
questions = ["somethin", "something else", "something else too"]

for question in question:
  answer = await wait_for(...)
  # do something with answer
modest plover
#

The answers are getting saved to a db. Is there a way to make it go to the db within the loop?

sick birch
#

yeah the same way you might outside of a loop

modest plover
#

The way I'm doing it atm is

config.insert({
    "welcome": welcome,
    "announcements" : announcements
})

So each of the answers is saved to a variable

#

I've only tested this on a terminal

sick birch
#

You can substitute answer for that

potent spear
sick birch
#

That would work as well, probably would be faster too actually

modest plover
#

That's what I'm doing

#

So each embed has its own name, so welcomeEmbed sends the welcome config, announcementsEmbed sends the announcements config

sick birch
modest plover
potent spear
#

right xd

sick birch
#
questions [
  ("welcome", "Please mention the welcome channel"),
  ("annoucements", "Please mention the annoucements channel"),
]

data = {}

for column, question in questions:
  answer = await wait_for(...)
  data[column] = answer

config.insert(data)
dire folio
#

Does anyone have good host recommendations?

sick birch
#

Their EC2 instances are perfect for hosting bots

modest plover
#

Are the EC2 instances free?

potent spear
#

1 year free trial

sick birch
#

They have a free tier

potent spear
#

with some limits, I'm currently using one

sick birch
#

700 hours each month for 1 year on t2.micro instances

#

I'm using a full fledged one since I'm paying but it's awesome

#
  • I also have other hosting needs (domain with route 53, storage buckets with S3, and a little bit of machine learning)
#

it provides everything in one ecosystem

royal jasper
#

when i click on reaction, it don't disappear

livid jacinth
#

What do you mean?

potent spear
echo lagoon
#

Uhh there should be a user activity - I'm not at home so I'll get back to you on it later

modest plover
#

How do I make the bot wait for a channel to be sent?

livid jacinth
#

Okayy

sick birch
modest plover
#

Like for a message containing a #welcome for example

#

A channel
Which is sent

sick birch
#

You'd just have to wait for on_message

#

then use TextChannelConverter to see if it's valid

modest plover
#

What's TextChannelConverter

pliant gulch
#

You don't even need to do that, unless you want to convert more than just mentions into a text channel

#

Message has a channel_mentions attribute which is a list of channel objects that were mentioned in the message

sick birch
#

Yeah true

pliant gulch
#

!d discord.Message.channel_mentions

unkempt canyonBOT
sick birch
modest plover
#

Ah ok

sick birch
#

But doing what andy said is probably eaiser

#

And it's a list so just get the first one

modest plover
#
  @commands.slash_command()
    async def config(self, inter):
        """Presents the user with a config command"""
        welcomeConfig = disnake.Embed(
            title = "Welcome!",
            description = "Welcome to the config menu. Each of the menu option will give you 30 seconds to reply. Let's start with the welcome channel."
        ).add_field(
            name = "Welcome Channel",
            value = "Please state the welcome channel ([#welcome](/guild/267624335836053506/channel/267631170882240512/) for example)"
        )
        await inter.response.send_message(embed = welcomeConfig)
        await self.bot.wait_for()

Is this the right place for the wait for btw?

#

(it only says <#id> because there's a welcome channel here)

viral wolf
#

Where do you host discord bots?

potent spear
modest plover
#

Why not heroku?

viral wolf
sick birch
sick birch
viral wolf
#

What are some other good options other than aws

sick birch
#

Google cloud hosting

#

Microsoft Azure

viral wolf
#

Would it be possible to run it on a raspberry pi?

sick birch
#

I've done it for quite a bit before I got an ec2 instance

viral wolf
sick birch
#

Why wouldn't you?

#

A raspberry pi will only hold for so long

#

Not very scalable either

viral wolf
#

Right

sick birch
#

Plus I was also building a web app (dashboard) to go along with my bot and honestly I needed the other services, so it was easier to keep everything in one place

#

These days I just do stupid stuff with the raspberry pi

viral wolf
sick birch
#

It depends on how big your bot is

viral wolf
sick birch
#

That and how many guilds your bot is in, the size of those guilds

#

Just the general amount of stress you put on your bot

final iron
#

A raspberry pi has some advantages over a vps but a vps has some advantages over a raspberry pi

#

It all depends on your situation and needs I guess

sick birch
#

Yeah, it can be cheaper than hosts once you pay off the initial investment

#

Considering it's 8gb of ram it's pretty beefy for such a small thing

#

And if you're just running a discord bot on the internet and electricity bills are going to be pretty low for it

scarlet aurora
#

how much gb do i need to run a discord bot on a server

sick birch
#

1 is the bare minimum

scarlet aurora
#

ok

viral wolf
modest plover
final iron
modest plover
#

And the advantages of a vps over a pi?

manic wing
#

more power potentially

#

broadband and processing

#

you can also choose its location

modest plover
#

Ah

viral wolf
#

How do you test it and update it? Do you just have to use ssh?

manic wing
#

you could also make a pull and restart command in your bot for ease of access

#

its best to just write, test and commit your code locally so its easy to pull and rerun

viral wolf
#

Would it be able to run on the raspberry pi and locally at the same time?

manic wing
#

bots can be ran in multiple places

viral wolf
alpine furnace
manic wing
#

usage of git cli is recommended for sshing between servers

sick birch
echo lagoon
manic wing
sick birch
#

Depends on the model

echo lagoon
sick birch
#

I have the 4 which was ~120ish which equates to about a year for many hosts

alpine furnace
#

Lol

manic wing
#

cough image not having the 4b

#

ps that is a joke

alpine furnace
#

I was willing to go with a cheap host for the discord bot itself, and I have some pod autoscaler set up on k3s for the actual backend that does work

echo lagoon
alpine furnace
#

Cheap as in $10 per year. shit's great if you know where to look, on lowendbox

sick birch
modest plover
#

I asked earlier but forgot the message, I got sidetracked 🧍‍♂️
But yeah, for wait_for, what do I put as the event if I'm expecting a channel? (#welcome for example)

alpine furnace
#

@modest plover There's a check parameter in that wait_for

sick birch
echo lagoon
#

. - . think i payed like £50 for 2 of them, aint half bad

sick birch
#

You'd want to use .channel_mentions

modest plover
#

So what would that be?

alpine furnace
echo lagoon
#

i got too many pi's lying around in my house tbh -- im sure i had 3 pi 2's buried somewhere . _ .

alpine furnace
#

The ones that aren't slow af and outdated

sick birch
echo lagoon
alpine furnace
#

Really now

modest plover
#

Make a 16gb super-pi

echo lagoon
sick birch
alpine furnace
#

Don't think the team updated raspbian to 64 bit, cause I had some trouble with that stuff before

#

At least for one model of the 4

echo lagoon
# alpine furnace Really now

ye rasp pi foundation only recently officially released their 64bit rasp os or what ever they call it, it wasnt pushed due to stability etc until very recently -- had to go thru a weird download website otherwise (not on main page)

cold sonnet
#

stay stable

alpine furnace
#

Don't what

#

Like, the raspberry pi team, the people who manage raspbian

modest plover
cold sonnet
#

I hate downloading those newest stuff

modest plover
#

Sorry I'm sort of confused lmao

final iron
sick birch
final iron
#

!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.9)"). 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.9)") 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.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
sick birch
#

You need to use return len(message.channel_mentions) > 0 in your check

final iron
alpine furnace
sick birch
#

Do note that if you want the user to be able to specify the channel by name or ID, you have to use TextChannelConverter

alpine furnace
#

That was the check parameter I was talking about

sick birch
#

Checking message.channel_mentions **will only work if the user pings the channel explicitly **

echo lagoon
modest plover
sick birch
#

Correct

#

(by the way, what you're doing right now would be perfect for the new modals)

echo lagoon
#

rather just create utility functions for all those things, which will test for what seems like a channel ID etc and return them. . . they really streamline the code etc

alpine furnace
sick birch
#

That's exactly what TextChannelConverter does

echo lagoon
sick birch
#

d.py has a built in emoji converter too

alpine furnace
#

Converters are great

#

You could also make your own converters as in, you can subclass converter and pass it in as a type hint

echo lagoon
#

welp, guess i was reinventing the wheel,
tho mine is designed for my usecase, like getting all emotes from text, limiting amount gotten from each input type was something i wanted too (and no repeats)

sick birch
#

The cool thing is you can use d.py's built in converters in your own converters that makes things incredibly easy

echo lagoon
#

^ yes, stole a bit of regex from somewhere internal for emotes,

echo lagoon
#

yall dont just source dive?

sick birch
#

I do but really no point in recoding something that's already given to you in a nice format

alpine furnace
#

That docs page takes forever to load, I just jump to definition if I don't have it open kekw

sick birch
#

One thing I don't like about d.py, feels very weakly typed

alpine furnace
#

What do you mean

sick birch
#

What can I say I work with typescript mostly and it's all documented in the intellisense

echo lagoon
alpine furnace
#

Wonder how something like pyright handles dpy

echo lagoon
#

oh this ones kinda nice, wanted to grab emotes from views too

#

there is no escape from my get emote commands, it will grab from anywhere and everywhere . - .

final iron
#

It's like a mix between camelCase and snake_case

echo lagoon
#

ye, we dont question my 3am naming conventions
||for peace of mind, i have rectified that name||

final iron
#

Thank you

#

🙏

modest plover
modest plover
#

I'm gonna make it as a slash first just so I can see if I can get my other commands working then I'm gonna make it a modal

echo lagoon
modest plover
#

Lol

final iron
echo lagoon
thorn field
#

TypeError: 'module' object is not callable

#

can someone help?

modest plover
#

What's the code?

echo lagoon
#

not enough info, dunno the code nor what your using (dpy??)

thorn field
echo lagoon
modest plover
#

mhm

thorn field
#

the whole thing?

modest plover
#

The bit you're working on

thorn field
#

alr

echo lagoon
#

atleast the portion around the error

thorn field
#

@client.event
async def on_message_delete(message):
snipe_message_author[message.channel.id] = message.author
snipe_message_content[message.channel.id] = message.content
await sleep (60)
del snipe_message_author[message.channel.id]
del snipe_message_content[message.channel.id]

@client.commands()
async def snipe(ctx):
channel = ctx.channel
try:
snipeEmbed = discord.Embed(title=f"Last deleted message in#{channel.name}", description = snipe_message_content[channel.id])
snipeEmbed.set_footer(text=f"Deleted by {snipe_message_author[channel.id]}")
except:
await ctx.send(f"There are no deleted messages in#(channel.name)")

modest plover
#
import disnake
from disnake.ext import commands
from deta import Deta
import os
from dotenv import load_dotenv

load_dotenv()
project_key = os.environ["project_key"]

deta = Deta(project_key)
config_db = deta.Base("Config")

class Config(commands.Cog):
    """Saves a config to the Deta database."""

    def __init__(self, bot: commands.Bot):
    	self.bot = bot

    @commands.slash_command()
    async def config(self, inter):
        """Presents the user with a config command"""
        welcomeConfig = disnake.Embed(
            title = "Welcome!",
            description = "Welcome to the config menu. Each of the menu option will give you 30 seconds to reply. Let's start with the welcome channel."
        ).add_field(
            name = "Welcome Channel",
            value = "Please state the welcome channel ([#welcome](/guild/267624335836053506/channel/267631170882240512/) for example)"
        )
        await inter.response.send_message(embed = welcomeConfig)
        
        def welcomeCheck(message: disnake.Message):
        	return len(message.channel_mentions) > 0
        	
        print(welcomeCheck)
        await self.bot.wait_for("message", timeout=30.0, check=welcomeCheck)
        
        await inter.response.send_message(embed = welcomeConfig)

def setup(bot):
    bot.add_cog(Config(bot))
    print(" | Loaded Extension: Config")
    print(" | ")

It says the interaction was already responded to. How else am I supposed to send another embed?
I'm confused lmao

thorn field
#

im having trouble at @client.commands

echo lagoon
#

could you add syntax highlighting -- put in code block with

then end with tripple of them too
modest plover
#
@client.event
async def on_message_delete(message):
    snipe_message_author[message.channel.id] = message.author
    snipe_message_content[message.channel.id] = message.content
    await sleep (60)
    del snipe_message_author[message.channel.id]
    del snipe_message_content[message.channel.id]

@client.commands()
async def snipe(ctx):
    channel = ctx.channel
    try:
        snipeEmbed = discord.Embed(title=f"Last deleted message in#{channel.name}", description = snipe_message_content[channel.id])
        snipeEmbed.set_footer(text=f"Deleted by {snipe_message_author[channel.id]}")
    except:
        await ctx.send(f"There are no deleted messages in#(channel.name)")
``` @echo lagoon
echo lagoon
#

thx

#

wanted to teach them how to do it tho . - .

modest plover
#

I mean you told em how to ._.

thorn field
#

AttributeError: 'Client' object has no attribute 'command'

echo lagoon
#

yes, but you can only get so far teaching someone how to build a house, without them practically using the tools and doing it for themselves (apply same philosophy to this ; -;)

thorn field
#

ok

echo lagoon
thorn field
#

client = commands.Bot(command_prefix=":")

echo lagoon
#

right, i think it should be client.command() ;-;

(for the commands)

thorn field
#

then it will give me a diffrent error gimme a sec

viral wolf
#

How do I keep a .py file running in the background in ssh on a raspberry pi?

thorn field
echo lagoon
#

should look something like this

thorn field
#

then i get the same error for client object has no attribuite command

echo lagoon
#

which if you look internally, command_prefix is a must have param to instance the class

thorn field
#

yes\

echo lagoon
#

right gimme a sec, i wonna give this a try

final iron
#

discord.Client exists

thorn field
#

then it doesnt work entirely since apperntly client cant run commands

#

every said to change to command.Bot

final iron
#

I never said to use discord.Client

thorn field
#

k

boreal ravine
#

otherwise you gotta defer the interaction

modest plover
#

I fixed it, it's fine

#

Well, the Disnake server fixed it lmao

#

I used inter.channel.send() rather than a second respond.send_message()

#

I mean it worked :)

boreal ravine
thorn field
#

i fixed the thing

thorn field
echo lagoon
thorn field
#

yes

#

ty for your help

echo lagoon
#

weird, mine dont work lol, dunno what i done

modest plover
#

How do I save a user's message to a variable?

final iron
#

That's basic python...

boreal ravine
modest plover
#

It's #welcome that j want to set to a variable

echo lagoon
modest plover
#

It's a slash so ctx isn't available

echo lagoon
#

interaction?

modest plover
#

Wait fuck my brains just had a moment. Sorry lmao

boreal ravine
echo lagoon
#

welp, not used slash so i dunno, dont like slash so im not willing to find out

boreal ravine
#

should not make slash commands if your bot isn't gonnna be verified tbh

modest plover
echo lagoon
#

say that again when you have /play and 5 different bots come up

boreal ravine
modest plover
#

Plus. You're saying /play brings 5 bots up, !play does the same

echo lagoon
modest plover
#

Except !play actually executes the commajd

echo lagoon
modest plover
#

well yeah but most prefixes are taken

echo lagoon
#

you can change prefix for most bots tho

modest plover
#

you genuinely think I'm gonna make a prefix of !?!?.play and expect people to remember it?
Most. But not all.

echo lagoon
#

mhm, mine uses !!! -- non configurable atm, no other bot uses it in my guild

boreal ravine
#

or use <, %, ~, *,

echo lagoon
#

^ theres all those options too

thorn field
#

@client.event
async def on_message_delete(message):
snipe_message_author[message.channel.id] = message.author
snipe_message_content[message.channel.id] = message.content
await sleep(60)
del snipe_message_author[message.channel.id]
del snipe_message_content[message.channel.id]

@client.command()
async def snipe(ctx):
channel = ctx.channel
try:
snipeEmbed = discord.Embed(title=f"Last deleted message in#{channel.name}", description=snipe_message_content[channel.id])
snipeEmbed.set_footer(text=f"Deleted by {snipe_message_author[channel.id]}")
except:
await ctx.send(f"There are no deleted messages in#(channel.name)")

now its no t working at all

#

its starting but the command is broken

echo lagoon
thorn field
#

ye

echo lagoon
#

try help command?

#

see if it shows up there. .

thorn field
#

well all the commands are working except the snipe one

#

!8ball is working

echo lagoon
thorn field
#

wdym in the console?

echo lagoon
#

assuming your prefix is !

thorn field
#

i dont have a help menu

tepid tiger
#

hi guys, can i ask a question about discord bot ?