#discord-bots
1 messages ยท Page 883 of 1
the event got triggered after 25th message
oopsie
Ok
lol
how can I send the bot's message now
In the if

await message.send('ok')?
Thx it worked
Messages hold a reference to the channel they were sent in, so you can send a message to the channel the message was sent
@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)```
oh
await message.channel.send("ok")
!d discord.Message.send
No documentation found for the requested symbol.
lol
lol
!d discord.abc.Messageable.send
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**.
ah
just showing that the Message class doesnt have such and attr
i didnt read the context of the discussion uh
method*
meth
same thing
MEH
if you set it it raises an attr error ok
time to change python
Okay
.event -> .listen()
okay
bro what?
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```
whatn't
You need await bot.process_commands(message) at the end of the event
how is the event deco better than listen?
...
youre so thick
I was looking this up. I am so slow
that's an arrow, not a smaller than sign
oh he ment change it
no u
๐คฆ
greater than
no?
> is greater he ment change it
meant*
wanna be my english teacher?
sure

talking about this?
ill give you a D ๐
yeah
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
gave*
thank you
np
i have a good teacher
iโm flattered โค๏ธ

the revolt api is so dead rn
What is this shit
grs
theres literally nothing in the revolt api
Everywhere that @slate swan is eventually turns into an edating zone
True story
Uwu zone
ashleys a dude
yes the UWU zone
werent you simping for ash the other day
im gay
ok
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
well, have any of you tried guilded.py?
what is guilded.py
*have any of you
*What | guilded.py?
social app like discord
become my english teacher
Guilded is a social app like Discord, yes
Missing a capital and punctuation
wheres your punctuation
punctuation is irrelevant
https://github.com/pawel02/image_bot/blob/main/music_cog.py
i have this problem with this code can someone help me?
wheres your punctuation
Where are your capitals and punctuation?
!ytdl
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)
this one
|| i literally just said punctuation is irrelevant ||
Where is your capital?
๐ฟ
Whither has thy capitalization and punctuation gone?
IDK old English.
anyone knows about it? ^
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
๐ฟ
whats guilded
damn so much competition
i need to make hundreds of accounts in all of them to be an og
All you care is being og until your account credentials get leaked and youre using just one password for everything.
How can thou say "whither" is old English?
realistically noone uses the same password for everything
[ sweats ]
Me rn: 
i use a different password for every single website and im definitely not just saying this so you dont hack me

Someone who know how to send the traceback to a channel?
how do i fix this?
!d discord.discord.ext.commands.on_command_error
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")).
wut
Indent await msg.add_reaction or sumthing
help?
this is the first time i've gotten an "outside function" error
.
indentation
what you mean
It means await was used outside an asynchronous function.
!d discord.on_command_error @pastel olive and use bot commands next time
No documentation found for the requested symbol.
No documentation found for the requested symbol.
!d discord.discord.ext.commands.on_command_error
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")).
wait ew

Why "discord" twice
!indent
indentation in the quote command
What is that indentation
!indent welp
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
thought you knew basic python?
Why can't people just learn basic python ๐
its the new meta ๐
Making Discord bots was the reason I started learning Python, I don't blame them.
im trying to make then not make the mistakes i did ๐คทโโ๏ธ
cuz discord bots cool
i mean that it goes back to giving an outside function error after i indent it again
I, too, was an eleven year old, hyped about making making Discord bots in Python from bad, old YouTube tutorials.
error says it all?
i started because of my career lol
indent it properly
you have a job?
when i indent it, it just goes back to that position
Python is a textual programming language that depends on the indentation of statements.
keep the if inside the event
and indent the next two lines properly inside the if statement
ok i just realized the problem
i indented the if statement as the ones above

you saw nothing
i saw everything
how do i define disnake
smexy
๐ณ
import disnake as disnake
yay
tf?
ayo

๐
this man really tried it
very comedic
i have severe brain damage

noice
How much can I take, my mind will break
i haven't indented disnake yet

*imported
i should stop with lyrics nvm


skill issue
!d pip
wait what's disnake?
you install it with pip and import it with the import statement
๐ use vs code, install tabnine, restart vscode, type disnake wait for the auto-import intellisense suggestion, press enter, boom it imports disnake for you
!pypi disnake
I wanted answer from them
am i not smart enough
@spice basalt
It has the same brief description as discord.py
nvm wrong ping
can i do this without disnake?
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

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)
hey akeno
btc_price = str(v.get_price())
print(btc_price)
use f strings
why are you making a string a string?
akeno
can you tell me a thing
self.price = self what do you expect
i am going to sleep if i can't
no
majik
then answer me first, I'll answer you
yes you can without disnake
how
I'm looking for the one who recommended you disnake
some raven edgelord
i would low-key recommend the same
then what would you high-key recommend
wrong channel

raw requests
yes
making the request to the endpoints is just high-key better
That will allow you to host the bot on PythonAnywhere, where all ports other than internet ports are blocked (no websockets)
so do you know the difference between discord.py and disnake?
namespace
i know they're different and nothing else
discord.py is unmaintained

It is going to be deprecated
sadge
i'm going to sleep
what's ur timezone
whats pythonanywhere though?
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.
UTC+9
A free Python hosting platform with great uptime.
use your hands-
Sorry, I'm not used to python
when I create the class in a different file it resets the variable
ohsh osh osh
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
I get the price from one file, set it in the variables file, call the variables file in the main
thats why you learn OOP-
self.price is a variable set to an instance of the class ofc it will reset ?
Well, that's why I am asking for help
hmph I see i see, may consider that later, thanks
listen I'm just asking what is the solution lol
your problem isnt even related to this channel
Im making a discord bot?
For questions and discussions relating to Discord bot development with discord.py and other relevant Python libraries.
with discord.py and other relevant Python libraries.
Read the channel description
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.
It is for issues regarding discord.py
Not random class issues
you guys are so fucking entitled lmao
why isn't it reacting to my message?
!ot
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
bro what?
basic classes isnt related to the channel?
what happened lol
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
scroll up my bro
the
emote
get the emoji
Anyone else unable to copy the token from developer portal?
lol
!d discord.ext.commands.Bot.get_emoji
get_emoji(id, /)```
Returns an emoji with the given ID.
regenerate it and then it will give you a copy button
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`...
wait
that should work
why does disnake mention that format in their guide then, okimii
oh i thought you needed to fetch the emoji or sm
I think you can put the ID of the emoji
Instead of, like, the string of the emoji
Not sure
you cant, I dont think so
ashley said you can't
Tias, otherwise, fetch the emoji.
iirc you cant
use utils.get otherwise
It might not be an emoji in the server
yeah depends
@spice basalt is the bot in the server where the emoji is from?
ok i did that, it didn't work
but
yes
I would suggest fetching the emoji
discord.utils.get(bot.emojis, name="uwu")
``` works too
just get the emoji lmao
wow
I mean, discord.utils.get(message.guild.emojis, name="BroKiss~1") is also an option

you sure?
yes
Why is it BroKiss~1 in the screenshot
In this screenshot
because the server i put above my server has an emoji with the same name
or if there are same emoji names for two different emojis in the same server
This confuses me
discord (:
Sociopathic left smiler
(:)

that just looks like a woman's
Omnibrow


how do i make it trigger when someone says "don't care"?
the ' is messing with stuff
anyone there?
like this?
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:
Use the other kind of quotes
ah so
don.split(' ' ')t?
And swap the strings
""?
Yeah
@slate swan :white_check_mark: Your eval job has completed with return code 0.
True
What the hell bro
ah
Iโm trying to make a premium system with a file. json, can anyone help me?
Canโt you just use replace?
Exactly
wait how should i put it in my case
I thought they meant to do
if "don't care" in message.content:
await message.channel.send("didn't ask")
yes
!d str.replace || python bot has docs on it
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.
I know, Iโm just telling the bot to clarify it
if "dont care" in message.content.replace("'", "").lower():
await message.channel.send("I have not asked!")
ah
Might as well throw in some whitespace stripping

but what about the i have not asked part?
What about it?
Code would be flawed kinda if they said "didnโt askโ
i want the bot to reply "didn't ask"
Oh it doesnโt show
Imagine going as far as to using regular expression matching
Actually, you could have...
if "dont care" in ' '.join(message.content.replace("'", "").lower().strip().split()):
await message.channel.send("I have never asked!")
Damn I was gonna suggest .split() but I was overthinking it
i want it to say "didn't ask" instead of "i have not asked"
Then change it to be didn't ask
change the string?
Then just delete the โI have not askedโ and replace it with โdidnโt askโ 
I wanted to be unique
Itโs not that hard
Discouraging comment
fuck i thought i have to add replace again
my brain isn't functioning properly

It seems to be a thing going on as of this hour.
All of the bugs are eating into our brains
it's 3 in the morning
10:45 PM here
4pm
But I feel like trash as well
check the author
i did
The event should have
if message.author == bot:
return
at the top of it
the spoonfeed
yes
i already added that when i started
assert not message.author.bot 
Is it late there?
you should go to sleep if itโs late there
That may raise AssertionErrors
3 a.m. and i have to wake up at 6
but if it is the bot it will raise an AssertionError

Then go to sleep
i think i'll just pull an all nighter
Your brain will work better after a good nights sleep
and do my missing assignments
Ask @manic wing ๐ณ
You won't be able to pull yourself the entire day, though
yeah
actually i'm just gonna sleep
whats sleep
Have a goodnight
Gn

This button above Shutdown
whats shutdown
The button that you press after the windows icon
i leave my pc on all day
catch AssertationError in the error handler
and ignore it
Or don't use assert
then youll need an error handler
who doesnt have an error handler
1 line > 2 lines
you people havent evolved to use assert yet
There are two kinds of programmers: Those who like erroneous programming and those who like branching programming
plus the error handler?
yeah but the 2 lines scales whereas the 3 doesnt
The error handler is more than one line
bro
hm?
you need to be joking
assert doesnt scale but the return does
Exceptions aren't meant to be raised, they are meant to be caught.
assert can return an error tho
Unless youโre raising a custom error
they are caught...in the error handler ๐ณ
your just saying yeah use assert so the bot raises an exception while an if statement wont
You do you
3 lines > 2 * 2^n - 2 lines
doubt
that looks bad and requires a :
skill issue
assert looks sexy (its purple)
if message.author == bot.user: return
Right
no
Why not
why not
caedens point is use assert because it looks cool
and because it doesnt scale
never seen it

you dont know whats assert?
no
no one wants their bot to raise an Assertion error
!d assert
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
```...
oh
if message.author.bot: return
?
as i said, catch the AssertationError
but youll need a error handler bro
yes
everyone has an error handler
how can you speak for everyone bro
If only that contract PEP was accepted
because im a seer
!pep 316
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.
Yes

bit of an L
Cope
why even have a website for your bot
cough caeden
i made one on google sites at one point
mhm
?
oh nothing
Jesterbot 
havent seen jesterbot with clout
seems like a skill issue
i used squarespace
costed 200$ to make it public

got paid 600$
never really bothered promoting it
From?
my dad's co worker
Luck 300
How do u get a user id out of an async function
wrong chnanelk
wut
quick question . does this py commands.when_mentioned_or("b","B") works like py ["b","B"]
What's the goto discord library that supports slash commands and buttons?
disnake?
Ill take a look into it, ty
yes, since when_mentioned_or(*prefixes)
anytime
alr tnx 
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?
!d discord.on_member_join
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.
and idk any commands that seem cool to you lol its your bot
okay thank you!
youre welcome
๐ฟ
?
Grammar ๐ฟ
cope
cry about it lol
does the bot.run have to be at the end of all of the code
code after .run will not be executed
ok
try to print something after it
Correction: Any code after bot.run() will only be executed after the bot stops running.
yeah
Under what circumstance does your bot stop running though
Mine just goes till I close my terminal
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)
what does your restart command look like
!d discord.ext.commands.Bot.close
await close()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Closes the connection to Discord.
It looks like a while loop that reloads the module of the bot and starts it unless its restart flag was False.
people use it lol
bot.run() is blocking. The code will run but the bot has to stop being run
yes
Well, not the command.
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
code doesnt execute after .run because the event loop needs to be closed right?
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.
mhm
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.
anyway to make it so when somone does !record it copy and pastes the next thing that they say?
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
thats the part i need help with
yup
dang i started making bots in september 2021 now i know so much its crazy
for me?
ye im looking through the api
thats no rly what i need
you mean the wrappers docs?
yeah the dpy docs ?
thats audio tho
use a kwarg lol
@bot.command()
async def echo(ctx: commands.Context, *, echo: str = "bacon") -> None:
await ctx.send(echo)
i cant find anything @supple crescent
yw
how does echo work
wdym?
this stuff
it takes a kwarg so all the text after the context of the command will be sent
It utilizes annotations
what does it do
user
!echo echo this sentence
bot
echo this sentence
yeah he word it a bit weird
Hey, How can I run multiple @tasks.loop s? Because when I start one, it stucks at the first one
@slate swan do u know how this is supposed to work cuz i did smth wrong
?
you dont await a task start
cant really help on utils ive never used them lol
remove guild__name=
dont know what you're trying to do with that
!d discord.utils.get
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...
fck, I'm dumb, thanks
so it seems that there is no channel called counting in the the guild?
idk
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?
maybe i did the msg.guild.name wrong
which client.event isnt working?
on_message
also what does msg.content.strip() do
msg.guild.name should be fine
removes whitespace before and after a string
should work fine
its not working lol
whats not working
But if I dont start the loops it works
the on_message client.event
is there a way to take out all of the spaces in the content of a msg
that shouldnt happen. can you be more specific?
try changing client.event to client.listen()
what makes you think that will do anything
does anyone know how to include a space in your command?
!paste
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.
chucking in random shit is not a solution
you cant
oh ok
you would use command groups
can you use the name kwarg in a listener or nah
you can
for a space or
what
no
plz help
oof
thanks not the listener kwarg, thats the command decorator kwarg
ratelimits:
wdym
is there a channel called counting?
yes
!d discord.ext.commands.Bot.listen
@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...
lol
thats not a command
yeah my fault
like this but the no_cursing can be whatever u want it doesnt do anything
Okay so I was wrong, it's not not working because of the .start(), the on_message @client.event is not working if there are also @tasks.loop s
yeah as it listens to the current event given
yes
w h a t
channels cant be uppercase
yeah, realised
seen too many weird fonts in the ot
relatable
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
i dont do dm work, sorry
Ok so I'll try to eb starightforward using paint ๐
good luck
actually
remove await msg.delete() and try again
just an idea
no i do that at the beggining of all my commands and everything has always worked
screaming to get ratelimited
wdym by nothing works
for example i do !help, nothing, no error, bot just sits there
why do you have a random subclass lol
experimenting
too lazy to remove

do you have an on_message event by any chance
@bot.event
async def on_message(message):
if message.content.startswith('!greet'):
channel = message.channel
await channel.send('Say hello!')
or
await message.channel.send('Say hello!')
and you can remove the channel = ... line
idk why i still have that, i never use it
are you actually running your bot?
you deadass think i wouldnt check that
theirs always that chance gotta be sure
remove it
alr
where teacher
rq can you just elaborate on what not working means?
like print("hi") in the on_message
it should trigger 
It does nothing on_message
just try printing
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
you know if you left click a guild and press
all of the pings will go away
true that
god sake
or even better if you dont use the guilds
Yea I currently have 5167 notifs On my main discord xd
ikr my ocd
lovely
@rocky trench sike
๐คทโโ๏ธ
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?
are we really flexing that we lonely
But as I said, if there are no tasks.loop s it actually works
cuz of no pings?
yeah

i have a command that says hi to the person that uses the command how do i make it so it @s them aswell
!d discord.Member.mention
property mention: str```
Returns a string that allows you to mention the member.
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?
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?
thats more of a general python question but if you purely want to ignore punctuation then you could replace all the unwanted characters before doing the comparison, either with str.replace() or more suitably str.maketrans() + str.translate(), or to handle more general typos you could use a fuzzy string matching library like rapidfuzz
It's for a discord bot I'm making, it basically has the lyrics of a song stored in a array, let's say song = ["1", "2", "3"]. The question would be song[i] and the answer would be song[i+1]
this looks like you're trying to emulate a dictionary, so you should use that data structure to manage different user sessions
Yes but, I wanna
name the usersโ dictionaries, according to to the number they are assigned to. Which I would need to stop k from changing to do
are you sure you want it to be enumerated instead of using a more unique identifier like their user id or a combination of (guild_id, user_id)?
How would I use the user.id indentifer
well you've effectively described your problem in a way that isolates it from how your bot works, so if you don't have any trouble with the dpy part then you can ask it like a regular question
Sry I just joined this server, where would I ask the question?
you can get the numbers from ctx.author / ctx.guild and then use them as the key for your dict
So like
ctx.author.id = {โitemโ: 0}
try asking your question in one of the available help channels (details in #โ๏ฝhow-to-get-help)
no the dict would be used to store each "variable"
it has a typo in line 12
For IDE?
correct
ok
should have a new line for each question on input
@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```
nice
remove the author id, don't set it to 0 lol
Ok thx
wdym remove the author id and not use 0 as the initial value
useless storage
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
...i see nothing wrong with how you described its behaviour
Itโs fine it helped me a lot
running_games[ctx.author.id] = 0
if ctx.author.id in running_games:
return await ctx.send('no more games for you')
# problem: author will be notified, even though he doesn't have any running games```
well i wrote the assignment after the check in my example
will result in the same issue though lol
I just put it on top to clarify
so you're assuming the function doesn't start the game and therefore should allow them to not start another game again?
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
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?
Iโm just making a RPG bot with my friend and I wanna store the items for each person. But it works now thx.
well, a DB should be your best bet, NOT a stinky json
ive been xy'd
some people just aren't asking for "the best method"
some as in 99% of the beginners
ye I tried a db, but the problem is that it doesnโt work for the IDE Iโm using and I canโt use a better one cuz I code on mobile
mobile coding? damn
your IDE shouldn't be an issue when coding tho, notepad could literally be an IDE
how exactly does your IDE not allow the usage of databases?
Anyone have the gist with the list of API's?
When it stops running it doesnโt save the data
Itโs called REPLIT
ah yes, its always replit
It could just be that Iโm super bad at coding tho
yikes
Replit allows for use of a database
they have their own key-value store and python package to interface with it, but afaik it doesn't support async/await
ye
from replit import db
just slow dicts/json/mongo
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)```
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
Can you edit the wrong parts of the code
oh and the emoji comparison has to be done with the corresponding unicode character...
How do I check for a reaction on a message? Is it possible to get the message the reaction is on too?
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
i made a modmail bot, and this line, await bot.process_commands(message) will not work anymore with my modmail bot, why is that?
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')
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
YOOOOO
WE BACK BOIS
https://gist.github.com/Rapptz/c4324f17a80c94776832430007ad40e6
WE'RE BACK IN BUISNESS
NO
omfg

lmaio
WWWWWW
LETS GOOOOOO ๐
time to migrate again
YUP
(im hyped but im never going to touch bot dev again)
SAME HERE
F for disnake?
wait but some of this shit they show is fire

@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
rate 1-10
facts
How do you fix
TypeError: โMemberโ object is not subscriptable
Welp time to migrate back to discord.py
!e
print(str[0])
@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
I think you can use a newline
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
So is there a new discord.py version?
!pypi discord.py
Still on 1.7.3
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.
Is the update only available on the master version?
i don't think theres an update yet
@silk ice Sorry for the ping but you're actually the GOAT
WAIT HE HELPED LOL
You helped with the resurrection of discord.py
nah dude i didnt do that much
pog
go thank danny
cap. you still helped
@bitter perch thank you for helping dpy 
they have been committing to the repo for a while
!d discord.Role.created_at
property created_at: datetime.datetime```
Returns the roleโs creation time in UTC.
how did we not see the commits?
๐คทโโ๏ธ
they started about 17days ago
development was not done on the public repo.
there was a private fork
botparameter to :meth:Client.loginand :meth:Client.startafkparameter to :meth:Client.change_presencepassword,new_password,email, andhouseparameters to :meth:ClientUser.editCallMessagemodelGroupCallmodelProfilemodelRelationshipmodelRelationshipTypeenumerationHypeSquadHouseenumerationPremiumTypeenumerationUserContentFilterenumerationFriendFlagsenumerationThemeenumerationon_relationship_addeventon_relationship_removeeventon_relationship_updateeventClient.fetch_user_profilemethodClientUser.create_groupmethodClientUser.edit_settingsmethodClientUser.get_relationshipmethodGroupChannel.add_recipientsmethodGroupChannel.remove_recipientsmethodGroupChannel.editmethodGuild.ackmethodMessage.ackmethodUser.blockmethodUser.is_blockedmethodUser.is_friendmethodUser.profilemethodUser.remove_friendmethodUser.send_friend_requestmethodUser.unblockmethodClientUser.blockedattributeClientUser.emailattributeClientUser.friendsattributeClientUser.premiumattributeClientUser.premium_typeattributeClientUser.relationshipsattributeMessage.callattributeUser.mutual_friendsattributeUser.relationshipattribute
all this shit got removed
what is that
ic clever
yoo back
ah so you guys pushed everything from the private repo to main?
yeah
nice when did it all started if i may ask?
!d discord.ClientUser.edit
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.
Basically no more self bots
Have the new changes not been pushed?
As a result, these parameters can no longer be None:
size,format, andstatic_formatin :meth:Asset.replacecheckin :meth:TextChannel.purgeiconandcodein :meth:Client.create_guildrolesin :meth:Emoji.edittopic,positionandoverwritesin :meth:Guild.create_text_channelpositionandoverwritesin :meth:Guild.create_voice_channeltopic,positionandoverwritesin :meth:Guild.create_stage_channelpositionandoverwritesin :meth:Guild.create_categoryrolesin :meth:Guild.prune_membersrolesin :meth:Guild.estimate_pruned_membersdescriptionin :meth:Guild.create_templaterolesin :meth:Guild.create_custom_emojibefore,after,oldest_first,user, andactionin :meth:Guild.audit_logsenable_emoticonsin :meth:StreamIntegration.editmute,deafen,suppress, androlesin :meth:Member.editpositionin :meth:Role.editiconin :meth:Template.create_guildpermissions,guild,redirect_uri,scopesin :meth:utils.oauth_urlcontent,username,avatar_url,tts,file,files,embed,embeds, andallowed_mentionsin :meth:Webhook.send
What

Am I reading this wrong?
doesn't seem like migration guide is up on website yet
I dont think Im going back to discord dev at any point
Am I reading this wrong or do these kwargs not default to None anymore
Because IMO that's dumb
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
Let's say you just wanted to mute a member
well dpy is now better than disnake
thats nice that dpy is back but im still not coming back to development
this was the same thing i was doing too, :blobpain:
same
i might mess with it for a bit but not long term
Same
wrapping apis with @final iron is just too much fun 
Because you get to bully me
binds you should join us
I'm on to making cursed generics and insane functions with TypeScript

yessir
i think there should be an annoucement pinned like there was when it shut down
Isn't this dumb though?
i said that too
maybe one of us can make one and get the mods to pin it
Because if you want to mute a member you have to go through all the trouble of passing in the roles and shit
#community-meta has someone said it here?
I think im gonna go contribute more examples
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
oof xD
The people who help are gonna be so pleased xD
all bot devs be like
๐
also, ngl, I sort of had the feeling discord.py would return, just not this soon :D
only time will tell
lets see what happens
NO FUCKING WAY LOL
lmao
That's a real kick in the balls
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 newapp_commands.choicesdecorator. - Groups and Nested Groups
- Modals with
discord.ui.TextInputanddiscord.ui.Modal - Member timeouts
- Role icons
- Alt-text for attachments
great
leaving this here for mods to pin
You're real thirsty to get pinned

nah
Thank God, no pycord now






