#discord-bots
1 messages · Page 1059 of 1
ye
@vale wing how would I make it get the ID of the channel?
how do you make that
@slate swan use @tasks.loop to create a loop and in loop just call clone method of channel object and then delete the original one
!d discord.ext.tasks.loop
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").
!d discord.TextChannel.clone
await clone(*, name=None, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Clones this channel. This creates a channel with the same properties
as this channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to
do this...
Just like you always do with the channel object
The channel ID.
OOP 😀
o ok thanks
so channel.id?
Yes
channel = discord.utils.find(lambda x: x.permissions_for(guild.default_role).send_messages, guild.text_channels)
if channel.permissions_for(channel.id).view_channel:
like that? @vale wing
"find" will return a single TextChannel object in this case in which your bot can send messages, so you dont need to check for permissions again
so channel is already the ID now?
channel is now a TextChannel object
!d discord.TextChannel
class discord.TextChannel```
Represents a Discord guild text channel...
how can I make it the id?
use the id property on channel
so just channel = channel.id ?
no
how can i make it so if someone does a certain amount of cmds in a certain amount of time they get put on cooldown for a certain amount of time
channel_id = channel.id
why is channel_id?
create your own cache?
named it anything you want
what is that
i know its possible i dont know how but like is there a way to make a command that can only be triggered by like one person
a temporary data load, that checks for the amount of cmds for a particular person and puts them on cooldown
so it wont work for anyone but that one person
!d discord.ext.commands.cooldown
@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/latest/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/latest/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType")...
I interpreted "certain amount of cmds" as one command, multiple times
thx
What does this mean
AttributeError: 'Role' object has no attribute '_roles'
that 'Role' object has no attribute '_roles' ....
meaning?
class.attribute
does discord.utils.get(ctx.guild.roles, name="everyone") get the ID for the @ everyone role?
@paper sluice ?
it should be "everyone" with "@" at the beginning
nope, just discord.py v2
20th May
That will return a Role object, to get the id, simply use the .id attribute (also as rud0lf said, it should be @everyone with the @).
you can also use the guild id lol
wasnt it deprecated?
no?
iirc.
the everyone role uses the guilds id thats just how discord made it
f"<@{Guild.id}>"
e.g
why isnt this working
channel1 = discord.utils.get(ctx.guild.roles, name="@everyone")
channel_id = channel1.id
channel?
?
shouldn't it be role1 = ...
Guild.default_role
wait im so dumb
Unless you can fetch everyone role like that
Bc if so you can just copy the channel id from discord and use bot.get_channel(id)
Okay
so the first channel that everyone can view then I want to get the channel ID of that channel
You would then have to look at the permission overwrites for each channel
Check if the guilds default role is allowed in the channel
If it is then that’s the first viewable channel.
How
you need to get the guild object
Then you can get the channels with said guild object
I’m on mobile right now I can’t really type out code
can you try? even if the indentation is wrong its all good
channel2 = discord.utils.get(ctx.guild.roles, name="@everyone")
channel1 = discord.utils.find(lambda x: x.permissions_for(channel2).send_messages, guild.text_channels)
channel_id = channel1.id
@heavy shard
it's okay, just change channel2 to role for readability
still saying 'NoneType' object has no attribute 'roles'
guild is None? are you doing it in private message?
nope
in a servers channel
is it in a command? can you show the code?
Guys can someone help me make a warning system tbf or refer me somewhere
You get everyone role like this
im so confused
!d discord.Guild.default_role
property default_role```
Gets the @everyone role that all members have by default.
so I do name="default_role"
channel = discord.utils.find(lambda x: x.permissions_for(ctx.guild.default_role).read_messages, ctx.guild.text_channels)```
Kinda spoonfeeding but since you couldn't fully figure it out by yourself here it is
Wtf im still getting
'NoneType' object has no attribute 'text_channels'
You probably use it in DMs
im not
Do you have intents enabled
are they needed?
Default ones are I think
Guys any good warning systems ?
!d discord.Intents.guilds
Whether guild related events are enabled.
This corresponds to the following events...
Just make a database with like target | assigned_by | reason | id fields
I don't think you need anything more
now im getting Role' object has no attribute '_roles'
Full traceback please
im done with this
That thing is fixable you probably mistyped something
Can u help me with it or guide me I guess
its to late for this 🤣
I’m using a cog
@warped mirage do yk how to use databases generally
Yes but no at the same time well it’s hard to explain . Do I use 1 database for entire bot ?
Yes why not
I use aiosqlite for my levelling system .
You mean CREATE TABLE statement?
Nah the actual warning system with remove well everything
Erm
The warnings system is in the same bot with the levelling system?
Doesn't really matter anyways just execute CREATE TABLE IF NOT EXISTS
It is not a destructive action
I’m using a cog file atm so ima do basics I guess
It doesn't really matter do you use cogs or not
Like I need the basic of the code
guys is this valid for py py guild_id : {member.id: [count, [(admin_id, reason)]]}
Are you asking if it's syntactically valid Python code?
For that, you could just fire up an interpreter and try to execute the code to see if you get a syntax error or not.
not completely
yes its valid
ok thank u
it's valid but it is not the proper way 
ye its for my warning system
var: {type: [type, [(type, type)]]} this one is right, where type are the types of the variables, not the variables themself
shifting back to using json files?
~~Nooo don't ask it ~~ 
sqlite is hard, maybe?
Can someone explain what a converter is and does?
Im having a hard time understanding the docs since I am not native.
People who change from json to sqlite have a lot of problems
a converter is a way to convert the type of a variable into an another one, to work converters requires a context object, there are builtin converters which convert for example the id into a member or another discord object but btw their most utility are the custom converters
well, I know
24-hour clock 😭
Alright, Thanks
Also is their a way to send messages straight from the terminal?
cuz its totally 2 different thing?
STOP JUDGING 😭
nah lol, sqlite not hard, at least at the base level
but they dont even learn sql syntax
maybe thats why they are stuck
just like those pepo who dont even know print() and they want to build a discord bot
whats even to learn, sigh there's just 4 main operations
they dont even know any of them
controversial
LOL
but they are all gone from here now
when they realise its not as easy as importing random packages like what those hacker movie does
print("Hello", end=" World!")
movie hacking scenes are too inaccurate, they literally get a ui where they can see the hacked device's screen :awkward:
my brain crashed after looking at that
LOL
hint: deafault end is "\n"
you tested it to make sure
sigh
hint: just use ''' '''
tons of end is going to mess up everything
🤣
@loud junco :white_check_mark: Your eval job has completed with return code 0.
World!
Cheers, I probably typed it out wrong. I am on my phone
some people code their bots on a phone
💀
Not me. Not me at all
AHEM
I pity them, I've tried it
and I swear it wasn't hard
im sure u havent tried replit mobile
The keyboard is just clunky for symbols
I have
the whole typing sh!t just faks ur code up
you just need practice
it literally glitches the line to everywhere
and combine all the line together
wdym
for example:
line 1 will goes to the end of line 2 for no reason
and line 2 will merge with line 3 and 4 for no reason
and line 5 will be in middle of line 3 for no reason
not really
just by writing non-indenting code is already suffering enough
non-indenting code....?
well
idk what is it call
Bruh i spent last Friday tryin' to fix a problem and today I found that there was no problems but the encode I used to read the file was wrong 
🤣
"Roses are red, violets are blue, indented block expected, in line 22"
@bot.command()
async def joined(ctx, *, member: discord.Member):
await ctx.send('{0} joined on {0.joined_at}'.format(member))
What is the " * " for?
(in "joined(ctx, *, member: discord.Member)"
I am so freakin blind
I could finish this project like Friday
bruh please use f-strings
bro its the offical discord docs 😭
he is using formatted string without formatter
💀
well f-strings doesn't change the output
!d f-string
!f-string
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
i did it lel
then use them =.=
but what is the * for?
THE CODE IS FROMN THE DISCORD DOCS I JUST DONT UNDERSTAND WHAT * STANDS FOR
It's basically taking all arguments after the command name, for example, !joined @user test, it would take @user test, not just @user.
its for tape and cds
But note that if you type !joined @user test, it will raise MemberNotFound, as discord.py could not convert @user test to an existing member. So, it's better if you don't include the * (except for member nicknames that contains space in it).
Alright, thanks
but why did they show code that returns a error in the docs?
It returns an error for specific cases only, if you try to do !joined @user and @user is a valid mention, it will work.
👍
why would I need to do this
await ctx.send(embed=embed)
couldnt I just do this
await ctx.send(embed)
If not, why?
try for commands in #bot-commands
ok
ctx.send(embed) will try to send a text, embed=embed says you want to send an embed
if you want to know details, google for "python positional and keyword arguments"
Thanks
use !f-strings in #bot-commands and dont use this channel for those
!kwargs
*args and **kwargs
These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.
Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.
Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.
Use cases
• Decorators (see !tags decorators)
• Inheritance (overriding methods)
• Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
• Flexibility (writing functions that behave like dict() or print())
See !tags positional-keyword for information about positional and keyword arguments
yeah ok i got it
as many you want
as many as you want
slow 😔
Why is every "code a discord bot in python" tutorial using
@client.event
async def ...():
if ...:
await message.send(...)
elif ...
...
instead of
@bot.command
async def ...(ctx):
...
await ctx.send(...)
Is there a major difference?
they are outdated, using on_message for making commands is bad.
and not every "code a discord bot in python" is using that, even the worst ones use @bot.command
u also need to call command :p
while tutorials:
we dont talk about that
im kinda curious to see whats inside
open it then
ohmi god, thanks
np im always there to help
🤣
and I'm seriously scarred...
maybe 6 minutes of that time are ads
scarred
LMAO
he just said, "ctx equals to commands.Context" and typehinted ctx using colons
😭
:D
looks like what they do
skip to the end of the video and click reply, and then no ads, and the time aint shown for ads
how to get text input in discord py ui
how do we handle already connected to a channel ?
which library?
discord py
ui and discord.py??
you could check if the client is connected to a voice channel using the is_connected method on the VoiceClient
disnake would also work
!d discord.VoiceClient.is_connected
is_connected()```
Indicates if the voice client is connected to voice.
!d discord.ui.Textinput
No documentation found for the requested symbol.
class discord.ui.TextInput(*, label, style=<TextStyle.short: 1>, custom_id=..., placeholder=None, default=None, required=True, min_length=None, max_length=None, row=None)```
Represents a UI text input.
str(x)
Returns the value of the text input or an empty string if the value is `None`...
why does everybody get mad at discord for such reasons lmao
because they hate everything in existence 🤣
interesting
but this guy is actually making good or atleast helpful tutorials
cant say bad, but they are usable at the least....
I randomly clicked on an aiosqlite video of his, and......imagine connecting to the db every command
i prefer written tutorials :S
how can my bot send a message every time it enters a discord server;
thanks
I actually need a reliable tutorial explaining discord.py
actually i can't understand what's written in docs
so any reliable vid?
!source
connecting to the db?
whats that mean
Depends on the content for me really, when I want to learn anything about rust I would always prefer to go for the rust book over some YouTube tutorial however for python because everything is so over the places and there is nothing created by the python organisation I will either read a realpython article or watch a YouTube video
Haha I feel you.
Actually just read the docs and then watch some useless tutorials and recreate them so you get understand the things a bit mora nad what they do.
and then just repeat
https://paste.pythondiscord.com/onozuviyaw Can someone help me plz
I mean I dont even understand what async means TwT
Is that something I am supposed to understand beforehand?
Absolutely yes
How to only respond to messages in dms
aww man
!d discord.on_guild_join is the event then
discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") or when the
[`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") joins a guild.
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
connecting to the file, as in connect("uwu.db")

no problem i asked the same question so i might aswell just give you the sam answer
How to only respond to messages in dms
be more specific
so are you understanding the docs now?
check if the channel is a private channel, in essence, a dm
!d discord.ChannelType.private
A private text channel. Also called a direct message.
oh hell no,
I feel like a illiterate
aww man
if isinstance(current_channel_obj, discord.ChannelType.private):
...```
are docs really hard to read...?
right?
OH HEY SOMEONE HELP ME
then must have described your issue more
!nickname in dms
bot's response: shut up in dms
you dont call event
if you're 14 and not native, yes
remove the parens
I tried deleting the message, but the discord bot did not send embed in log the channel
I feel this.
what?
you will get used to it :)
yeah i told you the solution then
its .event not .event()
then what do I call it
cope
its fine, you'll get better
oooh thanks, now it didn't raise any error
WAIT
it's the same, I tried deleting the message, but the bot did not send any embed to the log channel
yeah, thankfully I am pretty good/decent speaking and reading english.
Otherwise i'd be &$§/"?
it didn't raise any error as well
import os
import discord
from discord.ext import commands
from datetime import datetime
client = commands.Bot(command_prefix='-')
white = discord.Color.from_rgb(255,255,255)
class ChannelGetter:
def __init__(self, id_):
self.id_ = id_
self.channel = None
def __get__(self, obj, objtype = None):
self.channel = self.channel or client.get_channel(self.id_)
return self.channel
class Channels:
manager_report = ChannelGetter(978183282824986655)
mod_report = ChannelGetter(978166822027292702)
helper_report = ChannelGetter(978168038505476116)
# Log in
@client.event
async def on_ready():
print("Successfully logged in as {0.user}"
.format(client))
# Clear
@client.command(aliases = ["clear"])
@commands.has_permissions(manage_messages = True)
async def purge(ctx,amount=2):
await ctx.channel.purge(limit = amount)
user = ctx.author
if amount == 2:
embedsus = discord.Embed(title="Clear Messages | Peace Bot", description=f"The latest message has been deleted from this channel.", color = white)
await ctx.send(embed=embedsus)
elif amount == 1:
emb = discord.Embed(title="Clear Message | Peace Bot", description=f"You have deleted the command you sent.", color = white)
await ctx.send(embed=emb)
else:
embed = discord.Embed(title="Clear Message | Peace Bot", description=f"{amount} messages has been deleted from this channel", color = white)
await ctx.send(embed=embed)
repEmbed = discord.Embed(title=f"Clear Messages | Manager System", description=f"Channel: {ctx.channel.mention}\nPurge Amount = {amount}\nRequested by {user.mention}", timestamp = datetime.now(), color = white)
await Channels.manager_report.send(embed=repEmbed)
# Message delete
@client.event
async def on_message_delete(ctx):
embed = discord.Embed(title = f"Message Deleted | Moderation System", description = f"Deleted Message: {ctx.content}\nMember: {ctx.author.mention}\nLocation: {ctx.channel.mention}", timestamp = datetime.now(), color = white)
await Channels.mod_report.send(embed=embed)
bot_token = os.environ['TOKEN']
client.run(bot_token)
full code\
What do you want?
here
this
How should I implement it?
it didn't raise any error as well
ohmi god, thats too complicated than it should be
So message deletion logs?
yes
💫
😵
@slate swan thanks
I made a test server u can come and help me
class Channels:
manager_report = ChannelGetter(978183282824986655)
mod_report = ChannelGetter(978166822027292702)
helper_report = ChannelGetter(978168038505476116)
this doesn't really return the channel object....
so it wont send message
what did I do....
but it does work for the "-clear" function, just not the delete message log
@scarlet spear there is a on_message_delete event in dpy.
wehat's dpy and what does that mean?
What library are you using?
thats what is being used....
Oh ok let me see the code
I dono't get it, can u please help me solve the problem
because ctx.channel returns the channel object, Channels.manager_report doesn't
ooh, then how should I change it?
Why are you using ChannelGetter class when you can just do await client.get_channel()?
WHAT
...
MY WHOLE LIFE IS A LIE
poor ryuga
remove that class, its not necessary just do var = client.get_channel(id)
TY
You can just do:
channel = await client.get_channel(<id>)
Lol
Are you following a tutorial
wait it a coro in 1.7?
If it was lucas your code is a mistake
Wdym?
Start from python basics
was get channel a coroutine in discord.py 1.7
import discord
from discord.ext import commands
TOKEN = "Token"
bot = commands.Bot(command_prefix='*')
client = discord.Client()
@bot.event
async def on_ready():
print(f'{client} has booted up succesfully!')
@bot.command()
async def vouch(ctx):
embed=discord.Embed(
title="Thats the title", description="This is the description", color=0x45b6fe
)
channel = bot.get_channel("my channel id")
await ctx.channel.send(embed=embed)
bot.run(TOKEN)
why doesnt this send the embed to the choosen cahnnel?
Learn OOP
just do ctx.send
IDK if I said something wrong but I just use disnake.py.
this
but i want to send it to a diffrent channel
not the 1 where i commanded in
!d discord.on_message_delete
discord.on_message_delete(message)```
Called when a message is deleted. If the message is not found in the
internal message cache, then this event will not be called.
Messages might not be in cache if the message is too old
or the client is participating in high traffic guilds.
If this occurs increase the [`max_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client") parameter
or use the [`on_raw_message_delete()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_raw_message_delete "discord.on_raw_message_delete") event instead.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Use VS code
Learn python basics
then go channel = bot.get_channel(id) and channel.send(...)
Try removing await.
I find it very offensive
Can you show me your code
so no ctx?
hes not wrong, discord bots are not for beginners
ctx.channel returns the channel from which the command was called, like if i called a command here ctx.channel would return this channel ( #discord-bots )
The truth hurts, but silence kills
I learned python for 1 year
Time doesn't matter.
It doesn't matter.
Lines don't matter
ohhh
i forgot about that
Concepts matter
and I'm 14 years old too
😂
age doesn't matter
How dos that matter?
My grandpa writes code he's 78
🤨
@sullen pewter, @slender night If you guys don't want to help him don't respond.
700
alr
here is the error
im not going to judge
I WANT TO HELP HIM
import os
import discord
from discord.ext import commands
from datetime import datetime
client = commands.Bot(command_prefix='-')
white = discord.Color.from_rgb(255,255,255)
manager_report = client.get_channel(978183282824986655)
moderator_report = client.get_channel(978166822027292702)
# Log in
@client.event
async def on_ready():
print("Successfully logged in as {0.user}"
.format(client))
# Clear
@client.command(aliases = ["clear"])
@commands.has_permissions(manage_messages = True)
async def purge(ctx,amount=2):
await ctx.channel.purge(limit = amount)
user = ctx.author
if amount == 2:
embedsus = discord.Embed(title="Clear Messages | Peace Bot", description=f"The latest message has been deleted from this channel.", color = white)
await ctx.send(embed=embedsus)
elif amount == 1:
emb = discord.Embed(title="Clear Message | Peace Bot", description=f"You have deleted the command you sent.", color = white)
await ctx.send(embed=emb)
else:
embed = discord.Embed(title="Clear Message | Peace Bot", description=f"{amount} messages has been deleted from this channel", color = white)
await ctx.send(embed=embed)
repEmbed = discord.Embed(title=f"Clear Messages | Manager System", description=f"Channel: {ctx.channel.mention}\nPurge Amount = {amount}\nRequested by {user.mention}", timestamp = datetime.now(), color = white)
await manager_report.send(embed=repEmbed)
# Message delete
@client.event
async def on_message_delete(ctx):
embed = discord.Embed(title = f"Message Deleted | Moderation System", description = f"Deleted Message: {ctx.content}\nMember: {ctx.author.mention}\nLocation: {ctx.channel.mention}", timestamp = datetime.now(), color = white)
await moderator_report.send(embed=embed)
bot_token = os.environ['TOKEN']
client.run(bot_token)
i learnt python for 3 years and still go back to basic
its called not being ego
help me first pelase this is urgent
my project must be done within this week
tru
You can't use this outside a function.
Get the channel inside of a function and use await.
I know manager_report is None since the bot hasn't even started yet and it gets defined.
also why does it print this when on_ready
<discord.client.Client object at 0x000002B998F6E560> has booted up succesfully!
@scarlet spear this should work.
Maybe you put it yourself.
Not being ego?
Because you print format the object.
we dont talk about that
its just excuses for me for being weak in basic
ok now the clear functions work, but the delete message log doesn't work, it didn't show any error as well
import os
import discord
from discord.ext import commands
from datetime import datetime
client = commands.Bot(command_prefix='-')
white = discord.Color.from_rgb(255,255,255)
# Log in
@client.event
async def on_ready():
print("Successfully logged in as {0.user}"
.format(client))
# Clear
@client.command(aliases = ["clear"])
@commands.has_permissions(manage_messages = True)
async def purge(ctx,amount=2):
await ctx.channel.purge(limit = amount)
user = ctx.author
manager_report = client.get_channel(978183282824986655)
if amount == 2:
embedsus = discord.Embed(title="Clear Messages | Peace Bot", description=f"The latest message has been deleted from this channel.", color = white)
await ctx.send(embed=embedsus)
elif amount == 1:
emb = discord.Embed(title="Clear Message | Peace Bot", description=f"You have deleted the command you sent.", color = white)
await ctx.send(embed=emb)
else:
embed = discord.Embed(title="Clear Message | Peace Bot", description=f"{amount} messages has been deleted from this channel", color = white)
await ctx.send(embed=embed)
repEmbed = discord.Embed(title=f"Clear Messages | Manager System", description=f"Channel: {ctx.channel.mention}\nPurge Amount = {amount}\nRequested by {user.mention}", timestamp = datetime.now(), color = white)
await manager_report.send(embed=repEmbed)
# Message delete
@client.event
async def on_message_delete(ctx):
moderator_report = client.get_channel(978166822027292702)
embed = discord.Embed(title = f"Message Deleted | Moderation System", description = f"Deleted Message: {ctx.content}\nMember: {ctx.author.mention}\nLocation: {ctx.channel.mention}", timestamp = datetime.now(), color = white)
await moderator_report.send(embed=embed)
bot_token = os.environ['TOKEN']
client.run(bot_token)
full code above^^^
cuz its the client object, idk why you have bot and client, u dont really need it. Just do bot.user to get the name of the bot
Can you come to my DMs?
Shrey try'na slide
YES THANK YOU I LOVE U\
Whart

Thanks,
Also
How do I stop/kill the script/terminal in vscode?
I kill
ctrl+c or just close the tab
just close the terminal
Red square in the top should do it.
Shutdown pc
💀
burn the pc
closing the terminal doesn't stop the bot
Cut your power
You do:
import sys
sys.exit()
If you really want to make sure
throw away ur pc
Ehm, I hope it does lol
yes
I hope it does*
i dont host on vscode
so idk
what does then?
thats what i do normally
💀
just ctrl+c xD
with a gun, knife or just by punching
🗡️
was a joke btw
🔫
alright stop already
its getting ot
try sand in cogs
just throw away this pc and buy a new one
it will stop the bot
anything you like I call john wick when I am mad
yessir
yeah, that should do it just fine
ot intensifies
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
@slate swan can u come into my DM
ur here help him
how to close bot in vscode
didnt work, still runs
dont have acces to pc now tho
no thanks
💀
u know how to stop bot in vs code?
stop
What
He's got a point.
this is serious idk what happen but no one wants to help
detach the c drive ❤️
🤣
thanks
brooooooo some ppl said ctrl + D and other things
we told him to throw away the pc
and shut down the pc
Everyone said ctrl+c lol
You're asking people to go in dms
🤣
That's sus
bcuz a lot of peeps are posting a lot of question at the saem time
I'm doing the verification process, how long does discord expect you to store data?
claim a help channel, see #❓|how-to-get-help
#help-cake @scarlet spear
ye I claimed it, no one even wants to help me
you should know
Well you need to explain to Discord how long you store your data.
i remember for message content it was 30 days
mention the channel here
I meant in this chat.
not sure what it is for things like IDs
anyways bai bai, i got an exam
yeah I dint tho
F4
gl
thankee
Hello ashley
what exam
school?
Bye ashley
did work
vouch 10/10
would use again
atleast someone studies
i just finished mine last week
nice
:D
Oh that's why
Jotqiane
RecursionError: maximum recursion depth exceeded
doesnt everyone in this sever
No
well, im an exception ig
Everything about your account tells me your serious
Name: CokeCane
About me:
🤸♀️
🦽 🏌️♂️
well...
wait i typed Coke Cane and this emoji popped
Cokecane good
Technically iamSkev
my bio is cringe
shit ur 14, u didnt see anything .....
lol i missed ur old pfp
?
Wdym old php?
dont worry about it
the pfp before this ducky
There wasn't one
My avatar has been the same one for 4 years
!sf 381799048228896788
You are not allowed to use that command here. Please use the #bot-commands channel instead.
2017 owo
it makes me feel funny
sf means snowflake
huh
you can get the creation datetime of a object using its snowflake ( i.e. its ID)
everytime they win they go HEHEHEHA
its not funny
oo
!d discord.abc.SnowFlake
No documentation found for the requested symbol.
🤣
no lemme write it for u
if you dont use this app for one year, I will remove you from this entire database that you will never be able to join again or create again. If you try to use an alt to create, I will get your ip and ip ban you
https://paste.pythondiscord.com/onozuviyaw Can someone help me plz
hmmm why
try .cogs
I think the only bot that doesn't have ratelimit is Clyde.
?
but clyde is a bot
Well yeah depending on what you are doing
I'm creating a slash command, and once the bot is started, is it possible to change the choices in an argument in a command?
if you send many requests to the API, it won't let you use it for a certain amount of time
nickname = input()
print(nickname)```
How to do this in dpy
you want the user's nickname?
he wants input
yes
like, ask the user and wait for a response?
btw its print(nickname)
like
nickname:lil s
AHEM
^
i also want to know this
!d discord.Client.wait_for
ya
What's the best way of reloading a slash command without restarting the bot?
wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message,
or to react to a message, or to edit a message in a self-contained
way...
restart the bot
use cogs
!sync
I am using cogs
@client.command()
async def sync(ctx):
await client.tree.sync(guild=discord.Object(id=844747238445023242))
await ctx.message.delete()
print("Synced!")```
Does waiting for verification stop bot invites if you hit 100 if you need none of the intents?
@slate swan
What does that do?
and what library?
It updates slash commands
prob dpy 2.0
Pycord
if its discord-py-slash-comamnds im out
alright, lemme see the docs
My bot is at 85 servers after 7 days and im pretty sure it's gonna hit 100 before they get back to me with verification 
How can I make it work after bot sends message
like:
bot: What would you like your nickname to be?
user: nickname
reload the cog, and use this https://docs.pycord.dev/en/master/api.html#discord.Bot.sync_commands
what's the verification
click on the link it has an example iirc
Do I need to do both?
Didnt work
reloading the cog may not sync it with disocrd, so better do it
every Library has its own way of doing this so idk, Haven't used pycord/any discord.py related library in months
how to make it only get nicknames after bot's message
But if I do sync_commands do I have to reload the cog too?
did you see the examples?
how else would the bot know what changes did you make
and what do you not understand?
I just want bot to get users nickname after bot sends a message but if the bot doesn't the command won't work
well
Is it impossible?
try :
event = await bot.wait_for("event name")
except asyncio.TimeoutError:
# the event was not triggered
``` you recieve messages with on_message event so "message" would be the event name here
ty
await commands.sync_commands(["MyCommand"])
await commands.reload_extension("MyCog")
```Ìs this right if I want to reload one command?
no
LOL
i still need to wait for another 7 months
reload the cog first, then use commandw.sync_comammds, which takes ApplicationCommand objects as arg
they must prioritise based on growth speed
congratulations 🥳

im 16 but im december boi
show file structure
im still underage
@dull terrace
Finished my new bot, link in about me!
you don't have an about me 😔
for?
under 13?

ion see it
you can still get it verified
does that not show?
weird
still doesn't show
i cant
under 16
verify for bot btw
Recently, we've had to make a policy change which restricts users under 16 from verifying their bots on Discord alone. We created this article to explain what verification is and how you can help a...
read whats below it....
If you got some trustable friend who's older than 16 you can transfer the ownership to them and they can verify
Guys do anyone know how can we use perresoctive api in discord. Py
There is no tutorial so i asking here
u want to auto mod ur channels?
i dont trust other human
well then grow up
Ye
waiting for 7 months
so which part do u not understand
I made a client event on message
So me not understand how can I use aiohttp in sending request to api
what are the messages that are hidden to other users and are just one user called again
uhm do you mean ephemeral message?
yes lmao. can you call the disnake doc using the bot?
Do message components work in ctx?
what components do you mean
!d disnake.ApplicationCommandInteraction.send
await send(content=None, *, embed=..., embeds=..., file=..., files=..., allowed_mentions=..., view=..., components=..., tts=False, ephemeral=False, delete_after=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message using either [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message") or [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").
If the interaction hasn’t been responded to yet, this method will call [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message"). Otherwise, it will call [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").
Note
This method does not return a [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") object. If you need a message object, use [`original_message()`](https://docs.disnake.dev/en/latest/api.html#disnake.ApplicationCommandInteraction.original_message "disnake.ApplicationCommandInteraction.original_message") to fetch it, or use [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send") directly instead of this method if you’re sending a followup message.
Bruh buttons
!d disnake.InteractionResponse.send_message or generally this
await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., allowed_mentions=..., view=..., components=..., tts=False, ephemeral=False, delete_after=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Responds to this interaction by sending a message.
could i use ctx or should i switch to interaction?
um... i added another slash command to my disnake bot and all of the slash commands dissapeared
Lol tell the age above 16
don't tell anyone, but i made a discord account, 7 days before my b day on Oct 21st where i turned 13
shhhh
im 18 now lol
Don't tell anyone I started discord 2 years ago
alright
😐
GCSEs
no one will know , wait , is this a public discord server?
imagine
wow
im doing that next year
i just finished school
No way
lol
Ash told that ur 13-14
im not
im older lol
..
im 15🧍
Bday date?
jan 24
finished ||primary|| school
10 days me 4 feb
Wait 11 actually
ash just says im a child cuz shes 16😔
WHAWHAHWAWA
Weird
u r also a child to me then

hi child
wow, thank you
👍
😮💨
how can i kill a bot instance thats on my other system since im not home rn
ashley
are u the ashley in my class?
I didn't know u have discord
u said u only use iMessage
Guys can anyone help me make that bot deletes bad words using perresoctive api
Pls help
hiya yall, im currently trying to work out how to run different instances of my bot on 2 diff servers. ie, so inputs on one wont interact with story progression on the other server. any help would be much appreciated!
sharding might be what your looking for
Imagine
but dont ask me XD cause idk how it works or how to
from what i could find sharding is usually only necessary for large numbers of servers (or guilds i think is the other name for servers)
ahah no probs
if anyone here knows about creating multiple instances of a bot that run independent of each other on different servers, some help/experience would be much appreciated
Auto sharded bot
so i will need to set up sharding?
"auto" 🚶♂️
Just change commands.Bot to commands.AutoShardedBot
!d discord.ext.commands.AutoShardedBot
class discord.ext.commands.AutoShardedBot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
This is similar to [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") except that it is inherited from
[`discord.AutoShardedClient`](https://discordpy.readthedocs.io/en/latest/api.html#discord.AutoShardedClient "discord.AutoShardedClient") instead.
use this class... as hunter said
umm... its breaking all my stuff lmao
Stop button....?
do you have jishaku or something?
nope never heard of it
or just reset the token ;-;
If u use an eval, just do !eval exit()
alr ill take a look
yea, wont have to make any necessary changes, None of your code breaks
i dont use eval :/
Reset the token @flint isle
@flint isle
A discord.py extension including useful tools for bot development and debugging.
!e exit()
@cloud dawn :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'exit' is not defined
sys.exit() 🚶♂️
hmm would that break if i use disnake...
so how do i go about adding this into the code... which part is actually needed and where?
!pip disnake-jishaku xd
just change your commands.Bot to commands.AutoShardedBot, thats it
I think this issue is because of a poor management of state, rather than some issue with the Discord library you use. Sharding is not what you're looking for to rid this issue.
oh i didnt see that message, that has something to with blocking functions
Most likely the result of the fact it's hard coded.
!blocking @jagged adder
Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.
What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:
import discord
# Bunch of bot code
async def ping(ctx):
await ctx.send("Pong!")
What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.
async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!
This is not an issue with blocking either
lol i had issues with multiple bot instances because apparently i accadentally deleted my logoff command
so ... are you saying sharding wont create a seperate instance of the bot in server #2?
It might, it might not, it depends on how discord.py decides to create the shards.
or that creating a seperate instance wont fix the issue of the code pulling inputs from server 1
Sharding is not about several bot instances, it's about several connections. If you have a variable you store on the cog, that will still be shared.
I know it may be a dumb question, but do I need to register app commands?
Which library are you using?
discordpy
2.0?
yeah
Every app commands need to be "registered" it's called syncing.
Then yes, you need to sync the command tree
You would have to use the tree.sync attribute of client / bot
You only need to manually sync with dpy other forks have auto syncing.
But itd usually be better using discord.py itself
because forks are more complicated to learn and the help you can receive is minimal
I'd disagree? 
With how it's currently setup, and explained I won't blame anyone for using a more clear library like disnake or nextcord.
!d exit
quit(code=None)``````py
exit(code=None)```
Objects that when printed, print a message like “Use quit() or Ctrl-D
(i.e. EOF) to exit”, and when called, raise [`SystemExit`](https://docs.python.org/3/library/exceptions.html#SystemExit "SystemExit") with the
specified exit code.
Forks here have a great coverage of people who can help, personally I can help with disnake, nextcord, pycord and dpy. But I don't help anyone using an extension to dpy 1.7.3 since those are pretty bad.
Ok I'm making a discord bot message that tells the numbers in a users message if it starts with %ecofnum. Now whenever I type something like "%ecofnum 22". The bot stutters. What I mean is the bot says 2 and then 22. Here's the code:
if age1 > 18:
age2 = adult
else age2 = adolscent
Guys i am getting an error will anyone help me fix?
!indention
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
if age1 > 18:
age2 = adult
else:
age2 = adolscent
Ask in #python-discussion or see #❓|how-to-get-help. Not at all problems you encounter when writing a Discord bot, has to do with the Discord API!
Well true since, first iteration "2" then "2" + "2" == 22
https://paste.pythondiscord.com/demexafili How to add a role to the user automatically?
That's because there is a loop, what do you expect to happen?
i expect it to only say the number once
Is that not what the code does?
But you loop over the string.
Yeah why is there a loop haha
Yeah but am not too sure how do i mention the role to give to the user?
Let me visualize it for you.
Do i need to use discord utils?
hello do anyone know any meme api
!e ```py
content = "%ecofnum 22"
string = ""
for x in content:
if x.isdigit():
print(f"Found {x}, appending to content")
string = string + x
print(string)
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
001 | Found 2, appending to content
002 | 2
003 | Found 2, appending to content
004 | 22
!e print("hello world")
@wraith lion :white_check_mark: Your eval job has completed with return code 0.
hello world
wait
@forest parcelWith this visualization, do you see why it says 2 then 22?
API information in general can be retrieved by either using aiohttp(async) and requests (synchronous), maybe look up some documentation on this
er yes, im a bit new to python, wait lemme open some similar code in pycharm
A lot of people just use reddit.
oh.
Yeah since you print it afterwards.
Here the send is inside the for loop.
👍
now time to add strings to the send message
🥳
Ah the satisfaction of helping :D
anyone wanna try my bot?
sure
join the server
its in my bio
uh oh
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
can u dm me the link, I can't see bios for some reason
:D
^^ f strings are recommended but you could also just add the strings (very time consuming)
u need f in front of ' '
its a BIG NO for using strings and variable together without formatter
?
Yeah its just a bad practice
print even allows seperation by comma.
Really?
!e print("Hello world", ":)")
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
Hello world :)
How to reload a single command using sync_commands?
That’s new
It's not, it's because of the *
pass in that commands' object...
commands = [MyCommand()]?
New to me haha
no, use get_application_command to get its object, then pass it in the sync_commands
Ah
You don't really need to "reload" a command. Re-syncing only will update things like the name, input types, description etc, it won't update the code underneath.
🚶♂️ yea, i asked them to reload the cog first
I only want to update the input types
Yeah okay.
then you gotta reload the cog and sync too
await self.client.sync_commands(command = the_com)
await self.client.reload_extension(StaffCog())
```Ìsn't that right?
Tbh i just restart my script, I use Client.
you need to reload first~
nah doesn't matter.
and your args arent correct
why not, the changes are still unstated!?
what of them are wrong
It doesn't matter since the sync is only the meta data.
Let's see "slash" commands as a placeholder.
how would the bot know that what changes have been made?
the command state is still at the old one
It doesn't need to.
and they are not restarting the bot*
No since it's reloaded afterwards.
You can change the code and not re-sync the commands.
Since they aren't related. If you change any args/ kwargs/ names/ descriptions however you need to re-sync.
# before
@commands.slash_command()
async def command(ctx, arg: str):
...
# after
@commands.slash_command()
async def command(ctx, arg: discord.Member):
...
``` so you can simply sync the bot app commands before loading the #after part?
No, not with this configuration.
channels, member and role typehints need to be pushed, since discord provides a UI autocomplete for them from its side ;-;
which is different from other args
That's why slash is very gut, but they still need to add extra typehints.
Allow regex.
a channel typehint for instance
We. Want. Regex
Imagine how small bots can be if you could pass regex for input checking...
issue with regex is that it can be massively cpu intensive
but yeah it would be nice to have
vcokltfre u havent changed your status
Not that many people will use regex.
in like a year, it's still that log thing
Mine's pretty solid year as well.
Are you around 37?
Had to check sorry.
Anyone here know how to add buttons to message in discord.py?
I tried many tutorials but they not worked
if you tried tutorials through YT, then that's obvious
is there the event in nextcord
on_slash_command or on_command is for slash cmds too?
Check examples on discord.py repo
And make sure you have 2.0 installed
i want to have a class of 'items' which are basically set to true or false statements. how would i go about printing only those shown as true as a line of text? suspect it has something to do with string but could use some help
!e
a = True
print("yes" if a else "no")```
@vale wing :white_check_mark: Your eval job has completed with return code 0.
yes
This?
seems more like a list comprehension issue to me
[shit for shit in shitlist if shit]
im trying to create an 'inventory' of sorts, where i have the items in said inventory and only print those which are active at the time
Well I couldn't understand from his explanation
list comp it seems
Yes
So I'd image you have a 2d array.
Best explanation ive seen in a while
wdym?
9/10 of my code examples contain code like that
Lol
You want to filter out the items that are active and convert the list to string or smth
Would the data need to be stored permanently? Id assume youd want a database
like 20 mins after i submitted request
