#discord-bots
1 messages · Page 643 of 1
And me getting young ngl
proof m sending it before
thats why i asked for the code too, lmao
async def register(ctx):
def check(msg):
return msg.channel == ctx.channel and msg.author == ctx.author
view1 = Confirm()
embed=nextcord.Embed(description="Do you wish to continue?", color=nextcord.Color.blurple())
await ctx.send(embed=embed,view=view1)
await view1.wait()
if view1.value is None:
embed=nextcord.Embed(description=f"❎ Timed Out!")
await ctx.send(embed=embed)
elif view1.value:
try:
with open("usersforteams.json", "r") as f:
users = json.load(f)
channel = await ctx.author.create_dm()
await channel.send("Please enter your in-game name!")
msg = await bot.wait_for('message', check=check, timeout=60)
ign = msg.content
await channel.send("Please enter your in-game user ID!")
msg = await bot.wait_for('message', check=check, timeout=60)
uid = msg.content
if str(ctx.author.id) in users:
return await channel.send("❎ You have already registered!")
elif str(ign) in users:
return await channel.send("❎ This in-game name already exists!")
elif str(uid) in users:
return await channel.send("❎ This in-game user-id already exists!")
else:
users[str(ctx.author.id)] = {}
users[str(ctx.author.id)]["IGN"] = ign
users[str(ctx.author.id)]["UID"] = uid
embed=nextcord.Embed(description=f"✅ You have been registered!")
await ctx.send(embed=embed)
with open("usersforteams.json", "w") as f:
json.dump(users,f)
return True
except asyncio.TimeoutError:
embed=nextcord.Embed(title="❎ Timeout to respond!",description=f"{ctx.author.mention} this process has timed out! Please re-do the process again if you wish to register!")
await channel.send(embed=embed)
return
else:
embed=nextcord.Embed(description=f"✅ Process Cancelled! ")
await ctx.send(embed=embed)
return
!code dude
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
My eyes 😬
may God bless 'em
@bot.command(aliases=["reg"])
async def register(ctx):
def check(msg):
return msg.channel == ctx.channel and msg.author == ctx.author
view1 = Confirm()
embed=nextcord.Embed(description="Do you wish to continue?", color=nextcord.Color.blurple())
await ctx.send(embed=embed,view=view1)
await view1.wait()
if view1.value is None:
embed=nextcord.Embed(description=f"❎ Timed Out!")
await ctx.send(embed=embed)
elif view1.value:
try:
with open("usersforteams.json", "r") as f:
users = json.load(f)
channel = await ctx.author.create_dm()
await channel.send("Please enter your in-game name!")
msg = await bot.wait_for('message', check=check, timeout=60)
ign = msg.content
await channel.send("Please enter your in-game user ID!")
msg = await bot.wait_for('message', check=check, timeout=60)
uid = msg.content
if str(ctx.author.id) in users:
return await channel.send("❎ You have already registered!")
elif str(ign) in users:
return await channel.send("❎ This in-game name already exists!")
elif str(uid) in users:
return await channel.send("❎ This in-game user-id already exists!")
else:
users[str(ctx.author.id)] = {}
users[str(ctx.author.id)]["IGN"] = ign
users[str(ctx.author.id)]["UID"] = uid
embed=nextcord.Embed(description=f"✅ You have been registered!")
await ctx.send(embed=embed)
with open("usersforteams.json", "w") as f:
json.dump(users,f)
return True
except asyncio.TimeoutError:
embed=nextcord.Embed(title="❎ Timeout to respond!",description=f"{ctx.author.mention} this process has timed out! Please re-do the process again if you wish to register!")
await channel.send(embed=embed)
return
else:
embed=nextcord.Embed(description=f"✅ Process Cancelled! ")
await ctx.send(embed=embed)
return
Now they are blessed ngl
how do I pass perms integer to this? ```py
perms = ctx.channel.overwrites_for(role)
perms.send_messages = False
oof
Try removing the try except so u will know which wait_for is being triggered. I think I know the issue
perms = discord.Permissions(int) ig?
I need to pass a overwrites..?
Try doing that bruv. It returns a dict when u do dict(discord.Permissions(8))
It's an old problem for which he's asking for help when u were asleep/gone Eevee
Hmm
Interesting, good luck again
There's always dict(discord.Permissions())
timeout error..
:incoming_envelope: :ok_hand: applied mute to @prisma spoke until <t:1638361789:f> (9 minutes and 59 seconds) (reason: newlines rule: sent 115 newlines in 10s).
Whats the event for when a command gets invoked
<@&831776746206265384> any help?
!d discord.on_command
No documentation found for the requested symbol.
!unmute 885006461002977280
:incoming_envelope: :ok_hand: pardoned infraction mute for @prisma spoke.
Bruv
!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.
thanks
oof
Anyways it's on_command
Use this for large text @prisma spoke
Thanks Chris!
what bout errors?
really
Doesn't exist?
The bot is having a stroke
Traceback (most recent call last):
File "C:\Python310\lib\asyncio\tasks.py", line 458, in wait_for
fut.result()
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 168, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\admin\Downloads\underdev.py", line 173, in register
msg = await bot.wait_for('message', check=check, timeout=60)
File "C:\Python310\lib\asyncio\tasks.py", line 460, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\nextcord\client.py", line 351, in _run_event
await coro(*args, **kwargs)
File "c:\Users\admin\Downloads\underdev.py", line 67, in on_command_error
raise error
File "C:\Python310\lib\site-packages\nextcord\ext\commands\bot.py", line 995, in invoke
await ctx.command.invoke(ctx)
File "C:\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 895, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 177, in wrapped
raise CommandInvokeError(exc) from exc
nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: TimeoutError:```
timeout error
And now tell me which wait_for is there in Line 173
bruh i also know that we are trying to solve an unexpected issue can u help?
you have msg = await bot.wait_for('message', check=check, timeout=60) on line 173
game one..
Game?
write ur ingame name one..
so just try/except that error
ik that
But it's triggering before 1 min, as he is saying
i did..
its not forwarding the process i said
Have you saved the file, and restarted your bot?
Nvm
i swear if that wud be the issue imma cry
lemme do it once again
so how to fix it
👌
?
lmao
what are you looking for?
hm
!d discord.on_command doesn't work
No documentation found for the requested symbol.
lmaooo
an event for when each command gets invoked, i wanna count that in my database
!d discord.Client
it isn't having a stroke
Most of the other classes work
it doesn't exist?
Only with some of them
!d discord.ext.commands.Command
thanks
O it's in the commands namespace
Still the bot doesn't recognize it
alr i did it
@vocal magnet but same issue
Ahhh
@prisma spoke I'm looking at the code you tried to send but I see no try-except
cuz i cutted it out 
@maiden fable told to..
I'm guessing the symbols aren't setup correctly for it in the docs
two admins nice
so we were finding the error
!paste Try sending your code here vvv
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.
there isnt any event for checking commands invoked
We hardly see any admin here ngl
on_command Eevee
Same happens with tkinter docs
lol
Ok ok, lemme edit it
uh @maiden fable https://docs.disnake.dev/en/latest/ext/commands/api.html#discord.on_command not loading for me
does it exist in 2.0?
Gender confusion lol
o
@vocal magnet @jaunty sparrow ..
No lol
Nahhh, I call everyone bro most of the times czzz idk 😬
🤣
is it cuz m using bot and not client?
it got moved into the commands folder hm
No
That should work.
Try changing one of the strings
and see if it appears on your bot when you run the command
this is the error right?
wdym?
@maiden fable when will the timeout button come?
Idk, but till now the endpoint hasn't been released
I didn't keep up with any new libs. Any suggestions for a lib?
error handler i have
embed=nextcord.Embed(description="Do you wish to continue?", color=nextcord.Color.blurple())
change the description slightly
and see if the change appears when you run the command
I don't think your changes are actually being deployed to your bot
hm
will @unkempt canyon consider using time out buttonif discord adds it?
no
it's not a same thing as mute?
Meanwhile moderation bots: WHY does discord has to add each feature we have?!?
mute exists, why would they add the same thing as mute
one sec
whats the difference
We'll probably use it, but still keep it as a command so that we can log it in the db. That way we don't need to worry about maintaining the scheduler to remove the muted role
I just asked
Also we can get rid of the muted role too
Something well-supported and maintained
long time no see NIR
There's also gonna be an audit logs entry for the same
!pypi disnakw
!pypi disnake
Yea, since we don't need the code to actually remove the role after the mute lapses.
Why not sis xD
and we don't need to remove to add channel overrides for the muted role on every new channel we make
@tawdry perch new event to add to your bot
@vocal magnet it changed yes
Yeah school didn't gave me any time for hobbies really
Nah, better is to call by name tbh
Thanks
for the button? If yes fk
🤣
oof, how ya doing?
Interesting
dudes i need your help in the new bot dev portal i cant find the url needed to be put in the oauth2 section to save permissions were can i find it ? im a newbie pls help
It is based off of discord.py right?
OAuth2 > URL Generator
yes disnake is based of dpy
Yups dpy 2.0
I'm fine really, how about you?
And one last thing, does it have a discord server?
in the generated ui it just says please enter a redirect ui
it doesnt generate anything
Yea
pretty good, swithced to disnake and had a lot of painful hours of doing that stuff
Care sending a pic?
so what do i do ?
its oauth2 url generator
And which scopes u selected?
no idea
is it cuz of my check?
return msg.channel == ctx.channel and msg.author == ctx.author``` it has return msg.channel == ctx.channel
like i said im a newbie
and i am doing the msg in guild and process in dm
https://discord.com/oauth2/authorize?client_id=<YOUR CLIENT ID>&permissions=2147568640&scope=bot%20applications.commands
@sullen shoal rn: 🤬
In this url, replace <YOUR CLIENT ID> with the Client ID from the General Page
Your bot gonna get ratelimitef
dont use REPLIT!!
@vocal magnet @maiden fable i solved the issue...
If hes not having a problem with it leave him alone
github.dev + google colab
okay
Mind explaining me?
If replit is working for him chill ik its not great but people dont have god like pcs
but i need a solution right now about tht
also replit + browser will use more ram than vscode
google colab to test the code, and github.dev is basically vscode in browser
It was correct tho
it was msg.channel == ctx.channel
how do i solve my problem were can i get the url ?
and the process was in dms
url?
@sullen shoal is your pfp a pig or a demon i cant tell😭
Ah, u will still need to keep the tab open of VSC
demon
uri
Nah bruh thats a pig nose😭
You never told us that u ain't invoking the command in DMs
how can I delete role perms from channel, the whole role out
this was easy before why the hell did they make it so complex
i didnt tell that..
were can i find a good uri
!d discord.TextChannel.edit_permissions
yep but better than replit at least
!d discord.TextChannel.edit
await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
Changed in version 1.3: The `overwrites` keyword-only parameter was added.
Changed in version 1.4: The `type` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
hm
Change the permissions
it is something of both
i even did channel = await ctx.author.create_dm() @maiden fable
if everything is 0, it will remove the role out of channel?
😭
in the code
can anyone help me pls
class Pig: ...
class Demon: ...
class Myxi(Pig, Demon): ...```
hope it explains it well
Yes it does😭
how to mke a command that will fetch a categ by its id then check how many channels are there in that nd delete all those channels?
Hello, I'm trying to make a discord bot for welcome card. For now I have this, but the circle is cut on the top
from PIL import Image, ImageDraw, ImageFilter
im1 = Image.open('card4.png')
im2 = Image.open('prof.png')
mask_im = Image.new("L", im2.size, 0)
draw = ImageDraw.Draw(mask_im)
draw.ellipse((343.19, -34.12, 549.19, 171.88), fill=255)
mask_im.save('mask_circle.jpg', quality=95)
back_im = im1.copy()
back_im.paste(im2, (100, 50), mask_im)
back_im.save('test.png')
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
this proves am a noob. someone please help me find the error
really stupid question but
how do I create variables in the function parameters of a command?
member
not Member
do - textsize[0] or whatever ur text size is defined as
wdym?
so to read in args with a command
async def test(ctx, var, var2):
like that but I know I am doing something wrong
what do u wish to do?
Those are nonetype positional arguments
can i see the code?
u dont need to.. to solve that error..
ik
he wrote Member.avatar_url
ik
yes, but it's not working
@client.command(aliases=['av'])
async def avatar(ctx, member : nextcord.member = None):
if member == None:
member = ctx.author
memberAvatar = member.avatar_url
avatarEmbed = nextcord.Embed(title= f"{member.name}'s Avatar")
avatarEmbed.set_image(url = memberAvatar)
await ctx.send(embed = avatarEmbed)
Wdym by "not working"
simple avatar command
nextcord.Member
why assign a var to it..
i told u 🤷
@client.command(aliases=['av'])
async def avatar(ctx, member : nextcord.Member = None):
if member == None:
member = ctx.author
memberAvatar = member.avatar_url
avatarEmbed = nextcord.Embed(title= f"{member.name}'s Avatar")
avatarEmbed.set_image(url = memberAvatar)
await ctx.send(embed = avatarEmbed)```
u can directly use it
huh?
He type hinted it wrong you really didnt
My bad for the rough explanation but I want to read in arguments for a command e.g. .test bob 42
from nextcord import Member what?
You want many arguments in a var?
it works for my bot but i use discord py
no I want to make the variables in the functions parameter
its a wrong practice
eh?
async def test(ctx, the vars to be here):
You mean kwargs?
thats it
?
yes..
sorry for the shit explaining
he did from nextcord import Member
Theres no such thing as a var in parameters
got it. Thanks!
i dont usually do discord.Embed or discord.User or all that stuff
.. anyone?
def func(*arg,**kwarg)
nextcord is different that discordpy. it could be different, idk
also consider reading nextcord's docs
it is avatar.url
async def makecall(ctx, num1):
if num1 == None:
await ctx.Send("missing num1")
nvm fixed it
in nc
alright
ctx.send*
Thats a arg?
yeah thats what I said
i cant remember much of nextcord since discord-py-interactions doesnt work with it
also num1 : int*
You said var.......
ok ok
Not needed tbh
he wants to return a num 🤷
thank you so much, I was looking for that as well
.
Or maybe arg num1
Really cant assume but suggest
well he named it num1 so yeyah
this still considered wrong practice even though the command works perfectly? https://prnt.sc/218v7f2
ur welcome
this is just a portion
Yea i get it but you should just be like: if its a int type hint it
what in the world
why wud u import Embed
its already there when u do import discord
and commands
Guys, please help. I seem to have connected MySQL correctly, but it gives an error. I am creating a discord bot of the economy #help-cheese
true and can u help me?
With what exactly?
ik but i do it differently
thats called uselessly
but everyone has a different way of coding
ur point proves nothin
i gave u my question.. do uk the answer to that?
@brave moth btw dont do this
import disnake,asyncio
Give me a sec
Pep8 says not too
Soo?
I think you can get the category id and iterate through all existing channels
its just increasing ur imports unecessarily
lemme try
alr it worked thx.. and is it possible to divide a json file into 2 parts/2 json files..?
For what exactly?
eh a tourney managerbot m making..
if I write a command, then the bot thinks that such a command does not exist
Are you using json as a db?
..no and yes
why are you nesting classes
u have no values in ur embeds
Yeah dont
i didnt get my answer tho..
And i dont think so idk dont work with json
I don't wanna say anything dumb
I don't use nextcord
this?
but unless it's not in a cog, I don't think @commands.command() will do much
Yes that
u have no values there
it cog
Your sending nothing
dont use commands.command
show me where
IT COG
where?
learn python pleease
how can i get the bot to create a file and attach it to a message?
sus never did that.. lemme check
you got problems with creating the file or sending it?
also u r doing it wrong..
!local-file
Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:
# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")
# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
file = discord.File(f)
When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.
discord.Embed instances have a set_image method which can be used to set an attachment as an image:
embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png") # Filename here must be exactly same as attachment filename.
After this, you can send an embed with an attachment to Discord:
await channel.send(file=file, embed=embed)
This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.
is it possible to get the amount of messages a user has sent in that guild by getting attributes from the search feature in discord, or will i have to use a database for that? im referring to this:
to learn creating a file, you'll have to use like pillow or something
i need the bot to create a file with a custom name
I guess you meant a picture
A maintained fork of Danny's discord.py. Contribute to nextcord/nextcord development by creating an account on GitHub.
!d os ?
he is saying that he wants to create a cmd like !create then the bot wiwll make a file wit some contents in it as per the details of the user then attack that file and send it
u do !create the bot asks u for the contents then u write it then the bot converts it into a file format u wnant then sends it
???
well send has a file kwarg
ahh
!d discord.abc.Messageable.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
i never worked with it
here's written how the file kwarg is used
.. u need to convert the file also..
to a discord.File object
u do !create hello the bot will create a txt file withcontent as hello
yes
how to convert that msg to a file format?
Source code: Lib/os.py
This module provides a portable way of using operating system dependent functionality. If you just want to read or write a file see open(), if you want to manipulate paths, see the os.path module, and if you want to read all the lines in all the files on the command line see the fileinput module. For creating temporary files and directories see the tempfile module, and for high-level file and directory handling see the shutil module.
Notes on the availability of these functions:
actually, use the tempfile module instead
since this tag above says it
well I dunno, I didn't know this module existed
once he has the file tho, he's just gonna get a File object out of it and send it
if you're asking yourself how you're gonna get the File object,
file = discord.File(fp, filename=None, *, spoiler=False)
what if i want the bot to create a folder? Can you do this?
"For creating temporary files and directories see the tempfile module"
how to do somethin lke the user will do !choose 2 then the bot will randomly pick out 2 random things from the json file and then send em for example :- the output:- 2 vs 2
2 vs 2
as the user wanted 2 outputs it chose 2 and 2 vs if u r getting me
use bytesio
how come
from io import BytesIO
string = BytesIO(bytes("This is a test", "utf-8"))
await ctx.send(file=discord.File(string, filename="test.txt"))
..
doesn't look bad
i want to ask that how to create a command if someone delete the channel/role how bot recover it?
I mean why would you create a temp file
!d random.choice
random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
yes event you know?
sike I thought
!d discord.on_guild_channel_update
discord.on_guild_channel_update(before, after)```
Called whenever a guild channel is updated. e.g. changed name, topic, permissions.
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
That should work
bot recover ?
!d discord.on_guild_update or this, ig
discord.on_guild_update(before, after)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") updates, for example:
• Changed name
• Changed AFK channel
• Changed AFK timeout
• etc...
???
this work on channel delete bot recreates its
I wanted something that's not so boomer
discord.on_guild_channel_delete(channel)``````py
discord.on_guild_channel_create(channel)```
Called whenever a guild channel is deleted or created.
Note that you can get the guild from [`guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel.guild "discord.abc.GuildChannel.guild").
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
There (:
bruh i am saying if someone delete the channel/role bot recreate it
thats a scem
Because DM is also a channel
!d discord.on_guild_role_delete
discord.on_guild_role_create(role)``````py
discord.on_guild_role_delete(role)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") creates or deletes a new [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role").
To get the guild it belongs to, use [`Role.guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role.guild "discord.Role.guild").
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
what if they really wanna delete it
lesgo
And Eevee saves the day
you whitelist yourself
yes u need to fetch the role name and then re create it
how do that
but it's not gonna completely recover it
i understand now why ppl love/like you
unnecessary xD
messages gone, id changed
Aw why that
Blush
just fetch the role and re create it @slate swan
u a boy or a girl?
again, the id of the role will change
Who says that tho 🤨
!ot
Off-topic channels
There are three off-topic channels:
• #ot2-never-nester’s-nightmare
• #ot1-perplexing-regexing
• #ot0-psvm’s-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
thats anonymous
🤣
oof
oof3
i cant understand
he wants to make an anti nuke bot ig
wait
Best of luck getting ratelimited then
who tf's gonna nuke a server
if he doesn't have permissions
with the discord.on_guild_role_create(role) discord.on_guild_role_delete(role) function u can detect the role change and do the needful actions
oof
me
hecker
Some 12 year old hot tempered kids
many ppl betray...
Hmm, said wrong tho
huh? why?
also dont re create it just ban the user
Imagine when someone is cleaning up roles 😐
"maybe"
LOL
🤷♂️ your wish
(saved from ratelimit)
Rip that person
@maiden fable @slate swan
he told us he gonna have a whitelist
good hunter
@commands.Cog.listener()
async def on_guild_role_create(self, role):
with open('whitelisted.json') as f:
whitelisted = json.load(f)
async for i in role.guild.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.role_create):
if i.user.bot:
return
but like
like this?
whitelisting on something like this
json...
is the same as not giving him permissions
If a user is in a whitelist the bot won't even respond
;-;
please tell me your database is not a json file
wut?
explain noe plish
indentation..
🤣 it's self explanatory
it's discord bro @prisma spoke
!ot Anyways
Off-topic channels
There are three off-topic channels:
• #ot2-never-nester’s-nightmare
• #ot1-perplexing-regexing
• #ot0-psvm’s-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
Bruh not the JSON controversory
@slate swan use a counter instead of recreating, if the counter value exceeds, kick that person
yes so?
He talking about that specific key
evrytn understandable but "Depends"....nvm dont answer tht imma yeet myself ciao
so the indentation is right
Lmao, that's me 🤷♂️
Short answer yea I am single but that's an evergreen answer
that there but on damage bot recovers simply i want to do that@prisma spoke
makes sense
just use these two events
Hmm, I see, but you need to keep track of the role permissions
and recreate it using them
@commands.Cog.listener()
async def on_guild_role_create(self, role):
with open('whitelisted.json') as f:
whitelisted = json.load(f)
async for i in role.guild.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.role_create):
if i.user.bot:
return```
async defs indentation
fetch the name of the role
Welp I am out, my IQ too low for all this
that why i am taking help about that
you aren't alone
Bye
Lessgo
anti nuking, I see
Hi
but if its a public bot how other fetch the role
I'm also gonna go because I sense too many shitposters
yes
with the on_delete_function?
search google
@slate swan Why don't you see every bot account added and ask a staff member to authorize it but the person who added it
Like me?
idk much bout audit logs
No he's probably talking about me
Eevee gonna help them all since she got more IQ than us all combined
how would you be a shitposter
that seems like an insult, bye
Does it? It was meant to be a compliment tho
didnt seem like it dear
That's just me thinking tho 🤷♂️
close your eyes and dont
I am just saying that u got more IQ than all our IQs combined
smh bye
😐
dont what?
@bot.command()
async def start(ctx):
player = ctx.author
conn = sqlite3.connect('test.sql')
c = conn.cursor()
c.execute(f"UPDATE data VALUES('{player.id}', 100)")
conn.commit()
conn.close()
await ctx.send('you have started your journey with **100:nexus:** in your balance')```
"VALUES" syntax error
Becoming OT. Also let's leave it. They are uncomfortable with this talk
test.db*
and c execute also wrong
don't execute commands in databases like this
the file is in .sql
Sqlite?
hmm i guess thats why its highlighting VALUES
yes sqlite3
That doesn't matter. U can run a .txt file in Python also
#databases message @slate swan
yes u do smthn lik ethis await cursor.execute('Select * from users where user_id = ?',(member.id,))
not f strings
why are there two spaces between data and VALUES
is that causing a problem or just triggering me
isnt select use for to print values? and INSERT to add?
Its sqlite3 so it's not async
Yes u replace that
wtf
i used dbbrowser for sqlite so yeah
Triggering me too ngl
if that's not his point, he's not gonna change that
just an example of how u shud replace f strings...
ohhh
in database structures*
the heck is going on
But doesnt want to apply brain explaining how thats gonna happen xD
shitposters everywhere
..
damn
guess ima dip
on_member_update
what the command
imagine if the owner comes and sees some questions..
!d on_member_update
No documentation found for the requested symbol.
bre
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...
idk audit logs thing much i told u
okay
try it and see
member is not defines'
async for i in member.audit_logs(limit=1, after=datetime.datetime.now() - datetime.timedelta(minutes = 1), action=discord.AuditLogAction.member_update):
NameError: name 'member' is not defined
how do I put cooldowns in commands for each user?
ig its an event then
nvm
@client.event ?
@ client.command
read the error
member is not defined

Not in a codeblock 
@commands.cooldown(1, 30, commands.BucketType.user)
decorator of a command @slate swan
Thats for cooldowns
yes
Of the command not for a exact user
it's for users
And you cant use it in a event
How?
.
Never seen it been done before
isn't that what commands.BucketType.user does
learn english please
Not sure let me check docs
well I searched this on StackOverFlow
it's completely copied

I'm asking myself why other people can't do the same thing
- docs
- stackoverflow
- here
cuz they dont know python
these are the options in order
soo 30 represents second?
quite sure
users does cooldown on User object scope
if you want it to be within the server use member
@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.
A command can only have a single cooldown.
you dont need to
Always like too
you already know that User is not member
Yeah but docs is just cool to check out 
!resources or #python-discussion or #❓|how-to-get-help
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
for me?
definitely
uh ok
why i cant talk at voice chat ?
You need the voice verified role
TypeError: on_member_update() missing 1 required positional argument: 'after'
I get this error when trying to activate this event
async def on_member_update(member, before, after):
temp = discord.Object(910800167664488508)
if len(before.roles) < len(after.roles):
newRole = next(role for role in after.roles if role not in before.roles)
if newRole.name == "Banned":
await member.send(f"{member.mention} work?.")```
remove the member parameter
that will just rise another error?
definitely not
!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...
before, after
where is member defined then/
before and after are both member objects
so you think removing member will fix the code?
yes
alr lets see @kindred drum
and he can use after.send()
That really has a send attr?
Thats kinda cool ngl
Wym 🤨
Yeah ik
O nvm, you already got more IQ than me so I take time to understand things ;-;
No I am Hunter
fawk
(:
Sad, still broken
What
what's broken
Tbh the reason I ain't able to help u with this properly is cz I don't use webhooks that much
everything just 1 function for removing role perms from channel + removing the role wrong channel
It got fixed 'bout 2-4h ago
O
how do i make bot dm user msg
I like confusing people....
who do you want to send it too?
user who used the command
I understand it tho ngl
!d discord.ext.commands.Context.author
Union[User, Member]: Returns the author associated with this context’s command. Shorthand for Message.author
💀
uh
no i mean how do i make the bot dm user msg
ctx.author.send
Hehehe (:
This is a bit broken
so lets say i have this minimalhelpcommand class which gets the destination of channel then sends help
Facts
so idk if destination.author.send would work 🤔
Yea it won't
here's ma help command
class MyNewHelp(commands.MinimalHelpCommand):
async def send_pages(self):
destination = self.get_destination()
for page in self.paginator.pages:
emby = discord.Embed(description=page)
await destination.send(embed=emby)
bot.help_command = MyNewHelp()
💀
!d discord.ext.commands.MinimalHelpCommand.dm_help
A tribool that indicates if the help command should DM the user instead of sending it to the channel it received it from. If the boolean is set to True, then all help output is DM’d. If False, none of the help output is DM’d. If None, then the bot will only DM when the help message becomes too long (dictated by more than dm_help_threshold characters). Defaults to False.
There (:
my guy 💀 i really have to use a commands.MinimalHelpCommand.dm_help
so I have
async def test(ctx, var, var2, var3):
if var is None:
await ctx.send("Var is empty")
and so on
but it's not executing the ctx.send to say its None
I have tried that too
set the default value of all your your parameters to
None
oh yeah
I was doing var : int
async def test(ctx, var=None, var2=None, var3=None):
no
ain't it
num1 : None
?
not giving them will result in an error
instead of setting it to none
num1: int = None
That's a good habit
😄
That's the best way to declare parameters
what
but all I get is this discord.ext.commands.errors.MissingRequiredArgument: num1 is a required argument that is missing.
but its not doing ctx.send
its so weird and bizarre
Because it is a traceback callback, your function stop working cuz a required argument is missing
do this
(:
!d join
!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.
sorry, why my new members system is not working?
!intenrs
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
ohh thanks I'll try it
what is intenrs and where can i get them
https://paste.pythondiscord.com/itenerocax.py
i made this but this can only handle 1 tourney at a time,how to make it handle more than 1?
it is intents i guess
await client.process_commands(msg)
u need to put this at end of event
or wdym?
no intents dont need thhat
um
..
Intents*
Everybody at some point
class MyNewHelp(commands.MinimalHelpCommand):
async def send_pages(self):
destination = self.get_destination()
for page in self.paginator.pages:
self.dm_help = True
emby = discord.Embed(description=page)
await destination.send(embed=emby)
async def on_help_command_error(error):
await destination.send("We had an error. Try running the command again.")``` how make bot dm help
so how did I remove role from channel, I alrd forgot
U gotta set that in the init...
I told u before bruv
Has anyone done so far Mee6 welcome cards on custom discord bot?
somehow, yes
!d PIL
!d discord.TextChannel.edit
await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
Changed in version 1.3: The `overwrites` keyword-only parameter was added.
Changed in version 1.4: The `type` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
find what
way to delete a role from a channel
Like remove the role overwrites?
no, you just don’t know how to find what youre looking for
so it's just a function inside of a function 💀
read overwrites kwarg
when you go to edit channel -> select role -> scroll down click this
but with bot
!d discord.TextChannel.overwrites
property overwrites: Dict[Union[Role, Member], PermissionOverwrite]```
Returns all of the channel’s overwrites.
This is returned as a dictionary where the key contains the target which can be either a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") or a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") and the value is the overwrite as a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite").
def __init__(self): momen
what about this?
!d discord.TextChannel.set_permissions || you can just do this
await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sets the channel specific permission overwrites for a target in the channel.
The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that belongs to guild.
The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.
If the `overwrite` parameter is `None`, then the permission overwrites are deleted.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this...
.bm As I'm going to eat, I will forget this so I book marked
It's not a function...?
U do it in the init self.dm_help = True
oh i thought you meant __init__
def __init__(...):
super().__init__(...)
self.dm_help = True
What did you mean by function inside a function?
It's a function...
💀
Mayhabs
Hmm
@bot.command(aliases=["reg"])
async def register(ctx):
with open("usersforteams.json", "r") as f:
users = json.load(f)
if str(ctx.author.id) in users:
return await ctx.send("❎ You have already registered!")
def check(msg):
return msg.author == ctx.author
view1 = Confirm()
embed=nextcord.Embed(description="Do you wish to continue?")
await ctx.send(embed=embed,view=view1)
await view1.wait()
if view1.value is None:
embed=nextcord.Embed(description=f"❎ Timed Out!")
await ctx.send(embed=embed)
elif view1.value:
try:
channel = await ctx.author.create_dm()
await channel.send("Please enter your in-game name!")
msg = await bot.wait_for('message', check=check, timeout=60)
ign = msg.content
if str(ign) in users:
return await ctx.send("❎ This in-game name already exists!")
else:
await channel.send("Please enter your in-game user ID!")
msg = await bot.wait_for('message', check=check, timeout=60)
uid = msg.content
if str(uid) in users:
return await ctx.send("❎ This in-game user-id already exists!")
users[str(ctx.author.id)] = {}
users[str(ctx.author.id)]["IGN"] = ign
users[str(ctx.author.id)]["UID"] = uid
embed=nextcord.Embed(description=f"✅ You have been registered!")
await channel.send(embed=embed)
with open("usersforteams.json", "w") as f:
json.dump(users,f)
return True
except asyncio.TimeoutError:
embed=nextcord.Embed(title="❎ Timeout to respond!",description=f"{ctx.author.mention} this process has timed out! Please re-do the process again if you wish to register!")
await channel.send(embed=embed)
return
else:
embed=nextcord.Embed(description=f"✅ Process Cancelled! ")
await ctx.send(embed=embed)
return``` this doesnt send the msg that "this uid exits" this msg it doesnt send nd ussers can register with saame ign and uid ho to solve?
Drunk... Not on alcohol tho, since I am underage
caught 4k
🤣
..
sneaky Hunter
Hehehe u wish
help me..
You know am too lazy today, i'll try wait
Is it just me or your code snippets are always sooo long 
||ma'am||
If u r lazy, then I.... uhhh nvm I don't wanna roast myself
||jk no offense||
Stop with that, that convo is over tbh
Hehehe I am the laziest person
why are you doing
for str(uid) in users:
#abcd
,-, we already got that over with
light mode
Welp light mode in all dark background. Best eye killer for people like me tbh
its for a register command

Does anyone know/have experience on how Discord decides on how to display URLs
I'm trying to write a regex to match URLs in a message as close to how they are displayed as possible, Discord has some really weird rules on whether to exclude the final character
and i never used for
Can I get some more context?
There dark theme.
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
Long tags go brrr
oof
you know how if you put a link in a message Discord helpfully highlights the link, and the highlighted part would be what you can click on? I'm trying to match the way it highlights with a regex
yes?
hyperlinks?
and so far i found out that ) ] . < ; ' " are not part of the URL if and only if they are the final character:
https://lorem.ipsum/] but https://lorem.ipsum/)dolor
Huh? Highlights the link? Can I see a pic or something?
hyperlinks
Ah
The blue color?
yes
Take them out?
i never used for loop i the reg cmd
@pearl birch
description= [text goes here](url goes here)
this cant be used in the title attribute
!d str.split it returns a list of words in a string and see if any word starts with https://
str.split(sep=None, maxsplit=- 1)```
Return a list of the words in the string, using *sep* as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, the list will have at most `maxsplit+1` elements). If *maxsplit* is not specified or `-1`, then there is no limit on the number of splits (all possible splits are made).
If *sep* is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, `'1,,2'.split(',')` returns `['1', '', '2']`). The *sep* argument may consist of multiple characters (for example, `'1<>2<>3'.split('<>')` returns `['1', '2', '3']`). Splitting an empty string with a specified separator returns `['']`.
For example:
no but wanna know what to do?
Si, por favor.
what?
I'm aware but I'm not trying to put it in embeds, I'm just trying to scan messages
Leading whitespace (spaces and tabs) at the beginning of a logical line is used to compute the indentation level of the line, which in turn is used to determine the grouping of statements.
Tabs are replaced (from left to right) by one to eight spaces such that the total number of characters up to and including the replacement is a multiple of eight (this is intended to be the same rule as used by Unix). The total number of spaces preceding the first non-blank character then determines the line’s indentation. Indentation cannot be split over multiple physical lines using backslashes; the whitespace up to the first backslash determines the indentation.
Yes, please.
ohhh, Messages dont contain hyperlinks
ignored again
@peak loom read this.. and learn python
Learn Python isn't how u answer. That seems.... harsh ngl
whats the name of this emoji?
I know python but no matter what I do it doesn't fix!
It's a GIF
its a GIF
||ik that but i got to heard that a lot earlier||
u dont
its basic problem
I do.
Well then it's just toxic most probably (:
||i heard a lot and suffered too||
Same, but in dpy server for me
No. its a basic python problem
its the official discord server of python, you will meet beginners here, you cant stop it
@peak loom You know what indents are? what do you mean by "removing" indents?
So I need some help with a bot
No offense
unindenting the whole line, one time or two times.. as in.
then they shud ask in py help channels not go with discord bots like this but ahh nvm
but you should know indenting ,-,
ik m asking which gif is that emoji copied from?
Indenting is tabing over as many times as needed.
thats an emoji link
yes
from discord import Client
from discord.ext import tasks
bot = Client()
@tasks.loop(minutes=1)
async def loop():
cnl = await bot.get_channel(493451846543998977)
await cnl.send(1)
bot.run(token)
This doesn't work ;-;
Errors?
I'm gonna kill you
None
Don't, I wrote all that on a mobile 😭
stop making fun of beginners
Oh cool I wrote mine on mobile aswell.
Yes. This is what I'm trying to do:
Suppose someone sent a message that says:
This is Wikipedia: https://en.wikipedia.org
Now if you view the message as a person using Discord, you will see that thehttps://en.wikipedia.orgpart is blue, and you can click on it
— I want my bot to be able to find this blue part
I do have a regex to do it, and it's working for the most part, but there are some weird kinks that I'm trying to fix:
If someone sends https://en.wikipedia.org)
Notice how Discord decides to not show the right parenthesis as blue
My code can't tell that, so it will still extract https://en.wikipedia.org)
What I want is to see exactly how Discord decides which part to highlight so I can improve my regex
No but seriously that was me till last year November ;-;
My older self has returned
seek medical attention asap
didn't I literally tell u the answer dude, u will come to know if u stop ignoring me
You forgot to import the .env file into the code itself. Where the TOKEN is.
Nahh, I don't prefer vaccines
Ehhhh I ommited the token
i dont think it has any filters at all, afaik discord will call it a hyperlink if the word contains http:// or https:// until there's a whitespace https://take-this-as-an exmaple
You told me to find https:// that doesn't solve the problem of terminating punctuations
explain what doesn't work
That's also added to links
More of, what even works 😐
interesting, btw discord is written in javascript, and I am clueless about this matter
@bot.command()
async def brackets(ctx, n:int):
with open("usersforteams.json", "r") as f:
users = json.load(f)
a = (random.choices(users, k = n))
await ctx.send(a)```
doesnt work...
you didnt start the loop tho
I meant therapist
Yay u found the first problem
import os
my_secret = os.environ['TOKEN'] #Might be different for you.
does your bot go online
Yea
then you didn't start the loop
i dont think get channel is async either
I'mma just stop this, feels like I am trolling everyone ;-;
also, wait until the bot's ready before getting the channel, and the .get_xxx methods aren't awaitables
https://en.wikipedia.org)
That ending parenthesis ) is not added to the link, if you click it it will take you to https://en.wikipedia.org, not https://en.wikipedia.org)
Yea it ain't
Ah that
numbers in tasks.loop need to be a float ,-,
https://simple.wikipedia.org. a period isn't also added
not really
token aint defined
No
they can also be ints
wait lol, why does mine lag on ints
they're only type-hinted as floats but it doesn't make a difference
Mine doesn't tho
idk, i have some tasks with ints and it doesn't


