#discord-bots

1 messages · Page 989 of 1

slate swan
#

!d while

unkempt canyonBOT
#

8.2. The while statement

The while statement is used for repeated execution as long as an expression is true:


while_stmt ::=  "while" assignment_expression ":" suite
                ["else" ":" suite]
``` This repeatedly tests the expression and, if it is true, executes the first suite; if the expression is false (which may be the first time it is tested) the suite of the `else` clause, if present, is executed and the loop terminates.

A [`break`](https://docs.python.org/3/reference/simple_stmts.html#break) statement executed in the first suite terminates the loop without executing the `else` clause’s suite. A [`continue`](https://docs.python.org/3/reference/simple_stmts.html#continue) statement executed in the first suite skips the rest of the suite and goes back to testing the expression.
polar ice
#

https://paste.pythondiscord.com/ebuzejefok The code ive got works perfectly and posts all the chat logs the first time the code executes. but then when the loop comes after 30 seconds it doesn't post. I've been advised that its re-using the same cursor and it i need to make it create a new cursor? Could anyone help me, i dont fully understand how to do it. Been stuck with this problem for a good 4 weeks now, id really appreciate any help 🙂

static lintel
#
    client.crypto_pages = [cryptoEmbed, cryptoEmbed2, cryptoEmbed3, cryptoEmbed4, cryptoEmbed5, cryptoEmbed6, cryptoEmbed7, cryptoEmbed8]
    current = 0
    async def button_callback(interaction):
        await interaction.response.edit_message(content=client.crypto_pages[current+1])
    msg = await ctx.send(embed=client.crypto_pages[current], view=view)```
#

i was trying to scroll through embed pages using buttons but for some reason the interaction.response.edit_message part doesn't seem to do anything rn. did i mess up smt?

little ivy
#

How do i fix the module error:
No module found named discord.commands
?

little ivy
#

Import?

gaunt ice
#

yes

little ivy
#

from discord.commands import Options

gaunt ice
#

how do u use options

little ivy
#

In a Dropdown menu

gaunt ice
#

oh

#

the buttons

torn pier
#

hi soo i ve seen a lot of people talking about self-bots and I know they are against Tos and i dont intend to breach it but justout of curiosity how do u make a self-bot

little ivy
# gaunt ice the buttons

The weird thing is, if i host the bot on my pc it works, but on an raspberry it gives this error

gaunt ice
little ivy
#

So i think i need to install something on the rpi what i already did on my pc

#

But i dont know what

slate swan
vale wing
#

And pretty sure the components are in discord.ui

little ivy
#

No module found named discord.commands

little ivy
#

Than i get this

paper sluice
#

there is nothing called Option in discord.ext.commands

little ivy
#

When i remove the option, i get this...

little ivy
#

Thats what i have now

placid skiff
#

hood mornin'

placid skiff
velvet haven
#

how to set volume of the bot

cloud dawn
#

This can be so much shorter

#

Because your or statements are wrong

#

!or

unkempt canyonBOT
#

When checking if something is equal to one thing or another, you might think that this is possible:

if favorite_fruit == 'grapefruit' or 'lemon':
    print("That's a weird favorite fruit to have.")

While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.

So, if you want to check if something is equal to one thing or another, there are two common ways:

# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
    print("That's a weird favorite fruit to have.")

# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
    print("That's a weird favorite fruit to have.")
cloud dawn
#

if any(x for x in [hc, gm, ac] if x in user.roles)

#

or if hc in user.roles or gm in user.roles or ac in user.roles

#

Any error?

#

lemme recode it

formal basin
#

How can I make this thing in economy were if you buy something it will give me money every somthing seconds e.g I buy I manager then the manager gives me money every 3 minutes

cloud dawn
#
@bot.command()
async def demote(ctx, user: discord.Member):
    hc = discord.utils.get(ctx.guild.roles, name="Head Coach")
    gm = discord.utils.get(ctx.guild.roles, name="General Manager")
    ac = discord.utils.get(ctx.guild.roles, name="Assistant Coach")

    if roles := list(filter(lambda r: True if any(x for x in [hc, gm, ac] in user.roles) else False, user.roles)):
        await user.remove_roles(roles)
        embed = discord.Embed(title="Demotion Complete!", description=f"{user.mention} has been demoted from ``{', '.join(roles)}``!\n > **Franchise Owner:** {ctx.author.mention}", color=0x2C2F33)
        embed.set_author(name=ctx.guild.name, icon_url=str(ctx.guild.icon_url))
        embed.set_image(url="https://cdn.discordapp.com/attachments/898576566299262987/963653507490136094/final_62564dcc1a766400850b76de_691951.gif")
        
        msg = await ctx.reply(embed=embed)
        await msg.add_reaction(':white_check_mark:')
        print(f'Demotion Complete |\n Player: {user}\n {', '.join(roles)}: {ctx.author}')
        await user.send(f'{user.mention} you have been demoted from ``{', '.join(roles)}`` in ``{ctx.guild.name}`!')
    else:
        print(f'Demotion Failed |\n Player: {user}\n Coach: {ctx.author}\n No coach roles')
        await ctx.reply(f'`{user}` does not have any coach roles!')
formal basin
#

How can I make this thing in economy were if you buy something it will give me money every somthing seconds e.g I buy I manager then the manager gives me money every 3 minutes

formal basin
formal basin
formal basin
cloud dawn
formal basin
cloud dawn
formal basin
formal basin
# cloud dawn This can also be used outside cogs.

from discord.ext import tasks

@tasks.loop(seconds=5.0, count=5)
async def slow_count():
print(slow_count.current_loop)

@slow_count.after_loop
async def after_slow_count():
print('done!')

slow_count.start()

formal basin
#

But I know how to change it

slate swan
#

How to make discord slash command only visible to user

cloud dawn
#

You need the import yes but I assume you want it to never end when the bot starts.

cloud dawn
slate swan
cloud dawn
#

Per user slash visibility.

paper sluice
cloud dawn
cloud dawn
formal basin
paper sluice
#

ah they want only certain people to access slash commands, i c

slate swan
#

This

cloud dawn
formal basin
cloud dawn
#

That's weird

#

Try inputting just roles

slate swan
cloud dawn
#

About time.

#

Still that would most likely only work with permissions meaning custom checks still will be visible.

cloud dawn
formal basin
cloud dawn
formal basin
cloud dawn
#

You just need the loop and add x amount of money.

formal basin
#

Oh ok

cloud dawn
slate swan
cloud dawn
#

True I almost tackled that issue tough

#

setup hook

#

@slate swan We talked about this lol

#

That's the most weirdest way to do this.

placid skiff
cloud dawn
#

And according to Danny setup hook only runs once on launch so that would be a flaw in his own code.

formal basin
cloud dawn
formal basin
cloud dawn
formal basin
#

Because I want to do a thing where you buy something and gives you money every 3 minutes

placid skiff
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
cloud dawn
#

Honestly not including auto sync is a problem waiting to happen.

formal basin
formal basin
slate swan
#

nice tag

placid skiff
#

you do not connect it to a command, you'll declare this somewhere in your code and it will run automatically when the time you declared passed

cloud dawn
#

Ah okay well not syncing when nothing changed does make sense, so I will most likely code my own auto sync and detect changes to any parts of those code.

#

That could've easily be added to the main lib.

#

Well as long as you never change the slash sync command you can also just use a slash command that is registered to a specific guild.

unkempt canyonBOT
#

examples/background_task.py line 6

class MyClient(discord.Client):```
placid skiff
#

you don't need the sleep

cloud dawn
#

Only once then you can remove it.

cloud dawn
#

guild specific syncs are instant.

unkempt canyonBOT
#

examples/background_task.py line 21

@tasks.loop(seconds=60)  # task runs every 60 seconds```
placid skiff
#

what is hard about this?

formal basin
cloud dawn
#

Still if this wouldn't get changed I would honestly recommend everyone that wants slash commands to just code it in js or rust.

placid skiff
#

There is no sense to make a loop that runs in a command

cloud dawn
placid skiff
formal basin
#

Do I do @my_task_name.command

placid skiff
cloud dawn
#

Just 1 basic command, if you do nothing too fancy it's pretty doable.

formal basin
cloud dawn
#

Plus the libraries, compared to discord.py theirs is so up to date.

placid skiff
#

yeah.. so what do you not understand with this? D_D

formal basin
placid skiff
#

a tasks is just a block of code which runs every x time, in that block of code you can do whatever you want

placid skiff
#

just check if you have a manager like you would do for other things and if so give the money

formal basin
#

So what could I use then?

#

Asyncio?

placid skiff
#

the loop manage the Asyncio for you .-.

formal basin
#

Oh

#

So. What can I use?

placid skiff
#
from discord.ext.tasks import loop

@loop(minutes=3)
async def my_loop():
  print("This message will be printed in the console every 3 minutes")
formal basin
placid skiff
#

My god it doesn't go into a command

placid skiff
#

it is inside a command? no
it is an external function

#

put the task where you created the instance of your bot

formal basin
#

Then how can I do the manager thing

#

That it will give money

placid skiff
#

you check it inside the loop function

formal basin
#

Ohhhhhh

placid skiff
formal basin
#

How could I check it

#

I’m not good with checking

placid skiff
#

how you declare the manager?

formal basin
#

In like a Shop thing

placid skiff
#

yeah i want to know what you do with it, you save it in a database, you just assign a variable to it? what this manager is in your code?

cloud dawn
#
for member in role.members:
    await member.remove_roles(role)
    # Avoiding rate limit
    await asyncio.sleep(1)
placid skiff
cloud dawn
placid skiff
#

he could've bought discord users somewhere and have like 400 people in his testing server PepeLaugh

cloud dawn
placid skiff
formal basin
#

Not database

placid skiff
#

why i'm not surprised about it?

#

json is not a storage method, it is a way to represents javascript objects in text files

dire folio
#

^

formal basin
#

if user has name=“laptop”
[give the person the money]

formal basin
cloud dawn
#

If the nickname is laptop?

formal basin
slate swan
cloud dawn
# slate swan

Could you please stop sending this without any context?

slate swan
slate swan
unkempt canyonBOT
#

property display_name```
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.
placid skiff
slate swan
cloud dawn
slate swan
#

i mean uhhhh

#

get my point

placid skiff
slate swan
placid skiff
#

well you know when you have to think like a compiler you take everything literally

slate swan
#

well

placid skiff
#

HAHAHAHAHAHAHAAH

slate swan
#

@slash.slash(name="test", description="test", guild_ids=[958975820469256233], options=[create_option(name="input", description="test", required=True, option_type=3)])
async def user(ctx: SlashContext, username:str):``` how to use ephemeral
cloud dawn
slate swan
cloud dawn
#

!d discord.MessageFlags.ephemeral

unkempt canyonBOT
cloud dawn
slate swan
slate swan
cloud dawn
slate swan
slate swan
cloud dawn
#

Same goes for slash_command

slate swan
placid skiff
paper sluice
cloud dawn
slate swan
cloud dawn
placid skiff
slate swan
cloud dawn
#

But it does make browsing a pain since every company these days use js to handle data.

#

For website processing.

paper sluice
slate swan
slate swan
slate swan
placid skiff
slate swan
cloud dawn
slate swan
#

Yo

#

how do i update a print without having to print it again

#
async def register(ctx):
    con = lite.connect('user_data.db')

    with con:
        cur = con.cursor()
        cur.executescript("""
            DROP TABLE IF EXISTS user_data;
            CREATE TABLE user_data(UserID TEXT, Cash INT);
            INSERT INTO user_data VALUES(message.author.id,0)
            """)```

it doesnt work.. pls help
#

lmao

#

u dropping al the data to isert 1 record if im right

paper sluice
slate swan
paper sluice
slate swan
slate swan
slate swan
#

bru

#

dedication

golden vapor
#

hello plz tell me how can i get @PyDis Core Developers this role

slate swan
#

and

#

i found sql hard for somereason

slate swan
green lagoon
#

Why the cmd get context().prec = any number not worked in pycharm

#

Any number here is like 20, 30, etc .

#

Any1 here???

#

Ig no 😅

paper sluice
#

what is get context().prec = any number supposed to do?

green lagoon
#

It show the total numbers of the result example if 10/3 is 3.3 and we put the any number is equal to 30 it will have 3,3333(25more 3), the normal if we dont do the cmd is 15 ig

cloud dawn
#

@slate swan With SQL WHERE clause and by invoking register.

#

I'm watching Netflix rn i don't really want to switch between dm and channel lol

slate swan
slate swan
#

and also how to view table? @cloud dawn

#

i want to view the table with terminal*

placid skiff
cloud dawn
#

!e print(10/3)

unkempt canyonBOT
#

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

3.3333333333333335
cloud dawn
slate swan
cloud dawn
slate swan
#

thxs

slate swan
#
async def balance(ctx):
    con = lite.connect('user_data.db')
    
    with con:
        cur = con.cursor()
        cur.executescript(print(SELECT DISTINCT Cash FROM message.author.id;))```

i dont know how to do this pls help me @cloud dawn
#

..

#

how to fix it then

cloud dawn
cloud dawn
#

kek

slate swan
#
async def balance(ctx):
    con = lite.connect('user_data.db')
    with con:
        await message.channel.send(cur.executescript("SELECT DISTINCT Cash FROM user_data WHERE UserID = ?;", (message.author.id,)))```

it still not working, how to fix :/
pliant blaze
#

would love to get some feedback on my first python disocrd bot coding tutorial in german, delete if advertising isnt allowed, https://www.youtube.com/watch?v=Kj1P-dVX4eM&t=3s

Die Grundlagen um einen eigene Discor-Bot zu erstellen.

CMD-Befehle:
python --version
pip --version
pip install discord

Links:
Mein eigener Bot: https://www.tr3xbot.me/
Discord Developer Portal: https://discord.com/developers/applications
Discord.py API: https://discordpy.readthedocs.io/en/stable/api.html
Python: https://www.python.org/downloa...

▶ Play video
cloud dawn
slate swan
#

and i will go learn it*

cloud dawn
#

!d sqlite3

unkempt canyonBOT
#

Source code: Lib/sqlite3/

SQLite is a C library that provides a lightweight disk-based database that doesn’t require a separate server process and allows accessing the database using a nonstandard variant of the SQL query language. Some applications can use SQLite for internal data storage. It’s also possible to prototype an application using SQLite and then port the code to a larger database such as PostgreSQL or Oracle.

The sqlite3 module was written by Gerhard Häring. It provides an SQL interface compliant with the DB-API 2.0 specification described by PEP 249, and requires SQLite 3.7.15 or newer.

slate swan
#

pls help me write this code part, just this once

cloud dawn
floral badge
#

but yeah, one should learn the basic first, you won't learn anything otherwise

slate swan
#

thxs

cloud dawn
#

One of the better d.py tutorials.

slate swan
#

difference between listener and events?

cloud dawn
#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")

The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.10)").

Example...
loud junco
#

Is there any website for me to learn more python? i need to learn more

cloud dawn
#

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

loud junco
#

Thanks

slate swan
#

yo help

#
class giveaway(commands.Cog):
    """huh4?."""
    def __init__(self , bot: commands.Bot):
        self.bot = bot
    async def convert2(a1:int,a2:str):
             pass

    @commands.command(name="g")
    async def giveaway(self, ctx):
        if x in ["Start","start","st"]:
            await convert2()
``` i cant acces
#

convert2()

cloud dawn
#

Well since convert2 is in a class you need to pass self first or make it a @staticmethod.

#

And since it is a function inside the class you also need to call it using self, e.g self.convert2()

slate swan
#

oh ye thanks

boreal ravine
loud junco
#

Thanks

cloud dawn
#

Doesn't have geekforgeeks have a mandatory sign up these days?

boreal ravine
#

theres a way to not sign up and still be able to view g4g

brisk dune
#

Anyone here ever had to deal with the bot sending messages twice (#help-pretzel)?

slate swan
#

is it possible to use a dropdown menu that would be up forever

brisk dune
slate swan
#

like, no timeout

cloud dawn
brisk dune
cloud dawn
brisk dune
#

But... how?

#

I'm only doing bot.run() once in my main.py

paper sluice
brisk dune
slate swan
#

close

#

and reopen

brisk dune
#

Already tried

paper sluice
#

does it do it for all commands or only some?

brisk dune
#

I've narrowed down the problem to a Cog

brisk dune
cloud dawn
#

You are running main.py twice like Ryuga told you

#

Just close one off

brisk dune
#

When I have logging in there

#

it does the two messages thing

#

when loading is not there, it is fine

slate swan
#

in setup why u put bot = bot

#

@brisk dune

#

u can do bot only

brisk dune
#

I know

#

That just auto-completed through intelli-sense

slate swan
#

..

brisk dune
#

But that can't be causing the problem

slate swan
#

what is the error?

brisk dune
#

My discord bot just sends a message twice

slate swan
#

he says he run only 1 python file but in run twice

slate swan
brisk dune
slate swan
slate swan
brisk dune
# brisk dune ```py # Load cogs print("Loading Cogs:\n") cogs = ["debug", "logging"] for cog i...

Here's my code for logging.py:

import discord
from discord.ext import commands
from datetime import datetime


class Logging(commands.Cog):
    def __init__(self, bot: commands.Bot) -> None:
        self.bot = bot

    @commands.Cog.listener()
    async def on_message(self, message: discord.message.Message):
        # Current date-time in ISO-8601 format (without microseconds):
        # yyyy-mm-ddThh:mm:ss±tmzn
        time = datetime.now().astimezone().replace(microsecond=0).isoformat()
        print(
            f"[{time}] Message from {message.author} (Message ID: {message.id}, Message author ID: {message.author.id}): {message.content}"
        )
        await self.bot.process_commands(message=message)


def setup(bot: commands.Bot):
    bot.add_cog(Logging(bot))
slate swan
#

why did you process a listener btw?

#

..

cloud dawn
slate swan
#

lol

paper sluice
#

wait close ur VSC and see if the bot went offline or not @brisk dune

cloud dawn
slate swan
brisk dune
slate swan
final iron
unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

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

hash(x) Returns the message’s hash.
brisk dune
slate swan
#

ok

slate swan
slate swan
final iron
paper sluice
brisk dune
#

I'll try

slate swan
brisk dune
slate swan
paper sluice
brisk dune
slate swan
brisk dune
slate swan
#

A-Z
a-z

brisk dune
#

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

paper sluice
#

it wont work though

brisk dune
paper sluice
#

like it wont go past the frist one

slate swan
#

uh

brisk dune
#

...

supple thorn
slate swan
#

huh

supple thorn
#

!d discord.Message is it the same

unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

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

hash(x) Returns the message’s hash.
slate swan
#

imagine context

paper sluice
brisk dune
brisk dune
slate swan
brisk dune
#

Alright, this is it...

I'm restarting my PC

#

And hoping that this fixes the issue

slate swan
#

ur python is cursed

brisk dune
#

brb

brisk dune
paper sluice
#

oh wait

#

:sus:

slate swan
#

..

#

alr ill continue my giv cmd

slate swan
# supple thorn Why though

its just name spacing the first one includes the file name but since the discord folder with all models has an init file it becomes a class bound to the module and not the file itself

#

so it wont be
package_name.file_dir/name.ClassName but package_name.ClassName

cloud dawn
#

aka potential cursed typehints.

brisk dune
#

Nooooo!!!!! It still doesn't work!!!!

slate swan
#

this func has 3 parame

async def convert2(cts,a1:int,a2:str):

but i can only acces 2
a = await self.convert2()

#

is it a class method or just a method?

#

i suppose its a method since the example below

#

..

brisk dune
slate swan
#
class giveaway(commands.Cog):
    """huh4?."""
    def __init__(self , bot: commands.Bot):
        self.bot = bot
    async def convert2(cts,a1:int,a2:str):
paper sluice
#

nah thats too much work

paper sluice
brisk dune
slate swan
#

its vsc

slate swan
paper sluice
#

u will have to download it something from the extentions marketplace

slate swan
#

cts isnt correct and if it were a classmethod it would be cls

paper sluice
slate swan
#

linting

brisk dune
# slate swan name?

Name: Python
Id: ms-python.python
Description: IntelliSense (Pylance), Linting, Debugging (multi-threaded, remote), Jupyter Notebooks, code formatting, refactoring, unit tests, and more.
Version: 2022.4.1
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.python

slate swan
#

uh

brisk dune
#

That's the one I use

slate swan
#

not u

paper sluice
#

comment it out and see

paper sluice
#

or remove the message=message

brisk dune
#

Nah, that entire line was causing the message to be re-interpreted

slate swan
#

process_commands inside a listener?, be ready to get double responses 😳

paper sluice
#

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

Changed in version 2.0: `message` parameter is now positional-only.
supple thorn
#

When you do ctx.channel.send instead of ctx.send does that make it not usable in dm channels or no

#

I'm assuming no

brisk dune
#

TIL don't put commands.Bot.process_commands(message) in a cog

slate swan
#

!d discord.ext.commands.Context.channel

unkempt canyonBOT
slate swan
#

it can be a user too, since thats equivalent to Message.channel

paper sluice
#

oh i read it the other way lmao

supple thorn
slate swan
supple thorn
slate swan
#

ctx.send works on channel

supple thorn
#

And in dms

slate swan
slate swan
brisk dune
#

Lmao "fat chance"

cloud dawn
#

!d discord.ext.commands.Context

unkempt canyonBOT
#
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.

This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.

This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
slate swan
supple thorn
slate swan
#

!d discord.ext.commands.Context.send

unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=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.

This works similarly to [`send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for non-interaction contexts.

For interaction based contexts this does one of the following...
supple thorn
#

It also works in dms

#

If the user invokes the command in dms

slate swan
supple thorn
slate swan
#

i thought u were saying that if we do ctx.send it sends user msg

supple thorn
#

I'm talking about ctx.send and ctx.channel.send

slate swan
#

lol

#

OOP

#

not really

#

ok

cloud dawn
#

channel also has .send()

slate swan
#

Hello
I've question

eternal apex
#

what do i do when i have this?

cloud dawn
#

!d discord.TextChannel.send

unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=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.10)") 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.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
slate swan
#

I created a channel on a guild using discord.py
and created roles also
how can I make a channel I created (I have its id) to allow only people of certain role to write and read
I tried to set_permissions but I can still see other one without the role using it normally

cloud dawn
#

What version?

cloud dawn
#

send_mesage is only really used for Interaction

supple thorn
#

send_message?

cloud dawn
#

!d discord.InteractionResponse.send_message

unkempt canyonBOT
#

await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by sending a message.
supple thorn
#

I've never seen that before

slate swan
#

ctx.channel returns a Messageable, why would .send not work on it?

cloud dawn
#

@slate swan it's discord.InteractionResponse.send_message

slate swan
#

ok

slate swan
paper sluice
#

Interactions are cool af

slate swan
#

interactions are painful

eternal apex
# slate swan *code?*
import discord
import json
import random
from discord.ext import commands

client = commands.Bot(command_prefix='+')

@client.event
async def on_ready():
  print("Ready!")

@client.command()
async def bal(ctx):
  a=ctx.author
  await open_account(a)
  users=await get_bank_data
  wallet_amt = users[str(a.id)]["wallet"] = 0
  bank_amt = users[str(a.id)]["bank"] = 0

  users = get_bank_data()
  em = discord.Embed(title=f"{ctx.author.name}'s balance",color=discord.Color.red)
  em.add_field(name="Wallet", value=wallet_amt)
  em.add_field(name="Bank", value=bank_amt)
  await ctx.send(embed=em)

@client.command()
async def beg(ctx):
  a=ctx.author
  await open_account(ctx.author)
  users=await get_bank_data
  earnings=random.randrange(250)
  await ctx.send(f"Someone gave you {earnings}!")
  
  users[str(a.id)]["wallet"] += earnings
  with open("mainbank.json", "w") as f:
    users = json.dump(users,f)

async def open_account(a):
  users = await get_bank_data()

    
  if str(a.id) in users:
    return False
  else:
    users[str(a.id)] = {}
    users[str(a.id)]["wallet"] = 0
  with open("mainbank.json", "w") as f:
    users = json.dump(users,f)
  return True

async def get_bank_data():
    with open("mainbank.json", "r") as f:
      users = json.load(f)
      return users


client.run("TOKEN")```
cloud dawn
#

NP

eternal apex
#

okay

slate swan
#

and what panda said

eternal apex
paper sluice
#

What tutorial is that?

cloud dawn
#

😏

slate swan
supple thorn
slate swan
#

^

cloud dawn
#

😢 this is why i cry at night.

slate swan
#

can i do like
async def l(ctx):
await ctx.send("yo")
async def n(ctx):
l(ctx)

paper sluice
supple thorn
slate swan
#

ok

paper sluice
#

But n should be a command and l should be normal function

cloud dawn
cloud dawn
supple thorn
slate swan
cloud dawn
boreal ravine
supple thorn
#

Contemplating on if i should add my dataclass in my client file or in a utils file ducky_drawing

boreal ravine
slate swan
#

utils file ofc, keep your Client file clean😔

boreal ravine
#

client file if you don't give a shit about organization

supple thorn
paper sluice
supple thorn
#

Since i only have 2 files right now

boreal ravine
slate swan
#

okimii himself isnt clean

supple thorn
slate swan
#

bro

#

spawns

#

i said the opposite

paper sluice
#

Lol

slate swan
#

i said to have 2 files so another file for the class

supple thorn
supple thorn
boreal ravine
#

shove it in there

slate swan
paper sluice
slate swan
#

i have no dataclasses

paper sluice
#

More files = clean

slate swan
#

^

supple thorn
slate swan
#

just use references no?

cloud dawn
supple thorn
#

Guess i am making that file

paper sluice
gaunt ice
#

hm

supple thorn
#

Why did i learn typehinting

#

This is all for typehinting

gaunt ice
#

can I like get a user's id with username and discriminator

slate swan
#

!d discord.utils.get

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.

Changed in version 2.0: The `iterable` parameter is now positional-only.

Changed in version 2.0: The `iterable` parameter supports [asynchronous iterable](https://docs.python.org/3/glossary.html#term-asynchronous-iterable "(in Python v3.10)")s...
slate swan
#

use this to ger the User object, bot.users would be the iterable, name="name", discriminator="#1234" will be the kwargs

gaunt ice
#

hmm

#

tysm

slate swan
gaunt ice
supple thorn
slate swan
supple thorn
#

That you used to try

gaunt ice
#

okk

slate swan
#

and your bot must have member intents too

final iron
#

The file is named message

supple thorn
final iron
#

Smh

slate swan
#

channels[0] is the channel I want

#

and role is the role I want

#

role is one from guild.roles

#

that just resets all the settings to default, and turns off send_messages permission, all old configurations get cleared

supple thorn
#

Atleast they sent a snippet of 1 line of code

slate swan
#

this is literally the code @supple thorn

#

the rest of code is not relevant

slate swan
#

yo how do i add time as seconds in

sec = 124801284
a = datetime.utcnow()
#

something like that

slate swan
supple thorn
#

Just adds the seconds to right now

slate swan
slate swan
slate swan
slate swan
slate swan
#

I will try

supple thorn
#

Damn you sarth

slate swan
#

lol

#

!d datetime.timedelta

unkempt canyonBOT
#

class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to `0`. Arguments may be integers or floats, and may be positive or negative.

Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
supple thorn
#

I was typing it

slate swan
#

lol

supple thorn
#

Don't steal glory 😔

slate swan
#

it exists, surely some import error from your side

slate swan
#

it was a auto import issue

#

ohhm

#

i thought it was imported

#

but when i see its something like that
from datetime import date, datetime

#

;-;

#

😔 add a , timedelta

#

and use it directly

#

no need

supple thorn
slate swan
supple thorn
slate swan
#

😳sure

supple thorn
paper sluice
#

Ducksducky_devil

supple thorn
#

Are you on tomorrow

#

I've only show this to okimii

slate swan
#

tomorrow as in how many hrs? ( my timezone is IST)

supple thorn
#

Some of it in the python general and hunter

slate swan
#

..

supple thorn
slate swan
#

Yea surely ill be online by that time

supple thorn
#

I come online usually in 7-8 am

#

In my timezone

#

Cause school

slate swan
slate swan
supple thorn
#

I hate that my school doesn't have a coding class yet everyone else does

slate swan
#

1 hour and 30 minutes ahead

supple thorn
slate swan
#

acc to google

supple thorn
slate swan
slate swan
supple thorn
slate swan
#

!ot

unkempt canyonBOT
paper sluice
#

Cuz army...

supple thorn
#

You're 1 hour and 30 minutes behind

slate swan
#

ye

slate swan
supple thorn
slate swan
supple thorn
#

Kek

slate swan
#

..

#

someone got command ideas? 😔

supple thorn
supple thorn
supple thorn
#

Attack someone with the robot while on discord

slate swan
#

I'd need a robot for that first

supple thorn
#

Be the first to use discord as a weapon irl

brisk dune
#
@tasks.loop(seconds=30)
async def logs_dumper(self):
    _parent_dir = os.path.abspath(os.getcwd())
    with open((_parent_dir + os.sep + "log.txt"), "at") as logs:
        logs.writelines(self._temp)
    self._temp = []

Would this be alright? It works, I'm just wondering if I should do it asynchronously as well...

slate swan
paper sluice
slate swan
brisk dune
slate swan
slate swan
unkempt canyonBOT
supple thorn
slate swan
#

uh

slate swan
slate swan
supple thorn
#

Woman detector

slate swan
slate swan
slate swan
brisk dune
slate swan
#

make direct contact by server owners for suggestion and all

#

above 1k members

supple thorn
slate swan
#

🤨

supple thorn
velvet compass
#

Uhhhh can we switch the topics?

supple thorn
#

Oh no brad here

slate swan
#

Thanks!

#

:D

slate swan
#

..

slate swan
#

!pip lavasnek-rs

unkempt canyonBOT
slate swan
#

😩i love this binding

#

But there's no point of making music bots for me atm

#

Q/A how mods come here

  1. Python bot
  2. Visiting
  3. a guy told them
slate swan
supple thorn
slate swan
#

isnt their an akinator api?

supple thorn
slate swan
#

lol

#

i have seen a dc bot

supple thorn
#

Sadge

velvet compass
slate swan
unkempt canyonBOT
supple thorn
#

I should make a akinator wrapper next

slate swan
supple thorn
slate swan
#

what do you guys think on

@bot.on_event(GatewayEvent.READY)
async def on_connect() -> None:
    print("Ive recieved the READY gateway event!")
#

?

#

seems fine, what about other events like member join etc?

slate swan
#

would it be a single parameters of the event Class, or like discord.py events?

velvet compass
#

And help channels

slate swan
#

im still working with the gateway because of bad implementations

supple thorn
slate swan
slate swan
supple thorn
supple thorn
slate swan
# slate swan im sticking by gateway event naming

thats not what im asking, i was talking about the arguments of the event callback

@bot.on_event(MemberJoin)
async def foo(member : Member):
    ...
@bot.on_event(MemberJoin)
async def foo(event: MemberJoin):
    member = event.member
slate swan
brisk dune
# slate swan !pip aiofiles if you wanna do that
@tasks.loop(seconds=30)
async def logs_dumper(self):
    _parent_dir = os.path.abspath(os.getcwd())
    async with aiofiles.open((_parent_dir + os.sep + "log.txt"), "at") as logs:
        await logs.write(('\n'.join(self._temp)))
    self._temp = []

This works! Thanks again!

velvet compass
slate swan
slate swan
slate swan
slate swan
supple thorn
slate swan
#

im so bad i cant even import

slate swan
# supple thorn What are the differences between the two

in the first one, the event class is just an identification of what it is arguments are being provided to the function seperately and the number of arguments depend on the event

in the second case the class is the event type and acts like a dataclass with all information about that event Stored in it, the event function will always take a single argument event which would be the event class having the data related to the event

slate swan
slate swan
#

in simpler words,
1st one - dpy style
2nd one - hikari style

velvet compass
supple thorn
#

Imagine a async discord api wrapper that's esoteric

slate swan
#

yo help

supple thorn
#

And flex

supple thorn
supple thorn
slate swan
supple thorn
slate swan
#

i will be making mine clean and esoteric

supple thorn
#

😔

slate swan
#

😉

supple thorn
rain furnace
#

this is my code:

intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix = bot_prefix, intents = intents)
@bot.event
async def on_member_join(member):
  embed = discord.Embed(colour=0x95efcc, description=f"Welcome to Nextvision!", timestamp=datetime.datetime.utcfromtimestamp(1536229094))
  embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/933768511145250896/966459729738076180/n7dCH2pmCcaFVWXB.gif")
  embed.set_author(name=f"{member.name}", icon_url="https://cdn.discordapp.com/attachments/933768511145250896/966459729738076180/n7dCH2pmCcaFVWXB.gif")
  embed.set_footer(text=f"{member.guild}", icon_url="https://cdn.discordapp.com/attachments/933768511145250896/966459729738076180/n7dCH2pmCcaFVWXB.gif")
  channel = bot.get_channel(id=962006966086025216)
  await channel.send(embed=embed)

I need to do welcome discord bot but its not working and there is no error

supple thorn
slate swan
#

why not a synchronous api wrapper

#

oh wait this exists

#

!pip disco

unkempt canyonBOT
rain furnace
brisk dune
supple thorn
slate swan
rain furnace
supple thorn
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.

rain furnace
#

yes

slate swan
#

yes, its literally in his code

supple thorn
#

Oh sorry

#

I was looking at it pretty much cropped

#

!d discord.ext.commands.Bot.get_channel

unkempt canyonBOT
supple thorn
#

@rain furnace id is positional

rain furnace
supple thorn
rain furnace
#

where I need to put it?

supple thorn
rain furnace
#

remove this line?

supple thorn
#

What line

rain furnace
placid skiff
#

technically it is fine to specify id when using get_channel

rain furnace
#

so why its not working

placid skiff
#

what is the error?

rain furnace
#

there is no error

#

its just not working

slate swan
#

h?

cold sonnet
#

Changed in version 2.0: id parameter is now positional-only.

novel bolt
#

how can i write text to a file without saving it , so tat i can send it via bot?

placid skiff
slate swan
#

how

#

how is making an argument positional only make the whole update "bad"

cold sonnet
#

no dpy s tier

slate swan
#
import datetime 
from datetime import datetime,timedelta
cold sonnet
#

what's wrong with using pos arguments, they spare memory cuz id= is like 4 bytes which you'll need in the future 😎

placid skiff
#

Lol

cold sonnet
#

yo discord bots channel

#

😔

slate swan
#
        await message.channel.send('Guess a number between 1 and 10.')

        def is_correct(m):
            return m.author == message.author and m.content.isdigit()

        answer = random.randint(1, 10)

        try:
            guess = await self.wait_for('message', check=is_correct, timeout=5.0)
        except asyncio.TimeoutError:
            return await message.channel.send(f'Sorry, you took too long it was {answer}.')

        if int(guess.content) == answer:
            await message.channel.send('You are right!')
        else:
            await message.channel.send(f'Oops. It is actually {answer}.')```

Ignoring exception in on_message
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "/Users/bai/Documents/Personal Things/Do not delete/Only viewable by me/Aww Pika Discord Bot/aww pika discord bot.py", line 260, in on_message
    guess = await self.wait_for('message', check=is_correct, timeout=5.0)
NameError: name 'self' is not defined

pls help me with this error :/
slate swan
#
a = datetime.utcnow()
            b = a + datetime.timedelta(seconds=ab)
slate swan
slate swan
#

;-;

paper sluice
slate swan
#

ye

#

tell what to do! !

#

import as?

paper sluice
#

yes

slate swan
#

ok

slate swan
cold sonnet
#

replace self with bot

slate swan
slate swan
slate swan
cold sonnet
#

that's exactly what someone who copied the code would say

#

nah jk

slate swan
#

i wonder why he add self if he didnt copied

#

it works on my previous python bot script, cuz im rewriting it as a newer way of discord.py

#

i dont copy codes

cold sonnet
#

maybe your Bot instance is called self there

#

which is weird

slate swan
#

@paper sluice

slate swan
paper sluice
slate swan
#
    async def on_ready(self):
        print('Logged on as', self.user)```

this is very old already, my previous script* using discord.Client
#

irdk

#

so now im rewriting it*

paper sluice
cold sonnet
#

then that's cog.wait_for

slate swan
slate swan
#

its like very outdated code, so thats why i rewrite, not copy

cold sonnet
#

but it makes sense if u subclass client

paper sluice
# slate swan THAT DONT WORK
>>> import datetime
>>> from datetime import datetime as d
>>> datetime.datetime.now()
datetime.datetime(2022, 4, 21, 18, 23, 39, 406068)
>>> d.now()
datetime.datetime(2022, 4, 21, 18, 23, 42, 573662)
slate swan
cold sonnet
#

why don't u subclass bot too

slate swan
#

HI

slate swan
#

<@&831776746206265384>

cold sonnet
#

why did u

slate swan
velvet compass
#

One second

slate swan
cold sonnet
#

just tell him to go ot

slate swan
cold sonnet
#

you can't?

slate swan
#

ye

velvet compass
#

They cross posted in 5 channels at once

cold sonnet
#

yeah rule 6

slate swan
#

i wonder if mods have power to delete msg or they copy msg id and paste in bot

cold sonnet
#

probably the first

slate swan
placid skiff
slate swan
#

they advertise their channel and they havent uploaded since 3 weeks ago

cold sonnet
#

it does

slate swan
#

numbers*

slate swan
slate swan
cold sonnet
#

well like if a message has too many lines it is deleted

#

for sure

placid skiff
slate swan
placid skiff
velvet compass
paper sluice
slate swan
#

ig i need to change into int

paper sluice
#

print and see what it returned

slate swan
velvet compass
#

Not the one here, but the other channels got zapped

slate swan
#

lmao

#

ig its disabled in this channel cuz of ppl share youtube tutorial here maybe

slate swan
paper sluice
#

👏🏻

placid skiff
unkempt canyonBOT
#

@placid skiff :white_check_mark: Your eval job has completed with return code 0.

001 | 2022-04-21 13:04:02.554473
002 | 2027-10-20 10:18:35.554473
placid skiff
#

it really works lol

slate swan
#

cool

spice adder
#

Is there a simple method of editing an existing embed's description and nothing else in it?

dense swallow
#

how do i check if a user has a specific role by id.. ik commands.has_role() exist but is there any other way other than this decorator check?

brisk dune
slate swan
#
@bot.command()
@commands.has_any_role(692760082085183519, 940008547993927691, 863878825376743475, 902292952381001779, 863879069253894166, 902292952381001779, 863879304110276668, 940008547993927691)
async def пред(ctx, member: discord.Member = None, *, reason = 'Отсутствует'):
    print(45)
    cursor.execute("""CREATE TABLE IF NOT EXISTS warning(guild_id BIGINT, user_id BIGINT, warn INT, count INT, moderator_id BIGINT, reasons VARCHAR)""")
    base.commit()
    print(1)
    
    warnings = cursor.execute("SELECT * FROM warning WHERE user_id = ? AND guild_id = ?", (member.id,ctx.guild.id)).fetchone()
    print("работает")
    
    
    if member is None:
        await ctx.send("Выберите участника")
        return
        
    if warnings is None:
        cursor.execute('INSERT INTO warning(guild_id, user_id, warn, count, moderator_id, reasons) VALUES(?, ?, ?, ?, ?, ?)', (ctx.guild.id,member.id,0,1,ctx.author.id,'Отсутствует'))
        base.commit()
        print(2222)
        cursor.execute(f'UPDATE warning SET warn = warn + 1 WHERE user_id = ? AND guild_id = ?', (member.id, ctx.guild.id))
        base.commit()
        await ctx.send(f"**{ctx.author.name}** Выдал предупреждение #{warnings[2]} {member} (случай # ) {reason}")
    else:
        cursor.execute(f'UPDATE warning SET warn = warn + 1 WHERE user_id = ? AND guild_id = ?', (member.id, ctx.guild.id))
        base.commit()
        await ctx.send(f"**{ctx.author.name}** Выдал предупреждение #{warnings[2]} {member} (случай # ) {reason}")      

how to make it so that if the reason is not specified, then Отсутствует is not written in the chat?

lofty pecan
#

doesn't it work?

spice adder
lofty pecan
#

if the default value is that word it should be working ?

lofty pecan
slate swan
#

I just want to make sure that if there is no reason, Missing is not written in the chat, but if there is, then it is written. I just don't know how to do it..

lofty pecan
#

okay and what does this code do then?

#

does it do anything ? did you try ?

slate swan
#

._.

#

what?

lofty pecan
#

you paste your code, saying you don't know what to do, but what does the code do

#

does it work? what does it do? what's the output

slate swan
#

What? Can't you see what the code is doing? it issues warnings.

lofty pecan
#

no, you're saying how to make it so that if the reason is not specified, then Отсутствует is not written in the chat?, but as I can see, when your reason isn't speficied the default value is the word you enterered, so I don't see what's not working there

#

when you run the command what happens

slate swan
#

i got stuck for 30 min cuz of indents

lofty pecan
#

damn that hurts

slate swan
#

ok

#

sorry()

slate swan
slate swan
#

i got stuck here

             if a2 in d.keys():
              if a2 == "w":
                if a1 >= 5:
                    pass
                else:
                    pass
             elif a2 == "d":
                if a1 >= 30:
                    pass
                else:
                    pass                   
slate swan
#

idk how i didnt see

#

is it the same code huh

slate swan
#
async def channelid(ctx):
    channel = client.get_channel(channel_id)
    await ctx.send(channel)```

why does this not work? i want it to be when command is entered into a channel it sends the channel id, directly in the channel the author had sent it in, how to fix this??
#

but anyways, im not the one to judge 😔

slate swan
boreal ravine
slate swan
paper sluice
slate swan
slate swan
slate swan
#

no error, it just didnt send

slate swan
slate swan
# slate swan
  • did you save the file and rerun the not?
  • is it above bot.run() ?
  • do you have an on_messave event?
slate swan
#

and those ifs too

#

hm ic

slate swan
slate swan
#

this is how i get my bot online

#

thats lovely

#

eye hurting theme

#

I'm out

#

?

dull terrace
#

wheeze pika ffs

slate swan
slate swan
dull terrace
#

go through some tutorials like i told you to

slate swan
#

client and bot 2 var

#

it still works tho

dull terrace
#

Anyone here have experience with Patreon API?

#

Is there a way to test without Patreons?

slate swan
slate swan
slate swan
#

idk man mixing up 2 Bot objects will just spoil your code, use a single Bot for your commands

slate swan
#

huh? how is that related

#

nvm

brisk zodiac
#
async def math(ctx):
    await ctx.send(f"{number} {number2}")
    if == number + number2:
        await ctx.send('True')``` How do I get the user message in `if` when they answer correct It will reply with "True"
slate swan
#

ok

#

!d discord.Client.wait_for use this with "message" as the event

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.10)"). 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.10)") 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.10)") 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**...
slate swan
#

he is trying to explain*

silver wolf
#

But…ur command can either be really basic or complex depending on what ur doing

slate swan
#

..

slate swan
#

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

brave forge
#

how to add reactions to a message ?

unkempt canyonBOT
slate swan
slate swan
# brave forge how to add reactions to a message ?
@Command
async def uwu(ctx: commands.Context):
  msg = await ctx.send("uwu")
  await msg.add_reaction("joy") # raw unicode for default emojis
  await msg.add_reaction("\1f600") # for default emojis
  await msg.add_reaction("\N{THUMBS UP SIGN}") # for default emojis with name
  await msg.add_reaction("<:emoji_name:emoji_id>") # for custom emojis (should be present in the server)
#

whoever that was pls use a pasting service

velvet haven
#

how to change bot's volume

brave forge
#

@slate swan @slate swan in order for something to happen after pressing the reaction, it is necessary that what happens is about how the reaction is called?

river swift
#

How could I make a discord bot with python from scratch?

slate swan
unkempt canyonBOT
#

class discord.PCMVolumeTransformer(original, volume=1.0)```
Transforms a previous [`AudioSource`](https://discordpy.readthedocs.io/en/master/api.html#discord.AudioSource "discord.AudioSource") to have volume controls.

This does not work on audio sources that have [`AudioSource.is_opus()`](https://discordpy.readthedocs.io/en/master/api.html#discord.AudioSource.is_opus "discord.AudioSource.is_opus") set to `True`.
chilly igloo
#

@bot.command()
@commands.has_any_role(692760082085183519, 940008547993927691, 863878825376743475, 902292952381001779, 863879069253894166, 902292952381001779, 863879304110276668, 940008547993927691)
async def пред(ctx, member: discord.Member = None, *, reason = 'Отсутствует'):
print(45)
cursor.execute("""CREATE TABLE IF NOT EXISTS warning(guild_id BIGINT, user_id BIGINT, warn INT, count INT, moderator_id BIGINT, reasons VARCHAR)""")
base.commit()
print(1)

warnings = cursor.execute("SELECT * FROM warning WHERE user_id = ? AND guild_id = ?", (member.id,ctx.guild.id)).fetchone()
print("работает")


if member is None:
    await ctx.send("Выберите участника")
    return
    
if warnings is None:
    cursor.execute('INSERT INTO warning(guild_id, user_id, warn, count, moderator_id, reasons) VALUES(?, ?, ?, ?, ?, ?)', (ctx.guild.id,member.id,0,1,ctx.author.id,'Отсутствует'))
    base.commit()
    print(2222)
    cursor.execute(f'UPDATE warning SET warn = warn + 1 WHERE user_id = ? AND guild_id = ?', (member.id, ctx.guild.id))
    base.commit()
    await ctx.send(f"**{ctx.author.name}** Выдал предупреждение #{warnings[2]} {member} (случай # ) {reason}")
else:
    cursor.execute(f'UPDATE warning SET warn = warn + 1 WHERE user_id = ? AND guild_id = ?', (member.id, ctx.guild.id))
    base.commit()
    await ctx.send(f"**{ctx.author.name}** Выдал предупреждение #{warnings[2]} {member} (случай # ) {reason}")       

how to make it so that if the reason is not specified, then Отсутствует is not written in the chat?

slate swan
#

oh god

#

lol

#

!paste @chilly igloo

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.

slate swan
#

!code