#discord-bots

1 messages Β· Page 944 of 1

pliant gulch
#

get_context would block all commands

#

I said this earlier after noticing

placid skiff
#

as you can read: The returned context is not guaranteed to be a valid invocation context, Context.valid must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under invoke().

cloud dawn
#

By either typing it in a command OR by going to the file in explorer and opening the PS or CMD there using the context menu.

pliant gulch
#

iirc Context.valid just checks if there is an underyling prefix that's valid, and a command attached to it

#

This is all done via StringView's parsing

placid skiff
#

nope, if it is true it just means that the context is not a valid candidate to be invoked under invoke()

#

make an example of a disabled command

#

it is a command registered in the bot

#

but it will not trigger the Context.valid

unkempt canyonBOT
#

discord/ext/commands/context.py lines 259 to 262

@property
def valid(self) -> bool:
    """:class:`​bool`​: Checks if the invocation context is valid to be invoked with."""
    return self.prefix is not None and self.command is not None```
pliant gulch
#

πŸ€”

bleak karma
#

help

cloud dawn
#

@slate swan Anyhow i gotta get off to work, there are some smart people here, i recommend going to #β“ο½œhow-to-get-help or figure out how paths work inside cmd.

slate swan
#

if i make a embed like this:
em = discord.Embed()
do i send it like this?
await ctx.send(em=embed)
or the other way around (embed=em)

empty quest
slate swan
#

alr thanks

slate swan
pliant gulch
#

So it would only run the AI chatbot if context isn't valid

empty quest
#

yes already done that! thanks for the help

pliant gulch
#

Alright nice

#

Was in the heat of the moment, didn't think clearly enough to use control flow instead of switching the whole process

pliant gulch
#

I am correct

placid skiff
placid skiff
supple thorn
#

Reading the entire argument was fun

placid skiff
#

it raises an error xD

pliant gulch
placid skiff
#

so it is as i said, he has to make a further check

pliant gulch
#

Read my terminal

hearty dust
#
@bot.command()
async def register(ctx):
    cur.execute("SELECT userid FROM usersdata")
    # hito eito cum here
    result = cur.fetchall()
    for x in result:
        num = functools.reduce(lambda N, digit: N * 10 + digit, x)
        if num != ctx.author.id:
             registerr = "INSERT INTO usersdata (userid, balance, tag) VALUES (%s, %s, %s)"
             val = (ctx.author.id, "1000", "JOBBER")
             cur.execute(registerr, val)
             mydb.commit()
             basee = "INSERT INTO stock (userid, auracoin, silver, gold, tesla, tata, reliance, litecoin, dogecoin, tether, ethereum, bitcoin, bullcash) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
             val = (ctx.author.id, 1000,0,0,0,0,0,0,0,0,0,0,0,)
             cur.execute(basee, val)
             mydb.commit()
            embed = Embed(title="ACCOUNT CREATED ![ERK__tick](https://cdn.discordapp.com/emojis/958551041786413126.webp?size=128 "ERK__tick")", description="**SUCCESSFULLY CREATED YOUR ACCOUNT**\nTYPE $profile TO CHECK PROFILE", color=0x09EAF9)
            embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)
            embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/957544130077143060/957697600138674196/1071-bull-02.png")
            y = datetime.datetime.now()
            embed.set_footer(text=f"{y.strftime('%x')} {y.strftime('%X')}")
            await ctx.channel.send(embed=embed)
            
        elif num == ctx.author.id:
            msg = await ctx.channel.send("**YOU HAVE ALREADY REGISTERED TO BIG BULL**")
             asyncio.sleep(5)
             await ctx.delete(msg)

my if else statement is not working well

pliant gulch
#

It shows ```py
False
True
True

supple thorn
pliant gulch
#

Those were from the three messages I sent

supple thorn
#

Above the error

pliant gulch
#

It raises the error afterwards

placid skiff
#

didn't saw

hearty dust
placid skiff
#

not sure that discord existed in 1994 D_D

hearty dust
placid skiff
#

if you don't tell us what is the problem... we can't check all your code and know what is wrong with it

velvet compass
#

Just from a quick look from mobile it seems like the indentation is off starting with the embed.set_author

placid skiff
#

well you should not code in python with your phone anyways xD

#

at least, you should not code big projects

hearty dust
#

this is entering data in database even the data is already existing there nd the elif command also work

velvet compass
#

Right, just pointing out a possible issue that I see

hearty dust
placid skiff
#

better, you are taking results from your database but you are adding data by that results

hearty dust
#

hm

placid skiff
#

val = (ctx.author.id, "1000", "JOBBER") here you are using ctx.author.id but probably you wanted to use x if result is a list of all discord user id registered in your database

#

tbh your code is a little mess, i'm not truly understanding what you are doing

#

consider rewriting the whole block with a fresh mind

bleak karma
#

uhh help

zinc phoenix
#

I just got an error while running my discord bot on replit, its seems like a website

#

What should I do now

#

Ive been waiting for 3 hours but still nothing

gaunt ice
#

its because of the shared ip

zinc phoenix
#

Hm

gaunt ice
#

ik they give free hosting but

#

use smth else

zinc phoenix
#

Thanks for the recommendation

zinc phoenix
slate swan
#

havent gotten a ratelimit error like that once.

zinc phoenix
#

Hm

slate swan
# zinc phoenix Hm

fun fact: you can earn free upgrades to ur server through giveaways in their discord

zinc phoenix
#

Wow really?

#

Thats very generous

slate swan
#

idk if im advertising rn, if any mods see this sorry 😭

#

im not sponsored xD

flat solstice
#

So I'm getting this errorpy Failed to Load Extension cogs.eval Traceback (most recent call last): File "C:\Users\Teagan\Documents\Coding\Zupie\env\lib\site-packages\discord\ext\commands\bot.py", line 791, in _load_from_module_spec spec.loader.exec_module(lib) # type: ignore File "<frozen importlib._bootstrap_external>", line 879, in exec_module File "<frozen importlib._bootstrap_external>", line 1017, in get_code File "<frozen importlib._bootstrap_external>", line 947, in source_to_code File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "C:\Users\Teagan\Documents\Coding\Zupie\bot\cogs\eval.py", line 162 async def on_submit(self, interaction: discord.Interaction): ^ TabError: inconsistent use of tabs and spaces in indentationin this part of my code and I'm not really sure why since I've combed through it removing any unneeded tabs https://github.com/SnowyJaguar1034/Zupie/blob/master/bot/cogs/eval.py#L152-L164

unkempt canyonBOT
#

bot/cogs/eval.py lines 152 to 164

class Evaluate(discord.ui.Modal, title="Evaluate"):
    code = ui.TextInput(
        label="What code do you want to evaluate?",
        style=discord.TextStyle.paragraph,
        placeholder="Type the code you want to evaluate here.",
        required=True,
        max_length=4000,
		default="print('Hello World!')",
    )

	async def on_submit(self, interaction: discord.Interaction):
		await self.evaluate(interaction, self.code.value)
		await interaction.response.send_message(f"Processing your code now {interaction.user.mention}", ephemeral=True)```
rocky trench
#

@flat solstice

#

The error literally says what you did wrong

supple thorn
hushed galleon
#

their repo also shows the use of tabs for the method and spaces for the textinput

flat solstice
#

So is there any noticeable issue with my tabs and spaces that I'm just missing? @supple thorn @hushed galleon

swift acorn
#

So there's an error handler I have for a command if there is still a cooldown

I want different handling for each command, is there a way to have different handlers for each command?

swift acorn
#

how neutal

slim ibex
bleak karma
#

help ?-

swift acorn
slate swan
hoary cargo
slate swan
#

Recommended to make different command error handlers

slate swan
#

nice

slate swan
flat solstice
slate swan
slate swan
#

so the error wouldn't be raised

slate swan
slate swan
#

na das real

#

brad lurkinghehe

velvet compass
#

Also enabling linting should pick up on the mixed usage

slate swan
#

Brad is always here

velvet compass
#

I'll try to not lurk as much, and actually participate lol

slate swan
#

yeah def get at least flake8

flat solstice
# swift acorn okay so I'm using on_command_error And then checking if the error is a cooldown...
import sys 
import traceback
import lib
from lib.ext import commands

@bot.command()
async def example(ctx, number : int):
  pass

@example.error
async def example_error(ctx, error):
  if isinstance(error, the_error_to_handle):
    pass
  else:
    print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr)
    traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)```This isn't spoon feeding or anything right? Also what is this servers opinion on spoon feeding - not allowed right?
supple thorn
slate swan
#

it's not that spoon-feeding isn't allowed

hoary cargo
#

.format yugiPuke

slate swan
#

we're just against it because it's not the purpose of this server

slate swan
flat solstice
slate swan
slate swan
hoary cargo
#

depends how big is the spoon

supple thorn
#

No

slate swan
#

wait no

#

@flat solstice the option is called Tab Size

#

i just recalled

slate swan
supple thorn
flat solstice
slate swan
#

this chat is so funnysniff

slate swan
slate swan
slim ibex
hoary cargo
slate swan
supple thorn
#

Haven't seen one of Ashley's uwu examples lately

hoary cargo
slate swan
slate swan
slate swan
supple thorn
flat solstice
# slate swan yep

so does tab size = 4 seems correct in the ss? I think I've changed it in the past to fix these indentation errors but they still appear every so often

slate swan
supple thorn
#

πŸ˜”

snow ibex
#

Just use ppn bro

slate swan
supple thorn
#

The dpy server has alot of duck emojis

snow ibex
#

Because all of us are di- ducks

slate swan
#

lmao

snow ibex
#

The chat has gone into peace time talks

supple thorn
#

Everyone just waiting for someone to do !ot

#

And go back to talking to discord bots

snow ibex
#

Yes

slate swan
#

!ot derduck

unkempt canyonBOT
snow ibex
#

Fuck

#

Bois time to head back to base

slate swan
supple thorn
#

I should finally subclass for my bot constructor

stuck oyster
#

How can I make my bot online all the time

snow ibex
slate swan
supple thorn
slate swan
supple thorn
#

Trying to pull my smash ultimate game up

snow ibex
supple thorn
#

Kirby squishy ball of death

stuck oyster
supple thorn
slate swan
supple thorn
#

How is your bot online

snow ibex
stuck oyster
supple thorn
snow ibex
stuck oyster
#

because I cant leave my pc on with the vsc running

snow ibex
slate swan
snow ibex
#

There are alot of good options

supple thorn
stuck oyster
supple thorn
#

Vps or a cheap vps depending if you have spare money

neat salmon
snow ibex
#

I think some have free tiers i don't know if they are any good tho

neat salmon
#

"No, not even Heroku."

snow ibex
#

Ive also used heroku and my phone

snow ibex
velvet compass
neat salmon
#

this talks about all of the free VPS and how they're not good.

snow ibex
#

If you are wondering how to do it in your phone you need a phone and termux installed on it this is android only i believe no root required

velvet compass
neat salmon
snow ibex
#

It's amazing i stopped doing it cause

#

My python ran into issues

#

And a friend offered his raspberry Pi to be the host

snow ibex
neat salmon
#

Yeah, I have two Pi 2s downstairs, only using one right now... really should use the other one, but don't know for what.

snow ibex
#

You could make a storage server if you got some extra SSDs hdds or hell even CDs lying around

neat salmon
#

Jellyfin? Sure but like, my music files that are transferred on my phone are 27 GB in size (curse lossless files), and I don't know of anything that can automatically download everything.

swift acorn
#

So I want to use wait_for to wait for a reaction on a specific message, I know how to do that, but how do I make it so it only waits for 60 seconds or any specified time

neat salmon
#

Buut this is getting offtopic now. Moving on.

snow ibex
#

Ye

boreal ravine
hasty bison
#

How do i define?
NameError: name 'ctx' is not defined

snow ibex
boreal ravine
#

πŸ‘

hasty bison
#
embed = discord.Embed(title="Commands", url="eagea", description="akmewgouiam", color=discord.Color.blue())
 if user_message.lower() == '.embed':
     await ctx.send(embed=embed)
snow ibex
#

No above this

#

The part where you define the name of the function

hasty bison
#

i dont define

snow ibex
#

You need to have ctx as an argument in there

neat salmon
#

async def abc(xyz):

snow ibex
#

Well it makes the function

hasty bison
#

ok

hasty bison
snow ibex
#

@bot.command()
async def mycommand(ctx):

snow ibex
#

Make sure the code is indented

hasty bison
#

still

#
NameError: name 'ctx' is not defined```
neat salmon
#

define ctx as the first argument in your function

velvet compass
#

ctx is from a command invocation right?

hasty bison
#

can you say it more simple?

neat salmon
#

ctx must first defined in function as argument

snow ibex
#

Uh

#

It should be the first thing the function receives so inside () it should have ctx

#
async def myfunc(argumentone,argumenttwo):
hasty bison
#

where do i put this

snow ibex
#

Before the internal code

#

Outside the embeds

sage otter
snow ibex
#

Bro im just trying to explain in simple terms

sage otter
#

Signature is a simple term. You learn it when you learn functions.

#

Which is bottom level python.

hasty bison
#

because im confused

#
    async def mycommand(ctx):
        embed = discord.Embed(title="Commands", url="M", description="Hello", color=discord.Color.blue())
    if user_message.lower() == '.embed':
        await ctx.send(embed=embed)```
#

the code is like this?

snow ibex
#

You have indented the defining of the function

hasty bison
#

what means indented

snow ibex
neat salmon
#
# not indented code
def foo():
    # indented code

# still not indented code
    # indented code
snow ibex
# hasty bison what means indented

You know how the code seems pushed to the right that's called indenting
It's making a dent so python understands that it's where the function begins and ends

#

You should really learn the basics of python before trying to make a bot

hasty bison
snow ibex
#

Yes

#

I used w3school

hoary cargo
#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

hasty stump
#

can someone tell me what is the issue here

snow ibex
#

ban(Cog)

#

it should be a subclass of Cog

cold sonnet
#

no

#

second message right

hasty stump
snow ibex
#

you know where you defined the class

#

of ban

cold sonnet
snow ibex
#

it is just an object right now

#

you need to make it a Cog

cold sonnet
#

there's also no such thing as bot.send_message

#

bot.say neither

hasty stump
snow ibex
#

you can only message things subclassed from messageables
examples are
ctx
channel

cold sonnet
#

and on_message_delete has to have a commands.Cog.listener() decorator

snow ibex
#

this is how a cog is made

hasty stump
snow ibex
#

you are missing

#

ctx as an argument

#

in test

hasty stump
snow ibex
#

ye

#

you should have

#

self, ctx in the arguments

hasty stump
snow ibex
#

insteald of self.client.say it should be ctx.send()

#

or ctx.reply()

hasty stump
#

ok

snow ibex
#

send*

#

or reply

hasty stump
#

oh

#

oh yes working

hasty stump
snow ibex
#

now for your delete state ment

#

you need a decorator

hasty stump
#

i have already coded so many stuffs in 1file i want to destribute all of them in different files

snow ibex
#

yes

#

good idea

hasty stump
#

so do i have to rewrite all codes for each?

snow ibex
#

yes

hasty stump
snow ibex
#

above

#

the on_message_delete

#

cogs must have decorators since bot is on a different file

hasty stump
snow ibex
#

yes

hasty stump
#

oh

#

so how can i make a transform my other commands into a file?

snow ibex
#

instead oc clien.send_message

#

use message.send()

#

since client.send_message doesnt work

snow ibex
#

most of it you have to do by hand

#

no easy way to do it sadly

karmic valley
#

someone can tell me how to make a rank system or send me the code directly

hasty stump
snow ibex
#

client should be replaced with commands.command()

hasty stump
#

and?

snow ibex
#

and you need self before ctx

#

self, ctx

#

everything else is good

hasty stump
#

oh

#

interesting

snow ibex
#

ye its pretty cool

hasty stump
#

can i make them in folder too?

snow ibex
#

cogs?

hasty stump
hasty stump
snow ibex
#

yes but you need __init__.py files

#

inside them

snow ibex
#

so idk

slate swan
snow ibex
#

ye

#

forks exists

karmic valley
#

help someone can tell me how to make a rank system or send me the code directly

high nexus
#

yo guys can a asyncio event be set multiple times or does it have to be reset somehow

high nexus
#

and a would be called multiple times

slate swan
#

yeah, u can call it multiple times

high nexus
#

well idk for some reason it is working once but after that it isn't and I'm trying to find the issue

slate swan
#

try that

karmic valley
karmic valley
lament mesa
high nexus
high nexus
covert swan
#

Please help, I can't figure out the error command can't run cursor.execute("SELECT hp FROM economy WHERE userid = ?".format(ctx.author.id, ).fetchone()[0])

spring flax
#

Have you thought of using aiosqlite? It's async, what you're using is not

slate swan
lament mesa
#

PostgreSQL json like?!

slate swan
regal pulsar
#
@start.error
async def on_start_error(ctx, error):
    embed = discord.Embed(
        title="Timed Out!",
        description="You Have Taken Too Long To Reply. Closing This Session.",
        color=0xFF5733,
    )
    if isinstance(error, asyncio.TimeoutError):
        await ctx.channel.send(embed=embed)
snow ibex
regal pulsar
#

i dont get the message even after the timeout error

#

why is that

snow ibex
#

Hmm

#

What module is this

regal pulsar
#

what happens is

snow ibex
#

Weird decorator

#

Did you make the decorator a import as ?

lament mesa
regal pulsar
#

i have a command called "start", which sends an embed where i use bot.wait_for() to wait for a reaction

regal pulsar
#

its just an error handler for commands

snow ibex
#

Ah

regal pulsar
#

so if you dont react the the embed within 60 seconds

#

it returns an asyncio.TimeoutError

#

but i dont get the message sent

boreal ravine
snow ibex
#

first thing I noticed is that doesn't error need a bracket also isn't it

regal pulsar
#

bot.event and command.error dont need brackets iirc

regal pulsar
snow ibex
#

Nah

regal pulsar
#

my bot is gonna use bot.wait_for a lot

boreal ravine
snow ibex
#

It's just messy

regal pulsar
#

handling all the timeout errors from one spot seems logical

snow ibex
#

A whole cog wide or a bot wide

regal pulsar
snow ibex
#

Is more logical tbh

regal pulsar
#

i see

gaunt ice
boreal ravine
snow ibex
leaden plaza
#
@client.command()
async def add(ctx, member: discord.Member=None, amount=None):
    user = ctx.author
    users = await get_bank_data()
    members = member
    amounts = amount
    
    await open_account(member)

    if members == None:
        await ctx.send(f"{user.mention}, Please mention someone")
        return

    if amounts == None:
        await ctx.send(f"{user.mention}, Please enter the amount")
        return

    if amounts < 0:
        await ctx.send(f"{user.mention}, Amount must be positive!")
        return

    users[str(members.id)]["wallet"] += amounts
    await ctx.send(f"{user.mention}, You gave {amounts} coins to {members.mention}!")

    with open("mainbank.json", "w") as f:
        json.dump(users, f)

Can anyoe help me with add coins command?

snow ibex
#

shouldve pointed them to a learning resource instead

gaunt ice
snow ibex
#

yes

snow ibex
#

i should appologize

gaunt ice
#

yes

leaden plaza
snow ibex
#

@karmic valley i am sorry for being rude and should have done better

gaunt ice
boreal ravine
leaden plaza
#

Wait a sec my pc died

regal pulsar
#

oh no that was good advice lmao

#

im using try/except and it works now

snow ibex
#

nah nah should have been less rude about it

#

fuck pingedthe wrong person

#

sorry lad

#

im doing a bad job trying to appologize

#

im sorry guys

leaden plaza
#

Error

gaunt ice
boreal ravine
leaden plaza
boreal ravine
gaunt ice
#

im seeing replit everywhere

gaunt ice
leaden plaza
leaden plaza
#

there's nothing wrong with on_command_error its the issue in code ig

boreal ravine
gaunt ice
leaden plaza
#

everyhting is working fine except that code

leaden plaza
gaunt ice
#

under if statement

boreal ravine
#

No, the isinstance function is above msg not time

gaunt ice
#

and above msg

leaden plaza
#

ok

#

Like this?

boreal ravine
#

No

#

Do you know what above means?

gaunt ice
#

being both those time and msg under if

boreal ravine
#

the code earlier was already correct, just move time inside the if statement

leaden plaza
gaunt ice
#

umm

leaden plaza
#

under if sorry

#

wait a sec

#

nowok?

boreal ravine
#

yes

leaden plaza
boreal ravine
boreal ravine
#

or just do ```py
raise error

leaden plaza
#

else:
raise error?

slate swan
unkempt canyonBOT
slate swan
#

though the updated version is on github

spring flax
slate swan
spring flax
#

where's the github?

leaden plaza
#

member ==none command not working

slate swan
spring flax
#

but why make member optional if you are going to reject it as None?

slate swan
#

show how you're invoking the command

regal pulsar
#
    @commands.Cog.listener()
    async def on_message(self, message):
        if re.fullmatch(rf"<@!?{self.bot.user.id}>", message.content):
            embed = discord.Embed(
                title="Brrrrr",
                description="""
Embed Content
        """,
                color=ORANGE,
            )
            embed.set_image(url="https://media.giphy.com/media/igHg5yS08NvCwsvH0Z/giphy.gif")
            await message.channel.send(embed=embed)
        await self.bot.process_commands(message)
#

how'd i mess this up :/

spring flax
#

you don't need amounts = int(amount) when you can just typehint amount to int

regal pulsar
#

i get two responses to every command

#

only one instance running

leaden plaza
maiden fable
#

Remove the process commands

regal pulsar
#

doesnt that let the bot process other stuff tho

leaden plaza
maiden fable
regal pulsar
#

well thats good to know :/

#

thanks

cold sonnet
#

yeah listener is like listen

leaden plaza
maiden fable
#

Just do amount: int in the function

cold sonnet
#

amount is None anyways

maiden fable
#

Also, show yr code and how u r running the command from discord

boreal ravine
#

nevermind

leaden plaza
#

here's the error

#
@client.command()
async def add(ctx, member: discord.Member=None, amount: int=None):
    user = ctx.author
    users = await get_bank_data()
    members = member
    amounts = int(amount)
    
    await open_account(member)

    if not members:
        await ctx.send(f"{user.mention}, Please mention someone")
        return

    if amounts == None:
        await ctx.send(f"{user.mention}, Please enter the amount")
        return

    if amounts < 0:
        await ctx.send(f"{user.mention}, Amount must be positive!")
        return

    users[str(members.id)]["wallet"] += amounts
    await ctx.send(f"{user.mention}, You gave {amounts} coins to {members.mention}!")

    with open("mainbank.json", "w") as f:
        json.dump(users, f)
``` And here's the code
cold sonnet
#

do your if amounts == None: stuff before converting to int

#

actually no

boreal ravine
cold sonnet
#

do if amount == None before converting to int

#

or just typehint to int like hunter said

leaden plaza
#

oh ok

slate swan
cold sonnet
#

did u change something?

#

oh yeah

maiden fable
cold sonnet
#

then you don't need amounts

boreal ravine
cold sonnet
#

and keep the None default values

#

async def add(ctx, member: discord.Member=None, amount: int=None):

maiden fable
#

Good thing you changed the code @boreal ravine πŸ˜‚

leaden plaza
#

ok wait

maiden fable
#

That if statement was never gonna get executed since u have a function named db already

leaden plaza
cold sonnet
#

just do if not member

#

and leave the members variable

leaden plaza
#

ok wait

cold sonnet
#

though this shouldn't change anything

leaden plaza
leaden plaza
#

oh sorry

leaden plaza
cold sonnet
#

do your if statements before doing anything with the variables

boreal ravine
#

@slate swan Check issues.

leaden plaza
#

but if it's not specified it should tell the user to mention member

cold sonnet
#

you're trying to do something with nothing before checking if it's nothing

slate swan
fresh sable
#

can someone tell me how to make the discord bot read only one channel?

leaden plaza
#

lol sorry i'm new to it

cold sonnet
#

no need to be sorry

leaden plaza
#

and could u tell me how to only limit this command to admins

#

Ok thank u mate

maiden fable
#

!d discord.ext.commands.has_role @leaden plaza

unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")...
slate swan
cold sonnet
#

what

maiden fable
slate swan
#

I'm not making a bot lol

#

uh nothing just a helper library for databases for discord bots lol, I need to fix some stuff

zenith hare
#

Does anyone know what the best button library is? ,':

slow fog
boreal ravine
#

why would disnake be for a beginner but d.py for an intermediate coder?

boreal ravine
slow fog
#

thats true

#

im not lying

zenith hare
#

thankss

zenith hare
boreal ravine
#

in some cases yes, but you do realize disnake is a fork of d.py?

#

disnake's button syntax is exactly the same as d.py's since it's a fork

#

yes

slate swan
craggy cloak
#

I can't type in the terminal but how can I update my discord.py version?

slate swan
#

why cant you type in the terminal?

#

if its like a host limitation or something, configure your requirements.txt/ poetry that way

#

+1

#

slash command freaking everyone lmao

leaden plaza
#
@client.command(aliases=["bal"])
async def balance(ctx, member: discord.Member=None):
    await open_account(ctx.author)
    user = ctx.author
    users = await get_bank_data()

    wallet_amt = users[str(user.id)]["wallet"]
    wallet_amt1 = users[str(member.id)]["wallet"]
    # bank_amt = users[str(user.id)]["bank"]
    em = discord. Embed(
        title=f"{ctx.author.name}'s balance")
    em.add_field(name="Wallet balance", value=wallet_amt)
    em1 = discord. Embed(
        title=f"{member.name}'s balance")
    em1.add_field(name="Wallet balance", value=wallet_amt1)
    #em.add_field(name="Bank balance", value=bank_amt)
    if member:
        await ctx.send(embed=em1)
    if not member:
        await ctx.send(embed=em)```
Can anyone tell me what i did wrong?
slate swan
#

can u tell me if u got any error?

leaden plaza
#

whenever i'm typing ?bal without mentioning its sending me this error

#

with mention it's working fine

slate swan
#

mind showing your get_bank_data function?

leaden plaza
#

ok wait

slate swan
#

alr

cold sonnet
leaden plaza
slate swan
cold sonnet
#

some economy bot vid

pliant gulch
#

Why is this a coroutine function when it doesn’t need to be

cold sonnet
#

ig swastik

slate swan
#

i see lmao

#

well just wanna say @leaden plaza

#

pls don't use json

#

for db shit

cold sonnet
slate swan
#

LMFAOO

radiant wing
#

What's wrong here? Why does this not work?

async def on_guild_join(guild):
    welcomeMsg = 'Hello and thank you for choosing HangmanBot! Use `hm!help` to get help.'
    if guild.system_channel is not None:
        await guild.system_channel.send(welcomeMsg)
    else:
        from random import choice
        await choice(guild.text_channels).send(welcomeMsg)
cold sonnet
#

uh why are you importing there

#

await random.choice(guild.text_channels).send(welcomeMsg)

#

πŸ‘

proud rain
#

Why doesnt my changeprefix command not work?

cold sonnet
#

and you got the decorator rikzy?

radiant wing
radiant wing
cold sonnet
#

so you do have the @bot.event

radiant wing
#

Yes

proud rain
#

why does my change prefix not work

cold sonnet
#

not only there

slate swan
rocky trench
#
@bot.command()
async def clonechannels(ctx, guild_id):
    guild = await bot.fetch_guild(guild_id)
    for channel in guild.categories:
        await ctx.guild.create_category(name=channel.name)
    for channel in guild.channels:
        if isinstance(channel,discord.TextChannel):
            if channel.category is not None:
                category = discord.utils.get(guild.categories, name = channel.category.name)        
                await ctx.guild.create_text_channel(name=channel.name, category= category)
            else:
                await ctx.guild.create_text_channel(name = channel.name)
        if isinstance(channel, discord.VoiceChannel):
            if channel.category is not None:
                category = discord.utils.get(guild.categories, name = channel.category.name)
                await ctx.guild.create_voice_channel(name = channel.name, category = category)
            else:
                await ctx.guild.create_voice_channel(name = channel.name)
    await ctx.send('done!')``` any idea why it doesnt create any channels? The guild has channels and the bot is in there
cold sonnet
#
@bot.event
async def on_guild_join(guild):
    welcomeMsg = 'Hello and thank you for choosing HangmanBot! Use `hm!help` to get help.'
    if guild.system_channel is not None:
        await guild.system_channel.send(welcomeMsg)
    else:
        await random.choice(guild.text_channels).send(welcomeMsg)
slate swan
#

becasue it doesn't have perm to message in the channel that it choosed by random.choice thing

cold sonnet
#

you need the deco

slate swan
radiant wing
slate swan
#

it is used for specific events

radiant wing
cold sonnet
#

each time when creating an event

#

that the API recognizes

slate swan
radiant wing
#

discord py

radiant wing
#

Then I understand

leaden plaza
#

Is there any way to make it work for now?@slate swan

cold sonnet
#
on_message
on_guild_join
on_member_remove```
are all events, so the on_ is kind of telling you that you need it
slate swan
rocky trench
#
@bot.command()
async def clonechannels(ctx, guild_id):
    guild = await bot.fetch_guild(guild_id)
    for channel in guild.categories:
        await ctx.guild.create_category(name=channel.name)
    for channel in guild.channels:
        if isinstance(channel,discord.TextChannel):
            if channel.category is not None:
                category = discord.utils.get(guild.categories, name = channel.category.name)        
                await ctx.guild.create_text_channel(name=channel.name, category= category)
            else:
                await ctx.guild.create_text_channel(name = channel.name)
        if isinstance(channel, discord.VoiceChannel):
            if channel.category is not None:
                category = discord.utils.get(guild.categories, name = channel.category.name)
                await ctx.guild.create_voice_channel(name = channel.name, category = category)
            else:
                await ctx.guild.create_voice_channel(name = channel.name)
    await ctx.send('done!')``` any idea why it doesnt create any channels? The guild has channels and the bot is in both guilds.
radiant wing
#

@cold sonnet @slate swan thx

slate swan
#

:>

slate swan
#

check

leaden plaza
slate swan
#

show me da json

#

i wanna run screnn share in vc for 24 hour any idea what should i do cause bot cant

#

i kinda wanna see it

leaden plaza
slate swan
#

sorry if i sound dumb lmao

slate swan
leaden plaza
slate swan
slate swan
#

ok so ig

#

in case u don't pass the member parameter

#

when using the command.. it's taking as None.. becuase you've set its default value as None

slate swan
leaden plaza
#

but if i do it'll throw error of not mentioning member

slate swan
#

ahhh

leaden plaza
slate swan
#

see make error handler for that

slate swan
#

:>

tough lance
#

.

slate swan
#

Does anyone know how to turn an UTC date to secs? Welp im not talking abt unix codes but ye, for example if i did an action like a minute ago it should return 60secs πŸ«‚

slate swan
#

<t:1648739880:R>

slate swan
#

πŸ’€

#

πŸ’€ yes i was just trying if the code is correct

#

oh

#

lmao

#

wait wait

#

Does the strftime have something that returns the date but like discord-timestamp ?

#

use timestamp method @slate swan for datetime.datetime

#

how can i make the bot check the user account creation date and then if its less than a specific number will do something i tried many things and searched but nothing seems to be working

slate swan
slate swan
slate swan
#

πŸ’€

slate swan
slate swan
#

idk but for me its not working for some reasons

#

!d discord.Member.created_at

unkempt canyonBOT
#

property created_at```
Equivalent to [`User.created_at`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.created_at "discord.User.created_at")
sick birch
slate swan
#

well it did show the creation date but does not do the thing "if" its less

sick birch
#

And how does your code look like?

slate swan
slate swan
slate swan
slate swan
#

fr

#

i hope they add jsk support for slash commands too.. just like how they mostly support prefix commands

slate swan
#

Imma use dat then if it returns unix code i will cry

slate swan
slate swan
slate swan
slate swan
#

so jsk with slash commands would be awkward

slate swan
#

that's the point.. 😭

slate swan
slate swan
#

idk how u gonna convert tho

#

areee

#

his question is something else

#

it's not about getting unix code lmao

sick birch
slate swan
#

i have no idea what you're talking about

slate swan
#

:'/

#

he's not asking for unix code

#

Nvm

#

just use timedelta

#

Timedelta

#

!e

import datetime
print(datetime.datetime.utcnow() - datetime.timedelta(minutes=1))
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

2022-03-31 15:49:17.068385
slate swan
#

that's what you want, right?

slate swan
#

...

#

I just found dat on their docs pogu

#

I meant examples*

slate swan
#

but it's not a good idea/practice imo

#

:'/

#

Its ight just share it wit me >:(

slate swan
#

Ye sure

flat solstice
#

Hi so this code https://github.com/SnowyJaguar1034/Zupie/blob/master/bot/cogs/eval.py#L40-L44 is giving me this errorpy Ignoring exception in view <MyMenuPages timeout=60 children=5> for item <Button style=<ButtonStyle.primary: 1> url=None disabled=False label=None emoji=<PartialEmoji animated=False name='next_check' id=754948796361736213> row=None>: Traceback (most recent call last): File "C:\Users\Teagan\Documents\Coding\Zupie\env\lib\site-packages\discord\ui\view.py", line 364, in _scheduled_task allow = await self.interaction_check(interaction) File "C:\Users\Teagan\Documents\Coding\Zupie\bot\utils\eval.py", line 45, in interaction_check return interaction.user == self.user AttributeError: 'MyMenuPages' object has no attribute 'user'can someone shed some light on why as I've been looking at it for a while now and I'm not really getting anywhere.

quick gust
#

we cant see that code btw ^^

flat solstice
#

oh, weird since it should be a public repo, give me a min

unkempt canyonBOT
#

bot/utils/eval.py lines 41 to 45

async def interaction_check(self, interaction):
    if isinstance(interaction, commands.Context):
        return interaction.user == self.ctx.author
    elif isinstance(interaction, Interaction):
        return interaction.user == self.user```
quick gust
#

indeed is

flat solstice
#

yeah the fact that @unkempt canyon was able to embed it was a bit f a giveaway

hushed galleon
#

the superclass View doesnt call super().init() so MenuPages wont be initialized by itself

#

although neither of superclasses define a .user attribute, so you will need to define self.user yourself

flat solstice
unkempt canyonBOT
#

bot/utils/eval.py lines 27 to 37

    self.ctx = None
    self.interaction = None
    self.message = None

async def start(self, transaction):
    await self._source._prepare_once()
    if isinstance(transaction, commands.Context):
        self.ctx = transaction
    elif isinstance(transaction, Interaction):
        self.interaction = transaction
    self.message = await self.send_initial_message(transaction, transaction.channel)```
flat solstice
unkempt canyonBOT
#

bot/utils/eval.py lines 27 to 37

    self.ctx = None
    self.interaction = None
    self.message = None

async def start(self, transaction):
    await self._source._prepare_once()
    if isinstance(transaction, commands.Context):
        self.ctx = transaction
    elif isinstance(transaction, Interaction):
        self.interaction = transaction
    self.message = await self.send_initial_message(transaction, transaction.channel)```
hasty stump
#

can anyone help ?

hushed galleon
spice adder
#

What would be the right way to query the audit logs to retrieve a ban author?

hasty stump
lucid vine
#

!format

glacial echo
#

if i want ot make a role when my bot joins a server (or when someone with manae bot permissions runs a configuration command perhaps) and then save that role to check f someone has that role (in all servers its in) for commands, hwo would i do that?

hushed galleon
# hasty stump

your python script shouldnt use spaces or other special characters in its name

glacial echo
#

do i need to write a persistent database that checks if the guild has a role assigned for this purpose yet, and if not create one? and then reference the database entry for the guild whenever a command is used?

lucid vine
#
@client.command(pass_context = True)
@has_permissions(mute_members=True)
async def unmute(ctx, user: discord.Member):
        role = discord.utils.get(user.server.roles, name="Muted")
        embed = discord.Embed(title="{} has been unmuted".format(user.name), color=0xff80ff) # To change the color find a hex color you want and put it after 0x
        embed.set_thumbnail(url=user.avatar_url)
        await client.remove_roles(user, role)
        await ctx.channel.send(embed=embed)
@unmute.error
async def mute_error(error,ctx):
    if isinstance(error, MissingPermissions):
        embed = discord.Embed(title="You Baka! You are not allowed to do this!", description="You don't have permission to use this command.", color=0xff80ff)
        await ctx.channel.send(embed=embed)```
#

isnt working but its also not erroring

hushed galleon
glacial echo
#

is it possible to get a role by name?

lucid vine
#

yea lol

glacial echo
#

for example i make a role on join called "gamemaster" if no role with that title exists?

#

and then check role by name?

lucid vine
#

just do if else

hushed galleon
#

discord.utils.get() is a simple way to do that, although checking by name means the admins dont get any control over the role name and may break it unintentionally

glacial echo
#

to be fair if they break it unintentionally, the bot should eventually go "hey this command requires this role but it doesnt exist" and i can write a failsafe that creates the role

lucid vine
#

yes ok now can someone help me

#

lol

hushed galleon
#

oh wait

#

your mute_error parameters are flipped

lucid vine
#

ohhh

#

ctx then error

#

my badddd

#

let me try to fix and see

hushed galleon
glacial echo
#

that sounds like a admin problem, not a me problem tbh

maiden fable
#

Stop using role names and use role ids πŸ˜”

lucid vine
#

@hushed galleonyeah now it works but the commands arent getting executed like it prints it but then doesnt do anything and im owner of the server and it said im a sussy baka i dont have the permission

hushed galleon
#

only if your behavior is well documented

glacial echo
#

role ids arent universal smh

lucid vine
high nexus
#

yo guys how can I block while a value (specific index) in a list is equal to a specific value

lucid vine
#

dickhead

maiden fable
glacial echo
#

what

maiden fable
lucid vine
glacial echo
lucid vine
#

hack the framework and change the ids to the same kinda matrix thing here @maiden fable

maiden fable
#

idk what u mean by "universal"

glacial echo
#

if i have a bot in three servers, i can make a role when it joins called "test" and that name will be the same in all 3 servers

#

but each server will have a different role id

maiden fable
#

Ah that way

lucid vine
hushed galleon
#

hunter's assumption was that universal meant universally unique, and snowflakes are made of both a time and random component so they are unique

lucid vine
#

ok

maiden fable
#

code?

maiden fable
#

!code πŸ˜”

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

pliant gulch
lucid vine
#

same thing

maiden fable
#

Thanks

pliant gulch
#

But discord uses the twitter snowflake framework either way as well

#

And they hash in an internal ID

maiden fable
#

Yea, it is smth like mix of process ID and process number and utc timestamp and a random int

pliant gulch
#

E.g time, etc

lucid vine
#

pp

#

need help plws UwU oni chan?

maiden fable
#

Yup, I was partially correct lol

pliant gulch
#

Yep, and with this you can bitshift 22 bits to get the timestamp

#

Pretty clever

lucid vine
#

and i will titan shift 32

maiden fable
#

(Idk much about bits and bytes so no comments)

lucid vine
#

now can someone pls help me UwU

glacial echo
#

is there a clever way to check if role with name in guild

hushed galleon
#

i mentioned discord.utils.get()

maiden fable
#

see if it returns None

cold sonnet
#

hello meh back

maiden fable
#

Needed u here

cold sonnet
glacial echo
#

"guild" is not defined

hushed galleon
maiden fable
#

message.guild

#

member.guild

lucid vine
cold sonnet
lucid vine
cold sonnet
#

so what's the actual issue

slate swan
#

well it's not our place to judge

lucid vine
cold sonnet
#

what's the code

glacial echo
#

that is a very suspicous bot pfp

lucid vine
#
@client.command(pass_context = True)
@has_permissions(kick_members=True)
async def kick(ctx, user: discord.Member):
    embed = discord.Embed(title="Oni-Chan gave me a kick command!", description="Kicking {}".format(user.name), color=0xff80ff)
    embed.set_thumbnail(url=user.avatar_url)
    await ctx.channel.send(embed=embed)
    await client.kick(user)
@kick.error
async def kick_error(ctx, error):
    if isinstance(error, MissingPermissions):
        embed = discord.Embed(title="You Baka! You are not allowed to do this!", description="You don't have permission to use this command.", color=0xff80ff)
        await ctx.channel.send(embed=embed)
lucid vine
#

its a nsfw / community bot

cold sonnet
#

remove pass_context = True

slate swan
#

remove pass_context and use ctx.guild.kick instead of client.kick

#

that should do it.

cold sonnet
#

it's ctx.guild.kick

lucid vine
#

oh i was using old discord docs and then i realised

slate swan
#

or you can do user.guild.kick

cold sonnet
#

await ctx.send(embed=embed) is enough

lucid vine
slate swan
#

also you should handle your missingpermissions errors globally

#

instead of only for one command

cold sonnet
#

no we both told you to use ctx.guild.kick instead of client.kick

lucid vine
cold sonnet
#

yes await

lucid vine
#

i got it tyyy let me try

#

oh yh and whats with the mute cmd that didnt mute

cold sonnet
#

and the send one is a different thing that's using one additional unnecessary attribute

#

and we just don't like to see it

#

memory loss

slate swan
#

i mean it doesn't factually make a difference

#

ctx.send is just a pointer to ctx.channel.send

cold sonnet
#

unspeedy

slate swan
#
@bot.command()
@commands.has_any_role(692760082085183519, 940008547993927691, 863878825376743475, 902292952381001779, 863879069253894166, 902292952381001779, 863879304110276668, 940008547993927691)
async def ΠΏΡ€Π΅Π΄(ctx, member: discord.Member = None, *, reason = None):
    print(45)
    cursor.execute("""CREATE TABLE IF NOT EXISTS warning(guild_id BIGINT, user_id BIGINT, warn INT, count INT, moderator_id BIGINT, reasons VARCHAR)""")
    base.commit()
    print(1)
    
    warnings = cursor.execute("SELECT * FROM warning WHERE user_id = ?", (member.id,)).fetchone()
    print("Ρ€Π°Π±ΠΎΡ‚Π°Π΅Ρ‚")
    

    if member is None:
        await ctx.send("Π’Ρ‹Π±Π΅Ρ€ΠΈΡ‚Π΅ участника")
        return
        
    if reason is None:
       try:
           cursor.execute('INSERT INTO warning(guild_id, user_id, warn, count, moderator_id, reasons) VALUES(?, ?, ?, ?, ?, ?)', (ctx.guild.id,member.id,0,1,ctx.author.id,'ΠžΡ‚ΡΡƒΡ‚ΡΡ‚Π²ΡƒΠ΅Ρ‚'))
           base.commit()
       except Exception as e:
           print(repr(e))
       print(2222)
       cursor.execute(f'UPDATE warning SET warn = {warnings[2] + 1} WHERE user_id = ? AND guild_id = ?', (member.id, ctx.guild.id))
       base.commit()
       await ctx.send(f"**{ctx.author.name}** Π’Ρ‹Π΄Π°Π» ΠΏΡ€Π΅Π΄ΡƒΠΏΡ€Π΅ΠΆΠ΄Π΅Π½ΠΈΠ΅ # {member} (случай # )")
    else:
       cursor.execute('INSERT INTO warning (guild_id, user_id, warn, count, moderator_id, reasons) VALUES(?, ?, ?, ?, ?, ?)', (ctx.guild.id,member.id,0,1, ctx.author.id, reason))
       base.commit() 
       cursor.execute(f'UPDATE warning SET warn = {warnings[2] + 1} WHERE user_id = ? AND guild_id = ?', (member.id, ctx.guild.id))
       base.commit()
       await ctx.send(f"**{ctx.author.name}** Π’Ρ‹Π΄Π°Π» ΠΏΡ€Π΅Π΄ΡƒΠΏΡ€Π΅ΠΆΠ΄Π΅Π½ΠΈΠ΅ # {member}, ΠΏΡ€ΠΈΡ‡ΠΈΠ½Π° {reason}. (случай # )")

error: TypeError: 'NoneType' object is not subscriptable
If a person is not in the database, then at first he will give an error, after a reboot, it will work, how to fix it?

lucid vine
slate swan
#

if you care about the... single second it takes to type .channel. ..sure

cold sonnet
#

oh not that difference

#

it doesn't matter

slate swan
#

that's a start

#

._.

slate swan
lucid vine
#

u wrote ur function in russian

#

russian function = no no

slate swan
#

._.

lucid vine
#

russian function = special characters

slate swan
#

._.

cold sonnet
#

wzr is the command invoked?

slate swan
#

if the person is not in the database, then no, there is an error, after restarting the bot, everything works

cold sonnet
#

._. indeed

glacial echo
#

can i pass this the name of a role?

slate swan
#

grab the specific role using utils.get

glacial echo
#
@client.slash_command(
  name="init__util_",
  description="run this once when you add the bot"
)
async def initutil(ctx):
  if disnake.utils.get(ctx.guild.roles, name="Gamemaster") == None:
    await ctx.guild.create_role(name="Gamemaster",reason="init__util_/created_role")
    await ctx.author.add_roles()
slate swan
#

what is that lone await doing there

cold sonnet
#

now I'm wondering how getting a messageable with ctx's attribute to use send on it and using the inherited send in ctx doesn't make a difference

glacial echo
#

what?

cold sonnet
#

not u

#

or was that what not to me

slate swan
#

nvm, discord wonky format

cold sonnet
maiden fable
slate swan
#

uh, you're supposed to assign the role created a variable

cold sonnet
slate swan
#

lmfao

#
@client.slash_command(
  name="init__util_",
  description="run this once when you add the bot"
)
async def initutil(ctx):
  if disnake.utils.get(ctx.guild.roles, name="Gamemaster") == None:
    role = await ctx.guild.create_role(name="Gamemaster",reason="init__util_/created_role")
    await ctx.author.add_roles(role)```
#

there ya go

glacial echo
#

ah

#

thanks

slate swan
#

np

glacial echo
#

what does atomic actually do

#

the docs isnt exactly clear what that means

slate swan
#

ensures that the cached roles are always ignored

#

so for example, if a role isn't in the cache the operation could fail

#

so it will always use an api fetch request to get them

#

just leave it at default

cold sonnet
glacial echo
#

that sounds like its for complex stuff

maiden fable
lucid vine
#
@client.command()
@has_permissions(mute_members=True)
async def mute(ctx, user: discord.Member):
        role = discord.utils.get(user.server.roles, name="Muted")
        embed = discord.Embed(title="{} has been muted!".format(user.name), description="When the user needs unmuting do !unmute @user!" , color=0xff80ff) # To change the color find a hex color you want and put it after 0x
        embed.set_thumbnail(url=user.avatar_url)
        await ctx.guild.add_roles(user, role)
        await ctx.channel.send(embed=embed)
@mute.error
async def unmute_error(ctx, error):
    if isinstance(error, MissingPermissions):
        embed = discord.Embed(title="You Baka! You are not allowed to do this!", description="You don't have permission to use this command, if you do have the permission to execute this command make sure there is a Muted Role in your server!", color=0xff80ff)
        await ctx.channel.send(embed=embed)

why is this returning to the MissingPermissions error even though i am Owner of the server?

cold sonnet
#

but I was much sooner already suspicious of why you're doing base.commit() instead of cursor

slate swan
glacial echo
maiden fable
cold sonnet
#

maybe I'm just dumb for that lib

slate swan
lucid vine
glacial echo
#

isnt if not the same as if !

glacial echo
slate swan
#

regardless of whatever permissions the bot has, no operationsare allowed to the server owner

maiden fable
#

!d discord.Permissions.mute_members

unkempt canyonBOT
maiden fable
#

What the

glacial echo
#

mute_members should be for the new timeout feature

slate swan
slate swan
lucid vine
glacial echo
#

ooh yeah thats for voice channels

hasty stump
glacial echo
#

btw can bots not apply timeouts yet?

maiden fable
hasty stump
maiden fable
unkempt canyonBOT
#

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

Times out the member from the guild; until then, the member will not be able to interact with the guild.

Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.

You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.

New in version 2.3.
slate swan
#

yeah they can timeout

#

conventional mute bots are kinda useless now

cold sonnet
maiden fable
#

Yes

slate swan
#

unless you want to make it so muted users can still access a specific channel

lucid vine
#

ye i want it role based

glacial echo
cold sonnet
#

every class's functions' parameters have to start with self

slate swan
maiden fable
#

🀷 Useless API calls for the role mute command

glacial echo
#
@client.slash_command(
  name="init__util_",
  description="run this once when you add the bot"
)
async def initutil(ctx):
  if disnake.utils.get(ctx.guild.roles, name="Gamemaster") == None:
    role = await ctx.guild.create_role(name="Gamemaster",reason="init__util_/created_role")
    await ctx.author.add_roles(role,reason="init__util_/assigned_role")
slate swan
#

but uh, whatever, it's your server

maiden fable
glacial echo
#

does this look proper?

lucid vine
glacial echo
cold sonnet
slate swan
#

then again, i don't think a mute is something that should be carried out for long enough that it is required to have an appeal

maiden fable
cold sonnet
pure sparrow
#

hi guys, on what ide do you code ?

slate swan
cold sonnet
#

vsc

glacial echo
cold sonnet
#

why does it have to

pliant gulch
cold sonnet
#

oh

pliant gulch
pure sparrow
#

nice thank you very much

pure sparrow
glacial echo
#

ah made a typo with indentation

pliant gulch
#

Because without checking if it is None

maiden fable
pliant gulch
#

It has to check many things instead of one thing

maiden fable
#

Ah

pliant gulch
#

If that makes sense, as your only looking for either a truthy value or a non truthy value

maiden fable
#

Like it gotta check empty list, None and stuff?

pliant gulch
#

So it has to check more things yep

cold sonnet
slate swan
maiden fable
#

Yea

slate swan
#

undefined as in?

cold sonnet
#

as in undefined

maiden fable
#

Lol imagine if the if statement is never triggered

#

NameError: name role is not defined

glacial echo
#

== none is faster in this case especially becasue uitils.get resturns None

pliant gulch
cold sonnet
#

is

glacial echo
slate swan
glacial echo
#

is ther ea difference between is and ==

pliant gulch
#

Yes

#

Is compares the pointers

#

== compares value

maiden fable
#

andy is here to explain u the CPython's internal workings πŸ‘€

pliant gulch
#

This goes back to what I said earlier, and is slower here

#

Compared to using is

cold sonnet
#

== slower?

pliant gulch
cold sonnet
#

meh

maiden fable
#

lmao

spice adder
#

Are there any examples on using a message ID in a command to edit an embed field?