#discord-bots

1 messages Ā· Page 31 of 1

crystal glen
#

I wanna see what I can use

#

Where can I see it?

crystal glen
#

ty

glossy flame
#

did not work

crystal glen
#

Is there a way to check if someone is server muted?

silk fulcrum
silk fulcrum
crystal glen
glossy flame
#

hold on

silk fulcrum
unkempt canyonBOT
silk fulcrum
#

!d discord.VoiceState.mute

unkempt canyonBOT
crystal glen
silk fulcrum
glossy flame
crystal glen
#

I need something to check if someone is server muted by me

#

And if Someone tries to unmute them, Mute them instantly

silk fulcrum
# glossy flame

i guess message was edited in DMs cus that member doesn't exist, probably try fetching it, maybe that'll somehow help (user = await after.guild.fetch_member(after.author.id))

glossy flame
glad cradle
#

yes

silk fulcrum
# crystal glen I need a client event

on_member_update event will check if member is updated including VoiceState, check if before.voice != after.voice to make sure that VoiceState was edited, then check if before.voice is not None and after.voice is not None to not get into any errors and after that check if before.voice.mute == False and after.voice.mute == True. Checking if you muted the member is... um.. a bit of a cluster fuck, but to do so you need to get the last element of audit logs and check if augit_log_entry.user.id == your_id, then you do what you want

#

in case you didn't understand anything: I can't explain further

mossy jacinth
#

How is it possible to do this?

full lily
lament depotBOT
#
Command Help

**```
.epoch [date_time]

*Convert an entered date/time string to the equivalent epoch.

**Relative time**
    Must begin with `in...` or end with `...ago`.
    Accepted units: "seconds", "minutes", "hours", "days", "weeks", "months", "years".
    eg `.epoch in a month 4 days and 2 hours`

**Absolute time**
    eg `.epoch 2022/6/15 16:43 -04:00`
    Absolute times must be entered in descending orders of magnitude.
    If AM or PM is left unspecified, the 24-hour clock is assumed.
    Timezones are optional, and will default to UTC. The following timezone formats are accepted:
        Z (UTC)
        ±HH:MM
        ±HHMM
        ±HH

Times in the dropdown are shown in UTC*
silk fulcrum
full lily
#

.epoch in 14 hours

lament depotBOT
#

Date and time parsed as: Fri, 12 Aug 2022 11:07:32 +0000

#

<t:1660302452:R>

full lily
#

<t:1660302452:R>

#

I know the author of that command

silk fulcrum
unkempt canyonBOT
#

The timestamp of the embed content. This is an aware datetime. If a naive datetime is passed, it is converted to an aware datetime with the local timezone.

full lily
#

^^

slate swan
#

I have an embed which has select menu on it and i made add_item with class but why every time i change the code to fix error and restart the bot, i should type the command again so the bot to generate new embed with menu? And the previous menu i generated is not working anymore

silk fulcrum
slate swan
glossy flame
#

@silk fulcrum i fixed it

#

I used before.author instead of after.author and for some reason it worked

silk fulcrum
slate swan
#

Do i have to make a class with add_item?

silk fulcrum
#

idk? just make a view?

slate swan
#

I removed the add_item class but i got error

#

TypeError: expected an instance of View not <class 'cogs.auto_roles.menu'>

last shuttle
#

how can i fetch a channel and post a message in a non-async function?

silk fulcrum
#

idk what "add_item class" means

slate swan
#
class selectmenu(discord.ui.View):
    def __init__(self):
        super().__init__()
        self.add_item(menu())``` šŸ˜„
sick birch
#

Looks like you might have a naming conflict

last shuttle
slate swan
silk fulcrum
last shuttle
sick birch
last shuttle
#

how

mossy jacinth
#

Hey! I just found out, if a server doesnt have a server profile my bot spits a error... How can i make it that if the server has no profile it just disables the embed.set_thumbnail...?

silk fulcrum
#

that's if you use dpy 2.0

austere vale
#

i have the server moderation set for that, i just want the role to be assigned to them after the 10 minutes because if i assign it beforehand, then it bypasses the server moderation

last shuttle
#

how do i send a message/embed via the api not dpy

crystal glen
crystal glen
#
@client.event
async def on_member_update(before, after, member):
    if before.voice != after.voice:
        if before.voice != None:
            if before.voice.mute == True and after.voice.mute == False:
                await member.server.mute(member)

slate swan
#

never use server

#

use guild

crystal glen
#

I just want to show what I want

slate swan
#

let me see

crystal glen
silk fulcrum
#

aight I wasted like 5 mins but my message seemed rude so I decided to delete it and type this:
get server's audit logs, get it's last entry by augit_logs[0] and check if audit_entry.user.id == ur_id

slate swan
#

would guild.mute work?

crystal glen
#

wtf is augit_logs[0]

slate swan
#

*audit

silk fulcrum
crystal glen
#

BRUH

silk fulcrum
#

!d discord.Guild.audit_logs

unkempt canyonBOT
#

async for ... in audit_logs(*, limit=100, before=..., after=..., oldest_first=..., user=..., action=...)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the guild’s audit logs.

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

Examples

Getting the first 100 entries:

```py
async for entry in guild.audit_logs(limit=100):
    print(f'{entry.user} did {entry.action} to {entry.target}')
```...
silk fulcrum
slate swan
#

@silk fulcrum i need your help but i'll let you finish first with Jason Statham

silk fulcrum
#

it's member.mute()

slate swan
#

Ok

slate swan
#

So

silk fulcrum
#

bruh that bug on my screen is annoying

crystal glen
#
@client.event
async def on_member_update(before, after, member):
    
    if before.voice != after.voice:
        if before.voice != None:
            if before.voice.mute == True and after.voice.mute == False:
                await member.mute()

What would this do?

slate swan
#

just test it

silk fulcrum
#

you either use after or before, they're both Member type

crystal glen
#

How do I mute the member then?

crystal glen
#

HOW DO I AWAIT IT THEN

slate swan
#

before.mute

#

or after

silk fulcrum
#

AWAIT AFTER.MUTE()

slate swan
#

thats what i was going to say

crystal glen
#

HOW DO I TYPE THAT IN VISUAL STUDIO?

slate swan
#

šŸ¤¦ā€ā™‚ļø

silk fulcrum
#

LIKE NORMAL TEXT?

slate swan
#

with keyboard

crystal glen
#

jk jk

silk fulcrum
#

ohhh my cat is so cute))

slate swan
#

Can i say now my problems master?

silk fulcrum
#

yes I guess

slate swan
#

ok

silk fulcrum
#

rapgodmaster32 not defined

slate swan
#

sit tight šŸ˜‚

crystal glen
#

It doesn't work

#
@client.event
async def on_member_update(before, after):
    
    if before.voice != after.voice:
        if before.voice != None:
            if before.voice.mute == False and after.voice.mute == True:
                await after.mute()
slate swan
crystal glen
#

IF THE MEMBER IS ALREADY MUTED, AND SOMEONE TRIES TO UNMUTE, THEN MUTE THEM AGAIN

#

WHY IS IT SO HARD TO DO IT?

slate swan
#

Just use if statements

sick birch
#

Please stop shouting

crystal glen
#

jk

slate swan
#

work with if statements and else

sick birch
#

Just be respectful of other members

silk fulcrum
cold sonnet
#

don't check if before != after

#

that already means the guy switched channels

#

and that has nothing to do with mutes

slate swan
#

this is endless, i need help, can someone dm me?

silk fulcrum
#

shy?

slate swan
silk fulcrum
#

i am blind sorry

cold sonnet
#

feelin ignored

slate swan
silk fulcrum
cold sonnet
#

not sure about the last if

#

it doesn't really make sense

silk fulcrum
#

why doesn't it?

cold sonnet
#

before.voice and after.voice are voice channels

#

a voice channel can't be on mute, just the guy

slate swan
#

I have embed with menu for auto roles. The max_values is equal to 7 => max_values=7. I want when I select for example 3 roles, the bot to make 3 separate replies that i got role1, role2 and role3. But my code doesnt work like that. The way my code works is when i select 2 roles, it only adds the first role and it replies only for the first role

silk fulcrum
cold sonnet
#

that changes my view...

slate swan
#

something like this

slate swan
crystal glen
silk fulcrum
silk fulcrum
crystal glen
cold sonnet
#

!d discord.VoiceState

unkempt canyonBOT
#

class discord.VoiceState```
Represents a Discord user’s voice state.
silk fulcrum
#

so, what are you doing to get this to work? muting some member in a voice channel and then unmuting him? @crystal glen

crystal glen
#

If someone is already muted, And someone tries to unmute them, Mute them again

#

Simple

slate swan
#

dude

#

just work with if statements

silk fulcrum
cursive barn
crystal glen
cursive barn
#

your statements evaluate now, to if the user was not muted before and now they are, to mute them

crystal glen
cursive barn
#
if before.voice.mute and not after.voice.mute:
  await after.mute()
silk fulcrum
cold sonnet
#

ok I don't see a mute attribute on member

crystal glen
#
@client.event
async def on_member_update(before, after):
    
    if before.voice != after.voice:
        if before.voice != None:
            if before.voice.mute == True and after.voice.mute == False:
                await after.mute()

Current code

cold sonnet
#

it should be
await member.edit(mute=True)

crystal glen
#

changed to ```py
@client.event
async def on_member_update(before, after):

if before.voice != after.voice:
    if before.voice != None:
        if before.voice.mute and not after.voice.mute:
            await after.mute()
silk fulcrum
crystal glen
#

bro...

cursive barn
#

also I do not see where the .mute() function exists, only the attribute. Have you subclassed the discord.Member class somehow

crystal glen
#

You know what?

cold sonnet
#

a method is also an attribute

crystal glen
#

Fuck this, Thanks for the help

cold sonnet
#

callable one

cold sonnet
crystal glen
cold sonnet
#

have you tried what I said

crystal glen
#

No

cold sonnet
#

try it

silk fulcrum
#

oh, sounds so tragic, but... alright i've already been too rude ig

crystal glen
#
@client.event
async def on_member_update(before, after):
    
    if before.voice != after.voice:
        if before.voice != None:
            if before.voice.mute and not after.voice.mute:
                await member.edit(mute=True)
cold sonnet
#

yes

#

!d discord.Member.edit

unkempt canyonBOT
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timed_out_until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the member’s data.

Depending on the parameter passed, this requires different permissions listed below...
silk fulcrum
#

after 😭

crystal glen
#

HE SAID TO USE HIS SHIT

cold sonnet
#

well

crystal glen
#
@client.event
async def on_member_update(before, after):
    
    if before.voice != after.voice:
        if before.voice != None:
            if before.voice.mute and not after.voice.mute:
                await after.edit(mute=True)
silk fulcrum
#

DONT YOU SEE THAT YOU DO NOT GET MEMBER FROM ANYWHERE SO YOU SHOULD USE SOMETHING THAT IS INSTANCE OF IT?

cold sonnet
#

now everyone's shouting

crystal glen
cold sonnet
#

I'm getting a headache

crystal glen
crystal glen
cold sonnet
#

I am cool šŸ˜Ž

silk fulcrum
crystal glen
cold sonnet
#

I'm used to disnake aswell k

crystal glen
#

Okay

#

@client.event
async def on_member_update(before, after):
    
    if before.voice != after.voice:
        if before.voice != None:
            if before.voice.mute and not after.voice.mute:
                await after.edit(mute=True)```
#

good?????????????

cold sonnet
#

yes

silk fulcrum
crystal glen
#

STOP TALKING jk

cold sonnet
#

you're right, ArasoOsara stop shouting

#

I'm not wasting my last aspirin on you

silk fulcrum
cold sonnet
#

now you're joking

crystal glen
silk fulcrum
#

oh wait he's not here(

crystal glen
#

is he dead?

silk fulcrum
crystal glen
cold sonnet
#

you had no error even before

crystal glen
#

yes

#

Let me use some try and except

cold sonnet
#
  1. you have an error handler and it sucks
  2. code doesn't get past the if statements
#

how about some else statements

crystal glen
mossy jacinth
#

why does it not send this? but gives me the error again?

silk fulcrum
unkempt canyonBOT
#

8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.

cold sonnet
#
@client.event
async def on_member_update(before, after):
    
    if before.voice != after.voice:
        if before.voice != None:
            if before.voice.mute and not after.voice.mute:
                await after.edit(mute=True)
        else:
            print("messed up at 2")ā€Š
    else:
        print("messed up at 1") 
crystal glen
cold sonnet
#

like this

crystal glen
#

The code doesn't even work anymore

cold sonnet
#

where is this?

cursive barn
#

well it does tell you where the problems are occurring so maybe start there @crystal glen

however, I would wish you luck if you keep yelling at everyone trying to offer you assistance šŸ™‚

crystal glen
crystal glen
#

And he was the first one who shout at me, Right @silk fulcrum šŸ”Ŗ

cold sonnet
crystal glen
cursive barn
# mossy jacinth

because you have the @commands.is_owner decorator, it looks like you will be getting that flag first no matter what.

you can try to omit that line and just use your try/except or you could use an error handler

cold sonnet
# mossy jacinth

you don't check for the error there, you check for it in an error handler
if your bot is not the owner, the code doesn't start

silk fulcrum
cursive barn
#

however, because your try would succeed, it means the except would never flag and certainly not for a NotOwner exception

cold sonnet
#

!d discord.Member.voice

unkempt canyonBOT
crystal glen
daring olive
#

hello

#

why the shouting

crystal glen
#

why are you here, we were having fun

daring olive
#

please don't, then.

crystal glen
daring olive
#

i'm a member here too?

crystal glen
#

im getting muted?

crystal glen
#

that means you're a special member

crystal glen
# cold sonnet check `if before.voice == after.voice`

like this?

@client.event
async def on_member_update(before, after):
    
    if before.voice == after.voice:
        if before.voice != None:
            if before.voice.mute and not after.voice.mute:
                await after.edit(mute=True)
        else:
            print("messed up at 2")
    else:
        print("messed up at 1") 
cold sonnet
cold sonnet
#

what

limber bison
#

If ctx.guild.get_role(id) in ctx.aothor.roles

Any better option and what's maping ?

cursive barn
crystal glen
cold sonnet
#

not in docs so I don't know, I'm gonna look at src code once

silk fulcrum
limber bison
crystal glen
#

maping = maping

silk fulcrum
crystal glen
limber bison
#

Any link so I can read more about it

cold sonnet
#

a class like VoiceState should have defined operations, people don't know if it's checking if all attributes are the same, or just the channels

crystal glen
cold sonnet
#

no you should add an else statement for the 3rd if

#

and then you should tell if you have a horrible error handler

silk fulcrum
#

that's mapping in general

crystal glen
#
@client.event
async def on_member_update(before, after):
    
    if before.voice == after.voice:
        if before.voice != None:
            if before.voice.mute and not after.voice.mute:
                await after.edit(mute=True)
            else:
                print("No change")
        else:
            print("messed up at 2")
    else:
        print("messed up at 1") 

```2
cold sonnet
#

yes

crystal glen
#

Fucking hell it messed up at 2

#

AND I DIDN'T see it

cold sonnet
#

how did you get that result before on_ready launched

#

anyway

crystal glen
cold sonnet
#

before.voice is None

crystal glen
cold sonnet
#

indeed interesting

crystal glen
#

ikr

#

I'm testing it on SaN, He is my monkey for today

limber bison
#

Ohh there is map function too ok got it

#

Thanksssss

crystal glen
#

ur wlc

crystal glen
#

Or there is hope?

cold sonnet
#

(╯°▔°)╯︵ ┻━┻

crystal glen
#

(╯°▔°)╯︵ ┻━┻

limber bison
#

Custom Help command is complicated

crystal glen
#

yes

limber bison
#

😳

cold sonnet
#

do you need presence intents for this

#

do you have those

crystal glen
#
client = commands.Bot(command_prefix=['?'], intents=discord.Intents.all(), case_insensitive=True, owner_id=982551216196317214)

deep osprey
#
    elif ctx.channel.id != 1005827207815495791 or ctx.channel.id != 1007113905178427482:
        await ctx.reply("")``` is this the correct way to check the channel id?
crystal glen
#

guild.channel probably

cold sonnet
#

yes, if you want to check if the message was not written in those channels

cold sonnet
silk fulcrum
cold sonnet
#

stop swear

crystal glen
cursive barn
#

it looks like you will have to compare individual attributes of VoiceState because the TypedDict operations are a bit tricky sometimes to quote the python docs: ```A TypedDict type A with no key 'x' is not consistent with a TypedDict type with a non-required key 'x', since at runtime the key 'x' could be present and have an incompatible type (which may not be visible through A due to structural subtyping).

cold sonnet
crystal glen
#

one more thing...

#

BYE

cold sonnet
#

BYE

daring olive
hot matrix
#

How do I access the ScheduledEvent ID inside of the scheduled_events list?

[<ScheduledEvent id=123Numbers name= NAME >] ---> It is a list with angled brackets <> so I cant access it with [0] it seems (because [0] gives me the name instead of the ID)

last shuttle
#

how can i send a message without dpy but with the actual discord api

hot matrix
glad cradle
#

check out the official discord api docs

somber garnet
#

How do I make like a login system that will immediately be able to let the user execute the commands and get his/her htb details without having to execute the same $htbacc command again&again


#

Like it will give that user, private session with the credentials he provided

novel kelp
#

How can i change 603 seconds into 10.3 minutes

cloud dawn
#

What do you mean by login in again and again? After x amount of time or when the bot restarts?

silk fulcrum
novel kelp
#

!e


time = timedelta(seconds=603)
print(time.minute)ā€Š```
unkempt canyonBOT
#

@novel kelp :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 4, in <module>
003 | AttributeError: 'datetime.timedelta' object has no attribute 'minute'
somber garnet
#
@bot.command()
async def htbacc(ctx,email,passw):
    login = htbfunc.Client(email,passw)
@bot.command()
async def htbsearch(user):
    login.search(user)
novel kelp
#

!e
from datetime import timedelta

time = timedelta(seconds=603)
print(time.minutes)

somber garnet
unkempt canyonBOT
#

@novel kelp :white_check_mark: Your 3.11 eval job has completed with return code 0.

0:10:03
cloud dawn
#

!e ```py
from datetime import timedelta

time = timedelta(seconds=603)
print(str(time))

unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your 3.11 eval job has completed with return code 0.

0:10:03
somber garnet
#

is it possible to use another variable in an asynchronous function?

cloud dawn
glad cradle
#

use a variable in a function defined in another function?

cloud dawn
glad cradle
cloud dawn
#

!e print(603/60)

unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your 3.11 eval job has completed with return code 0.

10.05
novel kelp
cloud dawn
glad cradle
cloud dawn
#

!global

unkempt canyonBOT
#

When adding functions or classes to a program, it can be tempting to reference inaccessible variables by declaring them as global. Doing this can result in code that is harder to read, debug and test. Instead of using globals, pass variables or objects as parameters and receive return values.

Instead of writing

def update_score():
    global score, roll
    score = score + roll
update_score()

do this instead

def update_score(score, roll):
    return score + roll
score = update_score(score, roll)

For in-depth explanations on why global variables are bad news in a variety of situations, see this Stack Overflow answer.

glad cradle
#

it's not a good practice but i can't think of other ways

glad cradle
novel kelp
#

!e
from datetime import timedelta

time = timedelta(seconds=603)
print(time.days)

cloud dawn
#

603 sec is 10.05 minutes.

unkempt canyonBOT
#

@novel kelp :white_check_mark: Your 3.11 eval job has completed with return code 0.

0
novel kelp
#

!e
from datetime import timedelta

time = timedelta(seconds=603)
print(time.seconds / 60)

cloud dawn
novel kelp
#

F

unkempt canyonBOT
#

@novel kelp :white_check_mark: Your 3.11 eval job has completed with return code 0.

-999999999 days, 0:00:00
novel kelp
#

!e
from datetime import timedelta

time = timedelta(seconds=603)
print(time.hours)

unkempt canyonBOT
#

@novel kelp :white_check_mark: Your 3.11 eval job has completed with return code 0.

10.05
novel kelp
#

!e
from datetime import timedelta

time = timedelta(seconds=603)
print(time.hours)

unkempt canyonBOT
#

@novel kelp :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 4, in <module>
003 | AttributeError: 'datetime.timedelta' object has no attribute 'hours'
cloud dawn
#

!e ```py
def sec_to_min(seconds) -> str:
return f".".join([f"0{x}" if i == 1 and x < 10 else str(x) for i, x in enumerate(divmod(seconds, 60))])

print(sec_to_min(603))

unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your 3.11 eval job has completed with return code 0.

10.03
cloud dawn
#

So they would be able to write their own python inside a command?

#

Kind of like a saved eval command?

rugged shadow
#

yikes

novel kelp
#

#bot-commands

slate swan
#

hello im using nextcord and i want it that if u click buttons they become disabled

#

i tried using callback

golden tapir
#

WHAT DOES THIS MEAN

#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: coroutine raised StopIteration

slate swan
#

What code?

#

@golden tapir

golden tapir
#

nvm

slate swan
#

Ah

slate swan
#

how long does a discord rate limit last?

slate swan
#

nvm im not really qualified to help anyone

slate swan
vale wing
slate swan
#

how do i use intents without commands 😐

#

how do i specify intents for bot = discord.Client()

#

read thy documents

#

I saw people naming commands.Bot as client but .Client as bot prayge

#

lmao

#

homie following the outdated YouTube tutorial

#

i dont want commands in my bot

slate swan
silk fulcrum
slate swan
#

you would do discord.Client(intents=intents_instance)

#

thank you

#

you're welcome!

slate swan
silk fulcrum
#

:redTick: lmao

slate swan
#

:kek:

silk fulcrum
#

:XD:

maiden fable
#

:ot_talks:

silk fulcrum
#

:moyai:

slate swan
swift pumice
#

:redTick:

slate swan
#

i cant find anything that actually changes nickname the changenick checks if a person can change it

unkempt canyonBOT
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., timed_out_until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the member’s data.

Depending on the parameter passed, this requires different permissions listed below...
slate swan
#

imagine having a kwarg named as nick instead of nickname dogepray

#

imagine talking about naming conventions

pliant gulch
#

Probably called just nick instead of nickname because in the discord API the guild member object has a nick field, not a nickname one

slate swan
#

it has admin

silk fulcrum
slate swan
#

theres literally no roles

slate swan
#

hmm it cant have admin if it has anything else 😐

#

omg it was tryna nick me when im owner im stupid

vale wing
#

Happens

tired fern
#

I keep getting this error when i start up the music bot

#

It started to happen out of no where. This bot has been up and running for 3 days and just started happening

slate swan
tired fern
slate swan
#

no worriesšŸ˜…

tired fern
slate swan
#

Its ok, good luck solving your error!

glad cradle
#

okimi

slate swan
slate swan
#

instead of fixing my grammar why dont you fix the persons error? dont you know JS?

glad cradle
#

she's too pythonic to be fluent with JS

slate swan
#

skill issue

slate swan
silk fulcrum
#

@slate swan nice pfp lemon_hearteyes

slate swan
silk fulcrum
#

maybe i need to

slate swan
slate swan
silk fulcrum
#

why not

slate swan
#

your cat makes my day better

silk fulcrum
#

:))

#

i have more than 1 photo of my cat

slate swan
#

his mad look makes me less mad

silk fulcrum
#

lmao

slate swan
slate swan
#

😳

slate swan
glad cradle
slate swan
#

nice

glad cradle
slate swan
silk fulcrum
#

wtf why did this ss appear

silk fulcrum
slate swan
mossy jacinth
#

does someone know why this doesn't show up? I already put it there like 3 days ago

hallow kernel
#

how to make that if user not sent message in 10 seconds, bot will send "time is up"?

silk fulcrum
#

you just wait_for message

#

and set timeout to 10 secs

#

and except TimeoutError: send "time is up"

#

else: continue

placid skiff
hallow kernel
#

this is perfect, thank you

dapper cobalt
#

Is the cog called onlin?

#

I'm pretty sure you're making a typo.

#

Read the error

#

You're trying to start cogs.onlin

silk fulcrum
#

[:-4]
onlin|e.py

dapper cobalt
#

You're removing the last letter I believe

silk fulcrum
#

in code it's -3 which is correct

#

but errors says -4

#

lmao

#

from file name

#

you're listing all the files in /cogs to load them and to remove .py you somehow use [:-4], which removes .py and one more symbol behind it

#

yes, as I see in code that's what you do but error says -4

#

šŸ‘ļø

hallow kernel
#

it prints "bot ready" and then i send message in server with this bot, but it doesnt continue

silk fulcrum
hallow kernel
silk fulcrum
#

also it's wait_for 'message', on_message is an event reference

hallow kernel
#

ty

stable mulch
rugged shadow
#

Try :-2 then :p

#

this is messed up

#

can you send a screenshot on how your project files are named?

#

hmmmmmmm

#

you know what

#

try doing f'cogs.{fn.replace(".py", "")}' instead

#

eugh

#

you made a typo somewhere

#

try refreshing your replit tab

slate swan
#

how to get user and tag ?

#

kill 1

#

in shell

#

o idk

#

just add try except:pass

#

You have to enable applications through the portal

#

You have to add @commands.has_permissions underneath your command

swift pumice
vale wing
#

Let it sync ig

#

How long have you waited

#

Also try listing all commands and seeing if the bot has it

#

!d discord.ext.commands.Bot.commands or smth

unkempt canyonBOT
slate swan
#

!rule 9

unkempt canyonBOT
#

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

fierce locust
#

o my bad

#

@slate swan any platform where i can do that?

slate swan
#

below the @zenith sage.slash_command

rain olive
#

"theory" is not the word to describe, typehints

torn sail
#

i think what okimmi means is that they are not meant to do anything during runtime

rain olive
#

yes

maiden fable
red fiber
#
  File "C:\Users\Windows\Desktop\Nova pasta\xdxd.py", line 1, in <module>
    import discord
  File "C:\Users\Windows\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py", line 25, in <module>
    from .client import Client
  File "C:\Users\Windows\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 53, in <module>
    from .webhook import Webhook
  File "C:\Users\Windows\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\__init__.py", line 12, in <module>
    from .async_ import *
  File "C:\Users\Windows\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 52, in <module>
    from ..channel import PartialMessageable
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (C:\Users\Windows\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\channel.py)

error, its running another files

#

my code its just import discord

vocal snow
mental hollow
#

I forgot how to make custom command errors? Do I use this:

@ban.error
async def on_command_error(self, ctx, error):
   if instance(error, commands.CommandOnCooldown):
        await ctx.send("my error message")
unkempt canyonBOT
#

Hey @red fiber!

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

red fiber
red fiber
mental hollow
vocal snow
#

yes

mental hollow
#

ty

robust fulcrum
#

Is there any event in dpy which triggers when the bot stops?

slate swan
#

how will the code trigger when the bot stopped

torn sail
robust fulcrum
#

Or get rate limited

torn sail
#

!d discord.on_disconnect

unkempt canyonBOT
#

discord.on_disconnect()```
Called when the client has disconnected from Discord, or a connection attempt to Discord has failed. This could happen either through the internet being disconnected, explicit calls to close, or Discord terminating the connection one way or the other.

This function can be called many times without a corresponding [`on_connect()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_connect "discord.on_connect") call.
torn sail
#

This?

robust fulcrum
#

Will it be triggered when bot gets disconnected?

torn sail
#

Probably

robust fulcrum
red fiber
#

from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)

torn sail
slate swan
mental hollow
mental hollow
#

Can I not make it command specific?

mental hollow
# vocal snow why would you do that?

Both my errors are being sent. The embed is from my error handler (in another cog - events.py) and the normal text is from my @revive.error decorator.

vocal snow
#

ah ok i see what you're saying

mental hollow
#

Yeah.

vocal snow
#

does it need to be global?

mental hollow
#

It handles all my command errors. I just want to make it so I can override them and send custom errors for different commands instead of always relying on my global command error handler.

vocal snow
#

if not, I'd suggest making that cog-specific or command specific. If it does, you'll need to add some logic to ignore exceptions coming from commands which have error handlers

#

!d discord.ext.commands.Command.has_error_handler

unkempt canyonBOT
vocal snow
#

ashley typing fcking lord of the rings

slate swan
#

you can create error events for specific commands like so

@commands.command()
async def cmd(self, ctx): ...

@cmd.error
async def cmd_error(self, ctx, error): ...
# in the global error handler
if ctx.command.has_error_handler(): pass

I am a slow typer on phone zeffo

visual latch
#

Hi how do i start programming discord bots
I already have the discord bot setup but i dont know how to programme it šŸ™‚

visual latch
#

kinda (still working on making an objet move 😦

kindred kernel
#

im banned from dpy server on @silk fulcrum, that's pretty annoyin

vocal snow
#

that message needs to be pinned here

limber bison
#

'NoneType' object has no attribute 'url' // like user have defult pfp

#

discord defult

vocal snow
unkempt canyonBOT
#

property display_avatar```
Returns the user’s display avatar.

For regular users this is just their default avatar or uploaded avatar.

New in version 2.0.
limber bison
#

i have to use it in embed !!!

vocal snow
#

the documentation is there for you to read

cloud dawn
# kindred kernel

This is more in the context of, "How much Python you need to know until you can ask a question here".

kindred kernel
#

spamming mentions of myself account...

cloud dawn
#

It's called spam because that's their ot not literally a spam channel.

kindred kernel
#

it's cus i didnt read RoboDanny's source code and didnt see mentions autoBAN

cloud dawn
#

Just ask one of the mods to unban you and explain the situation.

sick birch
#

It’s sort of gatekeepy and we all know the culture in the discord.py server isn’t the greatest

#

The first pinned message in this channel is our stance on it

vocal snow
#

How is it gatekeepy, learning the stuff you're going to need beforehand just accelerates the process

#

It's up to the individual whether they want to do it or not

hushed galleon
#

his message plainly says, "certain knowledge is required before you can actively participate in the help channels"

silk fulcrum
#

view=View, view=view

#

think about it

#

2 views in one message is not possible, especially double using a kwarg

vocal snow
#

Another example of how much time can be saved by simply understanding of how things work before using them 🤷

slate swan
vocal snow
#

Read the prior messages

slate swan
#

I meant something else by that but okay

vocal snow
#

Oh okay i understand what you meant

hushed galleon
slate swan
#

MySelect is most probably a ui.Select subclass and is NOT a view but a component, so you have to add the component to the view View.add_item to be able to send the dropdown

vocal snow
silk fulcrum
#

sucuk=View 😭 wth is even that kwarg

slate swan
#

custom kwarg?

vocal snow
#

May I ask why

silk fulcrum
#

@vocal snow I edited it a little bit, is it good enough? Because, if I just send this message here I might seem rude to someone

vocal snow
#

I think just keep the part which lists the recommended prerequisite knowledge

vale wing
mental hollow
#
/home/container/main.py:41: DeprecationWarning: The object should be created from async function
  self.session = aiohttp.ClientSession()

I have this error always come up on my console when I run my bot. I’ve tried to put self.session = aiohttp.ClientSession() in a setup_hook but that doesn’t work, when I try to use self.session because it would say it’s not defined.

torn sail
#

well you can only use the session after the bot has been started

#

because only then will there be an event looop

#

so you should define it in the setup_hook

slate swan
#
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'``` Why it give me this error
#

@bot.command() async def user(ctx,member: discord.Member): roles = [role for role in member.roles] embed = discord.Embed(colour=member.color,timestamp=ctx.message.created_at) embed.set_author(name=f'User Info - {member}') embed.set_thumbnail(url=member.avatar_url) embed.set_footer(text=f'Asked by{ctx.author}',icon_url = ctx.author.avatar_url) embed.add_field(name=id,value=member.id) embed.add_field(name='Guild name:',value = member.display_name) embed.add_field(name='Created at:',value = member.created_at.strftime('%a, %#d %B %Y')) embed.add_field(name='Joined at:',value = member.joined_at.strftime('%a, %#d %B %Y')) embed.add_field(name=f'roles ({len(roles)}',value=''.join([role.mention for role in roles])) embed.add_field(name='Top role:',value = member.top_role.mention) embed.add_field(name='Bot?',value = member.bot) await ctx.send(embed=embed)

torn sail
mental hollow
slate swan
#

LOl

slate swan
torn sail
#

embed.set_footer(text=f'Asked by{ctx.author}',icon_url = ctx.author.avatar_url)

slate swan
#

embed.set_footer(text=f'Asked by{ctx.author}',icon_url = ctx.author.avatar.url)

torn sail
#

embed.set_thumbnail(url=member.avatar_url)

slate swan
#

Ok

torn sail
#

yes

slate swan
#
    await ctx.command.invoke(ctx)
  File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 990, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 204, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' 
object has no attribute 'avatar_url'```
#

again

#

@bot.command() async def user(ctx,member: discord.Member): roles = [role for role in member.roles] embed = discord.Embed(colour=member.color,timestamp=ctx.message.created_at) embed.set_author(name=f'User Info - {member}') embed.set_thumbnail(url=member.avatar_url) embed.set_footer(text=f'Asked by{ctx.author}',icon_url = ctx.author.avatar.url) embed.add_field(name=id,value=member.id) embed.add_field(name='Guild name:',value = member.display_name) embed.add_field(name='Created at:',value = member.created_at.strftime('%a, %#d %B %Y')) embed.add_field(name='Joined at:',value = member.joined_at.strftime('%a, %#d %B %Y')) embed.add_field(name=f'roles ({len(roles)}',value=''.join([role.mention for role in roles])) embed.add_field(name='Top role:',value = member.top_role.mention) embed.add_field(name='Bot?',value = member.bot) await ctx.send(embed=embed)

#

o

vale wing
#

Man add py to the start plz

slate swan
#

i think i can fix this

slate swan
cloud dawn
slate swan
#

oh, i must have been living under a rock then

vale wing
torn sail
cloud dawn
#

It's because avatar is an asset now.

mental hollow
vocal snow
#

Slowing down the program on purpose to make it realistic.

slate swan
#

fixed

vale wing
unkempt canyonBOT
#

@vale wing :white_check_mark: Your 3.11 eval job has completed with return code 0.

[1, 2, 3]
vocal snow
#

😭 šŸ˜‚

cloud dawn
vale wing
#

I forgor comprehension tho

mental hollow
torn sail
#

yes

#

oh oopss

#

sorry didnt see, can u show the code that u use it

mental hollow
# torn sail sorry didnt see, can u show the code that u use it
@commands.command(name="pat", aliases=['pats', 'headpat', 'headpats'])
    @commands.cooldown(1, 10, BucketType.user)
    async def pat_(self, ctx: commands.Context, user: discord.Member):
        """Pat someone"""
        if user.bot:
            return await ctx.send(embed=discord.Embed(description="**:error: You can't pat a bot.**"))
        if user == ctx.author:
            return await ctx.send(embed=discord.Embed(description="**:error: You can't pat yourself!\n--------------------------\nTry patting someone else.**", color=discord.Color.red()))

        url = "https://some-random-api.ml/animu/pat"
        r = await self.bot.session.get(url)
        if 300 > r.status >= 200:
            data = await r.json()
        else:
            return await ctx.send(embed=discord.Embed(description="**:error: An error occured while fetching the GIF**", color=discord.Color.red()))
        embed = discord.Embed(description=f"**{ctx.author.mention} patted {user.mention}**", color=discord.Color.embed_background(theme="dark"))
        embed.set_image(url=data['link'])
        await ctx.send(embed=embed)
torn sail
#

and it says that the bot had no attribute session?

mental hollow
#

yeah

#

i think

#

let me double check

torn sail
#

could u show ur setup_hook then

mental hollow
torn sail
#

hmm

#

im not sure why it would get that error.

#

could u show the full error traceback?

mental hollow
# torn sail could u show the full error traceback?
Ignoring exception in on_command_error
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 181, in wrapped
    ret = await coro(*args, **kwargs)
  File "/home/container/cogs/fun.py", line 365, in pat_
    r = await self.bot.session.get(url)
AttributeError: 'Bot' object has no attribute 'session'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.9/site-packages/discord/client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "/home/container/main.py", line 108, in on_command_error
    raise error
  File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 344, in invoke
    await ctx.command.invoke(ctx)
  File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 927, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 190, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'session'
torn sail
slate swan
#

I have a question related discord.py, Can I get Help?

torn sail
#

print(discord.__version__)

#

yes

mental hollow
torn sail
#

pycord doesnt have setup_hook

mental hollow
#

oh, so what do I do to fix the issue?

slate swan
#

I make select menu option from discord components module but from tomorrow the module not work so how I can make select menu option?

silk fulcrum
#

jkjk

torn sail
mental hollow
torn sail
#

this means it should happen after an asyncio.run call

mental hollow
#

hm, are you able to give a example? sorry if I’m being annoying lmao, I just wanna know how this works

silk fulcrum
torn sail
#
class Foo:
    def __init__(self):
        self.session = aiohttp.ClientSession()

class Bar:
    def __init__(self):
        self.session = None
    
    async def ainit(self):  # doesnt have to be async i think
        self.session = aiohttp.ClientSession()

foo = Foo()  # warning
bar = Bar()  # does not warn

async def main():
    foo = Foo() # does not warn
    await bar.ainit() # does not warn


asyncio.run(main())
#

basically if asyncio.get_running_loop errors then you will get that warning

silk fulcrum
#

why nhot typehint session in Bar

torn sail
#

and im lazy

silk fulcrum
#

lmaok

torn sail
silk fulcrum
mental hollow
sick birch
# slate swan ^^

Not a lot of people use that library, so might be difficult getting help. You should also not use that library since it’s not very good, just a word of advice

silk fulcrum
#

oh haven't noticed discord components

sick birch
silk fulcrum
mental hollow
#

^

sick birch
#

Oh they’re using pycord?

silk fulcrum
#

yes

pliant gulch
slate swan
torn sail
#

oh im blind

whole sparrow
#

Anyone got example code on how they implemented aiosqlite into their discord bots?

#

Im making database functions in a utils folder but i cant figure out how to use aiosqlite with discord

#

Any help is greatly appreciated i've been raking my brain

flint widget
#

Do you have an example of what you've done so far? People might be able to help if they spot an issue in your code

whole sparrow
#

Yeah ill send some code

flint widget
#

And is there an error, it's not working, or you're just not sure how to set it up?

whole sparrow
#

this is some example functions of database functions i have in a utils folder

#

This just doesnt work, database gets locked when too many people do balance command

#

This works perfectly fine with normal sqlite3

flint widget
#

For your SQL statement I might be wrong but I believe you need to have ' ' around the user ID

whole sparrow
#

Oh the sql statements are fine they work

#

i just switched from sqlite3 to aiosqlite

whole sparrow
#

but yh usually there should be ' '

flat solstice
whole sparrow
flint widget
#

if you print out the balance to the terminal just before you send it you could double check that it's not empty? Just trying to see where it's actually going wrong šŸ¤”

whole sparrow
#

This is another thing, this is bad practice i should implement a .register command but

#

in sqlite3 this worked absolutely great

#

but in aiosqltie theres just database locking

#

The problem is that aiosqlite isnt behaving as it should and theres database locking constantly

slate swan
#

Why can't the timeout = None be there?```py
class ticket_creation(discord.ui.Modal):
def init(self, ttype, member):
super().init(
(*[discord.ui.InputText(style = discord.InputTextStyle.long, label = i[0], placeholder = i[1], min_length = 2) for i in questions[ttype]]),
title = "Ticket Creation",
timeout = None)

sick birch
#

Don’t think SQLite has that because obviously it’s not asynchronous

#

So while it may seem like SQLite worked perfectly before, it really didn’t and was just waiting to corrupt your entire database file

whole sparrow
#

but it was working before, sqlite3 anyways when i wasnt using async

whole sparrow
#

but aiosqlite is supposed to be async?

sick birch
mental vine
#

any idea on how do i learn to make a bot?

slate swan
silk fulcrum
sick birch
#

Something working before but not working isn’t really a sign of anything, people say it a lot and it’s more or less a misconception

whole sparrow
silk fulcrum
#

do self.timeout = None

mental vine
#

can somebody just tell me how do i learn to make a bot from py

sick birch
#

Also, how are you telling that the database ā€œlocksā€? Does the command just take a long time?

whole sparrow
#

Terminal error

#

ill repeat the error one sec

slate swan
silk fulcrum
#

hi, okimii!

slate swan
silk fulcrum
whole sparrow
slate swan
silk fulcrum
sick birch
whole sparrow
whole sparrow
slate swan
#

you can always use global

mental vine
#

whats nextcord

sick birch
silk fulcrum
mental vine
#

alright

slate swan
#

like start the connection in a coroutine run it so it dets the value to a global variable since you cant await outside of a coroutine

#

only bad thing is you always need to stop the connection before shutting your file down

slate swan
slate swan
sick birch
# whole sparrow

Ah this happens where something else is accessing the database

slate swan
sick birch
#

It’s an SQLite issue as well

whole sparrow
slate swan
whole sparrow
slate swan
#

im not 14 and whats omipithink

silk fulcrum
hushed galleon
slate swan
#

also why are you guys on with databases in discord bots

slate swan
mental hollow
slate swan
whole sparrow
#

oof

#

yh ill keep that in mind

slate swan
silk fulcrum
slate swan
#

smh

slate swan
sick birch
whole sparrow
#

Im using disnake if that helps

#

never knew there was a setup_hook function

sick birch
#

It’s a 2.0

#

!d discord.ext.commands.Bot.setup_hook

unkempt canyonBOT
#

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

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

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

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

Warning

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

yh disnake doesnt have that oof

slate swan
#

disnake doesnt have a setup hook

#

rip messages on phone get sent with a nice latency

whole sparrow
#

bruh this tutorial does bot.db

#

this might acc work ill try it

rugged shadow
#

!botvars

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

whole sparrow
#

yh i realised rn seeing thats sick

#

never knew it was possible

slate swan
#

more like instance variables just attached to your Bot instance lol

whole sparrow
#

might fix my aiosqlite issue

silk fulcrum
#

bruh he thinks that maximum ver of googletrans is 3.0.0

#

stupid plugin

slate swan
#

calm down

silk fulcrum
slate swan
#

look for your cat

silk fulcrum
#

he's so stupid, he said that I have low version of asyncpg. it's said asyncpg>=0.12.0 and my ver is asyncpg 0.26.0

#

who the hell is it low

silk fulcrum
#

also I looked at him irl

#

noooo, I can't use thecatapi because of my region:(

slate swan
#

live in another area

silk fulcrum
#

how

#

and by the way, I can use alexflipnote api instead

#

oh, I completely forgot that I did this

#

How much Python do I need to know?

In short, this is what is highly desirable for you to know before asking for help:

  • The difference between instances and class attributes.
    • e.g. guild.name vs discord.Guild.name or any variation of these.
  • How to use data structures in the language.
    • dict/tuple/list/str/...
  • How to solve NameError or SyntaxError exceptions.
  • How to read and understand tracebacks.
  • How to surf the documentation properly.
    • using the Search utility
    • basic logical thinking (e.g. "Someone in the help channel said me to use on_raw_reaction_add to do reaction roles, so this event gives me a payload which is RawReactionActionEvent, I want to give the member who reacted, a certain role, payload.member would give me a Member object and it has a add_roles method which is just what I want!")

This list is not exhaustive

If these concepts are confusing -- please feel free to complete a smaller and simpler project first before making a discord bot.

Why do I need to know this all?
Knowing the above, solving the problems for which you ask for help will take much less of your time and the time of volunteers. In addition, if you know the basics listed above, many problems will be easily fixed by you, without the need for any help. Thanks for understanding!

silk fulcrum
slate swan
#

I'm fine

silk fulcrum
#

I'm not?

slate swan
#

OOOasd

mental hollow
silk fulcrum
#

It's highly edited

#

or not idk

limber bison
#

mysql free trial time period ?

whole sparrow
#

Well i figuredo ut how to use aiosqlite in my discord bot

#

i had to use context managers

#

But I dont understand why this lead to different results than just the normal procedural way

sick birch
# whole sparrow

You're still re-creating a connection object on every command aren't you?

whole sparrow
#

Yeah ig, i saw one thread saying how to fix it i believe

cloud dawn
whole sparrow
sick birch
whole sparrow
sick birch
#

Just create a connection object in your setup_hook, bind it to your bot instance, voila

whole sparrow
#

but i dont have setup_hook

#

do I bind it to my bot attribiute?

#

like bot.db.connect?

whole sparrow
swift pumice
#

is it possible to record voice chats with a bot? another question, is recording a voice chat against discord tos?

whole sparrow
#

most likely

swift pumice
#

damn

#

šŸ˜”

whole sparrow
#

is it even necessary to use aiosqlite in a discord bot?

whole sparrow
#

i mean aiosqlite

silk fulcrum
whole sparrow
#

is it acc?

#

or is there performance benefits

cloud dawn
cloud dawn
swift pumice
whole sparrow
#

Is it necessary to use aiosqlite compared to sqlite3

sick birch
#

It's a bit more complicated w/o setup hook but doable

whole sparrow
sick birch
#

Some of my older bots before 2.0 are still using that method

#

Yeah I suppose you're right

#

Any disnake folks know what's up with that? They have a different name for it or something?

silk fulcrum
swift pumice
cloud dawn
#

Not that I know of.

whole sparrow
swift pumice
whole sparrow
#

Without

sick birch
#

Sure can, hang on for a sec

whole sparrow
#

Thank you sm

hollow zephyr
#

Hey guys, I am using discord.py, and one of the commands requires the user to input some time, for example like this !somecommandname 9:05, where 9:05 is the time the user inputted, however i would like to know what the user's timezone (so that i can properly interpret the time the user inputted) is so how would i do that, i would really appreciate help

sick birch
#
bot = commands.Bot(...)

async def main():
  """ Entry point into the asynchronous application """
  connection = await aiosqlite.connect(...)
  bot.connection = connection # you can now access the connection where you can access your bot instance
  try:
    await bot.start(...)
  finally:
    await connection.close()

asyncio.run(main())

@whole sparrow, you can also have any other setup stuff here as you need (e.g aiohttp.ClientSession, which needs access to the event loop. You can also sync your commands here, or anything that doesn't require access to the websocket connection can be done here

cloud dawn
#

No need to thank

whole sparrow
cloud dawn
vocal snow
#

you can also use the connection as a context manager !

sick birch
cloud dawn
#

Else just use run

sick birch
#

is there any special implementation inside __aenter__ for __aexit__ for the bot class?

vocal snow
#

aexit calls bot.close

cloud dawn
sick birch
#

Disnake doesn't seem to have a setup hook

cloud dawn
#

Oh Disnake ._.

whole sparrow
#

this might be such a stupid question

#

but how can i access the bot object in other files

silk fulcrum
#

from your_file import Bot

whole sparrow
#

yh dont bother with me

cloud dawn
silk fulcrum
#

oh

#

I didnt get it

whole sparrow
#

i wanna access bot object in a database.py file that i have all my database funcs

#

wym by cogs?

whole sparrow
silk fulcrum
#

i just remembered of my launch file where I create Bot instance, so I immediately tpyed taht

vocal snow
whole sparrow
silk fulcrum
#

bro, this has to be in your main file

whole sparrow
#

yh bot instance is in my main

sick birch
vocal snow
silk fulcrum
#

or I'm dumb and i dont know anything about python

sick birch
#

Usually abstracting all your database functions is a good idea

#

Oh, and dataclasses for any returned data

vocal snow
#

you also might want to look into Prisma to make life easier

sick birch
#

Right, they've got a python client don't they?

vocal snow
#

yes, it's very fun

sick birch
#

I love Prisma, one of my favourite technologies to work with, though I've only ever used it with Typescript

slate swan
#

Anyone know why I am getting an error for embed and await?

silk fulcrum
slate swan
#

I tab both of these and still get errors.

cold sonnet
#

restart vsc

whole sparrow
#

using vscode? bottom right click spaces:4 and indent entire code to 4 spaces

#

or smt like that

#

how do you create an on_message background task

#

or can you use multiple on_message functions?

#

nvm

elfin plume
#

yo

#

can i ask a question about discord bots here

elfin plume
#

alr

#

so do buttons in discord.py not work anymore? Cause replit wont allow me to install discord_components

and so I cant run this

from discord_components import Button, Select, SelectOption, ComponentsBot, interaction
from discord_components.component import ButtonStyle
sick birch
#

It's a third party library. There's no point in using them, since discord.py and most other major forks/libraries have their own implementation now

elfin plume
#

ohhh, well how do i implement buttons with discord.py?

sick birch
unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
elfin plume
#

ty

fallow girder
#

anyone can help me for cogs ?

vocal snow
fallow girder
#

The cogs work but the controls do not work...

#
for file in os.listdir("./cogs"):
    if file.endswith(".py"):
        bot.load_extension(f"cogs.{file[:-3]}")
#

this is my code

vocal snow
fallow girder
#

Ahhh

#

I will say commands

#

not controls

vocal snow
#

Ahh

fallow girder
#

Sorry

#

My commands in my cogs, is don't work

mental hollow
#

How do I make {error.retry_after} into milliseconds?

sick birch
mental hollow
#

i multiplied it by 1000

#

yeah lol

sick birch
#

Great, that's your milliseconds

mental hollow
#

ty

gusty shard
#

guys

#

how can i create an help like the one discord automatically adds

#

i want to make it on embed

pale turtle
#

Either subclass the original HelpCommand or make your own

#

!customhelp for subclassing

unkempt canyonBOT
#

Custom help commands in discord.py

To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000

pale turtle
#

If you want to make your own just do help_command=None in your bot constructor and make the command

gusty shard
#

with that much detailed stuff

#

without using 50+ if in one command

pale turtle
#

Use a loop. Loop through all cogs, each cog make a help section or something

mental hollow
#

<t:{round(error.retry_after*1000)}:D> is returning 52 years ago? I’m quite confused lmao, I just want my command cool down to be in a unix timestamp?

austere vale
#

could someone help me with this error?

      await cursor.execute("UPDATE levels SET level = ? WHERE user = ? AND guild = ?"(guild.id,author.id,level))
pale turtle
#

Put a comma between " and the (