#discord-bots

1 messages · Page 841 of 1

slate swan
#

Self explanatory

vocal shuttle
#

kkk

arctic tiger
#

i like python

slate swan
slim ibex
#

!d discord.abc.GuildChannel.overwrites

unkempt canyonBOT
#

property overwrites: Dict[Union[Role, Member], PermissionOverwrite]```
Returns all of the channel’s overwrites.

This is returned as a dictionary where the key contains the target which can be either a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") or a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") and the value is the overwrite as a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite").
slate swan
#

WHAT HOW DOES THIS NOT HAVE COGS LMAO

slate swan
slim ibex
slate swan
#

the discord.Cogs

slim ibex
#

!d discord.ext.commands.Bot.cogs

unkempt canyonBOT
slate swan
#

its a coro

dull terrace
#

is creating a table for every user that's labelled as their user idea a bad idea?

slate swan
#

yes

slate swan
#

columns are a thing

slim ibex
#

make a users table where each user id is

slate swan
#

discord.PermissionOverwrite(ctx.author.mention) ? I don’t rlly understand permissions

dull terrace
#

if i use their user id as a column that means ill also have to have a unique column too

slim ibex
#

PRIMARY KEY, yes

#

you can specify it

dull terrace
#

yeah, but isn't that worse?

cedar stream
unkempt canyonBOT
#

class discord.PermissionOverwrite(**kwargs)```
A type that is used to represent a channel specific permission.

Unlike a regular [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions"), the default value of a permission is equivalent to `None` and not `False`. Setting a value to `False` is **explicitly** denying that permission, while setting a value to `True` is **explicitly** allowing that permission.

The values supported by this are the same as [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") with the added possibility of it being set to `None`.

x == y Checks if two overwrites are equal.

x != y Checks if two overwrites are not equal.

iter(x) Returns an iterator of `(perm, value)` pairs. This allows it to be, for example, constructed as a dict or a list of pairs. Note that aliases are not shown.
cedar stream
#

Read this

slim ibex
slate swan
dull terrace
#

no, because each user would need multiple columns

slate swan
#

i like UNIQUE better imo

slim ibex
#

only majoir diff between UNIQUE and PRIMARY KEY is that PRIMARY KEY doesn't accept NULL values

dull terrace
#

idk how a database finds the data, it seems like it would be slower

slate swan
#
# User table
| user_id | name|
123456     pepe
dull terrace
#

because i would need to use WHERE user_id = whatever

slim ibex
#

and there can only be one PRIMARY KEY constraint in a table

dull terrace
#

and then if each user has like 1k columns

slim ibex
#

it isn't slow

slate swan
slim ibex
#

!sql-fstrings

unkempt canyonBOT
#

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

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

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

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

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

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

slate swan
#

its not taking user input

#

youre fine

#

no need for placeholders as you cant inject anything to it

pliant gulch
#

Bad practice is a bad practice regardless

slate swan
#

how is that bad practice?

pliant gulch
#

Because it doesn't sanitise the input at all

slim ibex
slate swan
#

because it doesn't take input?

#

it doesnt really take user input

pliant gulch
#

🤔 how does that matter, you're still putting in data to the database

#

You should still parameterise the ID

slate swan
#

thats generated by discord

#

you can practice it but its kinda overkill and unnecessary

shrewd inlet
#

is there a way i can make a command where it will show images of a specific thing from google or some other image site?

#

like if i wanted it to just show pictures of olivia rodrigo

#

sorry if i sound dumb i’m kinda new to all this

slate swan
#

then youll need to webscrape or if they have a restful api use it

shrewd inlet
slate swan
#

🧐

slim ibex
#

REST api

slate swan
#

same thing

#
overwrites = {
   ctx.guild.default_role: discord.PermissionOverwrite(read_messages=False),
   ctx.guild.me: discord.PermissionOverwrite(read_messages=True)
}

  await ctx.guild.create_text_channel('test', overwrites=overwrites)
#

its called a REST api or a restful api

patent moon
#

RESTful

slim ibex
#

Representational State Transfer 🗿

patent moon
#

ful

slate swan
#

you know what i mean, so it doesnt matter

shrewd inlet
#

how can i make a command that will add a picture to a list of choices? i have a command ?img and i want people to be able to add images to the list of images that are already there (the code chooses a random image)

#

my god am i dumb, but yeah instead of an api this would make things easier

#

so ppl can submit pics for the command

dull terrace
pliant gulch
# slate swan you can practice it but its kinda overkill and unnecessary

How so, practising in a bad way will end up making bad habits; bad habits die hard. If your code base has a lot of non parameterised queries that take in dynamic values its gonna end up biting you in the ass, I'm sure you'd be more likely to mistake when and where to use it, or to use it at all. And I'm also sure some people will be looking back at their previous queries as a point of reference. Disastrous overall don't you think?

shrewd inlet
dull terrace
shrewd inlet
slate swan
#

ctx.guild.me: discord.PermissionOverwrite(view_channel=True, send_messages=True)

What do I replace .me to in order for author to have permissions

shrewd inlet
#

idk how to explain it well

dull terrace
#

🤔 what

slate swan
#

@bot.command()
async def start(ctx):
  overwrites = {
   ctx.guild.default_role: discord.PermissionOverwrite(view_channel=False),
   ctx.guild.me: discord.PermissionOverwrite(view_channel=True, send_messages=True)
}``` 

I can’t seem to make .me the command user
dull terrace
#

it's tiles to draw an image

#

not user submitted

shrewd inlet
# dull terrace 🤔 what

the image command shows one random picture from a set of random choices and i want to make a command that lets users submit pictures of their own to the image command

#

that makes the most sense

dull terrace
#

oh you're looking for help

shrewd inlet
#

yeah

#

so if a user submits a picture, it will show up (at some point) when i do ?img

slate swan
#
async def start(ctx):
  overwrites = {
   ctx.guild.default_role: discord.PermissionOverwrite(view_channel=False),
   ctx.author: discord.PermissionOverwrite(view_channel=True, send_messages=True)
}

  await ctx.guild.create_text_channel('test', overwrites=overwrites)``` how do I make it under certain categorie
umbral night
#

hi so I have a create role command and I'm wondering how I could make all the roles i create, have display differently toggled on

#

this is what I have rn

# createroll command
@client.command(aliases=['cr'])
@commands.has_permissions(manage_roles=True)
async def createrole(ctx, *, role:str = None):
  guild = ctx.guild
  
  perms = discord.Permissions(permissions=0)
  
  await guild.create_role(name=role, permissions=perms)
  await ctx.send(f'`{role}` was created')
hoary cargo
pliant gulch
#

Bad habits die hard

hoary cargo
#

Or don't die at all MR_canny_7

slate swan
#
async def start(ctx):
  overwrites = {
   ctx.guild.default_role: discord.PermissionOverwrite(view_channel=False),
   ctx.author: discord.PermissionOverwrite(view_channel=True, send_messages=True)
}

  await ctx.guild.create_text_channel('test', overwrites=overwrites)``` how do I make it under certain categorie
hushed field
#

get a channel, with the category id, then make the channel in the category

#

category = bot.get_channel(category_id)
await category.create_text_channel()

cloud dawn
#

import disnake as discord 😔

slate swan
#

smh how could they

pliant gulch
slate swan
hushed field
#

yes, assuming you changed guild for ctx.guild

cloud dawn
pliant gulch
#

The only thing they changed was the toolbar area

#

I'd expect something users would end up looking at 90% of the time to be at least appealing

cloud dawn
slate swan
#

I think I’ve used await wrong

#

My bot is not reacting

#

No Commands are working

hushed field
#

does the bot turn online

#

do you have an on_message event?

hushed field
slate swan
pliant gulch
slate swan
hushed field
#

no

#

do you have an event anywhere

#
@bot.event
async def on_message(message):
   ...```
slate swan
#

only 2

#

@hushed field

@bot.command()
async def start(ctx):
  overwrites = {
   ctx.guild.default_role: discord.PermissionOverwrite(view_channel=False),
   ctx.author: discord.PermissionOverwrite(view_channel=True, send_messages=True )
}

category = bot.get_channel(944748748117012560)
await category.create_te

Await outside function why tho

slate swan
hushed field
hushed field
slate swan
#

and then?

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.

slate swan
slim ibex
#

await can’t be used outside an async function

hushed field
# slate swan and then?

then in your on_command_error, after the isinstance add the following:

else:
  print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr)
  traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)```
slim ibex
#

The indentation is off

hoary cargo
#

🗿

slim ibex
#

🗿

slate swan
hushed field
#

fix indentation

slate swan
#

Ok

hushed field
#

and import sys

slate swan
#

Me?

hushed field
#

yes

hoary cargo
#

MR_uncanny_2 you

slate swan
slate swan
slim ibex
#

He prolly have an issue with on_message or his command handler

slate swan
#

my bot worked

#

but today i started and now its not working

hushed field
slate swan
hushed field
hushed field
hoary cargo
slate swan
#

ah sry

#

my bad

slim ibex
slate swan
#

i did now but nothing showed up

hushed field
slim ibex
#

!d discord.ext.commands.Bot.process_commands

unkempt canyonBOT
#

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

This function processes the commands that have been registered to the bot and other groups. Without this coroutine, none of the commands will be triggered.

By default, this coroutine is called inside the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event. If you choose to override the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event, then you should invoke this coroutine as well.

This is built using other low level tools, and is equivalent to a call to [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") followed by a call to [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").

This also checks if the message’s author is a bot and doesn’t call [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") or [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") if so.
hushed field
hushed field
#

did an error pop up?

slate swan
#

nothing

hushed field
#

what did you do

slate swan
hushed field
#

...

hoary cargo
hushed field
#

await ctx.send(embed=em) goes INSIDE your if statement

slim ibex
slate swan
#
category = ctx.guild.get_channel(CATEGORY_ID)

@bot.command()
async def start(ctx):
  overwrites = {
   ctx.guild.default_role: discord.PermissionOverwrite(view_channel=False),
   ctx.author: discord.PermissionOverwrite(view_channel=True, send_messages=True )
}
  await category.create_text_channel('test', overwrites=overwrites)

#

bro

hushed field
slate swan
#

idk just send me the code

@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        em = discord.Embed(title=f"Cooldown!", description=f"Try again in {error.retry_after:.2f}s.", color=0x9208ea,
                           timestamp=datetime.utcnow())
    else:
        print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr)
        traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
    await ctx.send(embed=em)
slim ibex
#

There is something called logging module

hushed field
hushed field
hushed field
slim ibex
#

indentation errors are brought up by VSCode

#

That doesn’t need some crazy dunder method shit

hushed field
#

mate what

slate swan
#

so anyone can help me or not ?

hushed field
#

if you dont know what that means or how to do it, learn python

slate swan
#

my english is

#

bad just edit it

hushed field
#

no

hoary cargo
slate swan
#

@hushed field it works but how do I make it so only 1 channel created at a time

#

?

#

right?

hoary cargo
#

What

drowsy birch
#

help me

hushed field
hushed field
#

now run it and try ?help

slate swan
#

kk wait

#

wtf still nothing

hoary cargo
#

Did you triggered the cooldown? MR_canny_2

slate swan
#

no

#

its ?help not ?gen

#

the cooldown only for ?gen

hushed field
#

well lets start with the basics

#

im assuming the bot comes online and the prefix is ?. i am also assuming the bot can see the channel

slate swan
#

and prefix is ?

hushed field
#

does the gen command work?

slate swan
drowsy birch
#
import traceback,sys
@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        em = discord.Embed(title=f"Cooldown!", description=f"Try again in {error.retry_after:.2f}s.", color=0x9208ea,
                           timestamp=datetime.utcnow())
    else:
        print('Ignoring exception in command {}:'.format(ctx.command), file=sys.stderr)
        traceback.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
    await ctx.send(embed=em)
hushed field
drowsy birch
#

and the traceback:Traceback (most recent call last):
File "c:/Users/ad/Desktop/python-exerise/Python/Python-progect/jjj.py", line 2, in <module>
@bot.event
NameError: name 'bot' is not defined

hushed field
#

bro

#

that isnt for you

slate swan
#

but why is it the same thing

slim ibex
#

@slate swan you have to process the commands in an on_message listener

slate swan
#

from my embed

drowsy birch
slate swan
#

yes

slim ibex
#
@bot.event
async def on_message(message):
    …
    
    await bot.process_commands(message)
hushed field
slim ibex
#

then make one lmfao

hoary cargo
slim ibex
#

the bot isn’t responding to commands

slim ibex
hoary cargo
#

Then he should fix the commands not doing something amateurish in on_message MR_uncanny_12

hushed field
slim ibex
#

I guess I’m misunderstanding

hoary cargo
#

You probably do

#

Probably I misunderstood too, since I don't get it if the cooldown it doesn't work or the whole command

slim ibex
#

He says no commands work

#

that is why I’m saying process the commands

slate swan
#

All Commands not response

#

It should

Vestige: ?help

Bot: Help: 1, 2, 3

#

But now:

Vestige: ?help

Bot:

slim ibex
#

idfk how on_command_error helps with the bot not responding to ANY command. But, again, I could be misunderstanding this whole thing

hoary cargo
slate swan
#

yes

#

but today not more

#

I want to do that when you do !close it deletes current channel your on but I’m not sure how to get channel id?

slim ibex
#

!d discord.Guild.get_channel

unkempt canyonBOT
#

get_channel(channel_id, /)```
Returns a channel with the given ID.

Note

This does *not* search for threads.
slim ibex
#

If you want to delete a channel

#

!d discord.abc.GuildChannel.delete

unkempt canyonBOT
#

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

Deletes the channel.

You must have [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
slate swan
#

It’s just getting id

slim ibex
#

There is also TextChannel.delete and CategoryChannel.delete but it seems like they are the same

slate swan
slim ibex
#

ctx.channel.id should be able to get the current channels ID

hoary cargo
#

If u do channel.delete my guess is that it will delete the current channel you type the command without a specific id

dull terrace
sullen plaza
#

do anyone know how to solve this?

slim ibex
slate swan
#

install

dull terrace
#

isn't it commands

slim ibex
#

and/or is the right interpreter selected

dull terrace
#

not command

slate swan
slate swan
sullen plaza
slim ibex
#

!d discord.ext.commands.Command

unkempt canyonBOT
#

class discord.ext.commands.Command(*args, **kwargs)```
A class that implements the protocol for a bot text command.

These are not created manually, instead they are created via the decorator or functional interface.
slate swan
#

Go to terminal

#

And type pip install (package)

slim ibex
#

pip install discord

#

(use a fork though) 🗿

sullen plaza
slate swan
#
@bot.command()
async def close(ctx, channel_id: int):
    channel = client.get_channel(channel_id)
    await channel.delete()
    await ctx.send("Successfully deleted the channel!")```
slim ibex
#

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

dull terrace
#

I think i've finally got my tables saved to a database 😓

slate swan
#

How i can make a Public Int?

Example in C#
public static int number = 1;

slate swan
#

hmm

slate swan
slim ibex
#

Python doesn’t have access modifiers

slate swan
#

Wait I got an idea

slate swan
slim ibex
#

the convention is showing that something is private is to add an underscore before the name

slate swan
#

i know how to do it on the main.py but no in cogs

#

should I replace ctx.send to self.send?

hoary cargo
#

MR_uncanny_2 it's the same thing
But with some addons

slim ibex
#

!e

x = 10

def main():
    y = 15

print(y)
unkempt canyonBOT
#

@slim ibex :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 6, in <module>
003 | NameError: name 'y' is not defined
slim ibex
#

Here, X is global (public) and y is local

slate swan
dull terrace
#

is there an official coding/python jargon dictionary?

slate swan
#

Just use api

slim ibex
sullen plaza
#

!d import discord

slate swan
slim ibex
#

yes

slate swan
#

alr

slate swan
slim ibex
#

but in class, self is the first param for methods

#

unless it’s a class or static method

slate swan
slate swan
slim ibex
hoary cargo
slim ibex
#

Since client is likely not a parameter of your command function, and it shouldn’t

slate swan
#
self.client
#

right?

slim ibex
#

pls don’t use global

#

!global-var

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.

slate swan
#

Smart asf

hoary cargo
slim ibex
#

💀

slate swan
#

@bot.command()
async def close(ctx):
    channel = ctx.message.author.name
    await channel.delete()
    await ctx.send("Successfully deleted the channel!")```
#

When you get 300iq buy python says otherwise

final iron
#

What

slim ibex
#

lmfao dude

final iron
#

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

final iron
#

Check this out

slim ibex
slate swan
#

Bro

final iron
#

You have no idea what you're doing

slim ibex
#

Holy shit u didn’t have to do him like that

slate swan
#

No way mans just pulls out resources

#

Na I just got quick vio

final iron
#

I'm already losing brain cells

slim ibex
#

💀💀💀💀

final iron
#

🗿

#

I'm out

slate swan
#

Bye

#

Ok so what I was saying

slate swan
final iron
#

Ofc

slate swan
#

LOL

final iron
#

bor discord broke

hoary cargo
final iron
#

Delete the authors name

#

💀

hoary cargo
slate swan
#

So rn channel name is alexlol

slate swan
#

And I tried to delete that way

#

But didn’t work out well

hoary cargo
slate swan
#

Like it’s bullying at this point

#

@final iron pls stop bullying me???🥺🥺🥺🥺

hoary cargo
#

maybe you really should check resources

slate swan
#

Not fair bro 😢😢😢😢😢

hoary cargo
slate swan
#

Tbh I’ve never used resources bc I get 15 minutes in and I get bored

hoary cargo
#

Then read docs
Still boring but well

slate swan
#

Docs is more fun

#

And it slower ect

pliant gulch
#

Read the source code, you'll have fun for 10 minutes trying to figure out whatever the hell danny was doing

#

Then spend the rest crying

slate swan
#

Sounds fun

#

When do I start?

hoary cargo
#

MR_uncanny_10 Danny did a good job since his main job is not even programming kekw

slate swan
#

O lol

hoary cargo
#

He's a doctor
Like fr, finding enough time to work at such library is insane

slate swan
#

The channel is the users id

#
@bot.command()
async def close(ctx):
    channel = ctx.message.author.name
    await channel.delete()
    await ctx.send("Successfully deleted the channel!")
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.

hoary cargo
slate swan
#

with self, ctx

slate swan
#

and without ctx

hoary cargo
hoary cargo
slate swan
#

but didn't

#

same error

slate swan
#

context is the attr that has send which youre using which it should be the second argument since the first is always self to access the class

#
guild = self.client.get_guild(ctx.guild.id)

Is this correct right?

slate swan
#

@bot.command()
async def close(ctx):
    await channel.delete()
    await ctx.send("Successfully deleted the channel!")


@bot.command()
async def start(ctx):
  overwrites = {
   ctx.guild.default_role: discord.PermissionOverwrite(view_channel=False),
   ctx.author: discord.PermissionOverwrite(view_channel=True, send_messages=True )
}
  category = ctx.guild.get_channel(944748748117012560)
  await category.create_text_channel(f'{ctx.message.author.name}', overwrites=overwrites)
  await ctx.reply("channel is created")

Plan: deletes the channel you say the command !close on

#

await ctx.channel.delete() if you mean the current channel

slate swan
slate swan
#

what do i type here

#

to run it

slate swan
slate swan
slate swan
slate swan
#

how i can use for this a global int

slate swan
slate swan
slate swan
slate swan
slate swan
#

and then i can use it

#

if you're double-clicking the file to launch it, this isn't a bug. Python files launched this way will open their own window, but won't automatically keep it open when the script finishes.

You can open a console and run the script from there, like this:

  1. open File Explorer to the directory where you have the file
  2. in the address bar at the top, type cmd or PowerShell and press Enter to launch a command line in that directory
  3. In the newly opened window, type python <filename>.py (where <filename> is the name of your Python file)
    3a) py instead of python may also work and is recommended whenever possible.
  4. this will launch it in a window that you can control.
pliant gulch
slate swan
#

i was told to do that

hoary cargo
slate swan
#

@slate swan actually I got better idea I’ll just make it so it auto closes after 30m

slate swan
slate swan
slate swan
#

@slate swan

slate swan
#

@slate swan

#

why ping me

#

xD

#

that you read xd and maybe help

slate swan
slate swan
#

Please its important for me

#

you want all cooldows to be the same?

#

i am making a setcooldown command

#

but its not working

slate swan
#

and i think maybe the int is not global is the problem

slate swan
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!

slate swan
#

a botvar is what you need lol

slate swan
#

not sure how it didnt pop to my head lol

#
@bot.command()
async def start(ctx):
  overwrites = {
   ctx.guild.default_role: discord.PermissionOverwrite(view_channel=False),
   ctx.author: discord.PermissionOverwrite(view_channel=True, send_messages=True )
}
  category = ctx.guild.get_channel(944748748117012560)
  await category.create_text_channel(f'{ctx.message.author.name}', overwrites=overwrites)
  await ctx.reply("channel is created")
  time.sleep(0.10)
  ctx.channel.delete()```
#

format it atleast

#

and time isnt async

slate swan
#

use .sleep from asyncio

slate swan
#

so you wont block your whole bot and disconnect it

slate swan
slate swan
slate swan
pliant gulch
slate swan
#

10s?

slate swan
pliant gulch
slate swan
slate swan
#

1.0 is one second time units lol

#

Damn

#

can anyone help me?

#

the set cooldown is not working

#

youve been told already.

slate swan
slate swan
pliant gulch
#

is genMax and genCooldown supposed to be dynanmic, if so it's not gonna work

slate swan
unkempt canyonBOT
#

discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").

When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.

To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.

If nothing is found that matches the attributes passed, then `None` is returned.

Examples

Basic usage...
pliant gulch
#

If you were to change the value of them, it wouldn't do a single thing

slate swan
pliant gulch
#

That wouldn't even work, again as I said above

slate swan
#

so what i need to do

#

just give me code example and i & you happy

#

bro

pliant gulch
#

!d discord.ext.commands.Command.update could work, if you pass in cooldown

unkempt canyonBOT
#

update(**kwargs)```
Updates [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") instance with updated attribute.

This works similarly to the [`command()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.command "discord.ext.commands.command") decorator in terms of parameters in that they are passed to the [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or subclass constructors, sans the name and callback.
slate swan
#

not us, we are not allowed to spoonfeed here.

slate swan
#

Andy, command handler when?

slate swan
#

🥴

slim ibex
#

t fook

slate swan
#

@bot.command()
async def start(ctx):
  overwrites = {
   ctx.guild.default_role: discord.PermissionOverwrite(view_channel=False),
   ctx.author: discord.PermissionOverwrite(view_channel=True, send_messages=True )
}
  category = ctx.guild.get_channel(944748748117012560)
  await category.create_text_channel(f'{ctx.message.author.name}', overwrites=overwrites)
  await ctx.reply("channel is created")
  asyncio.sleep(30.0)
  ctx.channel.delete()``` @slate swan will channel created delete in 30s
slate swan
# slate swan or are we? ;)

pithink cannot relate, i just give people hints with Objects and docs until someone gets annoying and ping me 100times

slate swan
slate swan
#

But await it as zilo said

slate swan
#

Channel is still here

slate swan
pliant gulch
jade tartan
#

wow no one answered my question

slate swan
slate swan
#

Wdym tho

slate swan
slate swan
slate swan
#

So will I just remove ()

#

bro

#

you await it like any coroutine.

#

I’m tired

#

Sorry

#

Ifs 3am so ye

#
await ctx.channel.delete()
```😱
slate swan
slate swan
#

Yea I’m really tired

#

no joke

#

How do I not notice that

#

you will when that big o tracemalloc error comes

jade tartan
#

Can someone help me with something

slate swan
jade tartan
#

Please

slate swan
#

dont ask to ask just say

slate swan
slate swan
slate swan
pliant gulch
hoary cargo
slate swan
slate swan
slate swan
# unkempt canyon

This is not the same thing i am trying it with @commands.cooldown(genMax, genCooldown, commands.BucketType.user)

#

but he with text or smh

hoary cargo
jade tartan
# slate swan Just ask the question

Is there any one here that knows how to make like where ur bot asks you questions from running the command in the discord server and then saves the info on the server and also sends you the results on the dm?

pliant gulch
slate swan
#

global genCooldown
genCooldown += int(arg)

slate swan
#

i use this

#

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

slate swan
#

😈😈😈😈😈👹👺👺👺

#

@hoary cargo damn this feels good

#

can someone help me

#

but how i can update it for all i mean that the value get updated for cooldown too

quick gust
slate swan
#

what do i type here

slate swan
#

if you're double-clicking the file to launch it, this isn't a bug. Python files launched this way will open their own window, but won't automatically keep it open when the script finishes.

You can open a console and run the script from there, like this:

  1. open File Explorer to the directory where you have the file
  2. in the address bar at the top, type cmd or PowerShell and press Enter to launch a command line in that directory
  3. In the newly opened window, type python <filename>.py (where <filename> is the name of your Python file)
    3a) py instead of python may also work and is recommended whenever possible.
  4. this will launch it in a window that you can control.
#

Imma have a look at lefi's

slate swan
pliant gulch
#

Lefi was pretty much discord.py type but I did all the internals cleaner

slate swan
#

make sure python is added to path

pliant gulch
#

If Rin ever does get message commands it will be different

slate swan
slate swan
#

what happend🙃

slate swan
slate swan
pliant gulch
# slim ibex 🗿

Rin 1.0.0v ETA by the end of this month. Be there or be square 😼

slate swan
#

How i can update a Int for all

My Problem

!cooldown

Bot: 5 Seconds

--------------------
!setcooldown 10

Bot: 5 Seconds

The Values:

genMax = 1  # Max Gens too get the Cooldown
genCooldown = 60  # Cooldown after Max Gens (in Seconds)

Code to update the Cooldown value

@bot.command()
async def setcooldown(ctx, arg):
    if ctx.message.author.guild_permissions.administrator:
        global genCooldown
        genCooldown += int(arg)
        embed = discord.Embed(title="Counter", description="", color=0x9208ea, )
        embed.description = "Current Cooldown to: " + str(genCooldown)
        await ctx.send(embed=embed)
    else:
        print("failed")

Why this happening??
The Cooldown Code @commands.cooldown(genMax, genCooldown, commands.BucketType.user)

pliant gulch
#

Now that I’ve actually committed I’m gonna kick this up high gear and do work 😔

slim ibex
#

ayo

slate swan
jade tartan
#

i want a more shorter one

final iron
slim ibex
#
def run(self) -> None:
  try:
    for filename in os.listdir("./src/cogs"):
      if filename.endswith(".py") and not filename.startswith("_"):
        self.load_extension(f"src.cogs.{filename[:-3]}")
        log.info("Cogs loaded successfully!")
  except FileNotFoundError:
    log.error("A cog or multiple cogs failed to load.")

  super().run(token="")

i think im fucking some shit up somehow because everytime I run my bot, it runs the except block ):

final iron
#

Okay not 40

#

Maybe like 25

slate swan
#

I need help for Windows directories, some letters aren't detected and causes errors

#

Like the D and the S

final iron
#

I have to make attrs for all of these

#

😔

#

@pliant gulch Is there some way I can do it dynamically and not have to hardcode all of it?

slate swan
cloud dawn
slim ibex
# slim ibex ```py def run(self) -> None: try: for filename in os.listdir("./src/cogs")...
from disnake.ext.commands import Cog, slash_command, Context
from ..utils.converters import TimeConverter # unused import don't worry bout it


class Moderation(Cog, name="Moderation"):
    def __init__(self, bot):
      self.bot = bot

    @slash_command(name="kick", description="Kick a user from the server.")
    async def kick(self, ctx: Context):
        """
        Kick a user from the server.

        Usage:
            `/kick @user`

        Parameters:
            ctx: The context of the command.
        """
        await ctx.send("TESTING")


def setup(bot):
    bot.add_cog(Moderation(bot))

this is me cog

final iron
cloud dawn
final iron
#

Lemme just give you the json data

#

Code is secret

#

😉

cloud dawn
final iron
#

Yeah I mean not have to hard code all the attributes

#

Theres so many

cloud dawn
# final iron Yeah I mean not have to hard code all the attributes

I have this in my own bot as well to convert yaml to an object:

def _obj_dic(d: dict):
    top = type('new', (object,), d)
    seqs = tuple, list, set, frozenset
    for i, j in d.items():
        if isinstance(j, dict):
            setattr(top, i, _obj_dic(j))
        elif isinstance(j, seqs):
            setattr(top, i,
                    type(j)(_obj_dic(sj) if isinstance(sj, dict) else sj for sj in j))
        else:
            setattr(top, i, j)
    return top
final iron
#

Ah yes

#

I totally understand that

austere solstice
#

pls help

cloud dawn
# final iron I totally understand that

!e ```py
def _obj_dic(d: dict):
top = type('new', (object,), d)
seqs = tuple, list, set, frozenset
for i, j in d.items():
if isinstance(j, dict):
setattr(top, i, _obj_dic(j))
elif isinstance(j, seqs):
setattr(top, i,
type(j)(_obj_dic(sj) if isinstance(sj, dict) else sj for sj in j))
else:
setattr(top, i, j)
return top

test = _obj_dic({"yes": "no", "no": "yes"})
print(test.yes)

unkempt canyonBOT
#

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

no
final iron
#

So it just creates an attr with the key name?

slate swan
slate swan
cloud dawn
austere solstice
cloud dawn
#

At least have some kind of async loop task.

#

time.sleep(5) i give up

slate swan
austere solstice
pliant gulch
cloud dawn
slate swan
#

Ok

final iron
pliant gulch
#

Updates the classes namespace with the stuff inside of self.data, that being the raw dict

final iron
#

Is there any way I can disregard some of the data in the raw dict?

pliant gulch
#

dict comp

final iron
#

Not exactly of course

#

I'll have to change the code

pliant gulch
#

eh

austere solstice
#

ayone help

pliant gulch
#

you could use that I guess, but it's kind of weird lmao

final iron
#

Could you show a different example then?

pliant gulch
final iron
unkempt canyonBOT
#

@final iron :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | IndexError: list index out of range
final iron
#

See the issue?

austere solstice
unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @jade tartan until <t:1645328091:f> (9 minutes and 59 seconds) (reason: newlines rule: sent 125 newlines in 10s).

cloud dawn
#

@jade tartan Wait a sec, mods sometimes will unmute.

cloud dawn
#

!paste use this next time for long code.

unkempt canyonBOT
#

Pasting large amounts of code

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

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

daring olive
#

!unmute 944796891873423390

#

!unmute 506940530333057025

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: pardoned infraction mute for @jade tartan.

final iron
#

Interesting

jade tartan
#

Ohh thank you sorry i didnt know about this

daring olive
#

npnp

jade tartan
#

weird

#

Thank you so much

pliant gulch
cloud dawn
pliant gulch
#

Basically my best attempt at a swiss-knife class builder

austere solstice
daring olive
#

i think i grabbed the ID of python's msg

#

!unmute 944796891873423390

unkempt canyonBOT
#
Bad argument

Could not convert "user" into UnambiguousMember or UnambiguousUser.
User "944796891873423390" not found.

jade tartan
final iron
cloud dawn
pliant gulch
final iron
#

What is that?

cloud dawn
final iron
#

A library?

pliant gulch
#

Yea, like dataclasses

final iron
#

!pypi attr

unkempt canyonBOT
#

Simple decorator to set attributes of target function or class in a DRY way.

jade tartan
#

Thanks tho

final iron
#

in a DRY way

jade tartan
final iron
#

Why is DRY capitalized

cloud dawn
jade tartan
#

for my bot

daring olive
#

!src unmute

unkempt canyonBOT
#
Command: unmute

Prematurely end the active mute infraction for the user.

Source Code
#
Command: unmute

Prematurely end the active mute infraction for the user.

Source Code
daring olive
#

jinx

cloud dawn
#

:(

jade tartan
daring olive
#

our repo is free for you to peruse

jade tartan
#

like sixteen is undefined

cloud dawn
daring olive
#

oh while i'm here

cloud dawn
#

You're using a variable pithink

daring olive
#

anyone experience vscode not running their bot when using the launch.json configuration? but using python -m bot works perfectly fine?

  File "/Users/mina/projects/bot/bot/api.py", line 68, in maybe_raise_for_status
    raise ResponseCodeError(response=response, response_json=response_json)
bot.api.ResponseCodeError: Status: 401 Response: {'detail': 'Invalid token header. Token string should not contain spaces.'}```
#

it's very strange, started today

#

python -m bot works no issue

#

pycharm run as module config works no issue

#

it's just using the run config in vsc that does this

cloud dawn
daring olive
#

yeah it doesn't

#

and it runs perfectly fine when doing python -m bot

#

same interpreter, etc.

#

it's a MYSTERY

final iron
#

So it's just an issue on vsc?

jade tartan
#

for that mute cmd do i need to do download any module

daring olive
#

yup

jade tartan
#

for that

daring olive
#

this is the launch config

{
    "configurations": [
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "bot"
        }
    ]
}```
cloud dawn
jade tartan
#

ohh so it doesnt use client?

#

if that make sense

cloud dawn
cloud dawn
daring olive
#

i gave up on it for now since i can just run in terminal

jade tartan
#

Ohh right ok so for that to work i need to change the from bot.... to from client?

cloud dawn
daring olive
#

this stuff yeah

cloud dawn
cloud dawn
final iron
#

@pliant gulch How does your base model account for type hints though?

cloud dawn
final iron
#

That's what I was worried about

#

Hard code time

#

😔

daring olive
jade tartan
daring olive
#

and if there were, why would it work when running in terminal?

jade tartan
#

@cloud dawn

pliant gulch
daring olive
#

no wait i'm dumb

jade tartan
final iron
daring olive
#

hmm

pliant gulch
#

You add the custom object to the type

#

That's what I'm doing at least,

#

And for complex types you use BaseModel.property

cloud dawn
cloud dawn
daring olive
#

ok i had a

#

X=XXXXX # comment

fiery veldt
#

Huii huii huiii

daring olive
#

which i pasted into my .env while i already had the debugger running

#

and hitting the green refresh button was fine

fiery veldt
daring olive
#

but it wasn't fine when i tried to run it again

cloud dawn
#

It wasn't updated yet.. xD

daring olive
#

ah

#

interesting tho that running from terminal still worked

#

so no end of line # comments are allowed i suppose

#

or at least, not consistently

cloud dawn
daring olive
#

right

#

well

#

idk the inner workings or reasons

#

but thanks lol

#

i was going crazy

#

can i put comments as new lines in .env files?

#

let's try

cloud dawn
#

Hahaha, i too have had these moments, think everyone has at some point.

daring olive
#

it appears i can

cloud dawn
jade tartan
#

to copy paste it with the specific module

#

!src mute

unkempt canyonBOT
#
Command: tempmute

Temporarily mute a user for the given reason and duration.

Source Code
cloud dawn
#

Maby
token="XXXXXXX" #comment

cloud dawn
# jade tartan ohh i just need the mute command then

The issue with copying @unkempt canyon his source code is that you need to understand Python since a lot of the commands use functions, classes, converters that they've made on their own. And those converters have other functions again etc..

daring olive
#

comment was on a different line

cloud dawn
#

I recommend not copying but to get the general idea of the command and try to make it work the same.

daring olive
#

BOT_API_KEY=XXX # comment

granite plume
#

hey

cloud dawn
granite plume
#

is there any way to get a bot's prefix to be slash commands?

#

well yes there's a way

#

but what is it

cloud dawn
granite plume
#

yeah. like the application

#

Like this

daring olive
#

so dpy

cloud dawn
daring olive
#

ty for the help & sanity checks :3

cloud dawn
daring olive
#

i have made a couple teeny tiny PRs to bot

granite plume
#

i added application command already to scope

native wedge
#

how to make subcommands?

.fact cat``` etc
jade tartan
slim ibex
#

!d discord.ext.commands.Group.command

cloud dawn
unkempt canyonBOT
#

@disnake.ext.commands.group(name=..., cls=..., **attrs)```
A decorator that transforms a function into a [`Group`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Group "disnake.ext.commands.Group").

This is similar to the [`command()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.command "disnake.ext.commands.command") decorator but the `cls` parameter is set to [`Group`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Group "disnake.ext.commands.Group") by default.

Changed in version 1.1: The `cls` parameter can now be passed.
slim ibex
#

oh thats the one i wanbted

#

oh so we defaulting to disnake now when searching the docs

#

🗿

cloud dawn
jade tartan
cloud dawn
#

As long as the libraries look alike i will just send whatever i got open in my tab rn 😂

cloud dawn
sick birch
cloud dawn
#

I'm going to sleep now, it's late.. @jade tartan, Robin has arrived, he knows all.

cloud dawn
slim ibex
#

ah yes the 🗿 is spreading

cloud dawn
sick birch
#

I popped in just to check but I suppose I’ll be staying a while hehe

granite plume
#

well that's nice

#

do you think you can answer my question i had to Pandabweer

sick birch
#

sure can you link it i'll take a peek

granite plume
#

ok

slim ibex
#

ayo robin

granite plume
slim ibex
#

help a man rq

cloud dawn
#

!src unmute

unkempt canyonBOT
#
Command: unmute

Prematurely end the active mute infraction for the user.

Source Code
sick birch
#

Oh you want the prefix itself to be /?

#

I mean it's doable but it's gonna make it very difficult for people to use your bot

granite plume
#

oh

cloud dawn
maiden fable
sick birch
slim ibex
#

my logger ain't logging info level stuff 😢

granite plume
final iron
sick birch
#

So you're just looking for slash commands? that's easy, just use one of the forks if you aren't already and problem solved

cloud dawn
sick birch
#

depends on the type of logger

slim ibex
#

also umm

@slash_command(name="kick", description="Kick a user from the server.")
async def kick(self, ctx: Context):
  ...

TypeError: <class 'disnake.ext.commands.context.Context'> is not a valid parameter annotation

sick birch
final iron
sick birch
#

e.g

import discord

or anything similar

granite plume
#

yeah

austere solstice
#

can anyone help how can i make that my bot do not win the giveaway

granite plume
#

what did you mean by "forks" though

slim ibex
sick birch
# granite plume yeah

Unfortunately discord.py does not support slash commands so you'll either have to implement slash commands yourself (i would be happy to explain how) OR use a fork which does it for you

austere solstice
sick birch
granite plume
#

oh

cloud dawn
cloud dawn
sick birch
#

I think the most prominent discord.py fork is disnake though at this point there's like 20 so you might wanna give all of them a try and see which implementation of the new features you like best and take it from there

slim ibex
granite plume
#

ok

granite plume
#

what about implementing them myself?

slim ibex
#

oh ok💀

sick birch
#

I'd be glad to tell you how I did it if you'd like

slim ibex
#

!d disnake.Interaction would it be this @cloud dawn

unkempt canyonBOT
#

class disnake.Interaction```
A base class representing a user-initiated Discord interaction.

An interaction happens when a user performs an action that the client needs to be notified of. Current examples are application commands and components.

New in version 2.0.
cloud dawn
slim ibex
#

oh that one

granite plume
slim ibex
#

thanks

#

first time working with InteractionBot so getting used to id

cloud dawn
austere solstice
sick birch
# granite plume ok sure

Alright, the hardest part is honestly registering the slash command itself. It's a one and done thing so what you'd wanna do is send a HTTP POST request to the discord API registering the slash command, and you can use on_interaction to handle the responses. You might also wanna make a decorator that automatically calls functions based on their names and slash command names

#
@slash_command
async def slash_command_name(interaction: discord.Interaction):
  # process stuff here
jade tartan
pliant gulch
#

kek finally

slim ibex
cloud dawn
pliant gulch
#

Unbelievable though, MESSAGE_CREATE's member object doesn't give user smh

slim ibex
#

i was going to unironically type everything out in Cache()

austere solstice
pliant gulch
#

Ok I'm taking back the v1.0.0 ETA I hate this already

pliant gulch
#

😔 I did that for like 1 hour and I'm already tired of it

cloud dawn
unkempt canyonBOT
#

Pasting large amounts of code

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

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

austere solstice
jade tartan
austere solstice
#

@cloud dawn here is the code

granite plume
jade tartan
granite plume
#

I might not be reading one part of what you said

cloud dawn
granite plume
#

so forgive me if that's the case

strong vessel
#

is it possible to move a bot to another bot? like combine multiple bots

cloud dawn
slate swan
slate swan
#

Rip rate limits

strong vessel
cloud dawn
slate swan
#

Idk

strong vessel
#

from my current understanding every bot is like a permanent unchangeable thing

slate swan
slate swan
strong vessel
#

i don't get it, if rate limits are bad how can bots run in like millions of servers

slate swan
#

If the bot is verified then it bypasses the rate limits

strong vessel
#

ok

cloud dawn
# granite plume ohh
import requests

url = "https://discord.com/api/v8/applications/<my_application_id>/commands"

# This is an example CHAT_INPUT or Slash Command, with a type of 1
json = {
    "name": "blep",
    "type": 1,
    "description": "Send a random adorable animal photo",
    "options": [
        {
            "name": "animal",
            "description": "The type of animal",
            "type": 3,
            "required": True,
            "choices": [
                {
                    "name": "Dog",
                    "value": "animal_dog"
                },
                {
                    "name": "Cat",
                    "value": "animal_cat"
                },
                {
                    "name": "Penguin",
                    "value": "animal_penguin"
                }
            ]
        },
        {
            "name": "only_smol",
            "description": "Whether to show only baby animals",
            "type": 5,
            "required": False
        }
    ]
}

# For authorization, you can use either your bot token
headers = {
    "Authorization": "Bot <my_bot_token>"
}

# or a client credentials token for your app with the applications.commands.update scope
headers = {
    "Authorization": "Bearer <my_credentials_token>"
}

r = requests.post(url, headers=headers, json=json)
``` This is a really raw requests, this is what you send but disnake has made it nice and readable for you. Discord parses this json data and put it as a command :)
cloud dawn
slate swan
#

Okay

cloud dawn
strong vessel
#

every where i read about rate limits it seems to have different info jfl

slate swan
granite plume
#

is that the on_interaction() command robin was talking about?

slate swan
#

Which panda just sent

granite plume
strong vessel
#

are there places i can put discord bots where it would become popular?

cloud dawn
snow ibex
#

top.gg and the other discord bot listing sites

slate swan
pliant gulch
#

Compared to that of bots in less servers

granite plume
pliant gulch
#

Plus, ratelimits have buckets

cloud dawn
pliant gulch
#

As long as regular bot's don't go over the 50/1s global ratelimit and handle their buckets properly your good

sick birch
#

if you've worked with cooldowns in discord.py it's similar as well, it also has buckets like andy is describing

slate swan
jade tartan
snow ibex
cloud dawn
snow ibex
granite plume
pliant gulch
snow ibex
#

mustve been the wind

cloud dawn
pliant gulch
#

You can really imagine discord's buckets as an actual bucket with water, this water is separated from the main source of water, thus has different amount of usages etc

sick birch
#

different buckets with different items as well

#

each bucket has a different amount of water in it if that helps you understand

pliant gulch
#

Depends on how you decide to hash your bucket identifiers though, that part could get messy if you don't do it properly

slate swan
#

Is it against TOS to attempt to bypass the rate limit

pliant gulch
#

Yea most likely

slate swan
#

Ok

sick birch
#

don't even attempt it, they're there for a reason

pliant gulch
cloud dawn
slate swan
#

Uhhh

#

No

#

I mean yes

cloud dawn
#

If you live in germany it doesn't count.

final iron
slate swan
#

I live in

snow ibex
#

or die

cloud dawn
snow ibex
#

if it isnt the first one discord gonna have to answer some tough questions

maiden fable
cloud dawn
#

You could bypass ratelimit but you'd need to master socket module and some udp networking first.

sick birch
strong vessel
#

how do people even generate >50 requests/second worth of activity from bots that are in <100 servers

cloud dawn
snow ibex
#

panda dangerous waters

maiden fable
sick birch
#

unless you're doing it deliberately

maiden fable
sick birch
#

possible but not really common

pliant gulch
maiden fable
pliant gulch
#

Plus, you also have bucket handling which your wrapper should be doing

#

Almost everything is gonna be trying to stop you from being ratelimited

sick birch
#

!d discord.TextChannel.slowmode_delay

unkempt canyonBOT
maiden fable
sick birch
#

yep

snow ibex
#

czechia and united kingdom?

maiden fable
#

I also asked for the same not to mention I deleted that bot cz, uhhh, we don't talk about it

maiden fable
snow ibex
#

ah

#

so no coding queen lizzy in track suit sadge

sick birch
#

I can't spoonfeed that to you, but discord.TextChannel would be replaced by the name of the channel variable

snow ibex
#

or the channel object fetched directly

slate swan
#

!d discord.Guild.get_channel

unkempt canyonBOT
#

get_channel(channel_id, /)```
Returns a channel with the given ID.

Note

This does *not* search for threads.
slate swan
#

Use the slowmode_delay property on the returned TextChannel object

cloud dawn
#

@maiden fable why did menudocs and disnake tag up

sick birch
#

define "it itsn't working"

#

errors? how's it behave now?

#

Okay nevermind I see a few issues here

#
  1. achannel = bot.get_channel() missing arguments
  2. achannel = bot.get_channel(channel) takes an ID, not a string
  3. oldsm = achannel.slowmode_delay() slowmode_delay is a property ,not a function, so no need for ()
  4. await ctx.channel.edit(slowmode_delay=(str(newsm))) slowmode_delay takes an integer, not a string
#

awesome, let me know if there are any other issues