#discord-bots
1 messages Β· Page 685 of 1
@visual island
intents = Intents.default()
intents.members = True
intents.reactions = True
bot = commands.Bot(command_prefix="?", intents=intents)
For some reason I am getting this error because of the intents:
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
read it 
yeah, ik, I can't find anything to do with it in the application thingy
help ._.
nvm, I found it @visual island
with?
discord bot
yea i know that, but what issue
A guide for how to ask good questions in our community.
oh
if any(word in message.content for word in wrod1):
await message.channel.send("Dont")
if anyone say that word then i want to add his name in a list.
and how many time he said that .
So, when i call on the help command(now, i haven't made one myself but it appeared anyway) a list of all the commands is sent, my code doesn't have this in it? Why did it send it?
the help command is default
oh
and also if your gonna make it subclass it (https://gist.github.com/InterStella0/b78488fb28cadf279dfd3164b9f0cf96), dont remove the default help command like what tutorials do
but then how do i show how to use each command
command description?
yup
use a database
how do i show command description, idk how because i didn't make the command
@client.command()
async def buy(ctx, *itemm):
actualitem = {}
for i in range(len(shopp)):
if itemm in shopp[i]["name"]:
actualitem = shopp[i]
break
print('works')
print(actualitem)
how to fix error?
@visual island also how do i get the command with its args
!d discord.ext.commands.Command.description
The message prefixed into the default help command.
like it's purge [limit] here in the base help
what is line 183?
command.signature
oh
i have no idea about OOP
learn
if itemm in shopp[i]["name"]:```
item is a tuple
There's a difference between a class and an instance. Think of it like this:
- A class is like a blueprint, or a concept. It defines what something should have, but it's not the same as actually having it.
- An instance is the 'realized' version of the class, it contains everything that the class defines should be on it, but you can actually access and interact with these features.
Let's consider the Cat. We know a Cat has a name and an age, but Cat.age won't work, because Cat isn't an actual cat, it just represents the concept of a cat. It's like asking "What is the age of a cat?" - it doesn't make sense, because we need to have an actual cat.
mimi on the other hand is an instance of a Cat - it has everything a Cat should have. Maybe mimi was constructed, like mimi = Cat("Mimi", age=4), or maybe mimi was retrieved from somewhere else, like house.cats[0], but in any case, it has everything we need, and mimi.age will rightfully give us 4.
There are many situations in Object Oriented Programming where you will need an **instance **instead of a **class **to perform an operation properly (in fact, you almost always need an instance instead of a class), and these cases will usually be documented.
You should learn a good amount about Object Oriented Programming before working extensively with discord.py.
https://i.imgur.com/dHYdejb.png
Read more about classes and instances here:
- https://www.digitalocean.com/community/tutorials/understanding-class-and-instance-variables-in-python-3
- https://docs.python.org/3/tutorial/classes.html
Credit: devon
your saying
if tuple in "string":
class = the infrastructure, an instance copies that same infrastructure and you can change it, but it doesn't affect the first class.
shopp = [
{"name":"item1","price":3000,"description":"somedescription"},{"name":"iitem2","price":500,"description":"desc"}
]
```i set it to be a dict tho.. ? :(
itemm not shopp
*args returns a tuple
in your case *itemm will return a tuple also
how do i get the bot descriptio
?? sry i dont understand
!e
def foo(*itemm):
print(itemm)
foo(1, 2, "hi")
@visual island :white_check_mark: Your eval job has completed with return code 0.
(1, 2, 'hi')
oh
how do i turn it into a str?
is there a character limit on commands? Because the documentation i wrote myself is around 7000 chars
make it ctx, *, itemm instead of ctx, *itemm
ohkk ty
commands?
ah, number of commands?
nah
no, the amount of characters you can send in a message using commands?
i want to make a nsfw command
maximum number of characters in a message is 2000 (without nitro) and 4000 (with nitro)
I dont get what you mean by "using commands"
its working perfectly, but the problem is
if ctx.channel.is_nsfw:``` wont work and its still sending the nsfw shit in non-nsfw channels
can anybody help?
show full code
icy do you have an example of a group command help in your bot
need some inspiration 
@client.command()
async def boobs(ctx):
channel = ctx.channel
if channel.is_nsfw:
r = requests.get("https://nekos.life/api/v2/img/boobs")
res = r.json()
try:
async with aiohttp.ClientSession() as session:
async with session.get(res['url']) as resp:
image = await resp.read()
with io.BytesIO(image) as file:
await ctx.send(file=discord.File(file, f"boobs.gif"))
except:
em = discord.Embed()
em = discord.Embed(color=0)
em = discord.Embed(title="Nsfw")
em.set_image(url=res['url'])
await ctx.send(embed=em)
else:
await ctx.send("WOAH! SLOWDOWN BUD! THIS CHANNEL AINT NSFW.")
return```
FULL bot code is over 300 lines
uhhhhhhhhhhhhh
server doesnt support .txt files
what
still wasn't expecting dat
no, will do in the next update
. Just need to add it to my todo list
Well, what errors do you have?
@visual island
bro what errors are you getting?
try to do ```py
@command
async def _command(self, ctx):
if not channel.is_nsfw:
return
# do your stuff here
i think that'd work
it still sending the command in non nsfw channels
alr
why self in command tho
the thing is ctx.send isnt in the if statement
it's outside of it
cog example
await ctx.send(embed=em)
so, returning would cancel the command
your else is inline with the try and except, not if statement
anyways else would be redundant since you have a return already
how do i fix
you could do ```py
@command
async def _command(self, ctx):
if not channel.is_nsfw:
return await ctx.reply('cant use this in non-nsfw channels')
# do your stuff here
just put everything inside the if statement
indentations, basic py
or that
this would save your hassle imo
!custom-check works also
Custom Command Checks in discord.py
Often you may find the need to use checks that don't exist by default in discord.py. Fortunately, discord.py provides discord.ext.commands.check which allows you to create you own checks like this:
from discord.ext.commands import check, Context
def in_any_channel(*channels):
async def predicate(ctx: Context):
return ctx.channel.id in channels
return check(predicate)
This check is to check whether the invoked command is in a given set of channels. The inner function, named predicate here, is used to perform the actual check on the command, and check logic should go in this function. It must be an async function, and always provides a single commands.Context argument which you can use to create check logic. This check function should return a boolean value indicating whether the check passed (return True) or failed (return False).
The check can now be used like any other commands check as a decorator of a command, such as this:
@bot.command(name="ping")
@in_any_channel(728343273562701984)
async def ping(ctx: Context):
...
This would lock the ping command to only be used in the channel 728343273562701984. If this check function fails it will raise a CheckFailure exception, which can be handled in your error handler.
ah yes
doesnt work
what doesnt work
i tried making it
@client.command()
async def boobs(ctx):
channel = ctx.channel
if channel.is_nsfw:
r = requests.get("https://nekos.life/api/v2/img/boobs")
res = r.json()
try:
async with aiohttp.ClientSession() as session:
async with session.get(res['url']) as resp:
image = await resp.read()
with io.BytesIO(image) as file:
await ctx.send(file=discord.File(file, f"boobs.gif"))
except:
em = discord.Embed()
em = discord.Embed(color=0)
em = discord.Embed(title="Nsfw")
em.set_image(url=res['url'])
await ctx.send(embed=em)
if not channel.is_nsfw:
await ctx.send("WOAH! SLOWDOWN BUD! THIS CHANNEL AINT NSFW.")
return```
so it still send those images in kids channels
discord is 13+


technically still kids
@client.command()
async def boobs(ctx):
channel = ctx.channel
if channel.is_nsfw:
r = requests.get("https://nekos.life/api/v2/img/boobs")
else:
await ctx.send("WOAH! SLOWDOWN BUD! THIS CHANNEL AINT NSFW.")
return
res = r.json()
try:
async with aiohttp.ClientSession() as session:
async with session.get(res['url']) as resp:
image = await resp.read()
with io.BytesIO(image) as file:
await ctx.send(file=discord.File(file, f"boobs.gif"))
except:
em = discord.Embed()
em = discord.Embed(color=0)
em = discord.Embed(title="Nsfw")
em.set_image(url=res['url'])
await ctx.send(embed=em)
``` try this
syntax error
send error
the indentation is broken, not me
no
ok
i don't use embeds tho
@visual island help
u messed the whole async def code 
ctrl+z
ye i did that
send code + error
this
@client.command()
async def boobs(ctx):
channel = ctx.channel
r = requests.get("https://nekos.life/api/v2/img/boobs")
res = r.json()
try:
async with aiohttp.ClientSession() as session:
async with session.get(res['url']) as resp:
image = await resp.read()
with io.BytesIO(image) as file:
await ctx.send(file=discord.File(file, f"boobs.gif"))
except:
em = discord.Embed()
em = discord.Embed(color=0)
em = discord.Embed(title="Nsfw")
em.set_image(url=res['url'])
await ctx.send(embed=em)
if not channel.is_nsfw:
await ctx.send("WOAH! SLOWDOWN BUD! THIS CHANNEL AINT NSFW.")
return```
your not kidding right
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
no
.
.
i not kidding
.
!ot
Off-topic channels
There are three off-topic channels:
β’ #ot2-never-nesterβs-nightmare
β’ #ot1-perplexing-regexing
β’ #ot0-psvmβs-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
idk
images of the images of messages
we are on topic ?
images of the messages*
BRUHHHH
didn't work
is this boy serious
no but imma do anyway

idk
can u help me
Sure
@client.command()
async def boobs(ctx):
channel = ctx.channel
r = requests.get("https://nekos.life/api/v2/img/boobs")
res = r.json()
try:
async with aiohttp.ClientSession() as session:
async with session.get(res['url']) as resp:
image = await resp.read()
with io.BytesIO(image) as file:
await ctx.send(file=discord.File(file, f"boobs.gif"))
except:
em = discord.Embed()
em = discord.Embed(color=0)
em = discord.Embed(title="Nsfw")
em.set_image(url=res['url'])
await ctx.send(embed=em)
if not channel.is_nsfw:
await ctx.send("WOAH! SLOWDOWN BUD! THIS CHANNEL AINT NSFW.")
return``` is my code and i want it to only happen if the channel is nsfw but it sends on normal channel too
@slate swan

shouldn't the except block have an error in it? or not?
it doesnt send a error
do u want the server invite?
no
so, does it send the file then say that the channel isn't nsfw?
On a other note, try to split up your code into separate functions.
A simple example using your code -
def async send_file(ctx, res, filename) -> None:
async with aiohttp.ClientSession() as session:
async with session.get(res['url']) as resp:
image = await resp.read()
with io.BytesIO(image) as file:
await ctx.send(file=discord.File(file, filename))
def async Emd(dis):
embeds = {"color": 0, "title": "NSFW"}
em = dis.Embed()
[em := dis.Embed(k, v) for k, v in embeds.items()]
return em
@client.command()
async def boobs(ctx):
channel = ctx.channel
if channel.is_nsfw:
r = requests.get("https://nekos.life/api/v2/img/boobs")
res = r.json()
try:
send_files(ctx, res, "boobs.gif")
except:
em = Emd(discord)
em.set_image(url=res['url'])
await ctx.send(embed=em)
if not channel.is_nsfw:
await ctx.send("WOAH! SLOWDOWN BUD! THIS CHANNEL AINT NSFW.")
returnβ
β’ Obviously this could be simplified further, its just an example.
β’ Tried to keep true to your original code as much as possible.
!d discord.ext.commands.is_nsfw use this
@discord.ext.commands.is_nsfw()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the channel is a NSFW channel.
This check raises a special exception, [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure"). DM channels will also now pass this check.
Ok
what i just sent
I also want it to send WOAH! SLOWDOWN BUD! THIS CHANNEL AINT NSFW. if the channel aint nsfw
Uh?
so, py @client.command() @commands.check(channel.is_nsfw=True) async def blank(ctx):?
im trying @discord.ext.commands.is_nsfw()
then what?
even if it was to be like that it would be
@commands.check(channel.is_nsfw)```
but we would have to DEF it
what
@boreal ravine it worked but i want it to send a message if it aint nsfw pls help
What's the discord.ui class for a button to send a message when clicking it?
Talking about discord.py 2.0
!d discord.Interaction.response.send_message
No documentation found for the requested symbol.
!d discord.Interaction
class discord.Interaction```
Represents a Discord interaction.
An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.
New in version 2.0.
@boreal ravine it worked but i want it to send a message if it aint nsfw pls help
what
!d discord.Interaction.response
Returns an object responsible for handling responding to the interaction.
A response can only be done once. If secondary messages need to be sent, consider using followup instead.
oh OK I GOT IT
gj
I'm sorry I have never used these kind of stuff, how do I insert an "interaction" into a button message?
you have the discord.ui.button object right?
or r u using something else
Yes I have
oh so I can get an interaction when pressing
right
for example I found in the github repo:
@discord.ui.button(label='Confirm', style=discord.ButtonStyle.green)
async def confirm(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.send_message('Confirming', ephemeral=True)
Are you trying to send a message on interaction?
yes
π
@boobs.error
async def boobs_error(ctx, error):
if isinstance(error, commands.CheckFailure):
await ctx.send("Yo! Nsfw not allowed in this channel bro!")
return``` worked for error
No need for return
Yeah, so imagine I have 5 buttons on one message, how can I check what button has been pressed to send the specific message needed?
okk
Well each button can send their own message on interaction just add a unique message to each button
If thats what you want to do
Yeah that's what I want to do. My question is do I have to define a different class for each button?
You dont
You subclass View and you add each button to the sub class and then you view the class on the Message you want the buttons on
okay I think I got it let me try, thank you
Anytime!
not an error/issue but i was wondering, this code right here
try:
for i in range(len(shopp)):
if itemm in shopp[i]["name"]:
actualitem = shopp[i]
break
except:
await ctx.send(embed=discord.Embed(description="that item doesn't exist! Check `m.shop` for more."))
return
```how do i make it so that, after the `for` loop is done and it still hasn't seen `itemm` in `shopp[i]["name"]` it raises an error?
also there a way to get a role object using client.get-?
i dont think so
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
ok ty
now this ^
class pogs(disnake.ui.Select):
def __init__(self):
options = []
for cog in bot.cogs:
options.append(disnake.SelectOption(label=cog.qualified_name, description=cog.description))
super().__init__(placeholder="pick!",min_values=1,max_values=1,options=options,)
async def callback(self, interaction: disnake.MessageInteraction):
await interaction.response.send_message('yes')
class v(disnake.ui.View):
def __init__(self):
super().__init__()
self.add_item(pogs())
await ctx.send('a', view=v())
``` im getting `RuntimeError: super(): no arguments` for some reason
You need to do super.init on the select as well
i did though
Oh just saw that
hm
doesn't have one, i was using jsk
hm
whats LGTM
looks good to me
o
I am trying to make a verification system using the on_raw_reaction_add function, and it all works correctly, whenever the user reacts to the "verification" message with the check mark emoji, he gets granted a role, which grants him access to the rest of the server, so it all works. But if the user decides to leave the server, he loses his role, but the reaction is still there on the message. So if he wants to rejoin, he will have to remove the reaction, and then add it again
Is there some kind of function which can remove the reaction if the user leaves the server?
on_member_remove
thanks
Check if the user that left has a reaction, if so, remove it
yeah, that's what I was planning to do, thanks
@sick birch my bad the super was outside the __init__ dunder
why am I getting this? ```py
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ui/view.py", line 367, in _scheduled_task
await item.callback(interaction)
File "main.py", line 25, in callback
await utils.HelpCommand().send_cog_help(cog)
File "/home/runner/bonbons-1/utils/help_command.py", line 88, in send_cog_help
await self.send_help_embed(
File "/home/runner/bonbons-1/utils/help_command.py", line 70, in send_help_embed
icon_url=self.context.author.display_avatar,
AttributeError: '_MissingSentinel' object has no attribute 'author
?
I had a idea but nvm
ok
what is "_MissingSentinel"?
self.context.author is like ctx.author?
@bot.command()
async def text(message):
with open('image_urls.txt', 'r') as f:
lines = f.readlines()
g = random.choice(lines)
e = discord.Embed(title='hello',
description='** tyfor Voting Me Here Is The Reward**', color=0xcf24ff)
e.set_image(url=f'{g}')
user = await bot.fetch_user(message.content)
await user.send(embed=e)```
it only sends text but no image
!d discord.ext.commands.HelpCommand.context
The context that invoked this help formatter. This is generally set after the help command assigned, command_callback(), has been called.
yes
does the user have default pfp?
no image? wdym by that
icon_url=self.context.author.avatar.url if yes, that should work
the embed has just text not any image in it
ig
try the code and if it does not work and same error is given, then I have no idea
wut code
display_avatar does the same thing though
give it a try
but like that isnt the problem
how can I see all the reactions of a particular message?
works fine
!d discord.Message.reactions
Reactions to a message. Reactions can be either custom emoji or standard unicode emoji.
oh...I thought because of this
I've already read the docs, there is literally only one line on it, and it is very unhelpful
like dis
get your discord.Message object, use the reactions attribute on it
msg = ...
print(msg.reactions)
huh
that embed does not look like the code you sent
i know cuz its long look at dis
@bot.listen()
async def on_message():
if message.channel.id !=898872072762195999:
return
with open('image_urls.txt', 'r') as f:
lines = f.readlines()
g = random.choice(lines)
e = discord.Embed(title='Hello, Goshujin-sama',
description='**Arigato Gosaimushta for Voting Me Here Is The Reward**', color=0xcf24ff)
e.set_image(url=f'{g}')
e.set_footer(text='Goshujin-sama The Above Image Is Fan-Art By Its Respective Anime Community, I or Creator-Sama Has 0 Contributions In It')
user = await bot.fetch_user(message.content)
await user.send(embed=e)```
It s a private variable in their files and if I think I might know what is causing it, let me see that part of your code
which part of my code?
Interested in your feedback.
L
god fucking damn why does await guild.create_text_channel('fuckyou') creates 5 fuckyou channels
it doesn't
whatever is around line 70
it's probably in a loop of some
the class
it is though
it cant create 5 channels for no reason
unless its in a loop of some kind
async def send_help_embed(self, title, description, commands):
embed = HelpEmbed(title=title, description=description or "...").set_footer(
text="Use help [command] or help [category] for more information.",
icon_url=self.context.author.display_avatar,
)
if filtered_commands := await self.filter_commands(commands, sort=True):
for command in filtered_commands:
embed.add_field(
name=self.get_command_signature(command),
value=command.help or "...",
)
await self.send(embed=embed)
unless py3.7 now goes back up the code without any reason then its some annoying bug or smthing
this is inside a class correct?
show your code around the method
yes
show me the class too
which part
for guild in client.guilds:
for channel in guild.channels:
if "adxbot-dm" in str(channel):
embed = discord.Embed(title="DM already open!", description="Wait for closing", color=0xFF0000)
await message.channel.send(content=None, embed=embed)
cmd = "a!dm open"
elif "adxbot-dm" not in str(channel):
await guild.create_text_channel('adxbot-dm')
its in the for loop
what did I say.
"elif"
yes
it should stop the loop right there
the elif gets called multiple times ig
loops cant stop unless you stop it
and you don't need a condition
you can just do else
ik I added it just to make sure

aight well I have added break in the first if
and this logic is really bad
well no shit its made in message.content not command kek
it makes a channel for every channel in the list that comes before adxbot-dm
how can I get all the users for a certain reaction tho?
my code is a mess but it works
only if the very first channel is the dm channel, right?
!d discord.Reaction.users
async for ... in users(*, limit=None, after=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") representing the users that have reacted to the message.
The `after` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
Examples
Usage
```py
# I do not actually recommend doing this.
async for user in reaction.users():
await channel.send(f'{user} has reacted with {reaction.emoji}!')
```...
could imagine something like
yeah, I found that, but how can I get the certain reaction from message.reactions?
discord.Message.reactions returns a discord.Reaction object, just use the users attribute on your reactions attr earlier
certain reaction?
like you wanna check?
if any("string" in channel.name for channel in guild.channels)
well, if a message has a few different reactions on it, and I just want to check for one of them
this doesn't work btw, I already have tried that
it doesn't return a reaction object da heq
first line of the tag
returns an Asynciterator
Are you sure about that
!d discord.Message.reactions it doesnt?
Reactions to a message. Reactions can be either custom emoji or standard unicode emoji.
wait bad tag
okay, I fixed it, it works now
reactions returns a list
yes my bad
you can index that list in order to get a reaction object
so:
message.reactions[0].users
.flatten()
is used most of the time on users
!d discord.Reaction.users
async for ... in users(*, limit=None, after=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") representing the users that have reacted to the message.
The `after` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
Examples
Usage
```py
# I do not actually recommend doing this.
async for user in reaction.users():
await channel.send(f'{user} has reacted with {reaction.emoji}!')
```...
yes
oh users is a method
kinda weird how it isnt a property
hm
might just be the discord api being weird
how to create new role?
!d discord.Guild.create_role
await create_role(*, name=..., permissions=..., color=..., colour=..., hoist=..., mentionable=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") for the guild.
All fields are optional.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to do this.
Changed in version 1.6: Can now pass `int` to `colour` keyword-only parameter.
stickers? not sure if thats possible...
i want to make like this
!d discord.ui.Button.emoji
property emoji: Optional[discord.partial_emoji.PartialEmoji]```
The emoji of the button, if available.
!d discord.ui.button
discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.
The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View "discord.ui.View"), the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") being pressed and the [`discord.Interaction`](https://discordpy.readthedocs.io/en/master/api.html#discord.Interaction "discord.Interaction") you receive.
Note
Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
it has an emoji kwarg you can use, just put the emoji + id in there and it'll work
thank you very much!
π
afaik stickers are different to emojis but if it works it works
they meant emojis
mmmm
is color supposed to be a str or int im having problems there
an int
How can I make my bot Dm a user when they send a specific message
For example: $help
Dms stuff ye
i did this:
@client.command()
async def add(ctx, hexx, *, name):
await ctx.author.guild.create_role(name = name, color = int(hexx))
await ctx.send("added!")
error:
its supposed to be 0x2f3136 my bad]
a

no idea
a base 16 int
so int(num, 16)
int(hexx, 16)
makes it int with base 16 - hex
casting can take another argument?
in int, yeah
hm
kk
if u want to use an event:
@client.event
async def on_message(message):
if message.content == '$help':
await message.author.send("ye")
use commands instead
Anyone good with dropdown menus?
bruh that's it wat
yeah true if it starts with the prefix
message.author.send
Is that actually it
!d discord.Member.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
how can you list all members with a specific role given
!d discord.Role.members
property members: List[Member]```
Returns all the members with this role.
i thought it was if role in ... or something
is it possible to list all the members with a specific role using in
sorry i worded that badly :P
[k for k in guild.members if role in k.roles]
so for <role_obj> in ctx.guild.members or the whole thing
how do i turn a tuple into a list
oh wait
list(tuple)
ok ty
!e py my_list = [1, 2, 3] print(tuple(my_list))
@manic wing :white_check_mark: Your eval job has completed with return code 0.
(1, 2, 3)
guild.members returns a lis of member objects not roles
can tuples be treated the same way as lists when using conditions? (eg if)
ex: ```py
my_tuple = (1,2,3)
if 1 in my_tuple:
#something
pretty sure
!e
my_tuple = (1,2,3)
if 1 in my_tuple:
print("test")
@shadow wraith :white_check_mark: Your eval job has completed with return code 0.
test
tuples are pretty much the same as lists, so yeah. only different is you cant mutate a tuple
okk
can i say my_tuple[0]?
yes
yep
think of it as a list
only different is you cant edit the contents
ty
!e ```py
t, k, w = (True, 10, 'yes')
print(k)
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
10
i never knew you could do that
int i think
int yeah
Yep, int
tuple unpacking
I ran in bot commands
so you stored values in tuple, but if you want to access that value it's same as you would have done ```py
a, b, c = 1, 2, 3
is there a way i can have an image below a field?
!source
discord limitation
!d discord.Embed.image
property image: _EmbedMediaProxy```
Returns an `EmbedProxy` denoting the image contents.
Possible attributes you can access are...
:o i didnt know that was possible ty
f bruh
It's called tuple unpacking
that works with all iterables right?
i already know about, but i was thinking of if i can put an image under each field
that would be cool though
Yeah and str too etc it's kinda weird if you dig deep enough'
Ah no.
how can I delete all categories and channels with the same start of name ? for example
all categories and channels that start with ge are removed by the bot
you can iterate through guild.channels and check if the name starts with ge
does it work with categories too ?
for channel in guild.channels:
if channel.name.startswith('ge'):
await channel.delete()
await asyncio.sleep(1)
you could iterate through guild.categories and check the name
Yes channels attr include categories.
okay thanks
!d discord.abc.GuildChannel
class discord.abc.GuildChannel```
An ABC that details the common operations on a Discord guild channel.
The following implement this ABC...
hey please help me
i creating socket server
and listen datas
i add thread
how to call async function inside a thread
i try this but not work
why are you using threading and asyncio? 
sorry for my bad english π
i create socket server
,
i read my game server chat
Is this discord bots
my error this
bot.get_channel, asynchronous, discord.abc.Messageable - i'd say thats good enough
alright
Full error?
ok sir 1 min
your code is a bit whack
RuntimeError: Timeout context manager should be used inside a task
!pypi pip install sockio
i reading
ceaden
socketio or sockio
Is there a difference
and is there a server example?
Server example?
!pypi socketio
me too π
this is my first discord bot project
Socket is used for the communication of two machines
Oh sorry couldn't notice it was sarcasm π
might be useful to get better at discord.py
yes
i love python
i dont love javascript
but if it continues like this i will love javascript more π
nodejs
i want to make same thing in console now lol
this is mtasa
gta sanandreas online mod
cool
not legal
actually i can make it with a setting
if admins enable message logging setting the messages will log in console
still illegal i guess
its probably the same as "we value your privacy" in many apps
or something
idk
π
Hello , how are you !
I'm working on a discord bot using discordpy , I just learn today than it's not up to date any more and It's better to use a fork
which one do you advise me ?
Who said itβs better
Itβs really just personal preference
I donβt like any of the forks, so I prefer to use the base discord.py
You can implement slash commands yourself quite easily
Not illegal, just breaks TOS
A friend , he didn't tell me "It's better" but " It might be better"
!pypi disnake
I will take a look thank you
Does anyone know how to make reaction roles that saves the data to a db
oh im using it
!pypi
package
!pypi <package>
Can also use: pack, package, pip
Provide information about a specific package from PyPI.
!pypi phlib
how
...
can you stop searching shitty libs here, use #bot-commands
!d discord.ext.commands.Bot.wait_for
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.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
!d discord.on_reaction_add
discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.
Note
To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
Note
This doesnβt require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message itβs required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
I think ik how to do the reaction role bit but idk how to save stuff to db
dont use embeds thats it, put the direct link as the content and send it. discord will do the embed work
thats not the topic of this channel, #databases
application bot system?
I was thinking of smth else while typing and accidentally wrote bot lol
whats application system
You know those bots that send questions in dms and stuff when you do a command
you would still use the Bot.wait_for method for the most part
!d discord.User.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
gonna be straight, what's easier to use between discord.py and discord.js?
hey guys how would i check if a member is online if i have the member object?
d.py i guess
idk js
member.status maybe,not sure
!d discord.Member.status
property status: discord.enums.Status```
The memberβs overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") instead.
huh?
There ya go
Oh
Isn't status either online, offline, idle, dnd?
What would be the easiest way to implement a feature into my bot that would give a role after x number of messages in the past 24 hours?
I think so
Then that is exactly what you should use @quaint epoch, right?
okay
It's worth to try, shall the docs page might tell me
!d discord.Member.status ?iggl
property status: discord.enums.Status```
The memberβs overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") instead.
@quaint epoch
thnx

how do you remove the default help command?
You shouldn't. Instead subclass it
A guide can be found here:
help_command=None as an option in discord.ext.commands.Bot()
Imagine not making your own help command
I borrowed mine
how would i send a dm to a user with their id?
put smth in the on_ready
the bot event
@bot.event
async def on_ready():
#whatever u want here
bot can be client
depending on what u put earlier
Bot status can be changed in the constructor
no
@hidden hazel
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.online,activity=discord.Game("with Essence")
print("Playing with Essence")
message.clean_content.lower.startswith("TEST") Should this work?
can ya stop
?
Dont

oh yh u should prob use bot.wait_until_ready
i forgot the thingy
I'm dying help me
okay sorry I'll stop being like that
Changing a bots presence on ready can make it disconnect as its an atomic action discord doesnt like when you sent a request and the bot isnt even connected fully with the gateway might not disconnect but after i think some tries you will get disconnected
Lol
Where you construct your commands.Bot instance
You can use an arg and typehint it to a member obj or get the user or use the author attr
can you transfer ownership to a bot?
cuz bots can create servers
how does that work
You can't transfer ownership I don't think
Plus bots can't make servers
They can make channels inside servers and categories n shit but they can't create a new server
They can
Since when?
I didn't know they could make a new server
they can
I thought they could only make channels n shjt
if the bot is in less than 10 servers it can make a server
How?
How do I invite the python bot to my server
On your application
On the discord Dev website
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
On there, pick your application, go to OAuth, URL gen then pick bot
There, exactly what I did, you go to the link you copied
how would i start a new line in an embed
He asked for the invite for the @python bot
Oh
Which you cant invite him since its only for this server
In the description it would be \n
woudl it be inside the ''
Yes
ty
Your welcome
Hey @slate swan! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
what is your host?
Back space
Hey @harsh abyss! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discordapp.com/developers/applications/me
Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!
You have to chill out rn
Lol is that the error?
Your being ratelimited youll have to wait
Yes
O ok stupid thx
Not sure but i think its like 2
Yw
im tryna run it and that blue text pops up idk how to fix it
You dont
And its not an error its the path of the file
well it dosent let me run it
Nice
so i cant test out the bot cause it dosent go online
Add the token
Show your run
How are you running your bot
client.run
Check line 41
and it was all working before and i used the bot but then ia dded the intents and it stopped working
Seems like its not right since its giving a syntax error
From what I can see in the traceback you have a bit of your bot's token outside of the method .run()
dont have any
Should be in the run as so:
client.run("oejtntkfjn")
its not the token cause that already worked its when i added the intents part
Show
do you have to use intents?
Depends
im using it for what im doing
what are u doing?
making a discord bot
Mind showing the intents var?
idk wtf that is
its towards the top of screenie
Or your whole code would be great
wym your whole
All.
let me cross out my token
Or copy paste it here without the token
Depends
i meant their
Mb
lol that's mb
ye thats why it doesn't come online
Show
wait let me put the token back in
lmao
Lol
you do kinda need the token
Need*
Still didnt work
is there an error?
Your doing soemthing wrong
^
then if i re indent it the blue text comes back up
is that the whole error?
send the whole error
Thatβs definitely not the full error
i'm pretty sure that's supposed to happen
i haven't used vs code in a while so don't quote me on it
its not cause when i used to run it like yesterday it didnt work
there is no way that is full
All the traceback
it can't be that short
i can send the full thing but its really long
I mean I know what it means in some circumstances. Itβs normal behavior when the bot closes on windows.
Did you type it out yourself or something?
Damn,you really gonna do windows like that?
The fuck is raceback
lmao
should i use something else the vs code
no vs code = good
ok
Try regenerating your token or restart vsc
alr
Not as good as PyCharm tho 
You just use it to act professional
i've never used PyCharm

Its boring
Looks dead to me
Anyway #editors-ides
& 'C:\Users\milky\AppData\Local\Microsoft\WindowsApps\python3.10.exe' 'c:\Users\milky.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy\launcher' '63205' '--' 'c:\Users\milky\code\practice bot\bott.py'
PS C:\Users\milky\code>
thats the error
Oof its 3.10
Py 3.10 is nice. It gots match case.
is 3.10 bad
Are you seriously using the interpreter from Microsoft store?
From my experience 3.10 isnt great
Holp upπΆ
i had to download it from the microsoft store cause it said i didnt have python
If I wanted to act professional, Iβd use PyCharm professional. I just like having good tools.
even though i litteraly had python open
There 2 separate things?π€¨ π
Yes
Bruh
PyCharm Community is free but professional you need a jet brains license.
Theres pycharm professional which is paid and pycharm community which is free
Ah i see
JetBrains releasing data spell really killed jupyter notebook
You obviously havenβt tried match/case then
Itβs pythons implementation of switch cases.
The better form of logic ofc
Type hinting on 3.10 was horrible in my case
Itβs the same for me as type hinting. Nothings changed.
Same
Could type hint everything and it would still thing it was a nonetype
Or it didnt had a attr
Is that what the interpreter thinks or vsc's intellisense
Thatβs not 3.10s fault then. Thatβs just your linter being trash.
Typing isnβt enforced at all as far as runtime.
how do i get a colour of someones name?
!d discord.Member.color
property color: discord.colour.Colour```
A property that returns a color denoting the rendered color for the member. If the default color is the one rendered then an instance of [`Colour.default()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Colour.default "discord.Colour.default") is returned.
There is an alias for this named [`colour`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.colour "discord.Member.colour").
Idk then. Personally I havenβt had any problems with typing in 3.10
Ic
Im just running 3.9.9
guys how to place for example 5 buttons in one row?
just add the buttons in the subclass of view
if your using discord.ui.View
lol
also i'm not sure if i'm being dumb isn't it name not text?
think so
SyntaxError: positional argument follows keyword argument
positional arg should be first
i suggest you learn basic python
dpy isnt beginner friendly as you need to know oop basic python and async programming
c:; cd 'c:\Users\milky\code'; & 'C:\Users\milky\AppData\Local\Microsoft\WindowsApps\python3.10.exe' 'c:\Users\milky.vscode\extensions\ms-python.python-2021.12.1559732655\pythonFiles\lib\python\debugpy\launcher' '64619' '--' 'c:\Users\milky\code\practice bot\bott.py'
what should i do
Don't use the Microsoft store python
Uh
Please tell me how to create a chat thread using a bot?
I have to cause cmd dosent recgonize that i have python if i dont have the microsoFT STORE VERSION
did you add python to your path?
and it works fine so far
Are you installing python to path?
no
Did the docs change?
the microsoft and the chrome
idk seems weird
stop spamming
Microsoft store one is very buggy
language
Have you read the error?
Why did u put arguments after keyword arguments
no need for help then
U dont put positional arguments after keyword arguments
Bro
U dont read what I tell u
Did u read the error
It says everything clearly
Itβ s literally underlined red
Lemme
@slate swan do u see what u did here
should delete this
?
Iβ m showing him where the problem in his code is
yes you are but idk what mods could do
β¦
forget it lol
No one even read that until u pointed it out
π€·ββοΈ
this is a pain to watch @slate swan here
embed.add_field(name="What you could have been muted for",value="porn content,spamming,being rude,talking about ip ban,personal questions")
This is one case where I actually support spoonfeeding
one in a life time
im leaving
Ppl that dont read errors and put them in the chat multiple times
Broβ¦
He gave u the code
not the first time ive seen it
Lmao
@slate swan do you want me to go to your home and code the bot for you?
how?
how
i have
^
straight up public service lmao
home service if you want for a fee
i selected 5, why does he swear?
does arent 5 buttons
those are many buttons lol
and what i should do if i want to have more than 5 buttons?
idk what lib is that?
so how did it work before i add more than 5 buttons
can i use other methods?
thanks
!pypi disnake
yw
How to create it correctly?
try doing
components = [ActionRow([Button(...), Button(...), ...]), ActionRow([Button(...), Button(...), ...])]
can any body help me with my problem
start_private_thread doesn't exists, what you can do is await channel.create_thread(name="something", message = "hi", type = ChannelType.private, ...)
you switched the parentheses with the bracket
ActionRow([Button(style=ButtonStyle.blue, label="βοΈ"),
Button(style=ButtonStyle.blue, label="π·"),
Button(style=ButtonStyle.blue, label="β"),
Button(style=ButtonStyle.blue, label="β
")],
Button(style=ButtonStyle.blue, label="π"]),
ActionRow([Button(style=ButtonStyle.blue, label="βοΈ"),
Button(style=ButtonStyle.blue, label="πβπ¨"),
Button(style=ButtonStyle.blue, label="π€"),
Button(style=ButtonStyle.blue, label="π₯±"),
Button(style=ButtonStyle.blue, label="π"])]
]```
do you have 2.0?
I'll check now
I will be very grateful if you place these brackets correctly, because i am really confused π«
components=[
ActionRow([Button(style=ButtonStyle.blue, label="βοΈ"),
Button(style=ButtonStyle.blue, label="π·"),
Button(style=ButtonStyle.blue, label="β"),
Button(style=ButtonStyle.blue, label="β
"),
Button(style=ButtonStyle.blue, label="π")],
ActionRow([Button(style=ButtonStyle.blue, label="βοΈ"),
Button(style=ButtonStyle.blue, label="πβπ¨"),
Button(style=ButtonStyle.blue, label="π€"),
Button(style=ButtonStyle.blue, label="π₯±"),
Button(style=ButtonStyle.blue, label="π")]
]
try that
what does it say if you hover it
discord.py==1.7.3
okay, thanks you
components=[
ActionRow([Button(style=ButtonStyle.blue, label="βοΈ"),
Button(style=ButtonStyle.blue, label="π·"),
Button(style=ButtonStyle.blue, label="β"),
Button(style=ButtonStyle.blue, label="β
"),
Button(style=ButtonStyle.blue, label="π")]),
ActionRow([Button(style=ButtonStyle.blue, label="βοΈ"),
Button(style=ButtonStyle.blue, label="πβπ¨"),
Button(style=ButtonStyle.blue, label="π€"),
Button(style=ButtonStyle.blue, label="π₯±"),
Button(style=ButtonStyle.blue, label="π")])
]
```try that now
in your from discord_components import ... add ActionRow
from the main branch
oh, it seems that you don't need a list inside ActionRow. Remove the [] inside it
pip install -U git+https://github.com/Rapptz/discord.py
win!!!!!!!! thank you very much for help!!

you don't have git installed..
Install git.



