#discord-bots

1 messages ยท Page 883 of 1

brazen raft
hallow tangle
#

the event got triggered after 25th message

cold sonnet
#

oopsie

buoyant igloo
#

Ok

slate swan
hallow tangle
#

how can I send the bot's message now

brazen raft
#

In the if

slate swan
hallow tangle
buoyant igloo
brazen raft
#

Messages hold a reference to the channel they were sent in, so you can send a message to the channel the message was sent

spring flax
#
@bot.command()
async def example(ctx, member : disnake.Member):
  embed = disnake.Embed(description=member.mention) #a simple example of an embed with the mention of the user you mentioned in the command
  await ctx.send(embed=embed)```
hallow tangle
#

oh

brazen raft
#
await message.channel.send("ok")
slate swan
unkempt canyonBOT
#
Nuh-uh.

No documentation found for the requested symbol.

slate swan
#

lol

cold sonnet
#

lol

slate swan
#

!d discord.abc.Messageable.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**.
slate swan
slate swan
slate swan
cold sonnet
#

MEH

slate swan
#

if you set it it raises an attr error oksadcat

cold sonnet
#

time to change python

hallow tangle
#

ok thanks it worked, but

#

all my commands stopped working

brazen raft
#

Okay

manic wing
#

.event -> .listen()

hallow tangle
#

brainmonokay

slate swan
spring flax
# hallow tangle all my commands stopped working

Overriding the default provided on_message forbids any extra commands from running. To fix this, add a bot.process_commands(message) line at the end of your on_message. For example:

@bot.event
async def on_message(message):
    # do some extra stuff here

    await bot.process_commands(message)

Alternatively, you can place your on_message logic into a listener. In this setup, you should not manually call bot.process_commands(). This also allows you to do multiple things asynchronously in response to a message. Example:

@bot.listen('on_message')
async def whatever_you_want_to_call_it(message):
    # do stuff here
    # do not process commands here```
cold sonnet
#

whatn't

brazen raft
slate swan
#

how is the event deco better than listen?

manic wing
brazen raft
#

I was looking this up. I am so slow

cold sonnet
slate swan
#

oh he ment change itcatsip

slate swan
manic wing
#

๐Ÿคฆ

cold sonnet
#

greater than

slate swan
#

no?

cold sonnet
#

bro I'm literally drunk

#

it's not a greater than sign

slate swan
#

> is greater he ment change it

manic wing
slate swan
manic wing
cold sonnet
spring flax
manic wing
#

ill give you a D ๐Ÿ˜‰

slate swan
unkempt canyonBOT
cold sonnet
#

NO

#

he gave the D to someone else

slate swan
#

he gaved me a D you probably got an A

manic wing
slate swan
manic wing
#

np

slate swan
manic wing
manic wing
#

the revolt api is so dead rn

alpine furnace
#

What is this shit

slate swan
#

grsstab

manic wing
#

theres literally nothing in the revolt api

alpine furnace
#

Everywhere that @slate swan is eventually turns into an edating zone

#

True story

#

Uwu zone

manic wing
#

ashleys a dude

slate swan
#

yes the UWU zone

slate swan
manic wing
#

im gay

slate swan
manic wing
#

anyways

#

!ot

unkempt canyonBOT
honest shoal
manic wing
final iron
honest shoal
honest shoal
brazen raft
#

Guilded is a social app like Discord, yes

final iron
#

Missing a capital and punctuation

slate swan
#

ayo?

#

officerPepeCurious

honest shoal
manic wing
#

punctuation is irrelevant

white adder
slate swan
final iron
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)
honest shoal
manic wing
final iron
#

๐Ÿ—ฟ

brazen raft
final iron
#

IDK old English.

honest shoal
unkempt canyonBOT
final iron
#

๐Ÿ—ฟ

manic wing
#

whats guilded

honest shoal
#
#

something like discord without paywalls

manic wing
#

damn so much competition

#

i need to make hundreds of accounts in all of them to be an og

slate swan
#

All you care is being og until your account credentials get leaked and youre using just one password for everything.

brazen raft
manic wing
manic wing
#

i use a different password for every single website and im definitely not just saying this so you dont hack me

pastel olive
#

Someone who know how to send the traceback to a channel?

spice basalt
#

how do i fix this?

slate swan
unkempt canyonBOT
#

discord.ext.commands.on_command_error(ctx, error)```
An error handler that is called when an error is raised inside a command either through user input error, check failure, or an error in your own code.

A default one is provided ([`Bot.on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.on_command_error "discord.ext.commands.Bot.on_command_error")).
final iron
#

wut

buoyant igloo
#

Indent await msg.add_reaction or sumthing

spice basalt
#

this is the first time i've gotten an "outside function" error

slate swan
pastel olive
#

what you mean

brazen raft
spice basalt
#

okay fixed

slate swan
#

!d discord.on_command_error @pastel olive and use bot commands next time

unkempt canyonBOT
#
NEGATORY.

No documentation found for the requested symbol.

slate swan
#

rip it

#

use docs

#

lol

unkempt canyonBOT
#
Nuh-uh.

No documentation found for the requested symbol.

final iron
#

!d discord.discord.ext.commands.on_command_error

unkempt canyonBOT
#

discord.ext.commands.on_command_error(ctx, error)```
An error handler that is called when an error is raised inside a command either through user input error, check failure, or an error in your own code.

A default one is provided ([`Bot.on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.on_command_error "discord.ext.commands.Bot.on_command_error")).
slate swan
#

wait ew

spice basalt
brazen raft
#

Why "discord" twice

kindred epoch
slate swan
buoyant igloo
slate swan
unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

kindred epoch
slate swan
#

this chat and its indents is giving me a stroke

final iron
#

Why can't people just learn basic python ๐Ÿ˜”

kindred epoch
brazen raft
#

Making Discord bots was the reason I started learning Python, I don't blame them.

kindred epoch
cold sonnet
spice basalt
brazen raft
#

I, too, was an eleven year old, hyped about making making Discord bots in Python from bad, old YouTube tutorials.

kindred epoch
#

error says it all?

slate swan
#

i started because of my career lol

kindred epoch
slate swan
#

but i want to get a job backendrooDuck

spice basalt
brazen raft
#

Python is a textual programming language that depends on the indentation of statements.

slate swan
#

yup

#

it depends on indentation

spice basalt
#

pain peko

#

is this still an indentation error?

slate swan
spice basalt
#

ok i just realized the problem

spice basalt
slate swan
spice basalt
#

you saw nothing

slate swan
spice basalt
#

how do i define disnake

spice basalt
#

๐Ÿ˜ณ

slate swan
spice basalt
#

tf?

slate swan
#

ayo

spice basalt
kindred epoch
slate swan
spice basalt
#

very comedic

spice basalt
honest shoal
slate swan
spice basalt
#

i haven't indented disnake yet

slate swan
spice basalt
#

*imported

slate swan
#

i should stop with lyrics nvm

spice basalt
#

as you can see, i am not sleep deprived

slate swan
#

loool

#

you guys sleep?

spice basalt
#

sleep with your mom i do

#

don't care, i dug 6 feet

slate swan
spice basalt
slate swan
#

skill issue

spice basalt
honest shoal
#

!d pip

unkempt canyonBOT
#
pip

%pip```
Run the pip package manager within the current kernel.
honest shoal
#

wait what's disnake?

slate swan
slate swan
# spice basalt how do i import disnake

๐Ÿ˜” use vs code, install tabnine, restart vscode, type disnake wait for the auto-import intellisense suggestion, press enter, boom it imports disnake for you

slate swan
unkempt canyonBOT
honest shoal
slate swan
#

am i not smart enough02angery

honest shoal
brazen raft
honest shoal
#

nvm wrong ping

spice basalt
#

can i do this without disnake?

slate swan
#

Hey! I'm trying to make a simple bot that returns a private variable from a class, but it just returns the byte offset instead of the string, if anyone could help me that would be great!

#

use commands?

#
New price set to: 39459.26
<variables.Variables object at 0x000002272D113D90>
done!
#

cool

spice basalt
slate swan
#
class Variables:
    def __init__(self):
        self.price = self

    def set_price(self, new_price):
        self.price = new_price
        print("New price set to: " + str(self.price))

    def get_price(self):
        return str(self.price)
honest shoal
#

hey akeno

slate swan
#
btc_price = str(v.get_price())
print(btc_price)
slate swan
spice basalt
honest shoal
brazen raft
spice basalt
spice basalt
slate swan
spice basalt
#

answer me

#

๐Ÿ˜”

honest shoal
slate swan
#

yes you can without disnake

spice basalt
#

how

spice basalt
honest shoal
#

I'm looking for the one who recommended you disnake

spice basalt
#

some raven edgelord

slate swan
#

i would low-key recommend the same

spice basalt
slate swan
#

wrong channel

spice basalt
slate swan
#

yes

#

making the request to the endpoints is just high-key better

brazen raft
# slate swan raw requests

That will allow you to host the bot on PythonAnywhere, where all ports other than internet ports are blocked (no websockets)

honest shoal
spice basalt
#

i know they're different and nothing else

brazen raft
spice basalt
brazen raft
#

It is going to be deprecated

slate swan
#

soon

honest shoal
#

sadge

spice basalt
#

i'm going to sleep

honest shoal
#

what's ur timezone

brazen raft
#

I have been using my eyes to look at the screen of my phone for hours, and now I am looking at the screen of my laptop, and my eyes hurt.

spice basalt
brazen raft
slate swan
slate swan
brazen raft
#

People usually host websites on PythonAnywhere, but any program can be hosted on there. They block non-internet ports, though, because only internet ports are necessary for.. hosting websites

slate swan
#

I get the price from one file, set it in the variables file, call the variables file in the main

slate swan
#

Well, that's why I am asking for help

slate swan
#

listen I'm just asking what is the solution lol

slate swan
#

Im making a discord bot?

final iron
#

with discord.py and other relevant Python libraries.

slate swan
#

oh im sorry I thought this was help thinkmon

final iron
#

Read the channel description

brazen raft
# slate swan Well, that's why I am asking for help

I do not know how this has anything to do with #discord-bots, but self in normal method definitions is the first parameter of the functions, obviously, but it refers to any instance of the class. So by doing self.price = self you're creating an instance variable self.price and assigning it the value of.. itself.. the instance itself.

final iron
final iron
#

Not random class issues

slate swan
#

you guys are so fucking entitled lmao

spice basalt
#

why isn't it reacting to my message?

final iron
unkempt canyonBOT
slate swan
#

basic classes isnt related to the channel?

slim ibex
#

what happened lol

brazen raft
#

I bet having an instance variable referring to the instance itself is useful somehow, I have seen it sometime, but I can't remember where. Anyway, that is not #discord-bots related topic

slate swan
spice basalt
slate swan
tidal hawk
#

Anyone else unable to copy the token from developer portal?

slate swan
#

!d discord.ext.commands.Bot.get_emoji

unkempt canyonBOT
kindred epoch
slate swan
#

!d discord.Emoji

unkempt canyonBOT
#

class discord.Emoji```
Represents a custom emoji.

Depending on the way this object was created, some of the attributes can have a value of `None`...
slate swan
#

wait

kindred epoch
#

that should work

slate swan
#

why does disnake mention that format in their guide then, okimii

slate swan
brazen raft
#

Instead of, like, the string of the emoji

#

Not sure

slate swan
spice basalt
brazen raft
#

Tias, otherwise, fetch the emoji.

slate swan
#

iirc you cant

slate swan
brazen raft
#

It might not be an emoji in the server

slate swan
#

yeah depends

kindred epoch
#

@spice basalt is the bot in the server where the emoji is from?

spice basalt
slate swan
#

but

brazen raft
#

I would suggest fetching the emoji

slate swan
#
discord.utils.get(bot.emojis, name="uwu")
``` works too
kindred epoch
#

just get the emoji lmao

slate swan
#

no

#

do it the harder way, make your code slower

spice basalt
#

wow

brazen raft
#

I mean, discord.utils.get(message.guild.emojis, name="BroKiss~1") is also an option

spice basalt
#

it's just Brokiss

slate swan
kindred epoch
spice basalt
#

yes

brazen raft
#

Why is it BroKiss~1 in the screenshot

slate swan
#

if two servers have the same emoji then

brazen raft
spice basalt
slate swan
brazen raft
#

This confuses me

slate swan
brazen raft
#

Sociopathic left smiler

slate swan
#

(:)

brazen raft
#

Unibrow

#

No

slate swan
spice basalt
brazen raft
slate swan
slate swan
spice basalt
#

how do i make it trigger when someone says "don't care"?

#

the ' is messing with stuff

#

anyone there?

#

like this?

unkempt canyonBOT
#

str.split(sep=None, maxsplit=- 1)```
Return a list of the words in the string, using *sep* as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, the list will have at most `maxsplit+1` elements). If *maxsplit* is not specified or `-1`, then there is no limit on the number of splits (all possible splits are made).

If *sep* is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, `'1,,2'.split(',')` returns `['1', '', '2']`). The *sep* argument may consist of multiple characters (for example, `'1<>2<>3'.split('<>')` returns `['1', '2', '3']`). Splitting an empty string with a specified separator returns `['']`.

For example:
brazen raft
spice basalt
#

ah so
don.split(' ' ')t?

brazen raft
#

And swap the strings

spice basalt
brazen raft
#

Yeah

unkempt canyonBOT
#

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

True
brazen raft
#

What the hell bro

spice basalt
#

ah

timber girder
#

Iโ€™m trying to make a premium system with a file. json, can anyone help me?

torn sail
#

Canโ€™t you just use replace?

brazen raft
#

Exactly

spice basalt
#

wait how should i put it in my case

brazen raft
#

I thought they meant to do

if "don't care" in message.content:
    await message.channel.send("didn't ask")
spice basalt
#

yes

velvet tinsel
#

!d str.replace || python bot has docs on it

unkempt canyonBOT
#

str.replace(old, new[, count])```
Return a copy of the string with all occurrences of substring *old* replaced by *new*. If the optional argument *count* is given, only the first *count* occurrences are replaced.
velvet tinsel
#

I know, Iโ€™m just telling the bot to clarify it

brazen raft
#
if "dont care" in message.content.replace("'", "").lower():
    await message.channel.send("I have not asked!")
spice basalt
#

ah

brazen raft
#

Might as well throw in some whitespace stripping

spice basalt
#

but what about the i have not asked part?

brazen raft
#

What about it?

velvet tinsel
spice basalt
#

i want the bot to reply "didn't ask"

velvet tinsel
#

Oh it doesnโ€™t show

brazen raft
brazen raft
#

Actually, you could have...

#
if "dont care" in ' '.join(message.content.replace("'", "").lower().strip().split()):
    await message.channel.send("I have never asked!")
velvet tinsel
spice basalt
#

i want it to say "didn't ask" instead of "i have not asked"

brazen raft
#

Then change it to be didn't ask

slate swan
velvet tinsel
brazen raft
#

I wanted to be unique

velvet tinsel
#

Itโ€™s not that hard

brazen raft
spice basalt
#

my brain isn't functioning properly

slate swan
brazen raft
#

All of the bugs are eating into our brains

spice basalt
#

it's 3 in the morning

brazen raft
#

10:45 PM here

slate swan
#

4pmkek

brazen raft
#

But I feel like trash as well

slate swan
#

check the author

spice basalt
#

i did

brazen raft
#

The event should have

if message.author == bot:
    return

at the top of it

slate swan
#

the spoonfeedcatgun

brazen raft
#

I

#

I am sorry

spice basalt
#

i already added that when i started

manic wing
#

assert not message.author.bot pithink

velvet tinsel
#

you should go to sleep if itโ€™s late there

brazen raft
spice basalt
slate swan
spice basalt
velvet tinsel
spice basalt
#

i think i'll just pull an all nighter

velvet tinsel
#

Your brain will work better after a good nights sleep

spice basalt
#

and do my missing assignments

velvet tinsel
#

Ask @manic wing ๐Ÿ˜ณ

brazen raft
#

You won't be able to pull yourself the entire day, though

spice basalt
#

actually i'm just gonna sleep

slate swan
#

whats sleepisFine

brazen raft
#

Have a goodnight

velvet tinsel
spice basalt
brazen raft
slate swan
velvet tinsel
slate swan
#

i leave my pc on all dayisFine

manic wing
#

and ignore it

brazen raft
#

Or don't use assert

slate swan
manic wing
#

who doesnt have an error handler

#

1 line > 2 lines

#

you people havent evolved to use assert yet

brazen raft
#

There are two kinds of programmers: Those who like erroneous programming and those who like branching programming

slate swan
manic wing
brazen raft
manic wing
slate swan
#

you need to be jokingrooFine

manic wing
#

assert doesnt scale but the return does

brazen raft
#

Exceptions aren't meant to be raised, they are meant to be caught.

slate swan
velvet tinsel
manic wing
slate swan
#

your just saying yeah use assert so the bot raises an exception while an if statement wont

brazen raft
manic wing
#

3 lines > 2 * 2^n - 2 lines

brazen raft
#

It can be one line if you really want it to be

#
if message.author == bot: return
cold sonnet
#

doubt

manic wing
slate swan
#

skill issue

manic wing
#

assert looks sexy (its purple)

cold sonnet
#

if message.author == bot.user: return

brazen raft
brazen raft
#

Why not

cold sonnet
#

why not

slate swan
#

caedens point is use assert because it looks cool

manic wing
cold sonnet
#

never seen it

slate swan
manic wing
#

noone wants a bot to respond to a bot

slate swan
cold sonnet
#

no

slate swan
brazen raft
#

!d assert

unkempt canyonBOT
#

7.3. The assert statement

Assert statements are a convenient way to insert debugging assertions into a program:


assert_stmt ::=  "assert" expression ["," expression]
``` The simple form, `assert expression`, is equivalent to

```py
if __debug__:
    if not expression: raise AssertionError
```...
cold sonnet
manic wing
slate swan
manic wing
manic wing
slate swan
alpine furnace
#

If only that contract PEP was accepted

manic wing
#

because im a seer

alpine furnace
#

!pep 316

unkempt canyonBOT
#
**PEP 316 - Programming by Contract for Python**
Status

Deferred

Created

02-May-2003

Type

Standards Track

brazen raft
#

Another opposing statement against using assert in this case, quoting from the commands' output: insert debugging assertions

#

It's used for debugging purposes.

#

If you run the Python program with the optimization flag to remove debugging assertions, that bit of code will literally not run.

alpine furnace
#

Yes

slate swan
manic wing
alpine furnace
#

Cope

slate swan
#

why even have a website for your bot

alpine furnace
#

Wasnโ€™t for a bot

slate swan
#

cough caeden

manic wing
slate swan
manic wing
slate swan
velvet tinsel
slate swan
#

havent seen jesterbot with clout

#

seems like a skill issuepeped

#

i used squarespace

#

costed 200$ to make it public

#

got paid 600$

manic wing
brazen raft
slate swan
#

my dad's co worker

brazen raft
#

Luck 300

slate swan
#

ikr

#

it was my first job

buoyant igloo
#

How do u get a user id out of an async function

slate swan
#

wrong chnanelk

slate swan
#

quick question . does this py commands.when_mentioned_or("b","B") works like py ["b","B"]

granite moat
#

What's the goto discord library that supports slash commands and buttons?

granite moat
full lily
slate swan
slate swan
novel sinew
#

im developing my first discord bot, and its going well so far. can anybody help with automated welcome messages, and also anything i should add to my bot?

unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
slate swan
novel sinew
#

okay thank you!

slate swan
#

youre welcome

final iron
slate swan
final iron
slate swan
final iron
#

๐Ÿ˜ญ

slate swan
#

cry about it lol

mellow gulch
#

does the bot.run have to be at the end of all of the code

slate swan
mellow gulch
#

ok

slate swan
#

try to print something after it

brazen raft
warm plover
#

Under what circumstance does your bot stop running though

#

Mine just goes till I close my terminal

brazen raft
#

I implement shutdown and restart commands for my bots

#

But it's all really separated into files and stuff, so I guess I don't have one simple file with bot.run() (I really don't)

manic wing
slate swan
unkempt canyonBOT
#

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

Closes the connection to Discord.
brazen raft
slate swan
#

people use it lol

final iron
brazen raft
#

The command really just closes the bot, and the loop automatically restarts it, but also reloading every library it uses and stuff like that.

#

The shutdown command also closes the bot, but it sets its restart flag to False

slate swan
#

code doesnt execute after .run because the event loop needs to be closed right?

brazen raft
#

Code does execute after bot.run(), it simply takes time until the bot stops running. It's like a giant while loop

#

The method is like a giant while loop, so it is blocking, and doesn't let anything else run.

slate swan
#

mhm

brazen raft
#

My restart & shutdown commands also make sure to finish everything the bot has not yet finished to do, close all task loops, close database connections, etc.

mellow gulch
#

what am i doing wrong

supple crescent
#

anyway to make it so when somone does !record it copy and pastes the next thing that they say?

mellow gulch
#

i dont know much

#

but u have to make that command

#

and then have them go through each vc until they find which one that the user is in

#

and then join

#

and then somehow record

#

and then when they say !stoprecord

#

or smth

supple crescent
mellow gulch
#

then it will stop

#

r u using discord api

supple crescent
slate swan
#

dang i started making bots in september 2021 now i know so much its crazy02love

mellow gulch
supple crescent
mellow gulch
#

ye im looking through the api

supple crescent
#

thats no rly what i need

slate swan
mellow gulch
#

this and using ctrl f

slate swan
mellow gulch
supple crescent
#

thats audio tho

mellow gulch
#

like

#

to record it

supple crescent
#

no like this

#

!record

#

i like dogs

#

bot: i like dogs

slate swan
#
@bot.command()
async def echo(ctx: commands.Context, *, echo: str = "bacon") -> None:
    await ctx.send(echo)
supple crescent
#

oh wow

#

thanks!

mellow gulch
#

i cant find anything @supple crescent

slate swan
#

yw

slate swan
slate swan
brazen raft
#

It utilizes annotations

mellow gulch
#

what does it do

slate swan
#

user

!echo echo this sentence 

bot

echo this sentence
mellow gulch
#

ohhhh ok

#

ohhhhhh wait so he was looking for like in chat

#

not in a vc lmao

slate swan
#

yeah he word it a bit weird

carmine quarry
#

Hey, How can I run multiple @tasks.loop s? Because when I start one, it stucks at the first one

mellow gulch
#

@slate swan do u know how this is supposed to work cuz i did smth wrong

slate swan
#

?

mellow gulch
slate swan
#

cant really help on utils ive never used them lolisFine

manic wing
#

dont know what you're trying to do with that

#

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

Examples

Basic usage...
mellow gulch
#

im trying

#

to use the channel name

#

to get the id

#

where i got it from

carmine quarry
manic wing
#

whats the actual problem?

mellow gulch
manic wing
# mellow gulch

so it seems that there is no channel called counting in the the guild?

mellow gulch
#

idk

carmine quarry
# manic wing you dont await a task start

And I have another question, @client.event isnt working while these tasks.loops are running. How can I overcome on that? Or I can create another task loop that contains the event?

mellow gulch
carmine quarry
mellow gulch
#

also what does msg.content.strip() do

manic wing
manic wing
manic wing
carmine quarry
#

its not working lol

manic wing
#

whats not working

carmine quarry
#

But if I dont start the loops it works

carmine quarry
mellow gulch
#

is there a way to take out all of the spaces in the content of a msg

manic wing
kindred epoch
manic wing
green nebula
#

does anyone know how to include a space in your command?

supple crescent
#

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

manic wing
#

chucking in random shit is not a solution

manic wing
#

you would use command groups

green nebula
#

What are command groups?

slate swan
#

can you use the name kwarg in a listener or nah

manic wing
slate swan
#

for a space or

manic wing
#

what

slate swan
#

no right?

manic wing
#

no

mellow gulch
slate swan
#

oof

manic wing
manic wing
mellow gulch
#

wdym

manic wing
mellow gulch
#

yes

slate swan
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.9)").

Example...
slate swan
#

lol

manic wing
#

thats not a command

slate swan
mellow gulch
#

like this but the no_cursing can be whatever u want it doesnt do anything

carmine quarry
slate swan
mellow gulch
manic wing
#

actually nvm

mellow gulch
slate swan
manic wing
#

seen too many weird fonts in the ot

slate swan
carmine quarry
# manic wing w h a t

Can I dm you, because it's a home project and I don't want to share the whole code (what ive already written) publicly

carmine quarry
manic wing
#

good luck

manic wing
#

remove await msg.delete() and try again

#

just an idea

supple crescent
#

pls help, i run the code nothing works, no errors, just nothing works

mellow gulch
slate swan
supple crescent
slate swan
supple crescent
#

too lazy to remove

slate swan
manic wing
supple crescent
#

@bot.event
async def on_message(message):
if message.content.startswith('!greet'):
channel = message.channel
await channel.send('Say hello!')

cold sonnet
#

or

#

await message.channel.send('Say hello!')

#

and you can remove the channel = ... line

supple crescent
slate swan
#

are you actually running your bot?

carmine quarry
#

And this way it works:

supple crescent
slate swan
supple crescent
#

alr

manic wing
#

like print("hi") in the on_message

#

it should trigger pithink

carmine quarry
manic wing
carmine quarry
#

I just became more confused

manic wing
#

ok so it does work ... problem solved, autographs in the form of a github follow
proceeds to slow walk out of the room while bowing

#

your welcome

slate swan
#

all of the pings will go away

manic wing
slate swan
#

even folders have that

manic wing
#

god sake

slate swan
#

or even better if you dont use the guilds

carmine quarry
#

Yea I currently have 5167 notifs On my main discord xd

slate swan
#

jeez mark as read is a thing

#

no pings

rocky trench
#

๐Ÿ˜…

slate swan
rocky trench
#

0 pings ๐Ÿ˜ฎโ€๐Ÿ’จ

slate swan
#

lovely

kindred epoch
#

@rocky trench sike

rocky trench
#

You motherf-

#

I instantly cleared it tho

#

๐Ÿ˜ฎโ€๐Ÿ’จ ๐Ÿ˜ฎโ€๐Ÿ’จ ๐Ÿ˜ฎโ€๐Ÿ’จ

kindred epoch
#

๐Ÿคทโ€โ™‚๏ธ

carmine quarry
# manic wing your welcome

ey yo, so if I can get some other help then related to this, debugged the messages and actually found the problem, do you have any idea on this why the passed message is just an empty string?

slate swan
carmine quarry
slate swan
cold sonnet
#

oh, not even normal messages

#

well I like to read my pings too

slate swan
#

i have a command that says hi to the person that uses the command how do i make it so it @s them aswell

unkempt canyonBOT
slate swan
#

ctx.author returns a Member obj

#

so just use the mention property

velvet tinsel
#

I have like 100+ ๐Ÿ’€

#

it's only been two weeks

edgy crater
#

How would I check user input without comas, full stops and whatnot. So if the answer is, "Hi, how are you", and the user put, "Hi how are you". How would I still count that as correct?

buoyant igloo
#

g = 0
k = 0
async def start(ctx):

global g
global k
g += 1
globals()["user{g}"] = 0
#the problem is that the g variable can change anytime when somebody runs .start, I am think of doing
#k+= g
#But, this means that k can also change when somebody says .start, so how do I stop k from changing?

hushed galleon
edgy crater
hushed galleon
buoyant igloo
hushed galleon
obtuse creek
#

Hi

#

I script code on python

hushed galleon
edgy crater
hushed galleon
buoyant igloo
hushed galleon
obtuse creek
#

I like this

#

nice

hushed galleon
potent spear
obtuse creek
potent spear
obtuse creek
#

ok

slate swan
hushed galleon
#

@buoyant igloo e.g. ```py
running_games = {} # {user id: current score}

async def start(ctx):
# check if they already have a running game
if ctx.author.id in running_games:
return await ctx.send('no more games for you')

running_games[ctx.author.id] = 0```
obtuse creek
#

nice

potent spear
hushed galleon
#

wdym remove the author id and not use 0 as the initial value

potent spear
#

you're literally checking if the author id is in the running games
so you would think that
if author id not found in running games, he doesn't have any games running, right?
well, that would be false, since your author id key will be in there with a value of 0

hushed galleon
#

...i see nothing wrong with how you described its behaviour

buoyant igloo
potent spear
hushed galleon
#

well i wrote the assignment after the check in my example

potent spear
hushed galleon
#

so you're assuming the function doesn't start the game and therefore should allow them to not start another game again?

potent spear
#

I'd just remove the author once he's done with it, that's all I'm saying
storing that someone doesn't have any games is pretty useless imo

hushed galleon
#

oh, then why didnt you just say that at the start

#

that is a true point, i just couldnt tell you meant that from "remove the author id, don't set it to 0"

#

oh yeah @buoyant igloo, what other things do you have outside the command that you need to use the 0 for?

buoyant igloo
potent spear
hushed galleon
#

ive been xy'd

potent spear
buoyant igloo
potent spear
hushed galleon
#

how exactly does your IDE not allow the usage of databases?

final iron
#

Anyone have the gist with the list of API's?

buoyant igloo
buoyant igloo
hushed galleon
#

ah yes, its always replit

buoyant igloo
#

It could just be that Iโ€™m super bad at coding tho

potent spear
final iron
#

Replit allows for use of a database

hushed galleon
#

they have their own key-value store and python package to interface with it, but afaik it doesn't support async/await

buoyant igloo
slate swan
#

just slow dicts/json/mongo

glacial kernel
#

My bot is not assigning the role I want can anyone help?

#

This is my code

#
async def on_reaction_add(interaction):

    message = interaction.message
    button_id = interaction.component.id
    if reaction.emoji == ":white_check_mark:":
        member = message.guild.get_member(interaction.user.id)
        role = message.guild.get_role()  
        await member.add_roles(role)

        response = await interaction.respond(embed=nextcord.Embed(title="Verified"))


@bot.command()
@commands.has_permissions(administrator=True) # you need to import command from discord.ext if you want to use this -> from discord.ext import commands
async def verify(ctx):
    embed = nextcord.Embed(title="Verificaรงรฃo",
    description="Clica para te verificares",
    colour=Color.orange()
    )
    embed.set_author(name="Nome", icon_url="")
    embed.add_field(name="Campo 1", value="Not an inline field!", inline=False)
    embed.add_field(name="Campo 2", value="An inline field!", inline=True)
    embed.add_field(name="Campo 3", value="Look I'm inline with field 2!", inline=True)
    embed.set_footer(text="Footer")
    embed.set_thumbnail(url="")
    
    emoji = ":white_check_mark:"

    message = await ctx.send(embed=embed)
    await message.add_reaction(emoji=emoji)```
hushed galleon
#

looks like you've mixed code used for message components in your on_reaction_add handler which you'll need to rewrite afterwards since on_reaction_add only receives (Reaction, User) as the argument

#

and the decorator should be @bot.event to register it as an event handler

#

and in your use case the preferred handler would be on_raw_reaction_add since on_reaction_add needs the message to be cached, otherwise it won't trigger for reactions on past messages after a bot restart

glacial kernel
#

Can you edit the wrong parts of the code

hushed galleon
#

oh and the emoji comparison has to be done with the corresponding unicode character...

stone moon
#

How do I check for a reaction on a message? Is it possible to get the message the reaction is on too?

hushed galleon
#

are you only checking for the reaction during a command, or is it any time?

#

for the former you could probably use bot.wait_for('reaction_add', check=check), latter would be suitable for the on_reaction_add / on_raw_reaction_add events
the first two would give you the Message object with the Reaction.message attribute, and the raw payload would give you channel_id + message_id which is enough info to fetch the message

frozen patio
#

i made a modmail bot, and this line, await bot.process_commands(message) will not work anymore with my modmail bot, why is that?

hushed galleon
# glacial kernel Can you edit the wrong parts of the code

here's an example of using the event handler py @bot.event async def on_raw_reaction_add(payload): if payload.message_id == 1234 and payload.emoji == '\N{WHITE HEAVY CHECK MARK}': # user has reacted on a specific message with check mark await some_channel.send('beep')

glacial kernel
#

Ok I Will try it

#

and how the bot will assign the role?

hushed galleon
#

you would use bot.get_guild() with the guild_id provided by the payload, get the role with the particular id you want, and then add it as you did before

glacial kernel
#

Ok

#

Thanks bro

slate swan
#

OMG NO WAY

slim ibex
#

YOOOOO

slate swan
#

LETS GO

#

dpy's development is resumed

slim ibex
#

WE BACK BOIS

slate swan
#

LETS GOOO

final iron
final iron
#

NO

kindred epoch
#

omfg

slate swan
wicked atlas
#

lmaio

slate swan
#

WWWWWW

slim ibex
#

LETS GOOOOOO ๐ŸŽ‰

kindred epoch
#

time to migrate again

slate swan
#

YUP

slim ibex
#

(im hyped but im never going to touch bot dev again)

slate swan
kindred epoch
#

F for disnake?

slim ibex
#

wait but some of this shit they show is fire

slate swan
slim ibex
#
@tree.context_menu(guild=discord.Object(id=MY_GUILD_ID))
async def bonk(interaction: discord.Interaction, member: discord.Member):
    await interaction.response.send_message('Bonk', ephemeral=True)

@tree.context_menu(name='Translate with Google', guild=discord.Object(id=MY_GUILD_ID))
async def translate(interaction: discord.Interaction, message: discord.Message):
    if not message.content:
        await interaction.response.send_message('No content!', ephemeral=True)
        return

    text = await google_translate(message.content)  # Exercise for the reader!
    await interaction.response.send_message(text, ephemeral=True)
#

context menus LETS GO

slate swan
#

everyone here is a living W

ember temple
#

rate 1-10

slim ibex
#

facts

vivid marsh
#

How do you fix
TypeError: โ€˜Memberโ€™ object is not subscriptable

final iron
unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | TypeError: 'type' object is not subscriptable
final iron
#

This is actually really good though

#

We don't have to deal with the fucking forks

wicked atlas
#

I think you can use a newline

slim ibex
#

but its good that they continued development, because discord was about to decommission API version 7, and D.py 1.7.3 was on that version. it would make all bots on that version not work anymore

unkempt canyonBOT
final iron
#

Still on 1.7.3

slim ibex
#

About three weeks ago, Discord announced that it would decommission API versions 6 and 7 on May 1st, 2022. While the current beta version, v2.0, is on version 9, the current stable version of discord.py, v1.7.3, is on version 7 of the API. This means that Discord's plan to decommission v6 and 7 will result in all bots on the stable version of discord.py ceasing to work as of May 1st, 2022. This wasn't something I envisioned happening so soon.

final iron
#

Is the update only available on the master version?

slim ibex
#

i don't think theres an update yet

final iron
#

@silk ice Sorry for the ping but you're actually the GOAT

slim ibex
#

WAIT HE HELPED LOL

slim ibex
final iron
silk ice
slate swan
#

pog

silk ice
#

go thank danny

slim ibex
slate swan
#

@bitter perch thank you for helping dpy blobsalute

slim ibex
#

they have been committing to the repo for a while

final iron
#

!d discord.Role.created_at

unkempt canyonBOT
slate swan
#

how did we not see the commits?

final iron
#

๐Ÿคทโ€โ™‚๏ธ

slate swan
#

they started about 17days ago

bitter perch
#

development was not done on the public repo.

silk ice
#

there was a private fork

slim ibex
#
  • bot parameter to :meth:Client.login and :meth:Client.start
  • afk parameter to :meth:Client.change_presence
  • password, new_password, email, and house parameters to :meth:ClientUser.edit
  • CallMessage model
  • GroupCall model
  • Profile model
  • Relationship model
  • RelationshipType enumeration
  • HypeSquadHouse enumeration
  • PremiumType enumeration
  • UserContentFilter enumeration
  • FriendFlags enumeration
  • Theme enumeration
  • on_relationship_add event
  • on_relationship_remove event
  • on_relationship_update event
  • Client.fetch_user_profile method
  • ClientUser.create_group method
  • ClientUser.edit_settings method
  • ClientUser.get_relationship method
  • GroupChannel.add_recipients method
  • GroupChannel.remove_recipients method
  • GroupChannel.edit method
  • Guild.ack method
  • Message.ack method
  • User.block method
  • User.is_blocked method
  • User.is_friend method
  • User.profile method
  • User.remove_friend method
  • User.send_friend_request method
  • User.unblock method
  • ClientUser.blocked attribute
  • ClientUser.email attribute
  • ClientUser.friends attribute
  • ClientUser.premium attribute
  • ClientUser.premium_type attribute
  • ClientUser.relationships attribute
  • Message.call attribute
  • User.mutual_friends attribute
  • User.relationship attribute

all this shit got removed

kindred epoch
#

what is that

slate swan
tame nymph
#

yoo back

slate swan
silk ice
#

yeah

slate swan
#

nice when did it all started if i may ask?

final iron
#

!d discord.ClientUser.edit

unkempt canyonBOT
#

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

Edits the current profile of the client.

Note

To upload an avatar, a [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.9)") must be passed in that represents the image being uploaded. If this is done through a file then the file must be opened via `open('some_filename', 'rb')` and the [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.9)") is given through the use of `fp.read()`.

The only image formats supported for uploading is JPEG and PNG.

Changed in version 2.0: The edit is no longer in-place, instead the newly edited client user is returned.
final iron
#

Have the new changes not been pushed?

#

As a result, these parameters can no longer be None:

  • size, format, and static_format in :meth:Asset.replace
  • check in :meth:TextChannel.purge
  • icon and code in :meth:Client.create_guild
  • roles in :meth:Emoji.edit
  • topic, position and overwrites in :meth:Guild.create_text_channel
  • position and overwrites in :meth:Guild.create_voice_channel
  • topic, position and overwrites in :meth:Guild.create_stage_channel
  • position and overwrites in :meth:Guild.create_category
  • roles in :meth:Guild.prune_members
  • roles in :meth:Guild.estimate_pruned_members
  • description in :meth:Guild.create_template
  • roles in :meth:Guild.create_custom_emoji
  • before, after, oldest_first, user, and action in :meth:Guild.audit_logs
  • enable_emoticons in :meth:StreamIntegration.edit
  • mute, deafen, suppress, and roles in :meth:Member.edit
  • position in :meth:Role.edit
  • icon in :meth:Template.create_guild
  • permissions, guild, redirect_uri, scopes in :meth:utils.oauth_url
  • content, username, avatar_url, tts, file, files, embed, embeds, and allowed_mentions in :meth:Webhook.send
#

What

tame nymph
final iron
#

Am I reading this wrong?

slim ibex
#

doesn't seem like migration guide is up on website yet

tame nymph
#

I dont think Im going back to discord dev at any point

slim ibex
#

same

#

i found typescript and i love it

final iron
#

Because IMO that's dumb

wanton cipher
#

damb, I just learned how to somewhat use disnake and discord.py returns, so happy to have the og back, but... back to the docs and rewriting xD

final iron
slim ibex
#

well dpy is now better than disnake

final iron
#

Now you have to pass in roles and shit

#

Isn't that really annoying?

slate swan
#

thats nice that dpy is back but im still not coming back to developmentrooSnap

hushed galleon
slim ibex
#

i might mess with it for a bit but not long term

slate swan
final iron
#

Because you get to bully me

slate swan
#

binds you should join uscatgun

slim ibex
#

I'm on to making cursed generics and insane functions with TypeScript

slate swan
sick birch
#

well looks like d.py is back

slim ibex
#

yessir

sick birch
#

i think there should be an annoucement pinned like there was when it shut down

sick birch
#

maybe one of us can make one and get the mods to pin it

final iron
#

Because if you want to mute a member you have to go through all the trouble of passing in the roles and shit

slate swan
sick birch
#

I think im gonna go contribute more examples

wanton cipher
#

I just wanna say, thank you to all involved in the growth and dev of discord.py, and so happy to have it back :D

slate swan
final iron
#

๐Ÿ˜”

final iron
#

THE PYTHON BOT JUST MIGRATED TO DISNAKE LESS THAN AN HOUR AGO

#

LMAO

wanton cipher
#

The people who help are gonna be so pleased xD

slate swan
wanton cipher
#

also, ngl, I sort of had the feeling discord.py would return, just not this soon :D

sick birch
#

only time will tell

slate swan
#

lets see what happenshehe

slim ibex
sick birch
#

lmao

final iron
#

That's a real kick in the balls

slim ibex
#

discord.py is back, with many new features! Read the gist from Danny for more information about why and the future:
https://gist.github.com/Rapptz/c4324f17a80c94776832430007ad40e6

New features include:

  • Autocomplete
  • Slash Commands: app_commands.CommandTree
  • Improved Interactions
  • Context Menus: app_commands.CommandTree
  • Range with app_commands.Range[] annotation
  • Command Syncing
  • Choices with Enum, typing.Literal, or a new app_commands.choices decorator.
  • Groups and Nested Groups
  • Modals with discord.ui.TextInput and discord.ui.Modal
  • Member timeouts
  • Role icons
  • Alt-text for attachments
Gist

GitHub Gist: instantly share code, notes, and snippets.

slate swan
#

great

slim ibex
#

leaving this here for mods to pin

final iron
#

You're real thirsty to get pinned

slate swan
slim ibex
#

nah

final iron
#

I'm going to stick with disnake for now

#

Actually what am I talking about

#

I don't develop bots anymore ๐Ÿคฃ

slim ibex
#

probably better for now. v2.0 might not be stable right away. but, it will probably be usable

#

same