#discord-bots
1 messages Β· Page 919 of 1
disnake and its a bot subclass
:/
msg = message.content.split()
checking = msg.count(element)
if checking > 5:
await message.send("Please Don't Repeat Same Words")
:/
stop spoonfeeding, they can do it themselves
:/
??
Hello
hi
What about walls of text?
Like
Hi
Hey
Wassup
Sup
Woah
This
Sucks
wa
hi i wanna ask something!
@drowsy thunder
he asked for an example π
No,a brief example
@sinful ridge LoL
anyone?
@sinful ridge english only
yes
:/
error 404
ig that you can check that
if message.content == "\n":
pass
ig not sure
How to check that
like i've created a music bot but when i use it and play a song it's ping rise up like hell, can anyone tell how to fix that?
@sinful ridge dm
which lib u use
you can count that too
checking = msg.count("\n")
if checking > 5:
pass
And i suggest you should try
We don't allow the coding of music bots here.
Can I use this with @client.event ?
If the event passes a message object yes.
π
fine
So it should be like this?
@client.event
async def on_message(msg):
#the code continues...
:/
use
@client.listen()
async def on_message(msg):
Ok
not u
oh
Where should I host my bots 
Except heroku,replit and buying my own server
@slate swan hru
can you tell me how to fix that?
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
sorry no idea
oh ok
.
lol there are the only options i think
explain me ur problem
Ohk
There are no other sites to host?
i have asked but all say no.
Ok
@slate swan how to make a bot??
u know python
Yes
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
π Mrinal do be back after a long time
Ohk
yes :)
any problem?
i was just looking for a way to play music in discord.py
Against ToS
...
How to fix
@slate swan block kyu kiya π€
my wish
@spring stone talk in #python-discussion
remove the .
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
:/
Where
Ok
after delete_after
That automatically comes
np remove it
is that a . ? -_-
I cant
hi everyone
hi
This channel is full of idiots
yes
For no reason
please only use english here. don't post random insulting gifs, or gifs in general
step away if you don't want to engage
yes like @slate swan
Yeah
Ohk
that is not . don't worry, it is just showing where the error is occuring
He isnt
he is :/
!mute 854600120247124000 that's uncalled for. read our #rules and #code-of-conduct
:incoming_envelope: :ok_hand: applied mute to @sinful ridge until <t:1647791722:f> (59 minutes and 59 seconds).
Yeah but whats the care here
nice
It's error at the last
How is your bot btw?
yes
Thanks there!
English only
Yeah,whats the error and how to fix
he is asking "Sparky, why did u block me" lmaoooo
Not sure but try putting :
I am also new so can't say
Let me try,I dont think if it will work but sure,trying wont do any danger
U guyz know how to code a bot?
don't think so...
Ya that's how u learn 
Theres an invisible character in your code
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
@slate swan
no
I said i am new and u can try 
ha...
Didnt work
??
Ok 
Its our daily job
Nextcord
the semicolon without opening a statement didn't work
what is advantages with that library
@slate swan you even know python
\
Nah,nextcord is better
how do you know it's the best?
please stop Ryan
i give up u tell
What
begginer best
i learnt it and i am doing projects to improve my python
discord.py is the official library with always the easiest and most creative ways of doing its own stuff
thats what i mean to say
discord.py isn't an official library?
But the forks do some more stuff,forks are for advanced
Nope,it is a official
huh????
Says who
forks only got in the way when discord.py was no developed anymore
What
soon it will also catch up
which one is the official then
discord
Show me
Yep
There is none
I will
danny stated talking with discord a lot
most used is discord.py then?
Itβs not the official one but yes itβs the most used for python
There is a difference between most used and official
yes
let's stay at the word "original" python wrapper
So what you're saying is it's not the official library
\
i dont know about that
@final iron
lol
See that verified icon?
What does this show?
See it,if not then I would suggest an eye checkup
..
Discord verifies api wrappers sometimes
.
Oh
well, one of the requirements is to get verified is the subject has to be official
and it doesn't mean it's official
A verified icon doesn't show it's the official wrapper
same as here
Any server can get verified if they meet the criteria
Just to suffer

you can't get a fortnite server verified if you don't ask epic games to make your server official
same with dpy
Lol
Not sure
not sure
Some of you guys clearly donβt know what it means to be a verified server
I am
can't get my server verified
pain π¦
Guys nobody helped me here
Just because the dpy server is verified doesn't mean it's the official library
ikr
You have invisible characters inside your code
how you learnt discord.py
Like
The server is verified because it is the official server of discord.py not because discord.py is the official library
Like a normal person would
check if there's anything after that bracket
whitespace
Nothing there
from where you learnt discord.py
Youtube ig
Search for Glowstik
that's profoundly unhelpful
Sorry
all youtube tutorials are outdated
YouTube tutorials a not very good and very outdated
Try removing all of the whitespace where the error got raised
and incredibly misleading
^
for me, i was watching yt tuto and reading docs
i want the way he tried
You mean the s?
yes
Ask him
There is none!
Ohk
ok, then try removing or rewriting the line again π€·ββοΈ
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
Ok sure
Ryan, your error is overall not dpy related, but we're sure something has to be there π’
β
What,its in nextcord
my carpenter can't fix my toaster even tho it's in my house and he works with houses
@boreal ravine I cut and pasted the line,it doesnt work,may i dm you the replit url?
don't paste it
π’
don't paste it
rewrite the line
Rewrite?
try writing again
yes
now repl
don't use replit for discord bots 
kayle save me
best advice
i am using vsc now
its pog
Replit
While this may seem like a nice and free service, it has a lot more caveats than you might think, such as:
-
The machines are super underpowered.
-
- This means your bot will lag a lot as it gets bigger.
-
You need to run a webserver alongside your bot to prevent it from being shut off.
-
- This isn't a trivial task, and eats more of the machines power.
-
Repl.it uses an ephemeral file system.
-
- This means any file you saved via your bot will be overwritten when you next launch.
-
They use a shared IP for everything running on the service.
This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.
Heroku -
Bots are not what the platform is designed for. Heroku is designed to provide web servers (like Django, Flask, etc). This is why they give you a domain name and open a port on their local emulator.
-
Heroku's environment is heavily containerized, making it significantly underpowered for a standard use case.
-
Heroku's environment is volatile. In order to handle the insane amount of users trying to use it for their own applications, Heroku will dispose your environment every time your application dies unless you pay.
-
Heroku has minimal system dependency control. If any of your Python requirements need C bindings (such as PyNaCl binding to libsodium, or lxml binding to libxml), they are unlikely to function properly, if at all, in a native environment. As such, you often need to resort to adding third-party buildpacks to facilitate otherwise normal CPython extension functionality. (This is the reason why voice doesn't work natively on heroku.)
-
Heroku only offers a limited amount of time on their free programme for your applications. If you exceed this limit, which you probably will, they'll shut down your application until your free credit resets.
hey help pls
see
how to host my bot online forever free without replit, uptimerobot
use a vps or a raspberry pi
you won't get a free and reliable host
nothing's free in life, darling
Use a free hosting website
^
ong
if anything is free ur the product , legendary quote by someone
ye no cap bruh
I'm gonna go think about that in the corner
Best free host: || ||
agree
Guys,still dont work
...
@boreal ravine @steep estuary
there is a space before await msg.delete() ...
!indents
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
Eg: uptimerobot
^
Then the entire code has __ __ saying 'yield' out of function
uhh.....................
..
whts tht
Or if you wanna pay for a powerful hosting and low ping then use Epik Host
ohh ic
Not really. Most large bots are hosted on a VPS.
Thats also true but this is also working and some verified bots use it
Ask your parents or a friend
If you're looking for hosting options the GitHub student developer pack is an option
If you're under 18 you should still be in some sort of education
how
U mean the Digital Ocean credit?
How what
hosting with github student
Gives you a ton of hosting options
!d discord.Message.jump_url
property jump_url```
Returns a URL that allows the client to jump to this message.
message.attachments then
education host
digital ocean
are the only ones I can see
rest are domains and tools
ah okay
that's sad, I used to use education host lol
Lol
wo
hm
scoopy

hyd
hey has anyone got any examples they can link me for buttons?
lib?
lib?
library
sure
idk im discordpy 2.0
yes ofc

guys how to convert json to utf-8?
your question isnt related to dpy
Hello
I'm badly stuck
How can I use a single sqlite connecting throughout my bot files?
!bot-var
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
but I have different cogs
how can i continue writing messages in the next line using one send function
wut
pardon like a new line?
I mean there should be only one sqlite connection in my main.py
and I want access to it in all other files
like shift enter
\n
oh
for line break
thanks
!e
print("Hello\nWorld")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | Hello
002 | World
new line*
\new line
what abt mine
well it wouldnt matter
self.bot.db
in this case db is the variable and self.bot is the bot instance thats passed in your cog class initiate
okay
another question
what If I don't use cogs?
like everything in a single file 
same thing its bound to a bot instance
whats the difference between using cogs and not using cogs?
cogs are extensions of listeners and commands
I've tried both

Hello guys
!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.
how do I make a MEE6 copy using discord.py?
hey kayle 
ig you can just check all its commands with its help command and duplicate them
there is a github repo of a spinoff of mee6 with premium features, lemme see of I can get its url real quick
spinoff*
def url_filter_cache(db_response):
try:
url_filters[db_response[0]].append(db_response[1])
except KeyError:
url_filters[db_response[0]] = [db_response[1]]
for i in db_response:
url_filter_cache(i)
response_string = {}
for i in os.listdir('./languages'):
if i.endswith('.json'):
with open(os.path.join('./languages', i,encoding='utf-8')) as file:
response = json.load(file)
response_string[i.strip('.json')] = response
def get_lang(guild, response):
try:
return response_string[server_config[guild.id]['language']][response]
except:
return response_string['english'][response]
with open(os.path.join('./languages', i,encodings='utf-8')) as file:
TypeError: join() got an unexpected keyword argument 'encoding'
the encoding kwarg is supposed to be in the open function not the join method
open(os.path.join('./languages', i, encoding='utf-8'))
open(os.path.join('./languages', i), encoding='utf-8')
open(os.path.join('./languages', i, ), encoding='utf-8')
mee6 is an amateur bot anyways
yeah
π³
ik it uses a private wrapper but i thought it was made with js
Nope. mee6 just a server comf bot.
thanks it works
it has voice recieve unless it has its own api
thanks
mee6 has voice receiving?
yeah
bro
Where is it?
recording voice stuff
Mee6 python bot? The oldest update in github says lang python
I want voice receiving too π¦
its a typescript bot so uhh
Nope. The most famous is Rythem
rip dank memer
no
No offence but I don't give a fuck what language it's made out of, just give the link
k
just tell me how they made voice receiving
jk 
yeah right
djs already has it
200k
Nextcord too
wtf
and py-cord
Who tf says that it is not supported
now you're telling me nextcord has done something
Its been in nextcord since weeks if not months
https://github.com/LordDhruvin/MEE69 @boreal ravine idk what you meant by that jk but here u go
Thanks
tf
Oh hmm, well dpy is also planning to add it
That too, the article is also old, yea
finally
where do y'all get these news though
wasn't there a pr but it got denied or something
uhhhhhhh
I never get these news so early
It is still a WiP, didn't get denied
leave discord bots, return to AI dev
Bro, nextcord has voice receive since like months now
Wait what
Eh, I was coding the game for pyweek, just came here for some time
Can you send the docs on it?
same bru
Yea, if not nextcord, then its pycord (idk I am confused most of the time between the two)
Send the docs
def not pycord
pycord has it
liar
Pycord stole the impl (PR) for voice receive
That discord.py had
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/discord/sinks at master Β· Pycord-Development/pycord
definitely lying
welp, rip, who even makes a game in python when you can use unity or unreal engine 
it did???
It had a PR, yes
humans
It wasn't for production though
Has the feature for voice receive been implemented in pycord yet?
Meh, its a small game so idfc
weird welp
did u say meh
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/discord/sinks at master Β· Pycord-Development/pycord
Ah my bad, I always get confused between the two since both do be cord
gtg match started
pycords src gives me a stroke each time i see it
just tell us directly that u have a ton of time to waste
Do they have examples on how to set it up?
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/audio_recording.py at master Β· Pycord-Development/pycord
lol
they didnt changed namespace
danny said he didn't like forks changing namespaces
well if I made some breaking changes to a wrapper, I'd fucking atleast take credit
I mean, school doesn't start for me for another week, sooooo
69 ISSUES
the on_member_update comes in which of the categories

no breaking changes, no credit, they did a good job
halp
!d discord.on_member_update
discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.
This is called when one or more of the following things change:
β’ nickname
β’ roles
β’ pending...
pycord's syntax is so shit, no offence
umm
status
activity
nickname
roles
pending
complete the list
syntax? you mean methods?
yeah that
This requires Intents.members to be enabled.
Parameters
before (Member) β The updated memberβs old info.
after (Member) β The updated memberβs updated info.
i agree
on_user_update
on member update
on_member_update for 2.0
thats for stauts and stuff
first two stuff need presences intents too
she said pfp
kinda creepy ngl
!d discord.on_user_update
discord.on_user_update(before, after)```
Called when a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") updates their profile.
This is called when one or more of the following things change:
β’ avatar
β’ username
β’ discriminator...
wth
I kind of like the voice receive and I kind of dislike it
I'd say it does make sense
what kind of changes?
im having a stroke reading pycords src so dont mind me
just use the voice recorder of your device huh
imagine discordpy brings recording voices....
ppl can literally create ai and stuff with dat
imagine recording voices and selling them on the dark web-
true
f
yes
sed

Stops it from recording either way no?
we won't disable all URLs because some people are dumb enough to click some of them
this why we should have voice receiving
:bruhkitty:
no nitro
and if it ever came to voice receiving, I'd finally have my way of turning off the lights
@cold sonnet I am DMing u smth
ono
on which part of your body are you having a stroke?
π Stop it
kayle simps for nitro
steelseries had free nitro giveaway for everyone, Epic Games aswell before
yup
neither don't we have that much
Only for users that haven't had nitro before
why do you think I'm not meh dpy coder anymore
Wait make that 10
wasn't that someone else
no
@slate swan hey
that's my acc
almost 1/2 pocket money
wait lemme get on that
https://github.com/Pycord-Development/pycord/blob/master/discord/member.py#L861-L883 a whole method to remove timeout when you can just set a default value of None to the duration argument 
stop ping
meh
No
Huh there is? Idk
meh
bro classic
O nvm
classic bad
Yea, I just clicked the Subscribe lmao
no banner cmon
@cold sonnet fuck you
fuck you too
more like love u
@cold sonnet @slate swan i thought you guys were the same person
fuck me
we sent the same image 
π
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
Imma logout and stop ot

you'll never see meh dpy coder anymore
not expensive

goodnight kids

Goodnight child
self.clear_items()
await self.ctx.edit(view=None)
return``````
Task exception was never retrieved
future: <Task finished name='discord-ui-view-timeout-06ea066112d8f19a0e78789cf04a90d8' coro=<MyView.on_timeout() done, defined at C:\Users\nikit\PycharmProjects\dpamong\docs\main.py:336> exception=AttributeError("'Context' object has no attribute 'edit'")>
Traceback (most recent call last):
File "C:\Users\nikit\PycharmProjects\dpamong\docs\main.py", line 338, in on_timeout
await self.ctx.edit(view=None)
AttributeError: 'Context' object has no attribute 'edit'``` why no work?
I am older than you?
how old are you
you mean ctx.message?
31 mate
42
!d discord.ext.commands.Context.message
The message that triggered the command being executed.
!d discord.Message.edit
await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
The content must be able to be transformed into a string via `str(content)`.
Changed in version 1.3: The `suppress` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
since the attr returns a Message obj just use this method ^
await self.ctx.message.edit(view=None) like this?
No
imagine someone thinks im actually 42π
maybe you are
π Stop it
no
im not @maiden fable can confirm dont ask how thoπ³
two pings?
DUDE STOP YOU BOTH
Hey yall question is there a contains function


pardon?
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
I'm not doing shit
wait no
Is there a function for like example py if message contains discord.embed: do something
yes
!d discord.Message.embeds
i though u 50
A list of embeds the message has.
im trying to add something where if they miss spell a word the bot says "invalid input"
@echo wasp ^
did i asked you something

i didnt "sayed" anything to u
you make more ot by asking me to stop ot tbh, so stop
said? you mean?
ur at the right place mate
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
No I want it to check if the message contains discord.embed if so do await channel.send(embed=message) else: channel.send(f"{message}")
?
thats what he said
im trying to add something where if they miss spell a word the bot says "invalid input"
code
Thanks okimii

I'm new
!d discord.ext.commands.Error
No documentation found for the requested symbol.
nvm im bad with path
thats nice, welcome
person who made this is very handsome
(not)
very very
no
why was alec demoted
elif message.content.lower() == 'support': await message.channel.send('Perfect Choice, What Payment Method Would You Like To Use? **okay')
just use else?
tbf I've had quite a lot of moments
Could you show an example
too many
I've already created a calculator, translator and I'm interested in artificial intelligence
!e
a = 1
if a == 2:
print("yes")
else:
print("No")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
No
as basic as i can do it
you've done more than me already
#data-science-and-ml is a bit more artificial intelligence here its just some discord bots that are made by a dev which cant learn as other bots
yeah its a bot but it cant like learn etc like ais do
it's easier to say these are like factory robots
you code something into it and it does it when you turn it on
it's more than that ofc...
more like a bot with an assignment thats all
alright, how would i fix this if you wouldnt mind helping me ot
you're doing this on_message
to send a message it would be await message.channel.send()

hm
ohhhh. Alright mb, thanks
show scopes
the scopes should be bot and application.commands
not the link
send a ss of the perms and scopes
lemme invite that bot real quick
you cant
y
you probably need more perms

once you open the ticket it prints out, and whenever you are closing the ticket it prints it out, i dont like that, is there an fix for that
excuse me?
elif message.content.lower() == 'SUPPORT': await message.channel.send('SUPPORT IS COMING') else: await message.channel.send("INVAILD")
well it will always be false
yeah lower won't be uppercase
elif message.content.lower() == 'support':
not worried abt that lmao
should be
!e
print("lol".upper())
print("LOL".lower())
it always goes to the else statement
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | LOL
002 | lol
bro wdym your problem is that if statement
it will always be false
alright, when they make an spelling mistake then the bot speaks, not when my other bots speak, so the message author has to say something in order to get the bot to say invaild
as soon as I just type something to another channel
in this server
I get a dude like this
pardon?

lmao, when the message author saying something invalid then the bot prints out INVAILD, but if another bot says something the bot doesnt print out anything

could you show an example of it
ni
my code atm
elif message.content.lower() == 'SUPPORT': await message.channel.send('SUPPORT IS COMING') else: await message.channel.send("INVAILD")
show the whole function
show your whole on_message function
and change
elif message.content.lower() == 'SUPPORT':
to
elif message.content.lower() == 'support':
^
alright ill show my whole function wait one moment
async def on_message(message):
if message.author == client.user:
return
if message.content.lower() == 'support':
await message.channel.send('support on the way')
elif message.content.lower() == 'hello':
await message.channel.send('hey how are you')```
python should already show that as a mistake in some way
if message.author == client.user:
return
```do you know what that means
- use listen() deco
- if the author is its self it wont do anything
- use commands
the whole thing won't continue if the message's author is the bot
these ain't commands
ig...
no prefix
how bro
it ain't !support or !hello
good point but its better if he uses commands
i dont want commands lmao for thoses
so it wont trigger for no reason
then nvm 3
so chain, does it work?
Well you can read them

You just need the right tools.
i want my else statement to work tho
Reverse engineering reverts it to x86
because when the mesage auther says something wrong then the bot prints INVAILD
oh I understand
it will always
should remove it
it always checks all the messages and if its wrong it will just send invalid so i suggest commands lol
how to remove all reactions from a message?
!d discord.Message.clear_reactions
await clear_reactions()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Removes all the reactions from the message.
You need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to use this.
AttributeError: 'Member' object has no attribute 'avatar_url'
i updated to discord 2.0 how do i get avatar url now?
member.avatar.url
thanks
can I make an init function an async function
you cant
is the short answer
make a classmethod
when do those even get called
jesus, Caeden is writing a book
Class Methods
Letβs compare that to the second method, MyClass.classmethod. I marked this method with a @classmethod decorator to flag it as a class method.
Instead of accepting a self parameter, class methods take a cls parameter that points to the classβand not the object instanceβwhen the method is called.
Because the class method only has access to this cls argument, it canβt modify object instance state. That would require access to self. However, class methods can still modify class state that applies across all instances of the class.
I see
!e ```py
import asyncio
class x:
async def bleh(self):
print(".")
@classmethod
async def start(cls):
self = cls()
await self.bleh()
return self
asyncio.run(x.start())```
@manic wing :x: Your eval job has completed with return code 1.
001 | File "<string>", line 6
002 | @classmethod
003 | ^
004 | IndentationError: unindent does not match any outer indentation level
fuck mobile
!e
import asyncio
class x:
async def bleh(self):
print(".")
@classmethod
async def start(cls):
self = cls()
await self.bleh()
return self
asyncio.run(x.start())
god I'm dumb
@cold sonnet :white_check_mark: Your eval job has completed with return code 0.
.
thatβs what a classmethod does
it returns an instance of the class which some people use it as an initiate
Might make a simple async method at this point, instead of classmethod
it helps when you need to call a coroutine on a creation of a class instance
yes
it's what I'm thinking about, but Idk how to call it
do I even have to
yes, but I call it with await
and I can't use await outside an async function
it also used for injecting variables in a class
this is a paradox
asyncio.run
right
meh
meh
if you have an event loop you can run tasks off of it
let's say I don't
and that this whole convo is ot
but it's dumb
asyncio.run(self.move)
async def move(self):
await asyncio.sleep(5)
self.rect = self.rect.move(
posnum(pos[0])*45,
(int(pos[1])-1)*80
)
print("done")
```ValueError: a coroutine was expected, got <bound method Piece.move of <Piece Sprite(in 2 groups)>>
Is there a good tutorial for making bots? I'm trying to make a Crypto tipping bot.
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
Thanks bro.
Sup im having trouble to find how im getting a ban Reson can someone help me Im using on_member_ban event
how would I set a rich presence for my bot?
!d discord.ext.commands.Bot.status
property status```
[`Status`](https://discordpy.readthedocs.io/en/master/api.html#discord.Status "discord.Status"): The status being used upon logging on to Discord.
property activity```
The activity being used upon logging in.
here's an example
bot = commands.Bot(
command_prefix = "%",
intents = disnake.Intents.all(),
activity = disnake.Game(name="With u")
)
hm
mh
it does work if I call it but it blocks my entire code
still
@bot.event
async def on_raw_reaction_add(payload):
if payload.member.id != bot.user.id and str(payload.emoji) == u"\U0001F3AB":
msg_id, channel_id, category_id = bot.ticket_configs[payload.guild_id]
if payload.message_id == msg_id:
guild = bot.get_guild(payload.guild_id)
for category in guild.categories:
if category.id == category_id:
break
channel = guild.get_channel(channel_id)
ticket_channel = await category.create_text_channel(f"ticket-{payload.member.display_name}",
topic=f"Channel pour {payload.member.display_name}.",
permission_synced=True)
overwrites = {
guild.default_role: discord.PermissionOverwrite(read_messages=False),
guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True),
}
message = await channel.fetch_message(msg_id)
await message.remove_reaction(payload.emoji, payload.member)
await ticket_channel.send(
f"> {payload.member.mention} Merci d'avoir crΓ©er un ticket ! Si vous voulez fermez ce channel, utilisez **'-close'**.")
try:
await bot.wait_for("message", check=lambda
m: m.channel == ticket_channel and m.author == payload.member and m.content == "-close",
timeout=3600)
except asyncio.TimeoutError:
await ticket_channel.delete()
else:
await ticket_channel.delete()
``` hello i have a error with this ticket code (key error = server id)
!e
my_dict = {1: "hi"}
print(my_dict[2])
@final iron :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | KeyError: 2
so i must include my server id in the dict ???
If I use the interactions webhooks instead of the gateway, is there a way to get the bot user to show as online?
it will only send interactions through the webhook, u still need to connect to the gateway for other things iirc
These two methods are mutually exclusive; you can only receive Interactions one of the two ways. The INTERACTION_CREATE Gateway Event may be handled by connected clients, while the webhook method detailed below does not require a connected client.
Gateway is disabled if you use the interactions endpoint, at least as far as I understand
only interactions
See, only interactions, that is slash commands and context commands and select menu and button clicks
Right, right
All that's only supported by the Gateway.
But I'm using the interactions endpoint, so I can't use the Gatway.
I enabled the interactions endpoint and created a bot user for my application. But the bot only shows as offline. Is there a way to have a bot show as online using the interactions endpoint?
Nope, you need to connect to the gateway
If I understand your code correctly, you run your coroutine using asyncio.run which creates a new event loop each time it's called, that might have caused the deadlock. You should create a new tasking maybe using something like: self.loop.create_task()
I'm gonna check, thanks
useless variable
Bro it was to make it clear
ok
does anyone know how i could make this a list, im new to python
https://cdn.discordapp.com/attachments/303906576991780866/955206929960022016/unknown.png
!e print(list("lol im a string"))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
['l', 'o', 'l', ' ', 'i', 'm', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g']
!d discord.ext.commands.Bot.latency
property latency```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.
This could be referred to as the Discord WebSocket protocol latency.
do i just swap that out
swap out what
and why make it a list? it would just send the list
ah
instead of
hi thanks test
!e print("This\nmakes\na\nnewline")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | This
002 | makes
003 | a
004 | newline
\n makes a new line
so would i put that after what i wanted
for each word yes
tysm
Instead of hard coding it you could just make a list and then use "\n".join(my_list)
!e
my_list = ["hi", "thanks", "test"]
print("\n".join(my_list))
@final iron :white_check_mark: Your eval job has completed with return code 0.
001 | hi
002 | thanks
003 | test
@nova bear
its all a string he doesnt have a list
as you can see here
Hard coding smh
thanks
!d str.join
str.join(iterable)```
Return a string which is the concatenation of the strings in *iterable*. A [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") will be raised if there are any non-string values in *iterable*, including [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") objects. The separator between elements is the string providing this method.
Hard coding the string
bro for a list you would manually need to make it a list and then use join while in a string it would just be adding 2 chars
how do i make it check this?
@commands.check(MYID or FIN)```
how can i make it check multiple IDS?
is it over the top to make a subclass to set a default color for embeds 
i think its not its just 3 lines
i edited the source code on my pi
you did whatπ
def owner():
async def predicate(ctx):
return ctx.author.id == [840606037378728007, 325749184902856715, 264862322751832066, 289794361758187522, 949119850788311070]
return commands.check(predicate)```
Why doesnt this work?
use in not ==
and i probably wouldnt decorate functions like that
alright thank you
Is there an option to suppress responses from interactions with e.g. selection menus?
I need help adding this, I would add certain words to a word list, alright and if the user types something that isnt on that word list the bot will have, invalid word
So I have this function (ctx and self are defined)
async def button_next_day_callback(interaction:discord.Interaction):
if interaction.user != ctx.author:
await interaction.response.send_message("You can't control the game of other people", ephemeral=True)
return
await interaction.message.edit(embed=embed_how_many, view=None)
user = interaction.user
answer_how_many = await self.client.wait_for('message', check=lambda message: message.author == interaction.user)
answer_how_many = answer_how_many.content
But after the bot waits for my message and gets the content I will get the following error
Ignoring exception in view <View timeout=180.0 children=3> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='Next day' emoji=None row=None>:
Traceback (most recent call last):
File "C:\Users\zockerbande\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ui\view.py", line 373, in _scheduled_task
await interaction.response.defer()
File "C:\Users\zockerbande\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\interactions.py", line 494, in defer
await adapter.create_interaction_response(
File "C:\Users\zockerbande\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\webhook\async_.py", line 211, in request
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
Is there any way to wait for an message without getting this error?
You need to respond within a few seconds or this will happen. However you can defer it which tells discord that u will send a response soon
!d discord.InteractionResponse.defer
await defer(*, ephemeral=False, thinking=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Defers the interaction response.
This is typically used when the interaction is acknowledged and a secondary action will be done later.
This is only supported with the following interaction types...
thank you
I need help adding this, I would add certain words to a word list, alright and if the user types something that isnt on that word list the bot will have, invalid word
Nah but with a list you can append on to it
You have to manually add it with a string
yeah yeah
on any error
my code crashes and stop running
i dont care about errors, i just want to my code stay running event if it hit a error
not in specified part, in the whole code
of what 5 reps of 5 poundsπΏ
best solution would probably be to fix the errors, also there are errors, which can't just be ignored
you can just a command error handler if you do get any errors from a command
also if you expect the errors, you could use a try-except block to do something in the case it happens
10 reps of my body weight πΏ
damn 3 pounds
yea and surely theres a valid reason that why im here
im too lazy to solve them, just wanna ignore them then code will work
πΏ

damn you smort
how do i make a dashbord
Well do you know js/html?
you first make a website, then make the dashboard

yeah html
eventually css too
CSS is pain
ok
pain but needed if you really want to do a website using html
Im trying to make bot use embeds and it says this when i use the command?
discord.errors.ClientException: Callback for displayembed command is missing "ctx" parameter.
well youre missing context

i need that emoji ares
wait hold on
you cant call the dict
i just realized i put () instead of []
!e
d = {1: 2}
print(d())
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | TypeError: 'dict' object is not callable
yeah
ye i figured it out ty
emoji looks creepy for some what reason
Try checking your wifi's latency or stuff since your bot is running on your IDE and I think that your IDE would be connected to the wifi, Im not that good in that area Β―_(γ)_/Β―
@silent ermine love the emoji bro
bro wut
How advanced
what emoji?
Quantum physics
well im still learning it so say thermodynamics lol
well I did solve the Time dependent Schrodinger equation but I needed a yt tutorial to know the propability of where an atom would "spawn"

Cool bro
thx
π

But bro
rip
yea idk how to sort of explain it
how can i make something that grabs a api and send it through the discord bot
like what?
to call an api
ok like before i tried to append a user to a json array
@add.command()
async def pilot(self, ctx, pilotUserID):
with open("./databases/staff/pilots.json", "r+") as f:
pilot = json.load(f)
if ctx.guild.id in pilot:
pilot[str(ctx.guild.id)].append({
"ID": pilotUserID,
})
f.seek(0)
with open("./databases/staff/pilots.json", "r+") as f:
json.dump(pilot, f, indent=4)
await ctx.send("Added {} to the database.".format(pilotUserID))
else:
pilot[str(ctx.guild.id)] = {}
pilot[str(ctx.guild.id)].append({
"ID": pilotUserID,
})
f.seek(0)
with open("./databases/staff/pilots.json", "r+") as f:
json.dump(pilot, f, indent=4)
await ctx.send("Added {} to the database.".format(pilotUserID))```
and the error:
```py
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'dict' object has no attribute 'append'```
You're appending to a dict?
well the json is so yes?
dont bully 
Does anyone know a good python api for slash commands
but I need to append it
not overwrite the current one
As the error tells you
i cant append to a dict
Dict has no attribute append
What about pilot.update(dict)
where dict is
dict = {"ID": pilotUserID}
Can someone please help me with slash commands
use nextcord ig
What about discord.py
not the best but works
Help with what abt slash cmds?
Sure try
How to migrate my regular commands to slash commands
ok
They said they might make something called mixed commands (both message and slash) but as of now Iβm just copying the code with interaction instead of ctx
Can you send a link to the docs please








zamn
i switched to digital ocean and idk what to do πΏ