#discord-bots
1 messages · Page 1151 of 1
It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page.
Straight from the error
``py
@client.command()
@commands.has_permissions(ban_members = True)
async def unban(ctx, member : discord.Member):
try:
await ctx.send(f"{member.name} has been unbanned.")
except:
await ctx.reply("The user you are trying to unban is not banned.")
await ctx.guild.unban()```
doesnt work and no errors , any ideas?
Okay
Do you have any error handlers?
for required arguments only
Can I see the error handler?
@client.event
async def on_command_error(ctx, error: Exception):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.reply(f'Please specify a username.', delete_after = 10)```
Is that everything?
yes
Oo that seems like a bad idea
Privileged gateway intents right?
Currently it's going to silently ignore all errors that aren't commands.MissingRequiredArgument
You can fix it by re-raising the error using raise error
can u help me please then
the gist explained all that lol
nope
@client.event
async def on_command_error(ctx, error: Exception):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.reply(f'Please specify a username.', delete_after = 10)
raise error``` like this?
These 3 are the privileged gateway intents, yes
Ah okay
You want to raise error regardless of it's type, so move it ouside of the if statement
wont work
You unindented it too far
It needs to be inside of the error handler but outside of the if statement
@client.event
async def on_command_error(ctx, error: Exception):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.reply(f'Please specify a username.', delete_after = 10)
raise error
``` can be like this?
That's perfect
ok
Now run the unban command again, and it should tell you what the error is
discord.ext.commands.errors.MemberNotFound: Member "@brandon08" not found.```
how can i unban , i wanna do it by the id if possible?
@client.command()
@commands.has_permissions(ban_members = True)
async def unban(ctx, member : discord.Member):
try:
await ctx.send(f"{member.name} has been unbanned.")
except:
await ctx.reply("The user you are trying to unban is not banned.")
await ctx.guild.unban()```
Doing it by ID should be possible
discord.ext.commands.errors.MemberNotFound: Member "940304995960643634" not found.
doesnt work
should be doable with a discord.utils.get through guild.bans
how can i do that
await ctx.guild.unban(discord.utils.get(await ctx.guild.bans(), id=id))
if I didn't miss something
discord.ext.commands.errors.MemberNotFound: Member "940304995960643634" not found.
still no
I need the full code please
@client.command()
@commands.has_permissions(ban_members = True)
async def unban(ctx, member : discord.Member):
try:
await ctx.send(f"{member.name} has been unbanned.")
except:
await ctx.reply("The user you are trying to unban is not banned.")
await ctx.guild.unban(discord.utils.get(await ctx.guild.bans(), id=id))```
well I thought we wanna do it by id
how are you gonna convert a user that's not in the server to a discord.Member
a discord.Member is in a server
oh so what should i do
I suggest converting member to an int
then
await ctx.guild.unban(discord.utils.get(await ctx.guild.bans(), id=member))
you can use get_user or fetch_user to get a discord.User object which you can use to unban
does the bot have access to the user
they do.
@warped mirage if the user is banned, they're probably not a discord.Member, so try typehinting to discord.User instead
it worked but py File "C:\Users\Program\Desktop\Bot\main.py", line 33, in on_command_error raise error File "C:\Users\Program\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1330, in invoke await ctx.command.invoke(ctx) File "C:\Users\Program\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 995, in invoke await injected(*ctx.args, **ctx.kwargs) # type: ignore File "C:\Users\Program\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object async_generator can't be used in 'await' expression it works but sends errors still, can i do smth to keep this clean
#databases @slate swan
that might be the await bans()
srry
as the bot was in python i thought i could send it here too
they're called context menu commands, what library are you using (discord.py)?
await ctx.guild.unban(discord.utils.get(bans, id=member))
?
or if you have converted to discord.User already
and it does provide a User instance
ye i did discord.User, btw will this work for multiguild
then you can just pass that instance to unban
go to line 19
and that's an example for both a user context menu command (right click username > apps) or a message context command
@cold sonnet
it's gonna work in the guild you use the command in
btw i need help doing 2 functions
so if a user is already banned it returns a message, or user is already unbanned message
why not convert to discord.Member and it's gonna show an error if the guy isn't in the guild
wait I'm dumb
that's not the same
if user in (await ctx.guild.bans())?
that's not the not the same part
you can handle errors
Idk how ig
im trying to build a discord bot that looks up an IP addr from a text file and creates an embed with the returned data however this is extremely slow whats the best way to multithread/pool this without breaking the bot
when you try to unban a user which is not banned, it raises discord.NotFound error which you can catch in a try-except
i have 20k ips to lookup btw so yh
Can u help me with that
ya, first give it a try then ill help you when you are stuck.
You're probably being bottlenecked by the lookup service you're using, in which case there's not much you can do about it
its a python module
no external apis used
if i print the data its fine but soon as i put data into an embed it takes years
man really said embouteillage
i was thinking if i did a function inside my command that did the lookup and for ip in ips asyncio.run that function but idk if that will work/be stable
well it doesnt cuz asyncio cant be called in a running loop
Hia
I want to make a music command, which api should i use?
Is there an api for that?
How do i run some code after a user has reacted to a message in DMS?
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body In name: String value did not match validation regex.
im trying to create custom emoji with discord py
i got that error when i did await guild.create_custom_emoji(name="emojione", image=img.read())
are you sure that line is the cause?
Most of them are against TOS
More like all of them
Hi guys !
My bot is receiving this message saying i'm being rate limited. The docs about it are really overwhelming me. It's been two weeks I'm running away from that task but now I have to face it. Can you just... cheer me up a bit and guide me through it please? 
What are you doing?
wdym?
anyone willing to work on an advance discord bot along with an official site and optional web panels for server moderation etc
using discord.py
work with the rate limit. how many request are you sending per minute ?
you trying add an imagine?
Please don't post unapproved advertising, thanks
you misunderstood him lol
easy. you can use create_task() from asyncio module
this does not break the bot or the new thread. i use this for other things on my bot
You'll still have to wait for the returned Task object, so that shouldn't change the time it takes
i was replying to this mainly
threading will break the bot process then restart once the thread is over or sometimes wont even start back up for a while
would you be able to find this for discord.py? this looks gr8
hello
is it possible to establish a websocket connection and have a discord bot interact with this connection (send & receive data)
and make it do some things based on the received data ?
yes @glossy shore. The socket server or client must be threaded
yep ofc
ive done it myself😅
i'm making a simple class that would handle the sending and receiving of data
using the websockets module
i've been using asyncio for a while but event loops and background tasks are new to me honestly ...
you can also use aiohttp to handle the gateway and to make requests to the RESTAPI
i'll first clean up my code and either send it here or in a help channel
to get some insight on how can integrate with discord.py
why not just switch over to disnake? it's a fork of dpy anyway
how can I answer this? I'd say around 100
Well there you have it then
Wouldn't a hundred requests a minute be totally fine
The global ratelimit is 50/1s
Are you hosting on some shared VPS?
do you use repl?

CF does not allow that much lmao.
once you send a good amount of request per second. you'll DOSIng the server
I do
it's not your fault then, it's because repl shares IP's with loads of other bots
Type kill 1 in repl's shell and it'll usually fix it but it'll happen from time to time unless you get your own host
That probably explains it too
wait how can the host be responsible of a discord rate limit?
the host is just a machine that'll run the same program
kill 1? whats that suppose to do ?
because the host has, say, 1000 bots all on the same ip making requests to discord
? 100/60s is within the global ratelimit of 50/1s (Not saying it's good to have 100 requests a minute although)
O_o, thats not gonnah do much?
eventually discord says no thank you and blocks the ip
whats kill 1 in repl shell?
kill the process with PID 1 iirc
.........
Yea and that causes the process manager repl.it uses under the hood to spawn a new enviourment
killing the process is suppose to stop IP Block from cloudflare? LOL
yes it kills your session and more often than not will also put you on a new server/ip therefore fixing the problem

i gotta learn how to host a bot on another cloud platfom then x.x
kill is a linux command, they provide you a new instance since the other one was destroyed thus providing a new ip.
Lmao
what does killing your procces have to do with stopping IP Block from CF 
You probably will regret it
eh, doubt it
Since it gets a new IP
Just incase you waste your time, be it known heroku also has the same issue
just buy a VPS, simple solution
I guarantee legit all of em are blocked, unless repl themself gets more often
I don't want a vps, I prefer a cloud because it'll force me to get used to them
It will you have to get slash commands working that by itself is not a part of discord.py
repl is where all the rookies are lol. most likely all IP blocked from CF
you're wrong
go get a rocket then
hmmm
a rocket wdym?
repl causing rate limit bans has been an issue for years this isn't a new or unique problem, and kill 1 has always been the (temp) fix
A VPS is on the cloud bro
its not repl with the rate limit
dude what, are you good
LMAO 
im legit dying rn
did u not see the cloudflare page?
discord is the one that has CF
i mean learn how to use google and azure cloud etc...
it isnt a repl error with the rate limit.........
Yep that's true
usually discord sends a rate limit error. not CF
ah ic
Discord sends it through cf? Firstly what is happening here i need some context to work with
discord ratelimit -> dpy handles it
and i think discord ratelimits through CF
this is true
wait wait
Sure, but repl.it did "cause" the ratelimit, in cases where you didn't spam the API. The discord API itself does API bans based on IP itself, with repl.it's clusters and shared hosts, IPs are shared among'st multiple users. So, really repl.it did in the end start the problem? Not to say that it's BAD for repl.it to share hosts between users, being a free service after all
dude
thing that i like with replit is that when you close the site and open it again you see all the console activity from when you weren't on the website if that makes sense
i don't know how to do this on virtual machine
look into tmux
~/.bash_history
@slate swan What are you trying to do?
You could use logging module as well
bro even if u ban the IP on discord end. it should reply blocked or some error code
not CF
I can see my console history dating back to a loooong time on my linux machine, so it's not really something special. Nice QoL though
not exclusive to linux, just bash
CF and discord API are different, unless they added rate limiting on CF aswell
i think zsh has zsh_history too
CF get's shown in cases of API bans with repl.it for some reason
you can have rate limiting on both API and CF
Discord API uses CF 😄 that's why it's given
CF panel is a whole different thing
Bash is kinda exclusive to linux due to it's licensing that's why apple switched to zsh
Uhh, ok? But discord API does indeed use CF
i guess, most distros ship with bash preinstalled
It's utilising CF
Yep it does
i've been using CF for so long, i dnt get that
Bash is the basic component
unless i set it
What's a QoL?
And... ok i know about bash history but that thing stores ALL the history... does that mean I have to code a specific thing to read all the history from last time I starter the bot, and then print it? or is there something that automates it?
As you can see here ^ Discord API is using CF, isn't that crazy?
qol = quality of life
@slate swan Please explain what you are trying to do
It's almost like, all the APIs used now a day use CF for ddos protection, and metics
Discord rate limiting system is source code wise. not CF panels
typically i'll create a VM on google cloud and host the bot on it, then ssh into the VM
but then i'll just find an empty console
??? Do you know how the API bans work? Instead of your request going through when API banned it gets routed to CF
fork bash and make that feature kekw
Well here is how to solve it run it through docker
Nothing you have to do. If it's in a VM you should just be able to scroll up?
Run it through docker
yes i know that
oh ok
Or use screen
CF is in between
Yes... so discord API uses CF??
Yes
no when u ssh into the VM it's empty console
I don't see the relevance of this debate it's bordering off topic
They were given a cause and solution
Nuff said innit
what is docker please?
do you know the different between IP Banning checking IP in source code and blocking IP in CF panels under "security/rules"
Container service
Containers. That's it. "a VM but lightweight".
This convo is perfectly fine under #965291480992321536
I would be glad if you could show me exactly which method discord API does, considering you seem to know exactly. Did discord become open source?
so that's just been made for console history?
thanks a lot, it that long to set up? does this method has cons?
most def
Okay, show me the part in their codebase regarding this
It's more easier
Afaik there are no cons
I'll send more info on dm
ok so here i got 2 options, i can either go in my source code and check for IPs that are blacklisted or use CF to block incoming IP like this below
@pliant gulch
i HIGHLY doubt discord uses any of CF settings. CF is mainly used to protect backend IP
with rate limiting, you should be good on DDOS attacks.
DDOSing is just a shit ton of request per second. i do it and work on related stuff for it lol
https://github.com/Rapptz/discord.py/blob/faad035fa24b39bb25da1233a779bfdbd547764a/discord/http.py#L102-L111 😅 It's almost like, your requests when ratelimited get routed to CF
discord/http.py lines 102 to 111
async def json_or_text(response: aiohttp.ClientResponse) -> Union[Dict[str, Any], str]:
text = await response.text(encoding='utf-8')
try:
if response.headers['content-type'] == 'application/json':
return utils._from_json(text)
except KeyError:
# Thanks Cloudflare
pass
return text```
discord/http.py lines 467 to 469
if not response.headers.get('Via') or isinstance(data, str):
# Banned by Cloudflare more than likely.
raise HTTPException(response, data)```
Crazy
whats that suppose to mean?
all you doing is confirming what im saying lol.......
there no proof of discord using CF settings lol
what you need help with ?
apparently commands isn't part of discord.ext?
? I've been saying this for the whole time now I'm not sure what you are saying anymore I'm kind of confused
oh
import discord.ext < delete
In py-cord this isn't the case
still doesn't work
py-cord has a different structure you need to follow.
ok
No clue just know it's py-cord stuff lol
I read they're rewriting pycord from the ground up
"deforking" it
Gave me a good laugh
Yeah it made me raise an eyebrow but good luck 2 them lol
They could make some improvements, sure but they would need a dedicated small team.
You there?
I take one look at a file in pycord, there is a method with no return type, sandwiched in-between two other methods that BOTH have a return type
Mostly a nit-pick but, typing is all-or-nothing imo 😔
d.bots are difficult projects to start out with if you're new to programming
ok, do you have any suggestions on what to do?
🤷♂️ my first project was an IRC bot years back pre-discord. I remember it was difficult at the time but I persisted with it.
there's some good lists of "beginner projects" on reddit if you search around a bit
o k
My suggestion is to learn a bit about the api
i gotta see this
Pycord, a maintained fork of discord.py, is a python wrapper for the Discord API - pycord/bot.py at 4ef42d50a82e1e2280bf9e460dc26b4befc45e46 · Pycord-Development/pycord
Hey I need some help with posting to an api would anyone be able to help me
My response.post just wont seem to work on my python bot
I have an api for reporting scam numbers and none seem to want to push through.
anyone awake ? lol
This is the discord api sir
No its a private api with a company
Its for busting and turning scammers into the authories
Meant this channel
since discord.py support has been cut, i uninstalled and installed py-cord but now none of my commands work
the bot goes online and everything but no commands do anything
i just did pip uninstall discord.py, is that incorrect?
D.py is still getting updated almost daily
yeah but discord cut support for it no?
thats why it doesnt have buttons n whatnot?
It does have buttons
oh what
I think you still have the old version installed 1.7.3
discord doesn't provide support to libraries, discord has its own independent api that the libraries connect to
https://www.youtube.com/watch?v=kNUuYEWGOxA
i was watching this but once he started doing the buttons, mine were being marked invalid
#web-development probably would work
not a server but eh
First install the new version using the repo url and pip+git
Then head over to the docs and switch it from stable to latest
In the repo there are also examples of buttons under view
pip install git+https://github.com/Rapptz/discord.py
latest version
and i think ashley has a tutorial on how to use message components
thats for app commands
but you can find plenty in the examples folder of discord.py repo
oooookay
tyty <3
Code jam overed?
idk if there's anything explainable in those ps there's a nice amount of examples for them
the qualifier is overed
await interaction.followup.edit_message(embed=e23,view=self)
i want to edit the embed which i sent through the command
image
how "idk"?
anyways, I've tried the exact code and worked fine
and usually, that error pops up when you are trying to register an app command with an invalid name
from helpbot import Dropdown,Dropdown2
Traceback (most recent call last):
File "c:/Users/hp/Desktop/bot/main.py", line 50, in <module>
bot.load_extension("helpbot")
File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\disnake\ext\commands\common_bot_base.py", line 487, in load_extension
self._load_from_module_spec(spec, name)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38\lib\site-packages\disnake\ext\commands\common_bot_base.py", line 419, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
disnake.ext.commands.errors.ExtensionFailed: Extension 'helpbot' raised an error: ImportError: cannot import name 'Dropdown' from 'helpbot' (c:\Users\hp\Desktop\bot\helpbot.py)
what's the problem? why cant i import
can i see your code after with open
i think i have problem in that
I don't do it with a context manager (the problem shouldn't be that)
hbday @visual island :D 🥳
await guild.create_custom_emoji(name="emojione", image=open("img.png", "rb").read())
``` something like this
thanks!!
Okay
anyone ..
same error) :
Your bday?
with open(filet, "wb") as file:
file.write(requests.get(u).content)
with open(filet, "rb") as ig:
jmh = bytearray(ig.read())
print("d")
try:
await guild.create_custom_emoji(name=f"emotes{randh}{h}{i}{randh}", image=open(filet, "rb").read())
except Exception as hh:
print(hh)
Happy birthday @visual island
https://c.tenor.com/5J6CwnLqBFcAAAAi/hasher-happy-sticker.gif
There are some possible issue:
- "helpbot" has no attribute "Dropdown"
- If it's a directory, you may not have those attribute imported in
__init__.py
thanks!
this is my code
i have a channel where there are emojies, and i get emojies from that channel and put it in a file and then put them in bot
then delete the file
most likely, the error comes from the variable randh, h, or i
oh
its just randomized characters and numbers
i removed them all and still the name error
@visual island hbd 
yeah that shouldn't be an error with create_custom_emoji()
are you using an app command?
a task
tyy!
you meant tasks.loop or asyncio.Task?
okay, do you have any app commands then?
tasks.loop
what are app commands
bot.command?
oh, basically just discord.py's slash commands
no i don't have any
!d discord.app_commands.command
@discord.app_commands.command(*, name=..., description=..., nsfw=False, extras=...)```
Creates an application command from a regular function.
i don't have
emoji url
why do you need that?
i have a channel in my server which has emoji urls, so it gets it from the urls
you can't have / in emoji names
Oh
that was the issue from the beginning 🙂
i removed it still the same error
and dot
ooh
why discord is so strict
it works :D
the solution was so easy i wasted an hour trying to fix the image thing 💀
not necessarily strict, just match regex and done
i don't know wwhats regex
string pattern matching stuff
ooohhh
can it have numbers
yeah
as long as u are good at regex there is no string u can't parse except html tags
nice
I bored
I wana make a comand but have no good idea
afk command
Already have XD
eval command
warning system
Already have
no, like @unkempt canyon's eval
Ye
the one like everyone can use
Ye
ticket system?
I have that
Hmm
you're using eval function?
What?
And i have one question
I have filled the form for the perspective api but they have not sent me email from 1 week is there any possible reason?
u dont need to fill a form for the api key iirc
In order to gain access to Perspective API, you will need a Google Cloud project (console.cloud.google.com). Upon completion of this form, you will receive an email confirmation and be able to view and enable the API.
They are asking me organization name what I have to type there?
just type none or student
i was wondering why the link disappeared 
I typed my discord bot?
yeah we zap forms links bc of people posting surveys
oh i c
yeah
Done!
How can i use perrespective api with key using python?
With aiohttp
Idk how you gotta provide the key to their API but in most of google APIs it goes as a param so
await session.get("...", params={"key": "your_api_key"}) #pseudocode```
I broke my brain yesterday trying to find a good URL pattern, at last I made my own lmao
wow
u found that out just to refute me didnt u🗿
🥲
No I have that link in my alt's dms because it's possibly the greatest stackoverflow post of all time
or at least, the top comment is
yeah it's uh, pretty famous 
How do i make a simple bot that starts when i do a command, then starts counting up from 1 (sending each number in the channel as it goes) until it sees another command?
have a command with a while loop and have another command that changes the condition to false
# command 1
run = True
num = 0
while run:
num += 1
# command 2
run = False
Are you sure that works?
Ill try
honestly, not 100% sure, but it makes sense to me
bots are asynchronous, it will
oh yeah, this too xD
For sending messages in a loop? Why would that ban it lol that aint how it works
spam I think
Iv had a bot in a loop sending messages for months now
Yea nah dude, iv had one going for months
You have to make alot more api calls then that
1 per second is nothing
ngl... I can kinda agree with the 1 per second thing as I've done tons of loops and they worked now that I think about it 🤔
With how ratelimiting works in most Discord libs each iteration will just happen as soon as the ratelimit bucket is refreshed or isn't empty
the ratelimits are dynamic so no sure shot way of saying if u get banned or not
Yes there is, await message
huh?
I think they're referring to Messageable.send(), which will wait for the ratelimits before making a request, thus meaning you never get blocked
how is a coroutine related to ratelimits if coro stopped rate limits then why would rate limits exist
Yup
prolly
Huh
Have you ever made a bot im so confused
no let's just take a simple example
what?
say i do client presence change every 1 second like u are saying
That's not how the API's ratelimiting works
it is what it is
i am doing await as well that dosent change the fact i get rate limited
the only time an unrelated route will get you blocked is if:
- you exceed the global limit
- you get banned by cloudflare due to 10k 4XX requests in 10 minutes
Can we come back to this
I just want a cancelable loop
You could have some sort of variable, say "stop" which is initialised to False when you run the count command. Each iteration of the loop you check if that value is True, and if so break out of the loop. In your stop counting command you just have to set "stop" to True
.
yeah, precisely that
sigh
xD
bot = commands.Bot(...)
@tasks.loop(seconds=1)
async def mes(channel: discord.TextChannel):
await channel.send("uwu")
@bot.command()
async def uwu(ctx: commands.Context) -> None:
mes.start(ctx.channel)
@bot.command()
async def not_uwu(ctx: commands.Context) -> None:
mes.cancel()

why use a while loop when you can use a task loop
do you think the command is triggered?
how do you know?
member = member or ctx.author
- Don't use f-string for the sql query
There are some possible issues, for example not having process_commands() in the on_message event or you didn't enable message_content intent
Actual explanations because just pointing out a bunch of shit doesn't help anyone:
- aiosqlite doesn't block the event loop while making queries, since discord bots are inherently asynchronous this means you can have multiple of a command running at once
- using
orin this way will return the first truthy object, a non-None member is truthy, failing that it will fall back to ctx.author - f-strings for SQL queries can lead to SQL injection, allowing people to make malicious queries. while this wont be an issue for a member id specifically, it's a good practice not to use
- it's important to catch named exception types, otherwise you could hide a different type of exception which makes debugging hell
- use this
cur.execute("SELECT wallet, bank FROM main WHERE user_id = ?", (member.id,))```
waiting for 2
2 is a statement, you dont need more than one connection, there's nothing more to say, you just dont
- Creating a connection is an expensive procedure, you can just have one connection and create own cursor for each operation, it is better to have an
executemethod somewhere in bot class for everything rather than creating new connection and cursor every time you want to make a query
2: // TODO: Create 2
How do I remove a slash command that is not in my code? I had it as part of my group thing, when trying to get figure out how slash commands work, and now it doesn't delete on re-sync
what library
I've been trying for hours and it won't delete itself
Last time I faced this issue I ended up making raw requests for each command to delete
How do I do that in Python
just use this ```py
import asyncio
import hikari
rest = hikari.RESTApp()
TOKEN =
GUILD_ID = hikari.UNDEFINED
async def main():
async with rest.acquire(TOKEN, hikari.TokenType.BOT) as client:
application = await client.fetch_application()
await client.set_application_commands(application.id, (), guild=GUILD_ID)
asyncio.run(main())
sarth they said dpy
just a quick code to purge all commands
why would you want an extra library for that
they just want to purge which doesnt needs any integeration with dpy...
a ic
guys i need help
Import hikari via pip?
discord.app_commands.errors.CommandInvokeError: Command 'mute' raised an exception: HTTPException: 400 Bad Request (error code: 50007): Cannot send messages to this user``` can someone help me make a error function so if the bot cant dm someone does as a reply ig
yeah pip install hikari
pip install hikari
As my luck would have it, it's not that simple:
Consider using the `--user` option or check the permissions.```
from requests import put
put(f"https://discord.com/api/v10/applications/{your_bot_id}/commands", json=[], headers={"Authorization": "Bot " + token})```
This should delete all commands tho idk ^
that seems like more of your python config settings....
maybe it is a guild command and you sync global or vice versa?
My brain is just mush now
Can I just resync locally?
@kind trellis try this to delete all the commands and then run your bot to add them back
i think you need to fetch the commands first, im unsure
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
can someone help me?
use try/except block
discord.app_commands.errors.CommandInvokeError: Command 'mute' raised an exception: HTTPException: 400 Bad Request (error code: 50007): Cannot send messages to this user i need to make a error function for this,
hmm idk ig
@client.event
async def on_command_error(ctx, error: Exception):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.reply(f'Please specify a user or ID to complete this command', delete_after = 10)
raise error``` i have this, can i add another error thing here
prob they closed their dms
!e py try: 50 / 0 except ZeroDivisionError: print("Can't divide by zero")
thats why i need a function for it
3.11
@vale wing :white_check_mark: Your eval job has completed with return code 0.
Can't divide by zero
@client.event
async def on_command_error(ctx, error: Exception):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.reply(f'Please specify a user or ID to complete this command', delete_after = 10)
raise error``` can i add it here by any chance?
NO.
try discord.HTTPException or discord.Forbidden
damn]#
Forbidden inherits from HTTPException iirc
yes, and is specific to 403 status
well i need to add the error thing for like 3 commands
;-; create a helper function to send dms then maybe..
@client.command(description="Mute the specified user")
@commands.has_permissions(ban_members=True)
async def mute(ctx, member: discord.Member, *, reason=None):
guild = ctx.guild
mutedRole = discord.utils.get(guild.roles, name="muted")
if not mutedRole:
mutedRole = await guild.create_role(name="muted")
for channel in guild.channels:
await channel.set_permissions(mutedRole, speak=False, send_messages=False)
await member.add_roles(mutedRole, reason=reason)
await ctx.send(f"{member.mention} has been muted for {reason}")
await member.send(f"You have been muted in {guild.name} for {reason}")``` how would i do it here
try-except is basic python
Wrap your critical statement (send) into it and there ya go
.. ok then nvm
def is_manager():
async def predicate(ctx: commands.Context):
async with ctx.bot.server_db.cursor() as cursor:
await cursor.execute("SELECT manager FROM donation_setup WHERE guild = ?", (ctx.guild.id,))
data = await cursor.fetchone()
role = ctx.guild.get_role(data[0]) if data else None
if role:
if role in ctx.author.roles:
return True
elif ctx.author.guild_permissions.manage_guild is True:
return True
else:
embed = discord.Embed(color=0xe74c3c)
embed.description = ':PinkWarn: User with **Manage Server** permissions or **Donations Manager** role have access to this command.'
await ctx.reply(embed=embed, view=DeleteView(ctx))
return False
else:
if ctx.author.guild_permissions.manage_guild is True:
return True
else:
embed = discord.Embed(color=0xe74c3c)
embed.description = ':PinkWarn: User with **Manage Server** permissions or **Donations Manager** role have access to this command.'
await ctx.reply(embed=embed, view=DeleteView(ctx))
return False
return commands.check(predicate)
isnt there any way to ignore the check for help command
@client.command(description="Mute the specified user")
@commands.has_permissions(ban_members=True)
async def mute(ctx, member: discord.Member, *, reason=None):
guild = ctx.guild
mutedRole = discord.utils.get(guild.roles, name="muted")
if not mutedRole:
mutedRole = await guild.create_role(name="muted")
for channel in guild.channels:
await channel.set_permissions(mutedRole, speak=False, send_messages=False)
await member.add_roles(mutedRole, reason=reason)
await ctx.send(f"{member.mention} has been muted for {reason}")
await member.send(f"You have been muted in {guild.name} for {reason}")
if not member.send:
try:
await ctx.send("This cannot be done")
except:
await ctx.reply("This has worked")
``` will this work?
is you help subclassed?
yes
Ok, it's definitely local to the guild
That thing didn't work?
reload your discord client after doing that
It worked, but it only removed the global command
oh
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
can someone help me?
use this then
Then this
from requests import put
put(f"https://discord.com/api/v10/applications/{your_bot_id}/guilds/{guild_id}/commands", json=[], headers={"Authorization": "Bot " + token})```
@client.command(description="Mute the specified user")
@commands.has_permissions(ban_members=True)
async def mute(ctx, member: discord.Member, *, reason=None):
guild = ctx.guild
mutedRole = discord.utils.get(guild.roles, name="muted")
if not mutedRole:
mutedRole = await guild.create_role(name="muted")
for channel in guild.channels:
await channel.set_permissions(mutedRole, speak=False, send_messages=False)
await member.add_roles(mutedRole, reason=reason)
await ctx.send(f"{member.mention} has been muted for {reason}")
await member.send(f"You have been muted in {guild.name} for {reason}")
if not member.send:
try:
await ctx.send("This cannot be done")
except:
await ctx.reply("This has worked")
``` will this work?
Thank you. I see I can also make it so only certain people can see certain slash commands
How would that be done?
Server settings -> interactions -> your bot app -> edit stuff
You can predefine it in code I think but I never tried
Those are called permissions v2 or smth
.
member.send is critical
Not ctx.send
what then
Alright. I'll probably do it when my brain isn't mush, lol
Ok gl
lol to fix my thing its impossible then
If you have basic python knowledge it's easy
It sucked that Windows forced me to update when I was in the middle of de-bugging
I got booted off the internet and had no choice but to restart my computer and let it install updates
not for dm stuff
Not to offend but the questions you ask make me think you just found some yt tutorial on "how to make a discord bot" and copypasted the code from there
Sorry if this is wrong but like fr @warped mirage
That looks like before the rewrite was done
Not you lol
No I coded the command myself.
And even so that doesn’t fix the dm error
Why don't you use 2.0?
f"{message_before.content}" is a useless str cast, content is already a str and in the future cast to str with str(obj)
I mean try-except is a very basic python and it's covered in most of python learning guides
Not knowing it is weird
That's just bad practice
Brb
Bro I’m not talking about normal python, I’m talking about discord.py, I’m normal py u don’t do dm stuff cuz it’s not related to discord is it?
I do use 2.0
discord.py is a python library and uses python, logic
Once again we are changing the topic but sure
Then do simple stuff use member timeout
Apparently, it's just like you usually do
I’ll try in the discord.py channel maybe cuz idk no one has answers here
await timeout(until, /, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Applies a time out to a member until the specified date time or for the given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").
You must have the [`moderate_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") permission to use this.
This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.edit "discord.Member.edit").
I’m already there lol
good
Ye dw I don’t need to timeout members, I’m talking about muting but thanks for ur advice
@warped mirage ok ima be nice and explain try-except to you 😇 (no idea why can't you just read the docs but ok)
So basically try block tries to execute a statement and if it fails, the except block is executed. In your case, the await member.send(...) may fail so you gotta put it to try block and in except put pass or print that bot failed to DM or whatever you want
hmm... interesting 
And behold the spoonfeed
try:
await member.send(...)
except:
pass```
It's also better to specify the exception
except discord.HTTPException:
...```
Bro this has been 3 hours they have not sent me api key on mail
maybe try to fill the form again?
I am filling form 3rd time
They are not sending ..........
Use a different api
What does that API even do
Perrespective best
what
I once before took the api key and deleted that mail .
Maybe this is the reason?
I didn't ask what is the API called lol
APIs usually have alternatives just tell me what it does
Checks that messages is toxic or it contains profanity
It returns the toxity in persentage
Lol nice
try to see if the mail goes to junk/spam folder
I cleared the bin last month 😢
Learn about machine learning and make own toxicity detection AI 🤓
Anyway why not just word filter
use tensorflow, they have pre-trained models
and best part: you don't need to fill any fucking form
someone please help me here
discord.py server is a mess f
@client.event
async def on_command_error(ctx, error: Exception):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.reply(f'Please specify a user or ID to complete this command', delete_after = 10)
raise error
# Mute Command
@client.command(description="Mute the specified user")
@commands.has_permissions(ban_members=True)
async def mute(ctx, member: discord.Member, *, reason=None):
print("test")
guild = ctx.guild
mutedRole = discord.utils.get(guild.roles, name="muted")
if not mutedRole:
mutedRole = await guild.create_role(name="muted")
for channel in guild.channels:
await channel.set_permissions(mutedRole, speak=False, send_messages=False)
await member.add_roles(mutedRole, reason=reason)
await ctx.send(f"{member.mention} has been muted for {reason}")
try:
await member.send(f"You have been muted in {guild.name} for {reason}")
except discord.HTTPException:
await ctx.reply("This DM could not be sent.")``` mute command doesnt return the error
What argument do you not specify
Idk , I have one for arguments but the dm doesn’t go through cuz some ppl have dms off
I need to fix that
try-except does that
Nope
I tried still nothing I legit have it in the code****^^^^
I tried printing and also doesn’t work
Does the dm message get sent
No it sends on console message coudnt be sent
It doesn’t crash bot but I want it as a reply to the user
What error does it send
I’ve sent multiple times but I’ll send again
K do please
discord.app_commands.errors.CommandInvokeError: Command 'mute' raised an exception: HTTPException: 400 Bad Request (error code: 50007): Cannot send messages to this user
Could you give the full traceback
It says ignoring from mute command
that's for an app command though, the code you sent is a normal command isnt it
Ye I need for a prefix command ,
Could you just give the full traceback
is there a way to get a user by their discord nickname (assuming they are all unique)?
yeah thats what i meant
I’ll have to do that soon cuz I’m busy atm but brb
Ok
Depends on what context you are trying to get it. If it is a command argument, you may just typehint it with discord.User ig
context as in i type something like ;giverole [nickname] [role] and the bot gives that person the role
async def giverole(ctx, member: discord.Member, role: discord.Role)```
Roles can only be given to members
is there also a way to do it like this?
as in later in the command
That's a bad way
well yeah but i have to use the member/username syntax for other parts and it doesnt work with [username]#4445
member = await commands.MemberConverter().convert(ctx, "username")```
Iirc it is like this
!d discord.ext.commands.MemberConverter
class discord.ext.commands.MemberConverter(*args, **kwargs)```
Converts to a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member").
All lookups are via the local guild. If in a DM context, then the lookup is done by the global cache.
The lookup strategy is as follows (in order)...
so like this?
You need to import commands
If you need a constant user just use their ID and get object with ctx.guild.get_member(id)
I have filled form for it but they have not sent mail from 3 hours
I got the response in 10 minutes, probably it got into spam folder of your mail
how i can get the reactions on a message
for example
channel = client.get_channel(#number)
msg = await channel.send("how many people think im cool")
await msg.add_reaction("\U0001F60E") #sunglasses
@tasks.loop(seconds=1)
async def check_results():
print(number_of_people_who_reacted)
*ik this program wont work, its just an example
I am trying to use on_command_error. When I am asking for a command which is not there, It should send a message, Instead I am getting an error: <disnake.ext.commands.context.Context object at 0x00000183B2DF4EE0>
you can make the variable a botvar
@client.event
async def on_command_error(error, ctx):
if isinstance(error, commands.CommandNotFound):
await ctx.reply("**__Command Not Found!__** The command you tried to use was not found. Please do `24?help` for commands list. If this is an error, Please contact `Shaolin_Dragon#9815`.")
elif isinstance(error, commands.MissingPermissions):
await ctx.reply("**__Not Allowed!__** You do not have permissions to run that command. Please contact `Shaolin_Dragon#9815` if this is a mistake.")
else:
print(error)
what does that mean?
@visual island Happy bday
see !botvar for more information
thanks!
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!
you switched the parameter of on_command_error
ctx should come first, so it should be (ctx, error) not (error, ctx)
Oh
Right... I am dumb
BUT! It was tabnine
Thx.
anytime 👍
No it's not there
@visual island
I not found it in spam
What should I do now?
🥺
I don't know, try making a support ticket here https://developers.perspectiveapi.com/s/contactsupport (make sure to give detail explanation and what you have tried)
I mailed them already
mail to?
Means i contacted them
Is there any alternative for perrespective api?
no I meant where did you contact them
At there contact website
I'm no expert in machine learning, maybe try asking in #data-science-and-ml
Here are the top 15 perspective api alternative and similar softwares as derived from our software tagged features and our tpsort score, these software features are tagged by our editors and we will give the most correct result.
googling is sometimes noice
I already seen this website
I not found any good one
tensorflow would be the best way
But i don't know machine learning
I'm new to building Discord Bots and I have a question on keeping the bots running.
Should I run the program on my home computer (very bad probably couldnt handle it with other stuff)
Or buy a server to run it on
The latter
a suggestion in advance, don't go for something like replit or heroku
wait for the mail then 
So i wanna make a event/cmd that makes the bot send a msg that stays in the end of the channel...like the sticky bot...
how can it be done ?
Send the message, once a new message has been sent in the channel, send it again?
would be annoying as hell lol
many bots do that already
{ut.strftime(%A %B, %d, %Y %H %M %S)}
https://cdn.discordapp.com/attachments/934720231757205535/998242973324148756/unknown.png
..
shouldnt they be strings?
Invalid syntax at %d
Maybe it should be capitalized?
can someone give an example of a hybrid command. I am having trouble implementing it
um?
strftime takes a string
ut.strftime("%A %B, %d, %Y %H %M %S")
Can you send the code you use it in?
@bot.command()
async def uptime(ctx):
ut = bot.uptime
await ctx.send(f"I've been up from/for <t:{ut.timestamp():.0f}:T> **{ut.strftime("%A %B, %d, %Y %H %M %S %p")}**")
Use '' quotes for the string you pass into strftime, otherwise it interrupts the fstring
@glass tangle i need help how 2 multiple file python to discord bot
but you are "Not Nakime" 
imposter
stop playing so much among us bro
you have among us all over you
😳
sus
class SlashBot(commands.Bot):
def __init__(self) -> None:
super().__init__(command_prefix=".", intents=discord.Intents.default())
async def setup_hook(self) -> None:
self.tree.copy_global_to(guild=discord.Object(id=12345678900987654))
await self.tree.sync()```
in this, should I have a separate setup hook for every server the bot is in?
no lol
yes.
precisely, a message common could be ideal but a setup hook works fine if you change the guild in copy_global_to
that is what I am asking. should I have the id of every server the bot is in?
how is it even possible if my bot becomes big(not that it will)
just remove the copy_global_to line
then it'll sync the commands to each server
the bot can see
and has permissions to create slash commands
class SlashBot(commands.Bot):
def __init__(self) -> None:
super().__init__(command_prefix=".", intents=discord.Intents.default())
async def setup_hook(self) -> None:
await self.tree.sync()```
yes
understood

I have another doubt
hm?
if I wanna have hybrid commands, should it be like
@commands.hybrid_command(with_app_command=True)
@client.tree.command(name="ping", description="Lise test")
async def _ping(interaction: discord.Interaction) -> None:
await interaction.response.send_message("pong")```
@commands.hybrid_command(with_app_command=True)
async def _ping(interaction: discord.Interaction) -> None:
await interaction.response.send_message("pong")```
then this
Parameters
name (str) – The name to create the command with. By default this uses the function name unchanged.
with_app_command (bool) – Whether to register the command as an application command.
**attrs – Keyword arguments to pass into the construction of the hybrid command.
so
@commands.hybrid_command(ctx,with_app_command=True)```
wait
no
it should be in the def
correct
then we don't normally need the interaction parameter?
got it. let me try if this works
uwu
,
we dont talk about that
with that
await interaction.response.send_message("pong")```
becomes
```py
await ctx.send_message("pong")```
ctx.send
ah yes
Hm
great. it doesn't work
ew
...?
pog 
ewu

😆
are we sure it is @commands.hybrid_command and not @bot.hybrid_command?
Both are valid
!d
discord.ext.commands.hybrid_command
@discord.ext.commands.hybrid_command(name=..., *, with_app_command=True, **attrs)```
A decorator that transforms a function into a [`HybridCommand`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.HybridCommand "discord.ext.commands.HybridCommand").
A hybrid command is one that functions both as a regular [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") and one that is also a [`app_commands.Command`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Command "discord.app_commands.Command").
The callback being attached to the command must be representable as an application command callback. Converters are silently converted into a [`Transformer`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Transformer "discord.app_commands.Transformer") with a [`discord.AppCommandOptionType.string`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.AppCommandOptionType.string "discord.AppCommandOptionType.string") type.
Checks and error handlers are dispatched and called as-if they were commands similar to [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command"). This means that they take [`Context`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context") as a parameter rather than [`discord.Interaction`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction "discord.Interaction").
All checks added using the [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") & co. decorators are added into the function. There is no way to supply your own checks through this decorator.
New in version 2.0.
wait a min, do I still need client=discord.Client()?
bot.hyb.... if not in a cog
idk why I missed that
It's a Bot thing so you'd need commands.Bot
that one is defined
okay. this solved one problem. slashcommands work now
but ones using prefix don't
did you enable the message_content intent?
class SlashBot(commands.Bot):
def __init__(self) -> None:
super().__init__(command_prefix=(['li ','Li ']), intents=discord.Intents.default())```
this is what I have
but it'd be like a annoying spam cause the old msg (same) wont be deleted...
i need to delete the old msg and resend it once a msg is send in a channel
enable the message content intent first too
def __init__(self) -> None:
intents = discord.Intents.default()
intents.message_content = True
super().__init__(..., intents=intents)
make sure to enable the message content intent from the Bot tab of the app from the discord developer portal as it is a privileged intent
yay. both works. thanks dude.
now it is just a matter of time to make this work for my older bot
pleasure is mine
goodluck 
@drifting gobletI don't konw anything about discord bots…. and, I don't understand what you want: what is "2 multiple file"?
how to edit a embed field?
Couldn’t have guessed myself
Any recommended sources except the python discord and the docs?
for discord bots? I'd suggest taking a look at https://tutorial.vcokltfre.dev/ if your just beginning or something
Oka
so
I want a message looking like this: @user, if you fucked up, contact the bot owner which is @me
is it possible to have it indeed ping the user but not ping me in the message?
No
@slate swan
Even this pings me 💀
oh dear
even if you add a slash it would ping you ofc even if its not formatted
yeah
Then just change my idea a little bit? Think creative.
Send the message, once a new message has been sent in the channel, delete the old message and send it again?
.
how can I thread in discord.py
Preview :
in on ready I've the script check and do requests continuously but I cant use other commands
like
@client.command
because it's a loop, what should I do?
C:\Program Files (x86)\Python37-32\lib\threading.py:865: RuntimeWarning: coroutine 'Command.call' was never awaited
self._target(*self._args, **self._kwargs)
this is the error
command()
I know thats not hte problem
@client.command()
async def add(ctx,id):
Do you also have a normal function called add
Nvm
no that's just it
^
What are you trying to thread
Why
because async on_ready has a while loop
and it cant pause or something if I do the add command
a task would be enough
can you demonstrate what's a task?
!d asyncio.create_task
asyncio.create_task(coro, *, name=None)```
Wrap the *coro* [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine) into a [`Task`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task "asyncio.Task") and schedule its execution. Return the Task object.
If *name* is not `None`, it is set as the name of the task using [`Task.set_name()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.set_name "asyncio.Task.set_name").
The task is executed in the loop returned by [`get_running_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop "asyncio.get_running_loop"), [`RuntimeError`](https://docs.python.org/3/library/exceptions.html#RuntimeError "RuntimeError") is raised if there is no running loop in current thread.
you should use the internal AbstractEventLoop attribute the Bot class has
because Bot.loop returns that class 
hmm
and its a cool word😳
that seems hard
It won’t return it tho
return what? the coros value?
Try printing bot.loop
💀 ok
Abstract event loop is unimplemented. Just for annotations and stuff
It’s never actually used
it never gets used but it gets set when running the bot afaik
since I don't understand I'll just make it pause every 3 secs lol

!e import asyncio; loop = asyncio.new_event_loop(); print(loop)
@torn sail :white_check_mark: Your eval job has completed with return code 0.
<_UnixSelectorEventLoop running=False closed=False debug=False>
it returns an internal class? weird
Abstract event loop is just for typing and stuff
And if u wanna make ur own event loop
are you sure the class that gets shown isnt a child class of AbstractEventLoop or something?
It is a child class but AbsractEventLoop is something that needs to be subclassed
Cause it’s an abc
i need to check asyncio's src lol
okimii can I put a async def function in a normal one?
a coroutine obj in a function? yes you can but you cant await it/call it
how do I get a desktop friendly clickable message link 
def f1():
async def f2():
...
this thing sure
Hmm
another question
I've a list that a for loop loops around and it's under a while loop
You mean matrix?
how do I make the for loop when it finishes the table (finishing doing whatever with all the content of the list) I want it to time.sleep()
Or what kind of table do you mean
list
Ok
bec if I do a time.sleep after it, it will rest every time she checks one only
You don't time.sleep() in discord bot you await asyncio.sleep()
will that solve the issue?
I don't really understand your issue but you definitely shouldn't use time.sleep because it blocks your whole bot
bounties = ["2887966607","700032621","1858461594"]
@client.event
async def on_ready():
bounty_channel = client.get_channel(998183276084744232)
while True:
for bounty in bounties:
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
can you show me an example of it in some code
Where did the usage examples go
nested functions🧍
There surely were some
Used pretty often in decorators yk
I dont see any
Especially at custom checks
most decos use nested functions yes
@sturdy tapir scroll up the examples are on top of that docs page, there are examples for cogs and non cogs
found this
@tasks.loop(seconds = 10) # repeat after every 10 seconds
async def myLoop():
# work
@client_event
It is a separate func
sorry
yeah and hows that
^
3rd code block from very top
You don't even need most of that stuff
What do I need exactly?
@tasks.loop(minutes=5)
async def my_task():
# await bot.wait_until_ready()
...
my_task.start()```
You might need to wait until ready might not, depends on your case
I'll test it
python can/does use camel case either way
!d discord.ClientUser.edit
