#discord-bots
1 messages · Page 261 of 1
i read it, it has TextStyle
ok in main.py
remove the setup_hook()
and in the def load(), first line add a
await bot.wait_until_ready()
@sharp whale https://youtu.be/hMuQJnFNm78 refer this until I'm busy
Welcome to #codekar , In this latest video, Learn about implementing discord modals or forms in your discord.py bot.
Discord Server [Must Join] - https://discord.gg/e3dXAmqqHf
Discord.py Example Reference:
https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Modal
Homework Reference: https://github.com/quotientbot/Quot...
@buoyant crescent
first make sure ur bot can run once before running ur cogs
now it don"t print the extension are loaded
Btw both things are same
ya that what confuses me
but does ur bot run once
or still twice
it not the bot that run twice but the commands in my cogs
ohhhhh
like i create a test command in my main ans it runs once but in my cogs the commands are running twice and the event too
so basically u saying when u do like example: !aide
it output twice?
YES
.-.
;-;
sorry miscommunication
i have did everything, like i watched a video and docs, i have an problem that it throws a name error,
File "main.py", line 22, in <module>
class suggest(ui.Modal, title="Suggestions"):
File "main.py", line 24, in suggest
suggestionbox = ui.InputText(label="Enter Your Suggestion", style=TextStyle.paragraph)
NameError: name 'TextStyle' is not defined```
np i have this issue since yesterday
you did not import it
what library are you using
yeah so you need to import this class
i dont see import that would import the TextStyle class
!d discord.TextStyle
class discord.TextStyle```
Represents the style of the text box component.
New in version 2.0.
no
discord.ui
works
!d discord.ui.InputText
No documentation found for the requested symbol.
hm
When you create an instance of MyBot, it automatically runs the bot using bot.run(), so there's no need to call it again.
It's discord.ui.Modal
he uses InputText class
It is TextInput i believe
ain't it another whole library
no
Nah
but then i dont really like using class super when im dealing with main.py so i usually dont add that in
It is discord.py
discord.ui is part of discord.py
ui components are now built in to discord.py
@sharp whale code needed
TextInput
import discord
from discord.ext import commands
from discord import ui
from config import suggestion_channel
from config import TOKEN
intents = discord.Intents.all()
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.event
async def on_ready():
print(f"bot is ready and logged on: {bot.user.name}")
# COMMANDS
class suggest(ui.Modal, title="Suggestions"):
type = ui.InputText(label="Type of suggestion")
suggestionbox = ui.InputText(label="Enter Your Suggestion", style=TextStyle.paragraph)
async def on_submit(self, interaction: discord.Interaction):
await interaction.response.send_message(f'Thanks for your response, {self.name}!', ephemeral=True)
async def on_submit(self, interaction):
await suggestion_channel.send(f"The type is {self.type}")
@bot.command(name="test", description="test command")
async def test(ctx):
button1= discord.ui.Button(label="Click me", style=discord.ButtonStyle.primary, emoji="⭐")
view = discord.ui.View()
view.add_item(button1)
await ctx.send("testing", view=view)
#START UP
bot.run(TOKEN)```
suggestionbox = ui.InputText(label="Enter Your Suggestion", style=TextStyle.paragraph) literally your code
there is InputText
Messed up class
i forgot
since when?
like i said you need to import the TextStyle class from discord library
theres no textstyle class
!d discord.TextStyle
class discord.TextStyle```
Represents the style of the text box component.
New in version 2.0.
File "main.py", line 4, in <module>
from discord import TextStyle
ImportError: cannot import name 'TextStyle' from 'discord'```
you sure its discord.py?
import discord
from discord.ext import commands
import os
from apikeys import BOTTOKEN
class MyBot(commands.Bot):
def __init__(self):
super().__init__(command_prefix='!', intents=discord.Intents.all())
async def setup_hook(self):
await load()
bot = MyBot()
async def load():
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
cog_name = filename[:-3]
bot.load_extension(f"cogs.{cog_name}")
print(f'Extension: {cog_name} successfully loaded')
@bot.event
async def on_ready():
await bot.change_presence(status=discord.Status.do_not_disturb, activity=discord.Streaming(name="Pokemon Unite", url="https://www.twitch.tv/mysterymom__"))
print("The bot is now ready")
print("--------------------")
@bot.command()
async def test(ctx):
await ctx.send("This is a text command")
bot.run(BOTTOKEN)
@buoyant crescent try this?
bruh
Ok
https://discordpy.readthedocs.io/en/stable/whats_new.html
no idea you can check
well there is indeed class TextStyle in discord.py so you are not using discord.py or you are running not updated version
can you do pip show discord.py in terminal?
wait
Version: 2.3.1
Summary: A Python wrapper for the Discord API
Home-page: https://github.com/Rapptz/discord.py
Author: Rapptz
Author-email: None
License: MIT
Location: /home/runner/papernodes-suggestion-bot/venv/lib/python3.10/site-packages
Requires: aiohttp
Required-by: discord```
@slate swan
and what python version is your interpreter in your text editor?
wait why am I seeing TextInput in discord.py when he is doing InputText
its replit
its latest
are they different?
can you do print(discord.__version__) on top of your script?
after you import discord obviously
bot.load_extension(f"cogs.{cog_name}")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```
await it
modal.add_item() for modals
.load_extension is awaitable as it says
ok
@sharp whale
thats not discord.py
bruh it still run twice
bnruh
discord.py does not have such version
hmmmm
!pypi discord.py
newest is 2.3.1
!pypi py-cord
py-cord 
@buoyant crescent can we not add a class MyBot or u want it like that?
EWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
from all libraries py-cord is the worst one
Check task manager.
i just want it to work ;-;
.-.
k
what i need to check
If any python processes are running,
uh what
but i imported discord
he does not have discord.py
pycord hmm
check for like python or ur ide
then uninstall pycord
py-cord*
That doesn't make different both libraries have same interaction methods
py-c🤢rd*
I read pycord documentation for interaction
Except py-cords core is messed up
yeah no
It has good and well explained documentation
pycord is different

It's documentation helps me in dpy (personal opinion) idk about others
Hikari is king
because the code shouldnt run twice unless it your ide or a duplicate instances of running the script
Nextcord is also good library
I used it when dpy was discontinued
I used disnake.
i deleted pycord
But does nextcord have hybrid commands?
.-.
and installed discord.py
i dont think
but still not working
nope its only in discord.py i think
That's where it lacks
That's why i switched THE ONLY REASON
Doesn't matter either use message commands or slash, not both imo.
it almost like similar to discord.py
I personally like nextcord so much
but hybrid commands are here for not a long time
It's good to provide both if your bot is public
We'll see
File "main.py", line 9, in <module>
intents = discord.Intents.all()
AttributeError: module 'discord' has no attribute 'Intents'```
bro wat
what did you install
😭😭
pip install discord.py
His errors
After 3 years it's pretty valid to finally force slash commands.
lel
it says it doesnt have _version_ atribute
@buoyant crescent any status?
then its not discord.py
Do you have a folder named discord?
no
Uff but most people still prefer message command and while other competing bots having message commands to how can i force slash commands
oh yeah maybe you named file discord.py
Stats gonna go down
do pip list
and send output
Shit


lmao
!paste
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.
Panda is hurt
bruh
what is this
discord 2.3.1
discord-py 2.3.1
you have so many random libraries installed
what is this
should i make a new repl
Yes
!pypi discord-py
I always throw my container away when I don't feel like fixing that bug.
i send you in pm a ss of my task manager can you check it
!pypi discord
A mirror package for discord.py. Please install that instead.
!pypi discord.py
use this if u want
I mean the fastest way to check would be to just restart your pc.
Then you know it was on twice.
Hi everybody.
I am using adb to control android devices and am having a problem where there is no way for adb to recognize more than 15 devices
Does anyone know how to fix it?
ngl mirror packages should be dissalowed except for bs4 since i always spell it wrong.
@sharp whale now install discord**.**py
wrong channel but ok
with a dot
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
like i said
!pypy discordpy
pypy 
pipi
!pypi replit
mhm
BRUH
pip uninstall discord
remove self.
well you are trying to access attribute that does not exist on your object
in self.interaction
you prolly want just interaction since you get it in the callback function
b r u h
waht it say
thats why you dont use replit
can i see the full code?
do print(dir(discord))
wait
can i see this function code?
OK
show code
it ran
i dont get the not indented part like if it is indented into class then its inside class else its not
It's not the cogs, but the classes. And if your function is not indented, it is not inside the class.
you only put self when its inside class
looks like it is not inside class since you get this error
then its not inside class
if its in global scope
Then just put that inside class if you need it
even when i restart my pc it runs twice
keep in mind if you put it inside class you need to be in that class or have class instance to run this method
then you just remove the self but you wont be able to use self.bot.something

which you prolly need
Code?
could be
||Learn python before making bots||
of my main or my cogs ?
is ur open_account and the command in same file or differeccn file?
Whatever is being done twice.
import discord
from discord.ext import commands
class Greetings(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def aide(self, ctx):
help = discord.Embed(title="Liste des commandes :", url=None, description=None, color=0x7434EB)
help.set_author( name="Menu Help du bot", url=None, icon_url="https://cdn.discordapp.com/attachments/1122145321535930499/1122145393032040519/20230624_142400_0000.png")
help.add_field(name="Musiques :", value="!join | !play | !stop | !resume | !pause | !music", inline=False)
help.add_field(name="Modération :", value="!ban | !kick", inline=False)
help.set_image(url="https://media.discordapp.net/attachments/1120608535672270939/1123258060983509124/pu.gif?width=747&height=312")
help.set_footer(text="Demandé par : {}".format(ctx.author.display_name))
await ctx.send(embed=help)
@commands.command()
async def music(self, ctx):
await ctx.send("La liste des musiques : black_clover, black_rover, demon_slayer_3, night_dancer")
@commands.Cog.listener()
async def on_member_join(self, member):
channel = self.bot.get_channel(1121386561150386276)
join = discord.Embed(title="Bienvenue dans le serveur de la Neo Destiny ! ", url=None, description=f":tada: Bienvenue {member} :tada:", color=0x7434EB)
join.set_image(url=member.avatar.url)
join.set_footer(text=f"Nous sommes désormais : {member.guild.member_count}")
await channel.send(embed=join)
async def setup(bot):
await bot.add_cog(Greetings(bot))```
@slate swan if it in a diff file use this instead
await open_account(self, interaction.user)
then it should work
can you send full code if you have few files send all the files use paste service
!paste
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.
function()
eh
!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.
its case sensitive
i need more help
heh
error: Traceback (most recent call last): File "/home/runner/sugg-bot/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 235, in wrapped ret = await coro(*args, **kwargs) File "main.py", line 45, in modal await Interaction.response.send_modal(suggest()) AttributeError: 'CachedSlotProperty' object has no attribute 'send_modal'
Interaction has this method
not random Classes
ok
._.
!d discord.InteractionResponse.send_modal
await send_modal(modal, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Responds to this interaction by sending a modal.
uh what
It should be interaction instance, not just class
.
wdym
You get instance from the library as the first argument when you call the command
sorry, my english isn't good
Interaction is a variable holding an instance made from class Interaction
white github

@bot.command(name="modal", description="modal command")
async def modal(interaction: discord.Interaction):
await Interaction.response.send_modal(suggest())```
you named your argument lowercase
so why use Interaction
ok i named the argument in upercase
no
._.
dont named varriables like classes
what
use lowercase interaction
okay
File "/home/runner/sugg-bot/venv/lib/python3.10/site-packages/discord/ext/commands/core.py", line 235, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 44, in modal
await interaction.response.send_modal(suggest())
AttributeError: 'Context' object has no attribute 'response'```
._.
thats prefixed command you get Context not Interaction

Yes
if ur not in cogs yes
async def modal(interaction: discord.Interaction):
await interaction.response.send_modal(suggest())```
Doesn't seem to work for me
send the error
it doesnt throw any error
What's not working
command not working
You need to sync your commands
That didn't explain anything
like, its not listed in the slash command listh thingy
@sharp whale did you do this?
bot.tree.sync()
Make sync command
You can use this whenever you want to sync your commands with discord
Make sure command is owner (developer) only
on_ready has chances of running multiple time it may time out
It will unnecessarily sync almost every time you restart the bot
@sharp whale this
but, if i sync it everytime, nothing will break
then why not sync everytime
That's not the point of my message
You don't need to sync everytime
You only need to sync after updating your code
I meant, nothing bad will happen if it syncs everytime it starts right?
Might not happen for you but it'll happen for discord
And discord will timeout it
wao
Why do you even want to use bad practices in your code
Use proper ways to do it
yk, lazyness
Happens but you've to do it you can't skip things
Just typehint channel as forum channel i think?
Or a union where you have both I guess

you cant annotate option as ForumChannel
means that you cant type hint the option as ForumChannel cause discord does not support it
Discord or discord.py?
discord
Discord mentions in their docs
Includes all channel types + categories
Not sure why you shouldn't be able to
you have a server with bot that has jishaku
I stopped coding in Python for over 2 years 
Just interested that discord documentation mentions all channel types are accepted
Which, according to what you say, is wrong
yeah i wanted to test it using jishaku
i guess i need to host one myself
is it for slash command or select component
Guild Forums are channel type 15 and public/private threads 11 and 12. Can probably try it out
dopn't use forumchannel
the forum channel select
what's the command for?
That
!d discord
In order to work with the library and the Discord API in general, we must first create a Discord Bot account.
Creating a Bot account is a pretty straightforward process.
Is the bot in the thread already? Dunno if it matters
And it's a thread channel if you want them to send in threads
!d discord.Thread
class discord.Thread```
Represents a Discord thread.
x == y Checks if two threads are equal.
x != y Checks if two threads are not equal.
hash(x) Returns the thread’s hash.
str(x) Returns the thread’s name.
New in version 2.0.
how do you sync slash commands in discord py
im noob
tree.sync I guess
!d discord.app_commands.CommandTree.sync
await sync(*, guild=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Syncs the application commands to Discord.
This also runs the translator to get the translated strings necessary for feeding back into Discord.
This must be called for the application commands to show up.
awaitable 
Yeah that
It's as bot.tree
yeah i know but how do you set testing guild in it
o there is guild keyword
well works then
there is x command with no errors but i have no threads to check on
Probably want discord.Thread
As they're independent I suppose
A forum channel contains threads and they want to send in threads

isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") exception is raised. [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") may not be raised for an invalid type if an earlier check succeeds.
Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
!e ```py
print(isinstance(5, int))
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
True
how about threads i cant check rn
Ye, works too

is it possible to run a bot inside another one?
pog
why would you want to do that
like i want to create a bot , that runs another one when a command is done
technically yes but doesnt look like a good solution what is your case
ok i'll try to run another python file when the command is done
Sometimes I wonder what atrocities people do
If you set it one bot up on a different server then it is possible
Imagine that he is trying to run the same bot
bro it's an order hh
Recursively
nope nope , another token
the token will be a parameter on the command
That's more than an atrocity
ah yes, what a great idea
That's like 21/20 design
lol
100% safe
😹
Would trust 21/20 in giving a token to some random bot
Especially if when they save it
And then probably run it on Replit
bro i'm not gonna give it to public .-.
not about token imagine someone makes a bot that all does is delete all files ☠️
Actually I tried to do it once but each discord bot needs its own running instance to work
the code will be on my file, all the person will do is to run the command with the token , and the project is made by mee
lmfao
How about just inviting your bot 
why would someone want to give your bot a token to run your bot
If it's to run 1 to 1 the same 
Sounds like shit
idk, that's not mine, one of my clients told me to do that and i'll do it
Bro is high af 💀
I got it, that's like these videos, but you don't even need to do something. Just get a token.
so you are doing bots for money but you dont even do them yourself?
Skidders

i just asked ! like if it's possible or not, cuz i don't want to try , and finally i can't you know
everything is possible but not everything should be done
yep .-. that's why i'm here !
Imagine people saying in comments "from where do i get bot token"
I believe there are
Exactly 😭
hhhhhhhh there are
yp
good bye .-.
isnt it goodbye
Could be both
But you'd put a comma in-between
okay but thats not a comma
Bad bye 
,
hhhhhhhhh
i want to add a hyperlink to an embed but the link has parentheses, too. like
https://smth.ssm.smthing/file(x).zip
and since the format for the hyperlink is [Text](Link) I'm wondering if my link will cut off on the x part and if so, what do I do to fix it?

how so?
@dense barn read
Ah yeah that\
you put backslash before
You sound condescending.
Why didn't you even try it before asking..
It works fine with just that string
**hello**

[hello](https://smth.ssm.smthing/file(x).zip)
(copy link gives the valid link)
so you can sent texts like this
yeah i could have just tested it 
hello
How tf you did this
**hello**
hello
You don't know how to use special characters?)
i cant even show you that cause i have links masking on my server
Works on discord?
yeah
yes
yes
49. 49. 49. 49. 49. wat

i like how discord works with markdown
Amogus 
how did you broke it like this

It doesn't take any arguments
oh yeah its self
Why wouldn't you know
So, you don't even know if a class you created take arguments?
Amazing
😵💫
🗿
I would say no
Ig I've seen someone doing that
async def callback(self, select, interaction: discord.Interaction):
if 'enable' in select.values[0]:
await interaction.response.edit_message(embed=discord, view=self)
@slate swan
You flipped the order
interaction is 2nd argument
Yes
with discord.py anyone knows how can i use slash commands as sub commands ?
but how do i add a slash command to that group
Just like you add commands to a bot tree
right now i have this
@commands.group(name="verify",invoke_without_command=True)
async def verify(ctx):
return
@verify.command(name="setup",description="setup a verify channel")
async def setup(self, interaction: discord.Interaction):
view = SetupView()
embed = Embed(title="Verification setup",colour=discord.Colour.brand_green(),description="``yaml\nuse the next drop down menu to select the roles that will be given to users after verification (MAX: 3)\n``")
await interaction.response.send_message(view=view,embed=embed)
how do i make it slash
That's not a slash command, that's a prefix command
i know thats what im asking because its in a cog and i dont know what the hell am i doing
nvm i found something thanks for trying to help me
discord.py 2.0+ slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
just found the same thing lol
can anyone help me fix this " import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.typing = False
intents.presences = False
client = commands.Bot(command_prefix="$", intents=intents)"
Save your file
i'm having trouble right now trying to use local files for images.
./images
img.png
./cogs
code.py
bot.py
So I want to put an author image img.png to my embed from code.py. How exactly do I access a file one parent directory then another folder in? I saw this
f = discord.File("some_file_path", filename="img.png")
e = discord.Embed()
e.set_image(url="attachment://image.png")
await ctx.send(file=f, embed=e)
but how exactly do I change some_file_path ? Should it be ../images/ or something else entirely
relative filepaths are based on your CWD (current working directory) regardless of where the script is, so if your CWD is the folder containing bot.py, the relative path to your image would be images/img.png
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
x == y Checks if two embeds are equal.
New in version 2.0...
wym ,could u elaborate?
I told you to save, not delete lines
so what do i do
Add those lines back 
they are alr in
on the bottom
Where are they?
Can't see intents=intents there
Maybe I'm blind though
in discord.py how do you know whether an interaction is coming from a mobile device user or desktop
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s handle (e.g. `name` or `name#discriminator`).
And why do you have twice all of that 
You need to define it once, at the top.
@tired pine go to the docs and read the methods/attributes
the names are in most cases self explainatory so you will find what you need
naming a Bot instance client how awesome
Welp lot of ppl do that now idk why
so i jus change everything to bot? dont thibk that will affect it g
Nah just keep it as it is
it wont change anything except the understability of your code
Because they all follow the same crappy tutorials
Idk why but ppl should go to docs or the dpy gist for examples
in my opinion it is because they read/watch tutorial from 3 years ago which told them to use Client then someone here told them to switch to Bot but the name stayed
so what shall i do
But instead they all go to yt
what you have problem with?
Just run your file
@slate swan
i did
!intents
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.
There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.
Afterwards in your code, 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
# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.
Already told you holy moly
Remove that code and just keep the code below
You don't need to define twice client
You don't need to import everything twice
Once. At the top.
Yeah that is the problem since u are defining client twice where in one of them u haven't put the intents
Replace line 13 with line 44
And then delete the line 37 to 44
This should fix your problem
I'm at my grandma's house it's hard to find the things you need with the docs on mobile
if you dont have pc right now you wont be able to code anyways
Welp the answer to your question was that u can create a check where it checks what is the user status
i belive his question was if the user is on mobile or desktop
Yeah there is a method to check that in dpy
yeah i know
i want him to go to docs and just look on the methods
the names are self explainatory
I can because I know dpy very well
async def lock(self, ctx : commands.Context,
channel : Optional[discord.abc.GuildChannel],
time : Optional[TimeConverter],
*,
reason : str = "No Reason Provided"):
if not channel :
channel = ctx.channel
await channel.set_permissions(ctx.guild.default_role, reason=reason, send_messages = False)
await ctx.send("channel locked",delete_after = 15 , ephemeral = True)
if time
await asyncio.sleep(time)
# unlock the channel
So , I'm trying to temp locking a channel.
I'm wondering if this is the way to go.
( I mean the sleep method)
it is good but has one con
- when you restart the bot and there was one channel locked ongoing it will stop waiting for it and will never unlock it
So what's the solution
I'm not gonna keep looking for it on mobile I just wanna know the methods name and I'll find it myself on the docs
bruh
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s handle (e.g. `name` or `name#discriminator`).
asking for the name is bad nowadays cuz people won't answer you when they know
here are the docs
its not about i dont wanna show you the answer its about i wanna show you how to look for solutions
I'm not your 9 yo son to teach me how to look for solutions if I was on PC I would find it myself but I have a hard time doing it on mobile
easiest one:
you can have infinite loop ongoing for example each 30 seconds which will check if there is any channel locked and if there is if the duration has passed
Zzz
There's a wonderful search bar
then wait until you have a pc
Make sense
why you need to know it so bad now when you cant code on mobile anyways
Thanks
👍
Why is this not working?
f = discord.File("../images/bot_icon.png", filename="bot_icon.png")
embed.set_thumbnail(url="attachment://bot_icon.png")
embed.set_footer(text=f"Requested by {context.author}", icon_url = context.author.avatar.url)
await context.send(file = f, embed=embed)
It's giving me No such file or directory, this worked before but I don't know where I went wrong this time. My bot_icon is not being found.
Ok just look for something called is_on_mobile that might help
file structure?
./images
bot_icon.png
./cogs
code.py
bot.py
Btw should i use while loop or task.ext ( i can check if duration is passed bc bot send embed with duration)
and where is this script located
I am able to edit .py files with an app, I run the files using a server
loops for sure
On code.py
How do you run the file
^
Thanks for you help
yeah it worked before but somehow while i was changing stuff up I messed up and now it's not working.
if you can do so many hard things on mobile im sure you can use search bar or scroll through docs for sure
I told u what to look for tbh u could have found it by searching for mobile in docs
No I have a hard time doing that, it's okay I asked ChatGPT and I got a proper answer
how about .././images/bot_icon.png no idea actually your current one should work
It's very hard I know
Don't get scared when you see how complicated it is
gpt trigger 
chatgpt with knowledge before 2021 when discord.py was totally different
hi i got an issue with my events ```python
ERROR discord.client Ignoring exception in on_member_remove
Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\site-packages\discord\client.py", line 441, in _run_event
await coro(*args, **kwargs)
File "c:\Users\MYOUSSEF\Desktop\bot\cogs\Greetings.py", line 36, in on_member_remove
channel = self.bot.get_channel(1080174110459580428)
AttributeError: 'Greetings' object has no attribute 'bot'
2023-06-29 21:02:17 ERROR discord.client Ignoring exception in on_member_join
Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\site-packages\discord\client.py", line 441, in _run_event
await coro(*args, **kwargs)
File "c:\Users\MYOUSSEF\Desktop\bot\cogs\Greetings.py", line 28, in on_member_join
channel = self.bot.get_channel(1037041281504903181)
AttributeError: 'Greetings' object has no attribute 'bot'
maybe this method existed that days
new one is march edition iirc but yeah not like there are a lot of decent data for it base of upon
@commands.Cog.listener()
async def on_member_join(self, member):
channel = self.bot.get_channel(1037041281504903181)
join = discord.Embed(title="Bienvenue dans le serveur de la Neo Destiny ! ", url=None, description=f"🎉 Bienvenue {member} 🎉", color=0x7434EB)
join.set_image(url=member.avatar.url)
join.set_footer(text=f"Nous sommes désormais : {member.guild.member_count}")
await channel.send(embed=join)
@commands.Cog.listener()
async def on_member_remove(self, member):
channel = self.bot.get_channel(1080174110459580428)
leave = discord.Embed(title="Un membre a quitté le serveur !", url=None,
description=f"Oh non aurevoir {member} 👋", color=0x7434EB)
leave.set_image(url=member.avatar.url)
leave.set_footer(text=f"Nous sommes désormais : ")
await channel.send(embed=leave)
didnt use it since like february
then for ../images/bot_icon.png to be valid, the CWD would have to be a subdirectory of your project directory containing the images/ directory, such as cogs/ (this would also imply you might have ran bot.py by doing python ../bot.py or similar)
wow you clearly don't know about it do you
Not a bad thing
show your cog constructor
in my main ?
if ChatGPT only has knowledge from before 2021 it wouldn't be able to give me proper 2.2 dpy code
no the cog you just sent sample code of
you know they dont shuffle method names each version this could have existed those days
import discord
from discord.ext import commands
class Greetings(commands.Cog):
def init(self, bot):
self.bot = bot
@commands.command()
async def aide(self, ctx):
help = discord.Embed(title="Liste des commandes :", url=None, description=None, color=0x7434EB)
help.set_author( name="Menu Help du bot", url=None, icon_url="https://cdn.discordapp.com/attachments/1122145321535930499/1122145393032040519/20230624_142400_0000.png%22_")
help.add_field(name="Musiques :", value="!join | !play | !stop | !resume | !pause | !music", inline=False)
help.add_field(name="Modération :", value="!ban | !kick", inline=False)
help.set_image(url="https://media.discordapp.net/attachments/1120608535672270939/1122594030241460336/20230624_142400_0000.png?width=1051&height=658")
help.set_footer(text="Demandé par : {}".format(ctx.author.display_name))
await ctx.send(embed=help)
@commands.Cog.listener()
async def on_member_join(self, member):
channel = self.bot.get_channel(1037041281504903181)
join = discord.Embed(title="Bienvenue dans le serveur de la Neo Destiny ! ", url=None, description=f"🎉 Bienvenue {member} 🎉", color=0x7434EB)
join.set_image(url=member.avatar.url)
join.set_footer(text=f"Nous sommes désormais : {member.guild.member_count}")
await channel.send(embed=join)
@commands.Cog.listener()
async def on_member_remove(self, member):
channel = self.bot.get_channel(1080174110459580428)
leave = discord.Embed(title="Un membre a quitté le serveur !", url=None,
description=f"Oh non aurevoir {member} 👋", color=0x7434EB)
leave.set_image(url=member.avatar.url)
leave.set_footer(text=f"Nous sommes désormais : ")
await channel.send(embed=leave)
async def setup(bot):
await bot.add_cog(Greetings(bot))```
its __init__
Okay okay, I think I got it now. This is making sense in my head right now but hopefully I don't lose it anymore. Thanks!
oh thank you
no I recognised it was a version higher than 2.1 because I read the update logs
wow, reading docs 
oh so you can read the docs
thought you cant do that on mobile

I read them on PC that's one
second, I said I was on mobile because I'm at my grandma's for a week
I didn't even use my PC
the time you spent here arguing you could have spent scrolling through docs
you read something on a PC without having a PC thats odd
No because I am sitting next to some people rn and waiting for them to go

And I already told u what u should look in docs
Huh, I was talking about a situation from weeks ago
oh so a week ago you already knew you will need to know when was something realeased so you read the docs
mysterious
on PC yes?
hi i have seen people talking about nextcord, is it better than discord.py
Nope
isn't nextcord a fork of dpy
i use it for my personnal projects so in my opinion it is
They are equal
Both are different and doing things differently, choose whatever you want
dpy ?
In the end you end up with the same features
ok thank's
I've never seen anybody so quick to assume things than you 😂
I'd say go with what u feel comfortable with
short for discord.py
they both have the same features/functionality they just have different naming or how you make things
ok ok
Man just go and check is_on_mobile in docs and u can build a logic from that
You could have said that 30 minutes ago lmaoo
I already did if u noticed
Maybe if you would read it'd be useful
if u did mb but the guy named Down didn't so I was here arguing to make time go, I'll go now
for example:
# discord.py
@bot.tree.command()
@app_commands.describe(
first_value='The first value you want to add something to',
second_value='The value you want to add to the first value',
)
async def add(interaction: discord.Interaction, first_value: int, second_value: int):
"""Adds two numbers together."""
await interaction.response.send_message(f'{first_value} + {second_value} = {first_value + second_value}')
# nextcord
@bot.slash_command()
async def add(interaction: nextcord.Interaction, first_value: int = SlashOption(description="The first value you want to add something to", second_value: int = SlashOption(description="The value you want to add to the first value")))
"""Adds two numbers together."""
await interaction.send(f'{first_value} + {second_value} = {first_value + second_value}')
To be fair I prefer discord.py here
Same
Slapping everything like that in the parameters, meh..
Just horrible imo
in this example it might be more readable for discord.py but knowing all features of it i still stick with nextcord
Welp it comes down to what u feel comfortable with
If it's your first discord library in python I suggest you start with dpy
You can start with any of them some ppl find one easier then other
I thought you had to go
XD

idk if this is the correct channel but, whenever i click "ctrl + c" to stop the file, it wont allow me to write commands again
can someone mention me if he knows the solution pls ?
ctrl + c stops the script
so the bot will stop
# disnake
@bot.slash_command()
async def add(interaction: disnake.Interaction, first_value: int, second_value: int):
"""
Adds two numbers together.
Parameters
----------
first_value: The first value you want to add something to
second_value: The value you want to add to the first value
"""
await interaction.send(f'{first_value} + {second_value} = {first_value + second_value}')
or you can do the same as in nextcord
first_value: int = commands.Param(description=...)
hikari
i used the second option when i was using disnake
maybe thats cause i was used to nextcord style
@buoyant quail you use disnake daily?
yes
this valid? ```py
@commands.slash_command()
@blocked_command()
async def quiz(
self,
inter: disnake.GuildCommandInteraction,
category: str = commands.Param(choices=QUIZ_CATEGORY_CHOICES, default="images"), # type: ignore
) -> None:
im just lurking but since the topic is on api wrappers, i recently made one https://aiocord.readthedocs.io, would be cool if yall could check it out and give some feedback :>
yeah, should be
I'll eventually check when I'm not on the phone because the website is unfortunately un-useable on phone
why is token passed via command
yeah the docs are not responsive 😢 tough stuff
And yeah ^
ease of use, not necessary https://aiocord.readthedocs.io/en/latest/pages/examples.html#integration
That's instantly a no-go
it can also be set via a environment variable
how come?
i was thinking about env varriables but since there is a way
Your token is in the history in plaintext
Either read from stdin or don't do it at all
what's the difference than it being somewhere in a file?
Ideally showcase the environment variable method on the home page, that's how you store secrets these days
Not necessarily in a file
where would u store ur token then?

Environment variables are not always .env files fyi
what about this?
you can still access them easily with access to the machine too
Yeah that's always the case
idk i put the command line method in the front page cause it's the easiest to use, i'm sure whoever decides to use this in production will have looked into the other options as well
Still better than using a command line
I'd at least showcase the environment variable method on the home page
And mention you can pass the token via a flag
idk how else you would do menu components! all this information is more or less necessary for discord
Also there are some overall CSS issues
i'd love feedback on it
it's my first time doing custom css with sphinx
https://aiocord.readthedocs.io/en/latest/pages/examples.html#http-only the highlighted lines in the code block here are stopping on smaller width windows
And shouldn't syntax highlight highlight more?
Yes and scroll to the right, the highlight will stop
i could use a different stynax highlighter
oh shoot ur right, good catch
I'd change the font for inline code to monospaced as well
i mean, when the bot stop it should allow me to excute commands, but yasterday this problem happened, it just keep that blank and not allow me to type anything
u mean these, right? they are already monospaced
And yeah I'll check out the rest tomorrow and play around with the library when on PC, if you want to remind me just ping me in case I forget 
u seem like ur good at giving feedback so i'll make sure to poke again :'>
The note here at the bottom isn't https://aiocord.readthedocs.io/en/latest/pages/examples.html#
Only place I found while scrolling a bit
oh that's not meant to be code, just special highlighting-ish
like it doesn't have the :code: directive for rst
but that's still monospaced :O same font as the black thingies
Maybe my browser/mobile that shows brew install ffmpeg non monospaced
did you focus on the terminal?
try pressing ctrl + c few times
that's really weird
ur browser just kinda gave up there
Yeah then I guess my browser
Ig connecting to a data base and not closing the connection?
i will try that
yeah, maybe i will check my scripts
thank you guys
Hi, i want to send the users name, and profile picture as author line in embed, how do i access name and icon (in a modal class)
i think its Tasks
are you using discord.py ?
it is tasks
try updating discord.py to latest version
down help me
pip install -U discord.py
@slate swan
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s handle (e.g. `name` or `name#discriminator`).
there are docs for a reason
discord.Member.Avatar
its hard to locate
its not an error, it just logs the work done
class discord.ClientUser```
Represents your Discord user.
x == y Checks if two users are equal.
x != y Checks if two users are not equal.
hash(x) Return the user’s hash.
str(x) Returns the user’s handle (e.g. `name` or `name#discriminator`).
go check yourself what it has and sort out what you need
hmm, what if i want the avatar as url
did you see what type avatar attribute is?
yes
and what is that
i used discord.Member.display_avatar
it isnt url
Command raised an exception: AttributeError: 'ClientUser' object has no attribute 'avatar_url'
it really says the error
this is good attribute
im asking what type is it
wdym
type
asset
oh nice and what attributes does asset have
now you know how to use the docs
icon_url=bot.user.avatar_url
there is no such thing as avatar_url
!d discord.ClientUser
class discord.ClientUser```
Represents your Discord user.
x == y Checks if two users are equal.
x != y Checks if two users are not equal.
hash(x) Return the user’s hash.
str(x) Returns the user’s handle (e.g. `name` or `name#discriminator`).
AttributeError: 'property' object has no attribute 'url'
go to the docs and see what is has and how can you get the avatar url now
what did you do so you have property
i dont know.
so show me the code
i used this discord.Member.display_avatar.url

you need to get some member object instance
using emoji
not a whole class
uh what
go to the docs i linked and search how to gather avatar url
man thats OOP basics 😭
you need to know this before doing discord bot
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
x == y Checks if two embeds are equal.
New in version 2.0...
!d discord.Client
class discord.Client(*, intents, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.
async with x Asynchronously initialises the client and automatically cleans up.
New in version 2.0.
A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client").
!e ```py
class MyClass:
def init(self, value):
self.value = value
def get_value(self):
return self.value
good:
myclass = MyClass(15)
print(myclass.get_value())
bad (wont work):
print(MyClass.get_value())
@slate swan :x: Your 3.11 eval job has completed with return code 1.
001 | 15
002 | Traceback (most recent call last):
003 | File "/home/main.py", line 14, in <module>
004 | print(MyClass.get_value())
005 | ^^^^^^^^^^^^^^^^^^^
006 | TypeError: MyClass.get_value() missing 1 required positional argument: 'self'
first one worked
second did not
to use methods you need a class object unless its static method (its not in your case so does not matter)
@whole hull
also i should mention that you dont create Member object yourself library gives them to you
for example when you have the Context you get into your slash command there is .author attribute which is of type Member
how did u mention without ping
and you can use it
!d
i think thats wrong trix 🤫
LMAO now he will be confused as hell
how do i get the avatar url brehhhh
ok
get the Member object and then do .display_avatar.url whats so hard
when did you write it
das not working
you are not havin Member object now
discord.Member.display_avatar.url
thats not a Member object
whats a Member object then
learn OOP its mandatory for a discord bot
are you talking about variable
instance of the Member class
ok ty mate
!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.
why dont you check yourself
yeah totally there is no user
Lol
maybe cause bot.user returns the bot itself
who would imagine it wont give you random member the bot wont even know
duh what a library isnt it
._.
@sharp whale are you looking to get the avatar URL of the user who invoked the command?
(Sorry I just got here and I'm missing context)
user who submited the modal*
Can you show your entire code file?
Acknowledged. One moment
Yeah so as the others have pointed out you need to call the .display_avatar property on an instance of discord.Member, not the class itself. This is what you have:
avatar = discord.Member.display_avatar
For example, if you wanted to get the username of the user who submitted the modal, you'd do interaction.user.name where interaction.user is the discord.Member object who submitted the modal
The same concept applies to getting a .display_avatar
how
File "/home/runner/sugg-bot/venv/lib/python3.10/site-packages/discord/ui/modal.py", line 188, in _scheduled_task
await self.on_submit(interaction)
File "main.py", line 31, in on_submit
avatar = Interaction.User.display_avatar
AttributeError: type object 'Interaction' has no attribute 'User'```
sorry, my english is bad
Even copy paste doesn't work 
Interaction is the class, not the instance
If you'll notice on line 27 of your code, you have:
async def on_submit(self, interaction: discord.Interaction):
interaction: discord.Interaction indicates 2 things:
interactionis the variable containing the instancediscord.Interactionis the type (or the class) of the variableinteraction
You (usually) always call methods and properties on instances
hmm
I think you seem to have some trouble understanding the differences between classes and instance, I think this article covers it pretty well ~ https://realpython.com/python3-object-oriented-programming/#classes-vs-instances
i want to get the url of the avatar
You can get the url of a discord.Asset object by calling the .url property on an instance of discord.Asset
You can, in turn, get an instance of discord.Asset by calling the .display_avatar property on an instance of discord.Member
anybody know how to fix this error? C:\Users\Metal\AppData\Local\Temp\tmp9s8v2jv2.wav: Permission denied
its for my discord tts bot
You probably wanted bot.latency instead
oh yup forgot i was using bot
i normally use client :v
async def unban(self, ctx, member: discord.Member, *, reason = "Not Specified"):
description = f"**Unbanned:** {member.mention}\n**Unbanned by:** {ctx.author.mention}\n**Reason:** {reason}"
embed = discord.Embed(title = "Unbanned Successfully!", description = description, colour = colour)
guild = ctx.guild
ban_entry = await guild.fetch_bans()
try:
for bans in ban_entry:
if bans == member:
await member.unban(reason = reason)
await ctx.send(embed = embed)
else:
await ctx.send("The member is not banned.")
except commands.MemberNotFound:
await ctx.send("Please give a valid user ID to unban.")
Error occured: Member "1043451874164092968" not found.
why the bot is not reading the members id
The error Member "1043451874164092968" not found indicates that the member with the given ID cannot be found in the guild. This could be due to the member ID being invalid or the member not being banned.
To fix this issue u need to check for the id in the for loop instead
and yes the member is banned, id is valid
The unban command fundamentally does not work with discord.Member because to parse an ID into a discord.Member object, they need to be in the server in the first place (which they can't be, since this is an unban command)
You probably should attempt to parse it as an int by typehinting it as such, then passing in a discord.Object into guild.unban
huh
robin is saying that unban command is uncompatiable with discord.Member
Error
Code
so i've been working on a little discord bot game, i've had to restart when i started formatting it to slash commands, but recently i've been getting this:
Error: 404 Not Found (error code: 10015): Unknown Webhook
does anyone have an idea about whats causing this? it began when i was trying to implement a check for timeouts as i was getting them alot and was suggested that i put in lines to catch it
async def unban(self, ctx, id: int, *, reason = "Not Specified"):
guild = ctx.guild
member = await guild.fetch_member(id)
description = f"**Unbanned:** {member.mention}\n**Unbanned by:** {ctx.author.mention}\n**Reason:** {reason}"
embed = discord.Embed(title = "Unbanned Successfully!", description = description, colour = colour)
try:
await guild.fetch_ban(member)
await guild.unban(member, reason = reason)
await ctx.send(embed = embed)
except commands.MemberNotFound:
await ctx.send("Please give a valid user ID to unban.")
except discord.NotFound:
await ctx.send("The member is not banned."
@winter token try replacing id with user
Error occured: Command raised an exception: NotFound: 404 Not Found (error code: 10007): Unknown Member
member = await guild.fetch_member(id) this isn't going to work, they won't be in the guild (they're banned)
You actually don't need a member object to unban someone
You can pass in discord.Object(id=user_id) directly into guild.unban
can anyone help me with this
did anything work?
hm idk abt discord.Object
what does it do?
It just represents a generic ID
btw what does bot.fetch_user do?
Returns a discord.User object
async def mute(self, ctx, member: discord.Member, duration: time_conv, *, reason = "Not Specified"):
description = f"**Muted:** {member.mention}\n**Muted by:** {ctx.author.mention}\n**Duration:** {duration}\n**Reason:** {reason}"
embed = discord.Embed(title = "Muted Successfully!", description = description, colour = colour)
guild = ctx.guild
guild_roles = await guild.fetch_roles()
mute_role = discord.utils.get(guild_roles, name = 'Muted')
user_roles = member.roles
try:
if mute_role is None:
mute_role = await guild.create_role(name = 'Muted', premissions = 0, send_messages = False)
for channel in guild.channels:
await channel.set_permissions(mute_role, send_messages = False)
if mute_role in user_roles:
await ctx.send("The member is already muted.")
else:
await member.add_roles(mute_role)
await ctx.send(embed = embed)
await asyncio.sleep(duration)
await ctx.send(f"{member.mention} has been unmuted.")
except discord.NotFound:
await ctx.send('Please mention a valid member to mute.')
def time_conv(duration):
total = 0
duration_pattern = r'(\d+)([dhms])'
duration_values = re.findall(duration_pattern, duration)
for value, unit in duration_values:
if unit == 'd':
total += value * 86400
elif unit == 'h':
total += value * 3600
elif unit == 'm':
total += value * 60
elif unit == 's':
total += value
return total
Error occured: Converting to "time_conv" failed for parameter "duration".
duration: time_conv
u cant do this .-.
?
u cant just put a function callable method to a function args
then wht do i do
u can treat the duration as a str
duration: str
duration_seconds = time_conv(duration)
await asyncio.sleep(duration_seconds)
^^^^
i meant yesterday I did the same way in my weird code if u remember
but it did work
eh hmmm lemme see
now im getting confused abt manual converter
@commands.command()
@commands.has_permissions(manage_roles = True)
@commands.bot_has_permissions(manage_roles = True)
@commands.cooldown(1, 3, commands.BucketType.user)
async def mute(self, ctx, member: discord.Member , duration: converter, *, reason = None):
guild = ctx.guild
description = f"**Muted:** {member.mention}\n**Muted by:** {ctx.author.mention}\n**Reason:** {reason}"
embed = discord.Embed(title = "Muted Successfully!", description = description, colour = self.colour)
permissions = discord.Permissions(permissions = 0, read_message_history = True, view_channel = True, send_messages = False)
guild_roles = await guild.fetch_roles()
user_role = member.roles
mute_role = discord.utils.get(guild_roles, name = "Muted")
if mute_role is None:
mute_role = await guild.create_role(name = "Muted", permissions = permissions)
for channel in guild.channels:
await channel.set_permissions(mute_role, send_messages = False)
if mute_role in user_role:
await ctx.send("The user has been already muted!")
else:
try:
await member.add_roles(mute_role)
await ctx.send(embed = embed)
if duration == True:
await asyncio.sleep(duration)
await member.remove_roles(mute_role)
await ctx.send(f"{member.mention} has been unmuted succesfully.")
except discord.NotFound:
await ctx.send("Please give a valid user ID to mute!")
u did this what and it works right?
it the same i provided u here
I wanna know why duration: time_conv didnt work
because, if you wanna do a converter in a type-hint like that, you have to make a Converter class, iirc, its been a long time since i touched d.py
u need to learn this call type hint
is basically an annotations that specify the expected type of values for variables, function parameters, and return values.
!d discord.ext.commands.Converter
class discord.ext.commands.Converter(*args, **kwargs)```
The base class of custom converters that require the [`Context`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context") to be passed to be useful.
This allows you to implement converters that function similar to the special cased `discord` classes.
Classes that derive from this should override the [`convert()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Converter.convert "discord.ext.commands.Converter.convert") method to do its conversion logic. This method must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.11)").






