#discord-bots

1 messages · Page 880 of 1

slate swan
#

how much is one megabit though?

#

1000

#

what 1000?

#

1000mbs

maiden fable
#

Idk much about all this stuff, anyways this all is ot

slate swan
#

1000mb is a gb but in windows 1024mb is a gb

fluid spindle
maiden fable
slate swan
#

so i said megabyte

maiden fable
#

Still ot

slate swan
#

its a kb lol

manic wing
#

okimii you just dont know when to stop do you

slate swan
#

ok? you arent my dad either02comfy

manic wing
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

maiden fable
#

he got it

manic wing
#

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

maiden fable
#

Ayo yea

slate swan
#

bruh

manic wing
#

that status= is whack

slate swan
manic wing
#

why have you put , intents=intents) in status=

#

when you closed the discord.Activity

slate swan
manic wing
manic wing
slate swan
#

better?

manic wing
# slate swan

it was fine before, you just cut off the bot = part

#

show full error

slate swan
#

NO ERRROR RNOW

manic wing
#

ok cool

slate swan
#

fuck

manic wing
#

why are you trying to send a message to a message?

#

just do await channel.send?

#

when you're programming always think of the logic

slate swan
#

how to send messages to channel

manic wing
slate swan
#

i got it last time

manic wing
#

well you must've done something different

final shard
#

im in a embed

#

i want the field's name to be a hyperlink

slate swan
silk mauve
#

How to ping @ here?

final shard
silk mauve
#

In a ctx

maiden fable
#

LMAO

final shard
#

bruh @cosmic agate

cosmic agate
slate swan
#

uh

final shard
#

nothing xd

maiden fable
#

!d discord.Member.mention ?

unkempt canyonBOT
maiden fable
#

!d discord.TextChannel.mention ?

unkempt canyonBOT
manic wing
#

I love the consistency

cosmic agate
#

for us ig

final shard
#

wait

manic wing
#

The string
and
Returns a
for basically the same thing...
consistency:

cosmic agate
final shard
slate swan
#

huh, then try

.add_field(name="[text](url/link)", value="")
final shard
#

i tried

manic wing
manic wing
cosmic agate
#

the like curly

final shard
cosmic agate
#

thingy

final shard
cosmic agate
#

oh ok

manic wing
final shard
#

i think that isnt a field

manic wing
#

!d discord.Embed.to_dict

unkempt canyonBOT
final shard
#

the one i send in the pic

#

i think the devs just added a text

cosmic agate
#

How to mention users from reactions?

final shard
slate swan
manic wing
#

ill take a hug

cosmic agate
#

How to mention users from reactions?

maiden fable
maiden fable
unkempt canyonBOT
#

async for ... in users(*, limit=None, after=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") representing the users that have reacted to the message.

The `after` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

Examples

Usage

```py
# I do not actually recommend doing this.
async for user in reaction.users():
    await channel.send(f'{user} has reacted with {reaction.emoji}!')
```...
cosmic agate
slate swan
maiden fable
slate swan
kindred drum
#

Hey, why does this loop only print 3 times? despite number_of_winners equalling 6?

@tasks.loop(seconds=5.0)
    async def giveawaytime(self):
  
        for i in range (0, len(Giveaway_Items)):
            if Giveaway_Items[i]['Expired'] == True:
                pass
            else:
                expire_date = Giveaway_Items[i]['Time']
                formatted_time = datetime.datetime.fromisoformat(expire_date)
                if formatted_time < datetime.datetime.now():
                    number_of_winners = Giveaway_Items[i]['Winners'] 
                    for x in (0, number_of_winners):
                        
                        winner = random.choice(Giveaway_Items[i]['Members'])
                        print(winner)

                    Giveaway_Items[i]['Expired'] = True
                    json.dump(Giveaway_Items, open("./Cosmic overground/giveaways.json", "w"), indent=1)
            
                    
                        
                    
                    print(winner)
                           ```
lament mesa
#

for x in range(0, number_of_winners):

short dust
#
async def test(ctx):
   
    name= discord.User.display_name  
    await ctx.send (f'Hello {name}') ```
#

why it's not returning my display name?

cold sonnet
#

use an instance of discord.User

#

not discord.User

#

ctx.author

paper sluice
#

is there a way to fix the width of an embed?

maiden fable
#

No

paper sluice
#

f

short dust
maiden fable
#

It renders differently on different screens

cold sonnet
#

what yes

short dust
#

not my display name, look

paper sluice
short dust
#

i want it to return "recon expert" for example

maiden fable
#

then use discord.Member

cold sonnet
#

bro

maiden fable
#

!d discord.Member.display_name

unkempt canyonBOT
#

property display_name: str```
Returns the user’s display name.

For regular users this is just their username, but if they have a guild specific nickname then that is returned instead.
cold sonnet
#

you know he's gonna type discord.Member.display_name now

maiden fable
#

LMAOOOO @cold sonnet best of luck then

cold sonnet
#

ctx.author is a discord.Member tho

maiden fable
#

Yea

feral jacinth
#

ctx.author.display_name

cold sonnet
#

so what is happening

#

that's what I just said?!

#

oh wait

short dust
#

ty

feral jacinth
#

memberconverter 😍

tardy atlas
#

Does not work. Only 222 is output to the console, why doesn't it work further?

@commands.command(aliases = ["information", "info", "информация"])
    async def инфо(self, ctx):
        print(222)
        guilds_count = len(client.guilds))
        emb=discord.Embed(title=f"**Информация о боте**", color=discord.Color.from_rgb(128, 0, 255), timestamp=ctx.message.created_at)
        print(1)
        emb.add_field(name="**__Основное:__**", value=f"**Версия:** 1.0.0\n**Серверов:** {guilds_count}\n**Всего участников:** скоро ", inline=False)
        print(2)
        emb.add_field(name="**__Второстепенное:__**", value=f"**Задержка:** Скоро\n**Запущен:** Скоро", inline=False)
        emb.set_footer(text=f"Запросил: {ctx.author.name}", icon_url=ctx.author.avatar_url)
        
        await ctx.send(embed=emb) 
slate swan
#

how can i make it so that something is only on the server the command was published
ex: $newprefix dog

slate swan
cold sonnet
#

guilds_count = len(client.guilds))
whatchu think

slate swan
#

when will people stop making on_command_error events which eats all of their errors

cold sonnet
#
guilds_count = len( #one bracket
client.guilds
)) #two brackets
wanton pebble
#

is there a way to make a button continue working after bot restart?

feral jacinth
wanton pebble
slate swan
#

how do i create a command that only changes someting about the bot like its prefix in the server the user was in when he posted it

tardy atlas
slate swan
cold sonnet
#

store the prefixes there

#

make a get_prefix that takes the prefix from the database

left crater
#

sql

quaint epoch
#

how do i fetch the last sent message in a guild?

slate swan
#

a json file

cold sonnet
#

no

#

not a json file

slate swan
#

would a json file work

kindred drum
#

yo, how would I get the message from this? like the content. ```py
def check(message):
return message.author == ctx.author and message.channel == ctx.channel

    try:

        em = discord.Embed(title="Cosmic Overground Giveaways 🎉", description="Please enter your giveaway message.", color= discord.Color.gold())

        await ctx.send(embed=em)
        await bot.wait_for('message', check=check, timeout=60)```
cold sonnet
#

I'm not answering

slate swan
#

train wifi = bad so the ping is horrible

#

GTG 10 mins

kindred drum
quaint epoch
cold sonnet
#

it's not?

tardy atlas
#

@feral jacinth I removed it, still doesn't work

feral jacinth
cold sonnet
#

lmao he getting rammed

quaint epoch
#

it's ```py
try:
await bot.wait_for('event_here', timeout=60, check=check_here)
except asyncio.exception.TimeoutError:

Do stuff when the timeout runs out

else:

do stuff here when the check is true and timeout is not over```

cold sonnet
#

literally what he did

quaint epoch
kindred drum
#

...

quick gust
#

if you're talking about the timeout, that's not required?

cold sonnet
quaint epoch
#

or excepts

kindred drum
cold sonnet
#

he has the timeout too

quick gust
kindred drum
#
...
except asyncio.TimeoutError:
            em = discord.Embed(title="Cosmic Overground Giveaways 🎉", description="You have run out of time to add a giveaway message. Please run the command again.", color= discord.Color.red())
            await ctx.send(embed=em)
        ```
kindred drum
#

I want to get the users message content, I know I can check it in the check statement

#

but how do I bind it

quaint epoch
#

message.content

cold sonnet
#

it's not necessary

quaint epoch
#

where's the code for if it doesn't timeout?

cold sonnet
#

it's after the except, outside of it

#

the code won't stop if the try statement is successful

tardy atlas
# feral jacinth then хз
@commands.command(aliases = ["information", "info", "информация"])
    async def инфо(self, ctx):
        print(222)
        guilds_count = len(client.guilds)
        emb=discord.Embed(title=f"**Информация о боте**", color=discord.Color.from_rgb(128, 0, 255), timestamp=ctx.message.created_at)
        print(1)
        emb.add_field(name="**__Основное:__**", value=f"**Версия:** 1.0.0\n**Серверов:** {guilds_count}\n**Всего участников:** скоро ", inline=False)
        print(2)
        emb.add_field(name="**__Второстепенное:__**", value=f"**Задержка:** Скоро\n**Запущен:** Скоро", inline=False)
        emb.set_footer(text=f"Запросил: {ctx.author.name}", icon_url=ctx.author.avatar_url)
        
        await ctx.send(embed=emb) 

Does not work. Only 222 is output to the console, why doesn't it work further?

quaint epoch
quaint epoch
#

use an else after the except, or return after the except

kindred drum
#

def check(message):
return message.author == ctx.author and message.channel == ctx.channel
message = message.content?

cold sonnet
#

or use return await ctx.send()

quaint epoch
#

or do you just want to check the content of the message

#

ah,

quick gust
quaint epoch
#

!d disnake.Message.content

unkempt canyonBOT
tacit horizon
#

why buttons interaction failed

left crater
#

code?

kindred drum
quaint epoch
kindred drum
quaint epoch
left crater
#
        return msg.author == ctx.author and msg.channel == ctx.channel
    msg = await bot.wait_for("message", check=check, timeout=30)
    print(msg.content)```
#

@kindred drum

slate swan
maiden fable
#

yea saw that

cold sonnet
#

reaction, user = await bot.wait_for("reaction_add", check=check, timeout=60)
do I have to save the user too?

#

I mean, if user has to be the member who invoked the command anyways

#

what for another variable

#

!d discord.Guild.get_member

unkempt canyonBOT
cold sonnet
#

!d discord.Member.send

unkempt canyonBOT
#

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

Sends a message to the destination with the content given.

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

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

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

well

#

for loops

maiden fable
#

i ain't here

cold sonnet
#

yesh you a:

maiden fable
#

and yea u have to

cold sonnet
#

damn it

maiden fable
#

else reaction becomes a tuple

cold sonnet
#

reaction = reaction[0]

#

saving a var?

maiden fable
#

Sure

quick gust
#

there was something like get_members

#

ah its fetch_members, nvm

#

no it returns an async iterator

cold sonnet
#

then there's not even a need for the id

quick gust
#

so you'll have to make a for loop anyways

#

just do what meh said

cold sonnet
#
    await member.send("hello")```
#

how many members are we talking about?

#

not that you wouldn't get ratelimited with this

#

if it's many

maiden fable
#

Lmao true

slate swan
fluid spindle
#

What if they just use time.sleep()
Probably won't get rate limited then, right?

cold sonnet
#

why are u even replying to me? sadcatthumbsup

slate swan
#

time.sleep will disconnect your bot and ratelimits are dynamic and mass dming users is against tos

slate swan
fluid spindle
#

But...
If you ignore the TOS thing, there could be a workaround the rate limit problem simply by using await asyncio.sleep() instead of time.sleep()

slate swan
fluid spindle
#

Oh yeah that too

#

Always miss those awaits

slate swan
fluid spindle
pliant gulch
vale sierra
#

hey, its possible to ctx a list of random choice ? if yes, how can i do that please ?

slate swan
vale sierra
pliant gulch
vale sierra
slate swan
mellow barn
#
@bot.command()
async def hello(ctx):
  await ctx.send(random.choice([
    f"Hello world {ctx.author.mention}",
  ]))```
slate swan
fluid spindle
pliant gulch
#

👍

slate swan
fluid spindle
#

👍

vale sierra
cold sonnet
#

I just speedrunned a tictactoe bot

#

I'm proud

livid jacinth
#

Why ```py
if str(reaction.emoji) ==

mellow gulch
#

hey is it possible to see if a bot has been timed out

final iron
mellow gulch
#

there is a feature

final iron
#

Oh

mellow gulch
#

where if u have admin

final iron
#

Timeout

mellow gulch
#

you can time people out aka just makethem not talk

#

yess

#

i got this 'friend' that has some issues and had admin and may have timeouted the bot but idk

#

bc the bot isnt saying anything anymore

final iron
#

!d disnake.Member.current_timeout

unkempt canyonBOT
mellow gulch
#

i got an error

livid jacinth
#

Hey, how do I delete a message when someone responds to the message with an emoji?

final iron
#

Oh wait

final iron
unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
stone beacon
#

*nextcord

#

mb but yh

#

!nextcord.Member.timeout

#

!d nextcord.Member.timeout

unkempt canyonBOT
#

property timeout: Optional[datetime.datetime]```
A datetime object that represents the time in which the member will be able to interact again.

Note

This is `None` if the user has no timeout.

New in version 2.0.
final iron
#

Code?

stone beacon
#

print(nextcord.Member.timeout) isn't gonna actually give you a timeout

mellow gulch
#

wdym

livid jacinth
#

?

final iron
mellow gulch
#

wait a minute

final iron
mellow gulch
#

my bot isnt even working in my own personal server

stone beacon
mellow gulch
#

where nobody else have admin

stone beacon
#

Idk how to simplify it sorry

mellow gulch
#

this is prolly rly obvious

#

but i dont understand

final iron
mellow gulch
#

nothing is showing up when i do !test

potent spear
mellow gulch
#

I got like…200 lines

potent spear
mellow gulch
#

Alr

potent spear
#

!paste

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.

potent spear
livid jacinth
graceful gulch
#

anyone here knows what hydra bot uses to play audio now?

#

i wanna move from youtube to another source

mellow gulch
unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
livid jacinth
#

Hey, how do I delete a message when someone react to the message with an emoji in a command?

graceful gulch
# final iron !yt-dl

i literally asked about a different source, this has nothing to do with ytdl since i dont even use it

final iron
graceful gulch
final iron
#

Then it's not the appropriate channel

#

Read the channel description

wanton pebble
#

can i edit an already sent message in the on_message event?

sick birch
#

If you have the message object, yes

wanton pebble
#

do you know how i would go about getting it?

sick birch
#

discord.Messageable.send() returns the sent message

wanton pebble
#

i will try it, thank you

sick birch
#
msg = await ctx.send(...)
await msg.edit(...)
kindred epoch
#

and if you dont have the message obj, you can fetch it by using the message id and then edit it

potent spear
wanton pebble
potent spear
# mellow gulch ?

you're using msg as first param for every command function, of what class do you think this is?

#

(this is not the error, I want you to learn something first)

#

the actual error is in your on_message, because, if you didn't notice yet, not a single command will be working in your case

sick birch
mellow gulch
sick birch
#

on_message consumes every message, so it doesn't get to the command handlers

mellow gulch
#

hmmmm

sick birch
#

It overrides the default on_message

potent spear
sick birch
#

Alternatively, use @bot.listen() instead (w/o needing await bot.process_commands(message)

livid jacinth
#

Hey, how do I delete a message when someone react to the message with an emoji in a command?

potent spear
#

also, msg as parameter name for a CONTEXT object is just terrible imo

sick birch
sick birch
#

If you change msg to ctx your code would stop making sense

potent spear
#

*start

mellow gulch
potent spear
#

which takes an event as arg

#

so in your case
@bot.listen("on_message")

sick birch
#
@bot.listen()
async def on_message(message: discord.Message):
  ...
livid jacinth
potent spear
sick birch
potent spear
#

a command he means

sick birch
#

A command, I see

mellow gulch
#

ok thx @sick birch and @potent spear

livid jacinth
#

I mean command

sick birch
#

Why do you want to do it in a command?

#

Is it like an interactive set up sort of thing?

potent spear
#

probably some "bin" emoji like this

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.

livid jacinth
sick birch
#

Yeah then you'll probably want to use wait_for

livid jacinth
sick birch
unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
kindred epoch
#

that should work, remove pass_context and try again

sick birch
#

I believe you can only have one argument after the * due to ambiguities

potent spear
#

you should "consume rest" as last parameter, your make command has no idea what rolenames are and what permissions are

sick birch
#

It has to be the second to last one

kindred epoch
#

and maybe rename your command to something like make_role instead of just make

sick birch
#

It says that the last argument would consume everything else

potent spear
#

I agree, with an alias maybe

kindred epoch
#

also, you dont need pass_context since you are already passing it in the args area

#

and cuz its outdated

potent spear
#

this is very user unfriendly imo, not a single sole that doesn't code knows the permissions by heart

neat pagoda
#

ayo, I found a dictionary for standard python

#

off of github,

potent spear
#

same issue tho

neat pagoda
#

I converted it to discord py

#

@young torrentmands.is_owner()

potent spear
#

you seriously want to type out all the role permissions?

neat pagoda
#

oop lol

#

how'd that ping someone?

potent spear
#

best would be maybe some kind of selection imo

neat pagoda
#

commands.is_owner()

neat pagoda
potent spear
#

I'm sharing my opinion, you'll notice later

mellow gulch
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.

mellow gulch
#

basically for me sometimes the bot.commands are underlined

potent spear
#

any errors?

#

any error handlers?

#

I feel like you do tho

mellow gulch
potent spear
mellow gulch
#

oh lol

potent spear
#

those are "suggestions" not actual errors

#

share your code, I'll find your error handler

#

I'll prove you wrong

mellow gulch
#

@potent spear

#

why is the top one not globalized

#

when the bottom one is

potent spear
#

just share your code

#

print something before and after the role creation
you'll see that it'll only print before the role was created and not after

final iron
#

Points even more to an error handler

final iron
potent spear
#

do you even have a decorator or an on_message? xd

mellow gulch
#

did i do smth wrong at the top

potent spear
#

I have to see your code, I don't want to ask for every single possible error tbh

#

It's not that someone would ever copy your code, let me tell you

potent spear
final iron
#

Why do you care so much about keeping it private?

potent spear
#

more code = more overview = faster solution

potent spear
#

there is your error handler lol

#

in plain sight

mellow gulch
#

but y the shit_function

final iron
#

You literally have an error handler lmao

potent spear
#

that's the whole point

#

just do

else:
  print(error)```
in your error handler and it'll smile back at you
final iron
#

It will eat up every error

mellow gulch
livid jacinth
#

How can i ignore the reaction of the bot ```py
reaction, user = await bot.wait_for('reaction_add')
if str(reaction.emoji) == "🗑️":

potent spear
potent spear
#

there, you can check if the user isn't a bot

#

the docs have a great example

#

the str(reaction.emoji) stuff can even be in the check too

#

error handlers are dangerous in a way

mellow gulch
potent spear
#

gl!

cold sonnet
#

or raise error

potent spear
# mellow gulch

I suppose your first if statement would be
if msg.channel.name == "count-to-999":

cold sonnet
#

which is of course better, because it tells you the line

potent spear
#

mhm, I like making a private channel / make the bot send me a DM with a formatted error (in an Embed) whenever some error occurs

cold sonnet
#

makes sense

mellow gulch
potent spear
#

that way, I never have to look in the terminal to find out what the error was

mellow gulch
#

this time there is no error

cold sonnet
#

how much time is it for y'all to make a tictactoe bot

#

what is that at the bottom half

potent spear
cold sonnet
#

bro you seem like a whole ass hacker there

manic wing
#

what linux distro is that

mellow gulch
#

to make sure they are saying like

sick birch
#

of course it's arch

manic wing
#

cringe

mellow gulch
#

123 or 124

cold sonnet
#

I love it

potent spear
manic wing
#

ive used arch, just not a fan

#

you spend more time fucking with the os than being productive

sick birch
#

"Fucking with the os" is productive though

#

You get to learn how your system actually works but that's just me

livid jacinth
#

How cam i delete the two recent messages in the channel?

sick birch
manic wing
manic wing
unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.

Examples

Deleting bot’s messages...
sick birch
#

Eh knowing your system and its inner workings can help you program more efficiently

manic wing
#

it can help you script bash more efficiently 😳

#

thats about it

potent spear
# mellow gulch 123 or 124

this is what your sexy check would look like

stripped_message = msg.content.strip()
if len(stripped_message) <= 3:
     try:
        sexy_number = int(stripped_message)
     except ValueError:
        return
     if 0 >= sexy_number or sexy_number <= 1000:
        await message.delete()
        ```
#

a very sexy thing you could do:
remove the message if it's not 1 higher than the previous OR if the author is the same as the previous message

potent spear
#

formatting in python > formatting in linux

livid jacinth
# sick birch `channel.history(limit=2)`

Now i use this but if i run the command 2 times it didnt work ```py
reaction, user = await bot.wait_for('reaction_add')
if str(reaction.emoji) == "🗑️":
if not user.bot:
async for message in ctx.channel.history(limit=2):
await message.delete()
return

potent spear
#

welcome back ig

livid jacinth
potent spear
#

alright, just remove the *,

buoyant igloo
#

‘’’py

@bot.command()
async def buy(ctx,**,item: str, quantity: int):
global iron_sword
global iron_armor
global gold
global iron_mace
global iron_spear
purchase = discord.Embed(title="Successfully Purchased")
if item.lower() == "iron sword":
if gold >= 50quantity:
iron_sword += quantity
gold -= 50
quantity
purchase.add_field(name="Iron Sword",value=f"You purchase {quantity}x Iron Sword")
await ctx.reply(embed=purchase)
elif gold < 50*quantity:
await ctx.reply("Bro, come back when you are less broke")’’’

(! Is my prefix)
When I type
!buy iron sword 2, it says missing required argument, can anyone help?

potent spear
#

yes, unless you want to make it sexy and add multiple roles at once

#

how are you invoking the command?

potent spear
#

alright, I'll tell you something, why are you overwriting the member argument in the first line by the author? xd

livid jacinth
buoyant igloo
potent spear
manic wing
#

!global

unkempt canyonBOT
#

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

Instead of writing

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

do this instead

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

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

potent spear
#

let's first face the first problem

#
def poop(shit):
  shit = "yes pls"
  return shit

print(shit("hell no"))```
will always print "yes pls"
you have a similar problem, get that?
#

you're overwriting your member argument instantly (they have the same name

#

depends

#

do you want the member to be you when no member is specified?

#

alright, pretty simple
member: discord.Member = None

#

you first of all have to make it default None

#

then, first line in your function would be
member = member or ctx.author

#

this basically means

if member is None:
  member = ctx.author```
alpine furnace
#

Also use Optional[commands.MemberConverter] = None for typing

#

A type hint

potent spear
#

alright, next step, to make sure you can add multiple roles

#

alright, that makes it easier

#

then you're all set normally

#

show the code

#

pls no screenshots lol

#

remove the role = line

#

afterwards, you're all set

#

actually not really

#

optional arguments should be the last ones

#

so it should be role: ..., member: ... = None

#

so ?addrole @stinkyrole
would give you the stinkyrole

#

nope

#

can be the ID, the name or a mention

#

you have to use role first THEN member ofc

kindred epoch
#

how?

potent spear
#

the bot can only give roles lower than him, note that

potent spear
#

it's also not a selfbot, right?

kindred epoch
#

amount of nerves lmfao

potent spear
potent spear
#

have you seen Zuckerberg tho?

kindred epoch
potent spear
#

a Lizard

kindred epoch
#

alien infused with lizard

final iron
#

Boutta hit you guys with the !ot

manic wing
#

!ot

unkempt canyonBOT
final iron
#

🗿

potent spear
#

ruining the fun

manic wing
#

L

kindred epoch
#

ppl addicted with !ot

#

the bot cant add roles to the server owner

manic wing
potent spear
#

it is

#

try adding to another stinky guy, and see if that makes a difference

kindred epoch
potent spear
#

damn, you must be constipated

#

can you get the role manually and print member.roles?

#

then also try to get the role via ID right underneath

livid jacinth
potent spear
#

omg, Imagine he's using that line tho :/

potent spear
unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
potent spear
#

the error is simple in this line tho:
role names are lowercase

kindred epoch
#

thats the error

potent spear
#

and him passing the member object as add_role is his exact issue

kindred epoch
#

thats the reason its not finding the role

manic wing
#

anyone got an open source bot they need help with?

potent spear
#

you just passed a member object as a role, that was the issue

kindred epoch
manic wing
#

hmmm if you dm me a checklist ill just do it

potent spear
#

lmao, you must be bored

kindred epoch
manic wing
potent spear
manic wing
potent spear
#

sounds very useful

manic wing
#

i said dm me things to do

kindred epoch
potent spear
manic wing
#

you have to loop it so its constantly checking for matching datetimes

potent spear
#

ofc you do, you don't want to check every 5 mins

#

RDanny (the bot in dpy server) has an opensource reminder command

kindred epoch
manic wing
#

sasuke

potent spear
manic wing
#

want me to make a reminder system for you?

potent spear
#

like make it persistent when the bot restarts etc

kindred epoch
manic wing
#

ok

#

what db do you use

#

json

potent spear
#

txt

kindred epoch
manic wing
#

|| gimme your credentials ||

kindred epoch
potent spear
#

the postgres db ofc lol

#

so he can access your tables

manic wing
fringe harness
#

Anyone here good with pytesseract and pyautogui dm me im tryna create a bot for something

kindred epoch
#

uhh

potent spear
fringe harness
#

I am tryna make a bot for this math game

#

Its gonna be hard to explain jn here

potent spear
#

I feel like it's a scraping issue

dry kelp
#

@potent spear

#

why is this happening bruh

potent spear
#

I know

#

you're pregnant?

#

equally as bad

manic wing
#

sort of

#

annoying kids like okimii just spam it to be funny

potent spear
#

shots fired

slate swan
#

very unnecessary imo

potent spear
#

that's a desperate man in need of some help

fringe harness
#

Ight, so I am trying to make a bot answer these questions rlly fast, so I am trying to use ocr to get the questions and answer it, and then I will try to correspond the answer to one of the choices and press 1,2,3,4 to get the correct answer

fringe harness
#

*2

fringe harness
#

Not the questiib

slate swan
#

seems like fun02comfy

manic wing
#

i hate to say it

slate swan
#

then why said it

manic wing
#

but noones going to help you write in c++ and rust making a realistic blackhole simulator from scratch

slate swan
manic wing
#

then why do it if you dont have the coding ability?

potent spear
manic wing
#

super advanced to the point where you cant even make it

potent spear
fringe harness
#

lmfai

final iron
#

🗿

fringe harness
potent spear
#

the great news is: your text fields are very recognizable because they are in different coloured boxes

fringe harness
manic wing
#

does anyone have an open source bot

potent spear
potent spear
fringe harness
#

Alr well I’ll start and ill see if I have any issues

manic wing
#

i mean someone here

potent spear
#

what's the website?

#

If you want, we can code it together, but we'll make a decent task management, so we're not overwriting each others code etc

fringe harness
manic wing
#

aight time to fix it all

potent spear
#

you clearly know where you're going with it tho xd

potent spear
manic wing
#

wtf is this set_event_loop_policy(WindowsSelectorEventLoopPolicy())

potent spear
#

I can see it since you have lots of empty folders

potent spear
manic wing
#

i see

#
if os.name == "nt":
    set_event_loop_policy(WindowsSelectorEventLoopPolicy())
``` im dong this so you can use it on linux as well
#

from config import TOKEN, DB_USER, DB_PASS, DB_HOST, DB_PORT whats config

#

up to you

#

im doing a lot of code refactoring btw

#

like bot.py is going in core/

#

license = "MIT"
no licence in the repo:

#

ill add it for you

left crater
#

is it possible to subclass a button inside of a button?

manic wing
#

from disnake.utils import search_directory
whats this

#

doesnt exist

#

let me go look at soure code

#

NEGATORY

unkempt canyonBOT
#

disnake/utils.py line 1209

def search_directory(path: str) -> Iterator[str]:```
manic wing
#

mm i had a fucked disnake version

#

time for my own bot to be broken

#

anywayy

#

is config a python file

left crater
#

!d edit

unkempt canyonBOT
#

%edit```
Bring up an editor and execute the resulting code.
manic wing
#

async def start(self, token, reconnect) -> None:
where do you even call this

left crater
#

how do i edit a message?

manic wing
unkempt canyonBOT
#

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

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.

Note

If the original message has embeds with images that were created from local files (using the `file` parameter with [`Embed.set_image()`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed.set_image "disnake.Embed.set_image") or [`Embed.set_thumbnail()`](https://docs.disnake.dev/en/latest/api.html#disnake.Embed.set_thumbnail "disnake.Embed.set_thumbnail")), those images will be removed if the message’s attachments are edited in any way (i.e. by setting `file`/`files`/`attachments`, or adding an embed with local files).
left crater
manic wing
#

yes

left crater
#

!d discord.Message.edit

unkempt canyonBOT
#

await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.
pliant gulch
manic wing
#

ok

left crater
#

https://paste.pythondiscord.com/aqutuzadot Ignoring exception in view <Mychoice timeout=180.0 children=2> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='Robot' emoji=None row=None>: Traceback (most recent call last): File "C:\Users\nikit\PycharmProjects\discord.py\discord\ui\view.py", line 359, in _scheduled_task await item.callback(interaction) TypeError: Mychoice.robot_callback() takes 2 positional arguments but 3 were given

manic wing
#
Application command synchronization:
GLOBAL COMMANDS
===============
| NOTE: global commands can take up to 1 hour to show up after registration.
|
| Update is required: False
| To upsert:
|     -
| To edit:
|     -
| To delete:
|     -
| No changes:
|     -
Command synchronization task has finished
``` why tf is this getting printed
manic wing
#

i see...seems annoying af but whatever

#

¯_(ツ)_/¯

#

you've got no commands as of right now correct/

#

mm okay

#

welll ive done a bit but considering theres not much ill just submit this pr unless you want me to add something

#

want me to add this to my pr?

#

ok

potent spear
#

this
if isinstance(message.author, Member):
could've just been
if message.guild is None

#

linter?

#

you're also checking some same stuff multiple times

#

~line 17 & 29

manic wing
#

pr'd

#

what next, ive got 3 more hours

#

im not a creative dude

#

@potent spear need help with anything?

potent spear
manic wing
#

cough defo didnt copy and paste it

#

realistically noone writes them

#

LICENSE and precommits are always copy and pasted

#

yaml is a pain in the ass for me

potent spear
# manic wing wdym? i wrote it out
bad_words = await connection.fetchval(sql_queries.SELECT_BAD_WORDS_FROM_COLLECTIONS, user_id)

    if not bad_words:
        bad_words = 0```

```py
bad_words = await connection.fetchval(sql_queries.SELECT_BAD_WORDS_FROM_COLLECTIONS, user_id) or 0```
manic wing
#

i didnt write that

#

it might look like i wrote that because black goes in and formats everything

#

thats his

manic wing
#

yes black likes crediting itself for doing nothing

potent spear
#

damn I should defo start using precommit hooks

manic wing
#

y e s

potent spear
#

instead of reformatting right before committing lol

manic wing
#

i reformat before anyway because i dont trust automatic shit 😳

teal bloom
#

How do you make discord bot online 24/7

manic wing
#

by not turning it off

slate swan
buoyant igloo
#

‘@bot.command()
async def buy(ctx,**,item: str, quantity: int):
global iron_sword
global gold
global iron_mace
global iron_spear
global iron_halberd
purchase = discord.Embed(title="Successfully Purchased")
if item.lower() == "iron sword":
if gold >= 50quantity:
iron_sword += quantity
gold -= 50
quantity
purchase.add_field(name="Iron Sword",value=f"You purchase {quantity}x Iron Sword")
await ctx.reply(embed=purchase)
elif gold < 50*quantity:
await ctx.reply("Bro, come back when you are less broke")’

(! Is my prefix)

When I do !buy iron sword 2, it says required element ‘quantity’ is missing

How do I fix this?

manic wing
#

you made quantity a kwarg

left crater
buoyant igloo
manic wing
left crater
#

Oh

manic wing
# buoyant igloo how not do that?

think about the logic; you did , *, item meaning you want everything to be captured as item, yet also want quantity? how does that work ??

buoyant igloo
#

Ye ur right

manic wing
#

i did nothing except tell you to think about the logic, maybe this foreshadows your entire programming experience

#

slowing down and thinking about logic is always a good way to go

buoyant igloo
#

Yo guys what can I use instead of global

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.

manic wing
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!

left crater
#

how can i get the button author?

manic wing
left crater
#

oh thanks

left crater
manic wing
#

!d disnake.MessageInteraction.author

unkempt canyonBOT
manic wing
#

looks fine to me

#

lets see code

buoyant igloo
#

How do I make it so that each person has a separate variable

async def dev(ctx):
global iron_sword
iron_sword += 100

(This gives everyone 100 iron swords)

manic wing
#

you use a dictionary

torn sail
unkempt canyonBOT
buoyant igloo
final iron
buoyant igloo
#

how do I create separate variables for each user?

final iron
#

You don't

#

Use a dictionary/database

buoyant igloo
#

I have been procrastinating learning SQLite but I will have to now 😭

azure depot
#

how to make a simple inventory system?

slate swan
#

anyone know how to add a command handler

manic wing
#

!d discord.ext.commands.Bot.on_command_error

unkempt canyonBOT
#

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

The default command error handler provided by the bot.

By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.9)") however it could be overridden to have a different implementation.

This only fires if you do not specify any listeners for command error.
slate swan
#

also

#

i got a error for cogs avatar url

buoyant igloo
#

Yo guys just making sure,

Databases can create variables for individual people right?

slate swan
#

found error

buoyant igloo
slim ibex
#

if you specify a variable that pulls a record from a database, I guess

mellow gulch
#

do i have to get the channel id or smth

slim ibex
#

but, why have tons of variables pertaining to the DB for each user, if you have the fucking db right there

mellow gulch
#

cuz i got an error about str and no attribute of send

final iron
#

A string object has no send method

mellow gulch
#

wdym by str object

slim ibex
#

string literal a.k.a "count-to-999"

final iron
#

!e

print(type(""))
unkempt canyonBOT
#

@final iron :white_check_mark: Your eval job has completed with return code 0.

<class 'str'>
final iron
#

@mellow gulch ^

slim ibex
#

!e print(type("count-to-999"))

unkempt canyonBOT
#

@slim ibex :white_check_mark: Your eval job has completed with return code 0.

<class 'str'>
mellow gulch
#

no but

#

how do i turn it into a str object

slim ibex
#

turn what into a str object?

mellow gulch
slim ibex
#

anything that is wrapped with "" or '' is a string literal/obj

#

a random string like count-to-999 doesn't have a send method

#

you can use get_channel to get a channel by id as the id will have a send method

final iron
#

You should prefer to use `

mellow gulch
#

i already had that done

final iron
#

Because on mobile it doesn't show

slim ibex
#

true

final iron
mellow gulch
slim ibex
#

whatever your bot var is

final iron
#

If you're in a cog it would be self.bot.get_channel

quaint epoch
final iron
vague grove
#

how can i defend against a spammer, like if they spam 5 messages in 3 seconds it kicks

quaint epoch
#

you want wait for a certain amount of time, if a user sends a message try it again 5 times, in total 3 seconds and if they all run because the user sent 5 messages in 3 seconds await member_obj.kick()

quaint epoch
vague grove
#

what after that?

#

yes

quaint epoch
#
try:
  await bot.wait_for('event_here', timeout=seconds_for_timeout, check=check)
except asyncio.exceptions.TimeoutError:
# code if the timeout ends
else:
# code if check=True and timeout is not over
#

btw can any moderator lurking the chat pin this?

#

because new ppl can just read pins when using bot.wait_for

final iron
quaint epoch
quaint epoch
vague grove
#

and how would I check?

quaint epoch
final iron
#

No

quaint epoch
vague grove
#

anything built in or would i haft to use txt files

final iron
#

You can't do everything with just the docs

quaint epoch
#

for certain things it would save a trip here

#

yes, im guilty of not reading the docs

final iron
vague grove
#

ill peek in the docs as well, ty for the info

quaint epoch
vague grove
vague grove
#

so if someone chats in between they're cleared

quaint epoch
#

isn't that would your trying to check

vague grove
#

hm..

quaint epoch
#

you can run it multiple times under the else to check if lets say, 5 messages are spammed by the same user under 5 seconds

#

just use a bit of logic

vague grove
#

and would I keep track with like a json file?

final iron
#

No

#

Don't use json as a database. It simply isn't one

vague grove
#

oh alr

vast gale
#

so anyways i broke vsc

maiden fable
#

arl, stop fucking up IDEs

vast gale
#

nO i refuse

quick gust
#

cough cough before this goes OT

maiden fable
#

I'mma just go away

quick gust
#

don't worry i won't !ot you

pliant gulch
#

👁️ 👁️

maiden fable
#

What's this

vast gale
#

i made it worse

#

so in short my editor is on fire rn

#

folks, this is why you don't work on discord api wrappers

maiden fable
#

😂

wintry panther
#

wait a sec ALL discord bots will now have to use slash cmds? i thought it was just for unvertified bots

maiden fable
#

Yea it's for verified bots only

maiden fable
wintry panther
#

so why are big bots like dishboard switching to slash commands because it says discord requires to be slash cmds

maiden fable
#

Because they have to have a valid use case to get access to message content

stone moon
#

i have the id of a user i want to add a role to. How do i, with the user's id, add the role to the user?

unkempt canyonBOT
stone moon
#

ty

maiden fable
#

!d discord.Member.add_roles

unkempt canyonBOT
#

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

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
stone moon
#

await bot.get_member()?

maiden fable
#

No

#

guild.get_member()

stone moon
#

k

stone moon
final iron
#

!d discord.User.send

unkempt canyonBOT
#

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

Sends a message to the destination with the content given.

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

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

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

You need a user object

#

This is basic dpy my guy

#

You need a user object

#

A string object will not have a send method

#

You can get a user object with

#

!d discord.Client.fetch_user

unkempt canyonBOT
#

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

Retrieves a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.

Note

This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.get_user "discord.Client.get_user") instead.
ivory quiver
stone moon
#

yea i fixed it

final iron
#

Sure?

ivory quiver
ivory quiver
slate swan
ivory quiver
#

wait wait whats timeout?

slate swan
#

if youre using a db and your bot goes down it will go on until the bot gets online the built in no it gets tracked by discord

#

though there already is an inbuilt slash command for that purpose

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

dpy doesnt support

#

but there is an inbuilt slash command within discord for timing members out

#

so, mute commands are rendered useless really

#

unless you want a few channels open for the muted members

ivory quiver
#

Discord updates be like

slate swan
#

its new but not new-new

#

been 2-3 months ig

#

yup

ivory quiver
#

I've been gone for like 2 years my g...

#

sigh

slate swan
ivory quiver
#

Discord ruins my life

slate swan
slate swan
ivory quiver
#

but I still would like to know what the problem is

slate swan
#

anyways, kill it, dont spam emojis

ivory quiver
#

huh

alpine furnace
frozen patio
#

so I have a problem in my code, my code is not working on this event

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

@client.event
async def on_ready(*, extension):
    client.load_extension(extension)       
        
@client.command()
async def load(ctx, *, extension):
    client.load_extension(f"cogs.{extension}")
    await ctx.send("Loaded cog!")

@client.command()
async def unload(ctx, *, extension):
    client.unload_extension(extension)
    await ctx.send("Unloaded cog!")

@client.command()
async def reload(ctx, *, extension):
    client.reload_extension(extension)
    await ctx.send("Reloaded cog!")
slate swan
#

!d discord.on_ready

unkempt canyonBOT
#

discord.on_ready()```
Called when the client is done preparing the data received from Discord. Usually after login is successful and the [`Client.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.guilds "discord.Client.guilds") and co. are filled up.

Warning

This function is not guaranteed to be the first event called. Likewise, this function is **not** guaranteed to only be called once. This library implements reconnection logic and thus will end up calling this event whenever a RESUME request fails.
frozen patio
#

Oh

slate swan
#

which can happen many times

slate swan
maiden fable
#

Someone ask something 😩

slate swan
final iron
#

Dead channel

warm plover
#

And?

slate swan
#

starting an argument to make the channel alive is not a good thing to do btwcatsip

final iron
#

🗿

slate swan
#

im not typing?

warm plover
#

Here I'll ask a question for something imma eventually get around to fixing, so On_disconnect happens multiple times in a row when it actually disconnects and i only want it running once until it reconnects, so i currently have a global variable storing the state and it gets set to false when on_disconnect runs and it gets set to True when on_connect runs, is this an okay solution? Or is there a better way of doing it

final iron
warm plover
#

Mainly for logging disconnect times btw

slate swan
warm plover
#

I mean in succession, im aware it runs multiple times lol

slate swan
slate swan
warm plover
#

It'll run 9-10 times within a minute of it disconnecting. I imagine its because on_disconnect is triggered when a connection fails including when it fails to reconnect.

slate swan
warm plover
#

So is running a global variable check a good solution to this?

slate swan
small igloo
#

helo okimi

slate swan
small igloo
#

why if item != "brewing stand" or item != "sword" or item != "armor": is always true :vv

warm plover
#

Okay that's exactly what I've done, I'll just leave it alone then

warm plover
#

Do multiple not checks work like that?

slate swan
slate swan
slate swan
slate swan
small igloo
# slate swan print whats item
 if item != "brewing stand" or item != "sword" or item != "armor":
            print(item)
            print("item_list")```

me test `item = "brewing stand"` and it friggin print `item_list` and `brewing stand`
small igloo
slate swan
small igloo
# slate swan yup
async def check_item(user, item):
    user = str(user)
    async with aiosqlite.connect('database.db') as db:
        if item != "brewing stand" or item != "sword" or item != "armor":
            print(item)
            print("item_list")
            item = item.upper().replace(" ", "_") if " " in item else item.upper()
            cur = await db.execute(f"SELECT {item} from item_list where NAME = ?", (user,))
            it = await cur.fetchone()
            item = it[0]
        elif item == "brewing stand":
            cur = await db.execute("SELECT BREWING_STAND from users_data where NAME = ?", (user,))
            it = await cur.fetchone()
            item = it[10]
        elif item == "sword":
            cur = await db.execute("SELECT SWORD from users_data where NAME = ?", (user,))
            it = await cur.fetchone()
            item = it[11]
        elif item == "armor":
            cur = await db.execute("SELECT ARMOR from users_data where NAME = ?", (user,))
            it = await cur.fetchone()
            item = it[12]
        return item
``` tbh that's [#databases](/guild/267624335836053506/channel/342318764227821568/)
warm plover
#

Is it because your using ors instead of and?

slate swan
small igloo
slate swan
small igloo
slate swan
warm plover
#

Oooh yeah your right

slate swan
unkempt canyonBOT
#

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

False
slate swan
#

since the if statement isnt correct False was returned

warm plover
#

I'm just getting lost in, and or logic im fine lmao

slate swan