@slate swan https://www.programiz.com/python-programming/json will this do?
In this tutorial, you will learn to parse, read and write JSON in Python with the help of examples. Also, you will learn to convert JSON to dict and pretty print it.
1 messages · Page 783 of 1
@slate swan https://www.programiz.com/python-programming/json will this do?
In this tutorial, you will learn to parse, read and write JSON in Python with the help of examples. Also, you will learn to convert JSON to dict and pretty print it.
Happens with me too sometimes
Sure
I completed a year in pydis today 

just a query it's usage will be dynamic_cooldown(message, type=BukketType.default) where the message will be actual message where i can access the user
I'm getting a disnake.errors.InteractionResponded: This interaction has already been responded to before
I looked on stack overflow and I need ctx.difer or smth
Is that correct?
can you make it so that an event triggers at a specific time, on a specific day? for example, if i want the bot to send a message at 1:00PM IST, every thursday, how can i do that?
I'm using bot.wait_for to get a response from a user
Tasks and datetime util
Mhm
U need to use inter.followup.send
No
Why? I'm not trying to respond to the message again, I'm just editing my response
Still
U can use inter.response only once
After that, u need to use inter.followup
For even editing the message
Discord Being Discord
Seriously? It works just fine for all of the rest of my shit
async for...
So if I can only use inter.response once why can I create a paginator with buttons just fine?
But it shows an error when I'm editing the message now
what error?
disnake.errors.InteractionResponded: This interaction has already been responded to before
else:
for alt in altjson['results']:
embed = discord.Embed(title = "Dewier Bot", description = (f"(alt{'_id'})"), color = (0x0b0909))
await ctx.send(embed = embed)```
How would I make it so it puts all the ids into 1 message like:
Dewier Bot
(_id)
(_id)
(_id)
and the code?
never mind can some1 tell how to implement ur own cooldown?!
!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.
do you use inter.response.edit_message?
Yes
@slate swan errors in the else statement when trying to edit the message
else:
for alt in altjson['results']:
embed = discord.Embed(title = "Dewier Bot", description = (f"(alt{'_id'})"), color = (0x0b0909))
await ctx.send(embed = embed)```
How would I make it so it puts all the ids into 1 message like:
Dewier Bot
(_id)
(_id)
(_id)
Would editing the response really cause an error because thats how my pagination system with buttons works and it works fine without errors
are you sure you get the error there?
Yes
Just added 2 print statements. 1 above it and 1 below it
The 1 above it prints but the one below doesn't
You know what, I'll go to bed and take another crack at it tmr
how can i get all playe's chat in my minecraft bedrock server to my discord server?
discord.on_thread_update(before, after)```
Called whenever a thread is updated.
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
New in version 2.0.
else:
for alt in altjson['results']:
embed = discord.Embed(title = "Dewier Bot", description = (f"(alt{'_id'})"), color = (0x0b0909))
await ctx.send(embed = embed)```
How would I make it so it puts all the ids into 1 message like:
Dewier Bot
(_id)
(_id)
(_id)
can someone help bru
Print your version
You could append them to a list
print(discord.__version__)
Are you using dpy or a fork
would i type
x = append(f'alt(_id)') then put x as the description?
or what would i do instead
Well no. You would loop through your json (like you're doing now) and appending them to a list
Hmm
Just try writing it anyway I guess
intelisense isn't everything
It gives me Unresolved attribute warnings for my bot variables
So its not always right
would i append it in the description? im new to this so im just checking
anyone here use buttons?
needs to be an obj not an int
TwT
how can i run 2 .py file?
@final iron
await remove_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.
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, and the removed [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
^
Imo when you're in the heavy development stage of your bot you only want to handle the Command not found errors
🥲
Just do await before.owner.remove_roles(discord.Object(self.CLAIMED_THREAD_ROLE))
Ezzzzz
then disnake.Object
!d disnake.Object
class disnake.Object(id)```
Represents a generic Discord object.
The purpose of this class is to allow you to create ‘miniature’ versions of data classes if you want to pass in just an ID. Most functions that take in a specific data class with an ID can also take in this class as a substitute instead. Note that even though this is the case, not all objects (if any) actually inherit from this class.
There are also some cases where some websocket events are received in [strange order](https://github.com/DisnakeDev/disnake/issues/21) and when such events happened you would receive this class rather than the actual data class. These cases are extremely rare.
x == y Checks if two objects are equal.
x != y Checks if two objects are not equal.
hash(x) Returns the object’s hash.
how to use buttons in pydroid 3?/terminal
Idk #editors-ides is a better channel for this imho
Weird
The role is lower than the bot's highest role, right?
Hmm yea
So it still prints the statement?
Weird...
Wait I have another idea
Just use self.get_guild(...).get_role(...) and print it
am I the only one using pydroid 3?
I guess?
So it does gets the role
And now, try setting this in a variable and then passing this in the remove roles
Do u have logging enabled?
Enable it
anyone know how to install button
#editors-ides is a better channel to ask for pydroid help
It is a fork, so the basic things are same. Just replace discord with disnake
ohh I thought u said that to the other person ty
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.
Wait
try printing before.archived, after.archived. before.owner
....
@versed finch is pro coder ask all doubts from him he'll solve them all
Could be its more of a discord UI issue that u still see the roles rather that yr code issue
Actually @slate swan is also a pro coder hehe
ok multiple people can be pro coder
Mhm
who is learning from lord hunter
Stop it in this server now
AHHHHHHHHHHHHHHH WHYYYY
What one reason to give discord to ask for presence intent which they couldnt say no ?
!d discord.Member.remove_roles
whats the error?
await remove_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.
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, and the removed [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
I will add any new command / feature or anything which will let them give me that
your bot is something like Mushroom bot
@slate swan did u subclass on_error or on_command_error method
probably not
what ?
features against tos or features that is useless or shouldnt be needed
WHY IS DISNAKE PLAYING WITH US THEN
Are you using some error handler@slate swan
read question again
No
try adding this line at the top of the function
Mushroom bot is a bot which tracks user's gaming activity and uses it for leaderboards or something , if you have a similar bot its likely that you may get those intents
simple features like member's status or spotify song wont help u get it.
await self.wait_until_ready
still applies
!d discord.ext.commands.Bot.wait_until_ready
await wait_until_ready()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits until the client’s internal cache is all ready.
k will do that
after this line
thx
after the def line
you cant use await outside a coro
best of luck , tho you would need to write a good tos and privacy policy cause the presence data is sensitive 
aight as long as it work idc how hard it is or how long it takes
what's self.CLAIMED_THREAD_ROLE
if its a Role object already , get_role() returns None , and thus role variable is None too
same goes for a string
any on_command_error/on_error event?
if message.channel.id == 916441194337296424 or discord.ChannelType.private
how to make it possible
if isinstance(message.channel, discord.DMChannel) or message.channel.id == id:
on client.wait_for('message'), it waits for a user input message. how do i make it wait for a mention?
i have a lot of other servers
just shut up and leave me alone bro
on client.wait_for('message'), it waits for a user input message. how do i make it wait for a mention?
that returns a message object so u can simply do something like
message = client.wait_for("message", check=lambda msg: len(msg.mentions) != 0)
oh
!d discord.Message.mentions
A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.
Warning
The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.
yeah someone told me message.mentions but i didnt know how to use it
!d discord.Message.channel_mentions also exists if u wanna wait for channel mention
A list of abc.GuildChannel that were mentioned. If the message is in a private message then the list is always empty.
!d discord.Message.role_mentions is also there
A list of Role that were mentioned. If the message is in a private message then the list is always empty.
is it also work with lambda m: len(m.mentions)
It should, yea
since 0 is the same as False and >0 is the same as True
!= is check right?
It means not equal to
if the length of message.mentions isn't equal to 0
That means, there should be at least 1 mention
so what im trying to do is like a complicated kick command
async def kick(ctx):
await ctx.send('mention member to kick')
try:
message = client.wait_for("message", check=lambda msg: len(msg.mentions) != 0)
except asyncio.TimeoutError:
await ctx.send('timeout')
```
why not use a member argument
Ah
yes im make complicated thing
but i think it wont work with wait_for
ic no purpose in why do this
His wish oki
haha it wont work i think

and in it, just do await message.mentions[0].kick(reason-...)
async def try(ctx):
try:
message = client.wait_for("message", check=lambda msg: len(msg.mentions) != 0,timeout=30.0)
except asyncio.TimeoutError:
await ctx.send('timeout')
finally:
await message.mentions[0].kick(reason='test')```
and do u know what is that code doing?
morning
i run command and it asks me to mention member then i mention and it kicks
how do it
No like the internal working
What it is doing
yeah
?
Do u know what is message.mentions[0] doing?
no i dont know message.mentions[0]
smh
Lmao thought so
Would anyone be able to help me hide a cog? I was looking at a thing a person sent me earlier but I can't see anything on it.
!d discord.ext.commands.Cog.hidden
No documentation found for the requested symbol.
class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.
A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.
When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
gimme a min
K
class MyCog(commands.Cog, command_attrs=dict(hidden=True)):
@commands.command()
async def foo(self, ctx):
pass # hidden -> True
@commands.command(hidden=False)
async def bar(self, ctx):
pass # hidden -> False
!d discord.ext.commands.CogMeta.command_attrs
A list of attributes to apply to every command inside this cog. The dictionary is passed into the Command options at __init__. If you specify attributes inside the command attribute in the class, it will override the one specified inside this attribute. For example:
class MyCog(commands.Cog, command_attrs=dict(hidden=True)):
@commands.command()
async def foo(self, ctx):
pass # hidden -> True
@commands.command(hidden=False)
async def bar(self, ctx):
pass # hidden -> False
can u explain me
!d discord.Message.mentions
A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.
Warning
The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.
so message.mentions returns a list of discord.Member objects which were mentioned in the message
Do u know about lists and how to index them?
can anyone provide an example for running a task at a specific time? i believe thats a new feature in 2.0.0, but i cant figure out how to use it with a timezone
Thank you
noo
an example with a timezone would be very useful
!resources then u should learn about data types and basic Python more before trying out a complex library like discord.py
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
?
yeah
the docs arent very clear with the usage of that
discord.py is pretty complex
!d discord.ext.tasks.Loop lemme see, I haven't heard about that tbh
class discord.ext.tasks.Loop```
A background task helper that abstracts the loop and reconnection logic for you.
The main interface to create this is through [`loop()`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.loop "discord.ext.tasks.loop").
see ?tag daily task in official dpy server
@tasks.loop(hours=24)
async def daily_task():
...
@daily_task.before_loop
async def wait_until_7am():
# this will use the machine's timezone
# to use a specific timezone use `.now(timezone)` without `.astimezone()`
# timezones can be acquired using any of
# `datetime.timezone.utc`
# `datetime.timezone(offset_timedelta)`
# `pytz.timezone(name)` (third-party package)
now = datetime.datetime.now().astimezone()
next_run = now.replace(hour=7, minute=0, second=0)
if next_run < now:
next_run += datetime.timedelta(days=1)
await discord.utils.sleep_until(next_run)
a very gud example
i actually got into d.py when i didnt know python that well, but learning dpy also improved my python skills significantly
🤣 u also ran the command in that server and so did I
lol btw i have a high-hoisted role in that server 🙂
Yups, saw it
i was actually referring to how theres now a time parameter that you can pass in @tasks.loop()
ok
maybe
import datetime
@tasks.loop(hours=24, time=datetime.datetime.now())
async def it():
...
hmm that could work, let me try it out
it didnt work 😦
oh damn
what are you trying to do?
make a task run at a specific time using the time param
ig i'll just do it long way lol
!d discord.ext.tasks.Loop
class discord.ext.tasks.Loop```
A background task helper that abstracts the loop and reconnection logic for you.
The main interface to create this is through [`loop()`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.loop "discord.ext.tasks.loop").
lemme see
!d discord.ext.tasks.Loop.time it needs a list of datetime objects for some reason @valid galleon @fading harness
property time: Optional[List[datetime.time]]```
Read-only list for the exact times this loop runs at. `None` if relative times were passed instead.
New in version 2.0.
Because they will run at that specific times.
See of it like planned events.
Yea, that is what they want to do...
ic
I mean ig you can generate a list of it for the next 30 days if your bot has structured maintenance anyways
how can I host my discord bot on vultr?
We help with coding here not the hosting part.
ah man
Also did you receive a message from modmail?
A wrong person mb
any mute command example?
i want to make the muted role on guild join there might be a example or someone has written it before i can use?
Timeout is used a lot now
hm?
@client.command(description="Mutes the specified user.")
@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member, *, reason=None):
guild = ctx.guild
mutedRole = discord.utils.get(guild.roles, name="Muted")
if not mutedRole:
mutedRole = await guild.create_role(name="Muted")
for channel in guild.channels:
await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_messages_history=True, read_messages=False)
something like that
i see thanks
np
await member.remove_roles(mutedRole) this for removeing right
Its just easier than configuring roles and stuff
can i have an example?
it's not a feature in discord.py , you'll have to use some fork
And the examples change according to what for you use.
ohh
bot.load_extension("./cogs/moderation.py")
discord.ext.commands.errors.ExtensionNotFound: Extension './cogs/moderation.py' could not be loaded.```
why this error?
Hello, does anyone know how to make a reddit feed? I.e. get all new posts from a specific subreddit and post them automatically to a channel
I got the connecting part down using praw, but the problem is I need to use commands to get a random post, I don't know how to make it automated
isnt it made with webhooks?
Yeah like why even make a command for it anyways now.
Can someone please explain this guild = ctx.guild
its gets the user's guild
Yeah, I saw that option
I was more aiming towards why to re assign the var
Yes I can
to reduce the ctx?
!d disnake.Member.timeout
await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.
You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.
New in version 2.3.
It's the difficult art of assigning the easy attribute, named guild, belonging to the commands.Context class to a variable so as to increase the memory usage of the application and to decrease the length of the line as a whole.
You are being sarcastic right?
Totally Not Being Sarcastic
I just explained it to you in the easiest way possible
i mean using this function is better lol
Still makes no sense, yet to be convinced.
Lmao
"function"?
Attribute/Property
I mean there is a difference yeah.
Idk if it has actual performance benefits to it though.
just makes it easier imo
Suggest more topics here!
btw have an expample for await timeout?
await timeout?
idk
???
a command to give new command ideas
Ingenious.
How do I check the vc that the bot is connected tto ?
property me: discord.member.Member```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
gives you the bot as a member , just .voice.channel to get the channel
so
ctx.guild.me.voice.channel ?
yes , but it may raise an error if the bot is not in a voice channel. you gotta check if ctx.guild.me.voice is not None first
so i have a task which checks the date and time and sends a message in a channel when the time is equal to the set value.is there a chance the bot could break if i run this every one second or so?
nope , looping every second wont break your bot
#help-rice does anyone know how to fix this
rate limiting?
read there complete question
sends a message in a channel when the time is equal to the set value
a loop wont make any change until you send a web req
I asked that generally
nvm
thanks for the help
still wont, it would just be a bit more resource hungry
oh hm
Not by much.
How to make a button after that Who presses the button It changes part of a message and writes the name of the person who clicked the button
(Private button)
get the interaction user and use the edit method on the Message object
!d disnake.Interaction.author
The user or member that sent the interaction.
await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
The content must be able to be transformed into a string via `str(content)`.
Changed in version 1.3: The `suppress` keyword-only parameter was added.
async def join(self, ctx, *, channel: discord.VoiceChannel):
if ctx.voice_client is not None:
await return
ctx.voice_client.move_to(channel)
await channel.connect()``` I tried running this and no synthax but bot never joined, any pointers?
oo making buttons?
yea depends on the task inside it tbh
Thanks.
Just wondering is a code editor like vs Code enough for bot developing or a proper ide would help more
how to send custom emojis with python
Yes
send the right url
Anything u want
?
do u know to send custom emoji
U can use terminal if u prefer
Just add a \ in front of the emoji name to get it's full name with the ID
Oneliners yeah
And then add it to yr bot code
Mhm, in arabic letters
!d discord.Client.get_emoji , and send it
get_emoji(id, /)```
Returns an emoji with the given ID.
where to put that
Nah I'm currently working on vsc , feels good for the most part, just asking if a ide would be actually better or no
Are you using discord.py?
class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.
New in version 2.0.
ok
This gives you an discord.Emoji instance, you can send that
self.add_item(disnake.ui.Button(label=':pexi2: Website', style=disnake.ButtonStyle.blurple, emoji=':pexi2:',
```?
emoji = discord.emoji… send(emoji)
No
You need full Id of emoji
It looks like this
It auto says that when i put it there it changed it
I think there are some plugins for vsc that make it an ide
Ye kind of , it's like a pseudo ide
or the object
correct?
Just get the object instance
I'm sure you can remove the emoji from label
Yeah that also
Try it
We arent interpreters
Just asking cuz i thought must it the emoji like somewhere
?
Ok works
instead of ctx.channel.purge
how do i delete the authors message
when command is executed
use a check
how?
!d discord.TextChannel.purge
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Examples
Deleting bot’s messages...
it needs to be a function
which returns a True if your condition is qualified
so what do i checek for
?
Just do ctx.message.delete()
oh
It will delete the command message
jeex , i misread the question
Imagine using purge rip
Did you know there is a parameter delete_after for ctx.send()
Author's Message Bruv
Not The Bot's Message
No ik, I’ m just saying
Ah well yea, I know about that. It's the same as
msg = await ctx.send(...)
await asyncio.sleep(...)
await msg.delete(...) tho
Yes lmao, I used to write this
Then I saw u can just add kwarg and get rid of all this
discord/abc.py line 1071
await ret.delete(delay=delete_after)```
!d datetime.datetime.now
classmethod datetime.now(tz=None)```
Return the current local date and time.
If optional argument *tz* is `None` or not specified, this is like [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today"), but, if possible, supplies more precision than can be gotten from going through a [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time") timestamp (for example, this may be possible on platforms supplying the C `gettimeofday()` function).
If *tz* is not `None`, it must be an instance of a [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo "datetime.tzinfo") subclass, and the current date and time are converted to *tz*’s time zone.
This function is preferred over [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today") and [`utcnow()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow "datetime.datetime.utcnow").

oh
yessir
user = guild.get_member(pre_user_id)``` anyone know why this prints as none? pre_user-id is the id of the user
no member with that id is in the server or you dont have member intents
nvm God Sarthak is here
i have 2 embed 1 embed for first message and embed2 is for edit it,How can I delete embed1 after sending embed2?
using on_message event
if its not in any of bot's server why would it be a member
whats the member intents thing
😂
!intents
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.
lollll, understand the meaning smh
😔 pardon me
lol, dont be like that
u may use bot.fetch_user() or smthng ig
has anyone made discord music bot
they want a member , not a user.
!pip pincer
ah sorry my bad
save the 1st embed message as a variable and after sending the second message do variable.delete()
llol
discord.py like
already it's embed1 = disord.Embed()
whats the point of making normal commands though
huh?
then send it (store in a var) and use the delete method on it whenever convenient
im not talking about your embed object, the message object is what u need
pincer commands look like dpy commands lol
oof
msg = await send(embed=embed1)
await send(embed=embed2)
await msg.delete()
``` get some hint 
ikr
i hope they dont make it look like a fork
the decorators lol
ah okayy
is it just me?
lol
the failed image embedding
you already know
Sad
subclass the bot class
its fun
?
subclass the Bot class to look cool
subclass discord.ext.commands.Bot
soz lost around 27 iq by #python-discussion earlier


what does it do actually?
better handling overall and it makes your code way better
ngl I literally lost some braincells ._. they keep telling me I should stop using android
they?
stop using android thats just nonsense
same
u first then ill
after you
and I didnt say anything about "I wont install discord anymore" hehehe
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
👁️ 👁️
k bye imma make my moderation bot
gl
delete discord first, then make it
Wish I can use that luck
no lol

ashley why dont you go to school
delete discord then install discord and then make the bot
focus infront
the teacher's absent
...
uk widgets are embeds too?

no 
They will need the "Absent Slip" ngl
anyways, Imma go bang my head, take care caeden
so you can stay shush
no they are called widgets 👁️ 👁️
oh btw ty for trying to help earlier
oh widgets is the Label and embeds are like categories in it
its like me calling discord.py a python library and you arguing over it saying its a discord api wrapper
or im wrong
okimii what time is it for you
not a good example 👁️ 👁️
nvm I should go lmao
it is
6:52am
ok

Iterating over range(len(...)) is a common approach to accessing each item in an ordered collection.
for i in range(len(my_list)):
do_something(my_list[i])
The pythonic syntax is much simpler, and is guaranteed to produce elements in the same order:
for item in my_list:
do_something(item)
Python has other solutions for cases when the index itself might be needed. To get the element at the same index from two or more lists, use zip. To get both the index and the element at that index, use enumerate.
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
#bot-commands
?
!ot
how
wym?
tell me you didnt add the id and <@>
damnn
oh I mean if u mention the bot it will say the messages u want it to send
P.R.O.
yes but you didn't do it the way i said right?
no thats not how u do it , its @Username#Discim
no, use the ids lmfao
got the wrong thing
yeah so he used the on mention prefix
when_mentioned actually
@client.event
async def on_message(msg):
if client.user.mentioned_in(msg):
await msg.channel.send(embed=discord.Embed(title="Prefix", description=f"My prefix is {prefix}",color=0x206694))
!d discord.ext.commands.when_mentioned
discord.ext.commands.when_mentioned(bot, msg)```
A callable that implements a command prefix equivalent to being mentioned.
These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.
boomer ¯_(ツ)_/¯
you know , everyone pings work too
or u guys talking bout other thing

theres when_mention_or("")
no
yes
from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
Unable to import discord.ext.commands, for some reason
My imports:
import os
import colorama
import discord
import discord.ext
import datetime
from discord.ext import commands
from discord.ext import tasks
import random
import requests
import json
import asyncio
import time
from colorama import Fore
Does anyone know why this doesn't work? I'm using Discordpy.
It's when_mentioned_or
import commands
remove import discord.ext
Ok, thanks
Okimii, learn tenses
and you can use brackets to import msny stuff
you said to add the ids
that was a joke
Still unable to import, same error.
idk chief
can you give me free nitro
Try pinging everyone, the bot will respond that time also
pls
hey you, how you dare to talk to God Okimii like that, everything works for God Okimii
i dont have nitro myself
from discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)
My code:
import os
import colorama
import discord
import datetime
from pypresence import Presence
from discord.ext import commands
from discord.ext import tasks
import random
import requests
import json
import asyncio
import time
from colorama import Fore
someone else
i made everything
how?
@lemon#0001 we need free nitro
I believe in caeden supermacy
ohh
did you do pip install discord or pip install discord.py
I'll change mine then
how did you make it
pip install discord i think, idk i usually use pycord
I mentioned lemon on purpose lmao
😂
its discord.py
@slate swan
pycord ☠️
how did you make it
agreed
nope
Still same error
.
lmfao
No, pycord is not uwu


||you are||
how did you make it
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
make what
okimii high spams random commands?
like a dev?
yes pycord is uwu
no just you
SOFTWARE dev

yeah yeah, I suck ikrr
that chicken thing feels like nitro
chicken?
whats to make it organised?
do ban/unban then mute/unmute and lasty Kick?
wut chicken thing
this
or should I just make the #------Mute------#
Fine , I don't want to talk shit about that library rn
very
how do i code a discord bot in python? i cant find a proper tutorial on youtube (like what do i need to install etc.)
timeout them, kick, ban, report to discord
easy
pls
i mean should I use the #----------# to separate each commands or not xD
sir , it's a help channel related to discord bot development
https://vcokltfre.dev/ follow this
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
guys is it useful if I made a calculator bot which calculates almost anything like doing calculus and trigonometry stuff?
You may ask for your nitro in #python-discussion
thanks 🙂
yw
oh yeaaa I forgot timeout exist
any help
yes please
:)
Tho how would it get user inputs like the integration sign and log
depends if you are able to make one
pfp grabber? xD
no no im already making it with commands like diff() integrate() and expanding polynomials
no im trying to do image manipulation
can someone help pls

Seems good. Lemme know when you're done with it 
I would love to get that bot ngl
no ip grabber
nty
im almost done, if you wanna join the test server, you're most welcome
Are you on 2.0
try to change author to Member
idk how tbh but try it
BRO WHAT
the author is a member obj
how to clear help command?
shhh
WHATTTTTTTTTTTTTTTTTTTTTTTT
u ruined my plan
help_command=None
Don't clear it , just subclass it
And make your custom one
who actually subclasses it
2 people ruined my plab 🥲
Me
cuz i dont👁️ 👁️
i want to clear :/
ctx.author.avatar.with_size(512)
i sent it
anyone wanna test my calculator bot?
sure imma hop in
sheesh dont have to be rude...
caeden chill out
yeah thx
werent you a clueless beginner once?
u got a point, but ik author mean the members
and im saying u got a point cuz theyre once a beginner
we all started from somewhere and people start at different times yes its misinformation just say he isnt correct no need to be hostile he isnt a threat
and that 2nd one is to answer that caeden
!d discord.ext.commands.Context.author can be a user or member.
Union[User, Member]: Returns the author associated with this context’s command. Shorthand for Message.author
@primal salmonbro my bot started check it out
I already did
im going to school have a great day guys 
bai bai, good nighto
broken link
gn for you gm for me
yeah yeah lol, take care
you too 
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
i know you to well

lol
lol
Lol you do you change your pfp that many times 
nah
is there difference between discord.guild.ban and discord.Member.ban?
No
You can use the guild instance to ban any user, including users that are not a member of your community. For a Member.ban, it has to be a Member.
Yea, that too
thats pretty useful
yea in case you want to ban someone who is not in the current Guild
imma use guild so I wont have to change it if im planning to ban someone whos not from the server
syntax error in About Me???!
oh nah, I just can't read it till the end
What happened to this
wait do I use if after doing async def
async def if?
like async def lol(ctx):
if
what?
hm? whats wrong innit
no no xD
yeah why not
the hyperlink
ah kk
all of them work for me 
where have I heard the name cirno from
ok
holdup I forgot how to do this lol
anime
async def ban(ctx, guild): or should I just remove the guild
Use a member instead 
why do you want guild as a parameter in ban command?
why?
did you even add guild

if you want current server's object use ctx.guild...
.
mate which one are you gonna use
Guild.ban or Member.ban??
Guild.ban
either use ctx.guild and add member argument, or add guild, member and use await guild.ban(member)
and typehint it
aight
There is a difference between a user and a member.
imho, the member.ban is cleaner if u got the member object
Actually there's no need for it to be updated that much... The source code is easily and u can easily edit it to match with the latest syntax and use it
Your own IPC or API.
If you ever want to make it public the dashboard you would need to make your own api.
The only mechanism it works in is, creating a websocket connection with the bot and requesting for data
you don't even need to be smart to do what hunter said
If I can understand the source, anyone can
I recommend your own api or maby even a redis to connect it to.
as extra.
Err well, dashboard is a bit out of the discord-bots spectrum but we can give a general idea. For more extensive problems or errors please use #web-development or #networks combined with #cybersecurity. You can also ask for some tools to help you at #tools-and-devops.
yo anyone know why this returns none? await user.add_roles(role)
I have member intents
You can't add roles to a user.
Try to fetch it
fetch_member?
Sarthak god literally told you why ;-;
You would also need to use an aoth extension or make one yourself. Conclusion you need a lot of skills and combine that to make this all work.
Why fetch
!d discord.Guild.fetch_member
await fetch_member(member_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") from a guild ID, and a member ID.
Note
This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_member()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.get_member "discord.Guild.get_member") instead.
I tried what he suggested, but it didn't seem to work
uhuh
member could be not in the cache ig?
That's a very edge case tbh
Yeah will it is doable, but you do need a lot of skill.
People can simply open the console, see how your API works and very easily request yr bot's token or any other sensitive information without anyone knowing
at least try it yourself and then ask ;-;
await guild.fetch
'guild is not defined'
yeah didn't work so was wondering if I did the syntax right lol
cof cof
Yes.
AttributeError: 'coroutine' object has no attribute 'add_roles'
.
What if they are using the difficult art of assigning the easy attribute, named guild, belonging to the commands.Context class to a variable so as to increase the memory usage of the application and to decrease the length of the line as a whole?
await
I'll go to my class, thats way easier
bye
👋
Okay
Does anyone know how I can do a perms check with the database, I have a command to add a person in the premium category and I would like her to use only those commands. I use mongodb
you can assign the "premium" role optionally
I use mongodb to store users
!d disnake.ext.commands.check
@disnake.ext.commands.check(predicate)```
A decorator that adds a check to the [`Command`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Command "disnake.ext.commands.Command") or its subclasses. These checks could be accessed via [`Command.checks`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Command.checks "disnake.ext.commands.Command.checks").
These checks should be predicates that take in a single parameter taking a [`Context`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Context "disnake.ext.commands.Context"). If the check returns a `False`-like value then during invocation a [`CheckFailure`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.CheckFailure "disnake.ext.commands.CheckFailure") exception is raised and sent to the [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.disnake.ext.commands.on_command_error "disnake.disnake.ext.commands.on_command_error") event.
If an exception should be thrown in the predicate then it should be a subclass of [`CommandError`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.CommandError "disnake.ext.commands.CommandError"). Any exception not subclassed from it will be propagated while those subclassed will be sent to [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.disnake.ext.commands.on_command_error "disnake.disnake.ext.commands.on_command_error").
Sniper's method has flaws since they then only can perform that command inside 1 guild.
I want for all guilds

then you'll have to keep a cache of all guild / member_id's who are premium, because you obviously don't want to fetch whenever a command check is executed
anyone know how to make it like the bot sent dm to the member when the mod using the commands
like if a mod banned someone , the bot will dm the banned person
await member.send("this is a DM")
oh I thought I need the DM something
nope
🥲 ig im dumb
it's in the FAQ of the docs
Old code.
No ableist language in this server please.
albeit?
Yes, I have already tested the database and everything works, I don't know how to check only
look at the given link ^^
and scroll down to the examples
Blue == clickable url
Yea yea ik thx
await ctx.send is suppose to make the bot send the messages right?
Yep
somehow mine didnt 
Well, can you share the code?
The general example is:
@bot.command()
async def command(ctx):
await ctx.send("your content goes here")
you have to pass ctx as a param
async def on_comand_error(ctx, error):
if isinstance(error, commands.MissingRequiredArguement):
await ctx.send('Please include all the requirement')
if isinstance(error, commands.MissingPermissions):
await ctx.send('You dont have permissions to do this!')
parameter?
It's on_command_error
What's the error :P
nvm it didnt change the problem
the one changed the problem was I added @client.event
but still I got the same problem
Well, a few questions:
client.event or not?in a cog?
and 1) if I use client.event it somehow give other problem like this
there's a typo

It's commands.MissingRequiredArgument
!d discord.ext.commands.MissingRequiredArgument
exception discord.ext.commands.MissingRequiredArgument(param)```
Exception raised when parsing a command and a parameter that is required is not encountered.
This inherits from [`UserInputError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.UserInputError "discord.ext.commands.UserInputError")
All good
ty xD fixed
👍
!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/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.
wait what
Yeah -> #926115595307614252 message
hy guys is there is any way that my bot will only work in server not in private dm
!d discord.ext.commands.guild_only
@discord.ext.commands.guild_only()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that indicates this command must only be used in a guild context only. Basically, no private messages are allowed when using the command.
This check raises a special exception, [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
should i paste in any where in the code ?
I dare you to try
yeah tryying
gl on that
how to stop the same command being run at the same time
or before the last one has finished
or stops the last one
i try but fail
!d discord.ext.commands.max_concurrency
@discord.ext.commands.max_concurrency(number, per=discord.ext.commands.BucketType.default, *, wait=False)```
A decorator that adds a maximum concurrency to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses.
This enables you to only allow a certain number of command invocations at the same time, for example if a command takes too long or if only one user can use it at a time. This differs from a cooldown in that there is no set waiting period or token bucket – only a set number of people can run the command.
New in version 1.3.
can you help me where to implement this .. ?
remove discord.ext and you'd be left with what you need
shitt
I keep misspelling
thats what happen to everyone
🗿
imagine misspelling smh
🗿
how xD
btw guys where you hosted your bots ?
:v now ill need to make more
He insulted you, now reading back his infractions had a good laugh
netcup
lol ?
wait when did he insulted me?
was bout to reply to that
We all laughed at him, we got a private server with all the regulars of the python-bots channel
xD but is he at the private server
well was
I dont think he got banned just by 1 insult
Well we discuss some small things there.
You got that right, he kept fighting with 2 mods lol
sheesh
got no respect but I can see that he's a good/bad person xD aka half half
His intentions are good.
but the way he said it
Just the execution.. err
many ways
hy guys can someone help me where to implement this
client.ext.commands.guild_only()
it didn't work like this
Caeden is **** and **
some bad ways and some good ways ig
its meant for commands, not events
lmao I can see caeden's reaction rn
!d discord.Message.guild
The guild that the message belongs to, if applicable.
wait what are u making actually?
this will not be None if the message was used in a server
web scarping thing
u need to put that under @client.command
Yeah lol
wtf
wotah?
so you can py if not message.guild : return
it's an on_message 
nvm
thx bud
This makes no sense 😂
how?
probably you should have said client.listen() or something else
I only have ban/unban and help conmands so far
for your bot?
Oh no this is valid mb