#discord-bots
1 messages · Page 1085 of 1
where can I find that
nvm, I figured it out logically, I’m sick rn lol so that’s why I can’t really make up questions
!d discord.Reaction
class discord.Reaction```
Represents a reaction to a message.
Depending on the way this object was created, some of the attributes can have a value of `None`.
x == y Checks if two reactions are equal. This works by checking if the emoji is the same. So two messages with the same reaction will be considered “equal”.
x != y Checks if two reactions are not equal.
hash(x) Returns the reaction’s hash.
str(x) Returns the string form of the reaction’s emoji.
the return type is well written
I mean I just want to know if for this event, does it internally fetch the message
Guys I’m trying to make a server lockdown command but I got an error can someone explain
!d discord.Embed.set_footer
set_footer(*, text=None, icon_url=None)```
Sets the footer for the embed content.
This function returns the class instance to allow for fluent-style chaining.
@slate swan is there anyway to get footer like text that supports markdown?
Reaction.message.channel would do
@spring flax ^
i don't get what that's for
not possible
That's unfortunate 🙁
question, How would I check if the person running the command has higher roles than the bot?
Anyone?
import typing
@Bot.listen("on_reaction_add")
async def __(reaction: discord.Reaction, user: typing.Union[discord.User, discord.Member]):
print(reaction.channel.name)
Yeah but that's not what I want
Anyone?
if member.top_role > guild.me.top_role:
...
How do I define member?
is there a way to test if discord would be able to embed something
ANYONE? what do I put instead of guild
right now i can check if it's a link to an image but not much else
channel
No I want it to change it for the whole server
your wish
like member would equal what is my question
I want it to lockdown the whole server
Also would the reaction event for live tracking of reaction counts when there are multiple polls at once with like 5 reactions per message be bad for a big server
would be tricky
member should be an instance of discord.Member
how would i check if there's an image somewhere on the linked page? right now im checking the meta data for a website
only seems to work if it's a direct link
set a limit for the total number of polls at a time then?
for one server that is
I don't get it? can you show an example
The bot is in 1 server only but 10 polls at a time
ANYONE? what do I put instead of guild
@Command
async def _(ctx, member: discord.Member):
if member.top_role > ctx.guild.me.top_role: ...```
With 5 reactions on each. Would this be too hard on the bot?
Oh I see
not really
guild.text_channels
Does that put permissions on every channel
missing 1 required keyword-only argument: 'member' ?
that should afaik, try it out
make sure you have guild defined
Ok
guild.text_channels is used to get all channels in the guild
Isn’t that mass channel permissions
you do want to change permissions of all channels right?
No.
I’ll show you
what do you mean by server lockdown then o.0
I want the bot to go on the role section then change the roles there
Check if user executing command has permission to ban members?
so not the channel permissions, but the role permissions instead?
try role.edit(permissions=permissions)
Ok
permissions = discord.Permissions()
permissions.update(send_messages = False)
@formal basinpy permissions = discord.Permissions() permissions.update(read_messages = True, read_message_history = True, connect = False, speak = False, send_messages = False) await role.edit(permissions=permissions)
this should definitely work, try and see
wont work, iirc it has to be a Permissions object
await role.edit(permissions=discord.Permissions(read_messages...```
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!
^^
oh wait i messed it up lmao
okay cool now
@commands.has_permissions(kick_members=True, ban_members=True)
I tried adding this check to my command but it still allows the user to run the command even if they dont have permissions @slate swan
that should work...
should it go above my bot.command or below?
check permissions lmao, perhaps they have kick members and ban members
below
they don't have permissions. and I added a error handler for the command. they both send.
should be above
nahh
since the value of one decorator is passed down to the decorator below it iirc
I did
same thing, it sends the error handler message and the message for the command if it succefuly run
@odd mango can I see an example code of it working?
what command is it? kick members?
are you the one running the command?
no I am running it on an account that doesn't have permissions
ban members
@bot.command() async def addclient(ctx, arg1): premium.append(arg1) await ctx.send("Added")
Any who know why it didnt add the cluent to list?
@bot.command()
@commands.has_permissions(ban_members=True)
@commands.has_permissions(kick_members=True)
async def ban(ctx, user: discord.Member, *, reason):
await ctx.guild.ban(user, reason=reason)
await user.send(f"You have been banned in {ctx.guild} for {reason}") #dm user
await ctx.send(f"{user} has been successfully banned.")```
I think it might be somethinf wrong with my code, since I tried @commands.has_permissions(ban_members=True) and it still lets me run the command
@client.command()
@commands.has_permissions(ban_members=True)
async def test(ctx, *, test_name):
global artist
artist = test_name
await ctx.send(f"testset as: {artist}")
@test.error
async def test_perms(ctx, error):
if isinstance(error, commands.MissingPermissions):
em = discord.Embed(title=":x: You do not have permissions to run this command", color = discord.Color.blue())
await ctx.send(embed=em)
else:
raise error
@odd mango
welp this one works, go ahed and copy paste it
I don't need a ban command
as for error handling
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('Please pass in all requirements :rolling_eyes:.')
if isinstance(error, commands.MissingPermissions):
await ctx.send("You dont have all the requirements :angry:")```
hey uhm can I ask a discord related question? (Not py related)
yeah go ahed
Because I need to see how I check if user running the command has permssions to run the command
uhh what is the endpoint for user login and registeration?
@slate swan ?
okay dunno that
the authorization headers
uh alr
I asked what endpoint
token
BRUH token is an authorization header not the endpoint for user login
try, has_guild_permissions instead, ig thats the problem
/auth/login
Uhh is there any documentation on that?
@client.command(name="moves")
async def moves(ctx: commands.Context, pokemon: str):
with open('moves.json') as json_file:
movedata = json.load(json_file)
pokemon_moves_list = movedata.get(f'{pokemon}')
if pokemon_moves_list is not None:
pokemon_moves = '\n'.join([str(elem) for elem in pokemon_moves_list])
print(pokemon_moves)
else:
print('error')```
this is a command block of mine
in this, i am using `is not None:`
is there a faster alternative to it?
You both just told different ones...
Like commands.has_guild_permissions ?
yes
I'm dumb, ignore me
and what are the headers passed?
@slate swan, you know? ^^
I don't know all of them, one is token though
if pokemon_moves_list: do stuff
got it tyyy
ah alright thank you so much!
I hope you don't use this information for malicious things 😄
I am trying to make a discord clone 🙂
Oh sweet
@slate swan It didn't work..
I don't think that's malicious
well
there"s probably an issue within discord then, do all the roles not have the req perm?
the ban permission?
yeah
no issue with discord, my bot commands which require permissions work just fine
No roles in the server have ban permissions @slate swan
and the user running the command has no roles at all
is it the owner of the server?
No
weird
that's weird then.....how do you know the command is getting triggered
await ctx.send(f"testset as: {artist}")
Yes ^
oh nvm
i need to puke again, brb
but it sends that aswell as the You do not have permissions to run this command
oop
oh, then bingo it's working
Could it be something how im using a global var?
Can discord bots use custom emojis from other servers?
yeah its because of the global var
only if they're in the same server as the emoji
yeah they can, if theyre in that server
no
my bot does...
thats what i told...
Do I just need the ID of the emoji?
yeah
Savvy do you know how I fix my code?
"if they are in that server", I might have took that wrong
\
Thanks
at this point, no idea
but you do think it has something to do with the global variable?
stop using globals
yeah
vars*
I want to access those variables in other commands, so isn't that the only way?
its cause of the global var, cause if missing permission error is triggered, then permissions are working fine
!botvar
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
^^
ash, can i borrow you for a minute? if you're free
that sounds wrong, so wrong
Nice
...
(I am not here)
mind out of the gutter
sure, what is it
come at asher's server?
sure
im gonna kms
Those are like globals tho
@maiden fable How do I use them, like can I see an example command of setting a new text for the bot.test
That is what the embed example shows
I tried it and it still didn't work
client.test = "None"
@client.command()
@commands.has_guild_permissions(ban_members=True)
async def test(ctx, *, test_name):
client.test = test_name
await ctx.send(f"testset as: {artist}")
@maiden fable
artist isn't defined.....?
it is though wtf
I don't see a var with that name
when I ran the command it still somehow sent the right name
Im so confused h
@maiden fable I cahnged the artist to test_name
now it sends as double though
?
like i did !test name
and it sent as
testset as: name
testset as: name
what the
@slate swan can u help him here pls? I am sleepy 😔

WTF
@slate swan so it still is broken..
whats broken and show code
client.artist = "None"
@client.command()
@commands.has_guild_permissions(ban_members=True)
async def artist(ctx, *, artist_name):
client.artist = artist_name
await ctx.send(f"Artist set as: {client.artist}")
@artist.error
async def artis_perms(ctx, error):
if isinstance(error, commands.MissingPermissions):
em = discord.Embed(title=":x: You do not have permissions to run this command", color = discord.Color.blue())
await ctx.send(embed=em)
else:
raise error
it lets anyone run the command even if they dont have ban member perms
!d discord.ext.commands.has_permissions
@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
try this one
I have
not sure whats the problem never seen the source code either of that deco
the problem before was because I was setting the variable globally, now I am not and it still lets anyone run the command
do you have members intent?
idk
show
I just have
intents = discord.Intents.default()
intents.members = True
seems like a yes
is their anything that can ignore/shush exceptions?
I only have that one error handler
because your local handler looks good to me
not sure really
Why is my client.wait_for response prints twice or sends twice whenever I call to use it?
yeah I have it enabled @slate swan
dont really see the issue tbh i would check src code of the deco but i can't 😅
i want to embed a string
how do i embed it this way
like only 30 elements in 3 columns and 10 rows on page 1, similarly on page 2 and so on
inline=True on the add_field
you mean False
I can check it
maybe
would it do 3x10 though
i just know it wont, it will just add fields like that, until the list finishes, wont go to next page
github dpys repo lol
i would check it im just on mobile and it kinda looks bad and unreadable
what if I just add an if statement in the code?
if ctx.author.guild_permissions.ban_members: ?
i mean yeah you could lol just check the authors perm or you can go to the dpy server and ask their if you wohld like to know the issue
iirc yes
@slate swan something interesting, the user running the command that doesn't have the permissions only sends the message once but if they do have permissions its sending twice
show code
@slate swan I added an else statement with a print
client.artist = "None"
@client.command()
#@commands.has_guild_permissions(ban_members=True)
async def artist(ctx, *, artist_name):
if ctx.author.guild_permissions.ban_members:
client.artist = artist_name
await ctx.send(f"Artist set as: {client.artist}")
else:
print("No permissions")
I don't have permissions and ran the code, it sent the Artist set as once then printed No permissions
how can I add an button to the embed that inlcudes a link to the dashboard?
async def command_dashboard(interaction: discord.Interaction, suggestion: str) -> None:
value=suggestion
embed = discord.Embed(
colour=58111, title="Dashboard", description="Drück den Button, um zum Dashboard zu gelangen."
)```
@slate swan if you have any ideas can you send me a dm, im gonna be leaving soon and wont be online
interaction.response.send_message(embed=embed, view=...)
!d discord.ui.View this is what you pass in to view
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
@fading marlin any idea how?
list comp ig. Add all of your elements to a list, and the enum them or something to keep track of how many elements you're adding to the column. If you reach the limit, then make another column and repeat the process
okay i do have a list, do you have a further example?
is the list arbitrary? or do you always have the same amount of values in it?
arbitrary, its the value to a key
as the key changes, the list changes too, so does the amount of values in it
the other way around, ||<invite_link>||
then do what I said earlier; iterate through your list while keeping track of how many values you've iterated through (you could use a variable or make a new list, send the value to that, and check the length of it). If your counter reaches the desired number, add another column. Then just reset the counter and repeat
are there any example blocks
Hi, can anyone direct me to some good modern tutorials for making a discord bot in Python? Are year old videos like https://youtu.be/SPTfmiYiuok still up to date?
And is Python the best language for discord bots?
don't watch YT vids about frequently changing libs
what's your source on that? xd
What resources do you recommend?
And I'm asking if Python is good for discord, not claiming it is
#discord-bots message
and the docs
Python is fine... you're asking this in a Python help server? xd
Thanks I'll look into those. Though I guess nextcord and disnake and discord.py are all different libraries? I've also heard of pycord. I'm a little confused about which one is best or most used
Hey I got an error
And I have not seen it before
Collecting dotenv
Using cached dotenv-0.0.5.tar.gz (2.4 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [65 lines of output]
WARNING: The wheel package is not available.
error: subprocess-exited-with-error
python setup.py egg_info did not run successfully.
exit code: 1
Something like this
Hello, just wondering how i can go about downloading a file sent by the user and read it on my computer
have you made commands before?
yes
and events too probably, right?
yes
doesn't seem discord bot related
when do you want the bot to read the file?
when it's sent in a specific channel? or..
What is going wrong then when I try to install a dotenv package
wrong help channel
on command if possible so like !test [attachment] and my bot downloads it and reads it if possible
Which one would I ask in?
alright, perfectly possible
yes, just use attachments property on the context message which returns a list of File objects
!d discord.File
class discord.File(fp, filename=None, *, spoiler=..., description=None)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
I've tried to understand the documents lol but can't get my head around it. I don't suppose you have an example?
#<your command decorator>
async def shit(ctx):
# first, you should ofc check if there are any attachments...
file = ctx.message.attachments[0]
# file is a discord.File object, check out what methods it has
# such as read, save, ...```
Hey @dusk tundra! 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!
have a pretty basic question, how do you catch a specific error? never needed to do it before
async def shit lmao
specifically this one: urllib.error.HTTPError: HTTP Error 403: Forbidden
import discord
TOKEN = "insert token"
client = discord.Client()
@client.event
async def on_ready():
print("{0.user} is now online!".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('!hello'):
await message.channel.send('Fuck off')
client.run(TOKEN)
thank you
run the correct code
wrong person?
nope
what you mean?
do it in the error handler if there is a chance for it to be raised from multiple funcs, else a simple try except will do
no way your bot is sending "hello", double check that you're running the correct file
i have different exceptions going on
it totally loves you
it is lmao
global error handling is the terminology you're looking for
@potent spear I have another question, How do I actually read and save the contents of the file to a variable or something?
handle them in the error handler then
if I program a bot to say hi then change it to fuck off do I have to make a whole knew bot
through its methods...
await attachment.save("shitfile.txt")
thanks
i got no clue
be aware, it returns a list of Attachment objects
fixed it
oops my bad, thanks
yeah but how would i catch the specific error would it be except urllib.error.HTTPError:
403 specifically?
you should check out global error handling
What error does it give you
urllib.error.HTTPError: HTTP Error 403: Forbidden
Hi btw sniper, long time ago
Then I'd use that one
@potent spear what am I doing wrong?
What doesn't work?
reading is aync
ahh thanks
^^
the file doesn't even have to be read first...
lastly, if you were to read it, that's async
And u gave 2 positional arguments, use file.read() or read(file) (not sure about the last one)
oh you can just turn the exception into a string with except ValueError as variable: then do an if statement that's the best way right?
the comments are incorrect
file is a discord.Attachment object
the former with await
Wait what?
await file.read()
file being a discord.Attachment object
Ah, I didn't get former. English giving me a hard time sometimes in coding terms
the former = het eerstgenoemde
the latter = het laatstgenoemde
Right, you were dutch right? 🤯
yup
Completely forgot😅 I've advanced since we spoke last time.
💪
can someone help me code a discord bot
sorry to bother you again But how can I save the file as for example the command authors name?
will the file extension always be the same?
yes that doesnt matter '.txt' if possible
await attachment.save(f"{ctx.author.name}.txt")
ahhh
except Exception as e:
print(e)
if e == "HTTP Error 403: Forbidden":
content = "Your link is not publicly accessible."```
what am i doing wrong here? When i print e i get `HTTP Error 403: Forbidden`
thank you
the file will obviously be overwritten once it saves again
try str(e) == ...
oh okay, that worked thanks
you should also catch specific errors, not just Exception
I cannot get the file name to work, it keeps getting the length of characters
file = file 
^^
have you read the docs and checked the methods of discord.Attachment as suggested?
what you're doing can be done in 3 lines
i cannot undestand why cant i import it even tho i did "pip install discord"
hello
Hello python experts, I need help in discord.py, I want to make a command that can mention each user of a server one by one
most likely, you have multiple python versions installed
how do i see if i have it?
find the interpreter you're using in vs code, you can google on how to find that
then type in the terminal python
and check which version of python that's on
than make sure they're similar
how would I do that?
you're asking me how to read the docs?
no how to do what I need help with I've tried reading the docs but I don't understand it which is why im here lol
you know basic OOP, right?
yes
then you should know what methods are, right?
yes
so let's say you have a discord.Attachment object
this has different methods, right?
!d discord.Attachment
class discord.Attachment```
Represents an attachment from Discord.
str(x) Returns the URL of the attachment.
x == y Checks if the attachment is equal to another attachment.
x != y Checks if the attachment is not equal to another attachment.
hash(x) Returns the hash of the attachment.
Changed in version 1.7: Attachment can now be casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") and is hashable.
check them out ^
Hello python experts, I need help in discord.py, I want to make a command that can mention each user of a server one by one
i.. uhh.. couldnt find anything
cant u just help me out? my vs code is brand new
nvm i found it
ctrl + shift + P
I need help pls
we aren't therapists, sorry
I'm trying to display user avatar in current guild not default guild, I looked everywhere in documentation but could not find anything
what have you tried?
Parse what
don't crosspost in different help servers...
I still want to see the code...
if you don't ask you shall not receive...
most likely, they have an API
help
Whenever I type a command w/out the proper arguments, the on_command_error event fires twice? Any common reason for that happening? I'm using cogs for this and the event is in the main folder
But they don't want you sharing the sub
Wrong version of aiohttp
How can I format it here
pip install aiohttp==3.8.0
!codeblocks
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.
If you're on mobile:
Does anyone have a good way of listing out role permissions in a more human readable format like add reactions, send messages as so far I have thispy ", ".join( [ permission for permission in role.permissions if role.permissions is not None ] ),and I'm thinking this will keep the _ in the names like add_reactions
make sure you're not accidentally running 2 instances
I mean I don't think I am but how would I check
Oh you mean 2 instances of the bot
task manager
Oh that actually might be why lol
what's the use of that if statement...?
sharing the sub?
ah, I see what you're trying to say
so let's make things clear
you want a bot to log in to your acc and screenshot that part?
they make it difficult to just link it there are bots to tradingview but they don't have my algorithms for stocks
yea basically it just has to change the ticker on command of the discord user
def image_from_url(url):
return Image.open(get(url, stream=True).raw)
....
image = image_from_url(user.display_avatar)
....
@potent spear
the ticker on your acc, right?
oh my, lol
what version of dpy are you on?
oh I have a else which puts a no permissions found msg if the role has no permissions, I just chopped that off by accident when I copied it
2.0
you want the member's avatar, right?
in the guild, or just the main one?
the bot would work by discord user making commands like !ARKK 1d
Yes but in current guild
As most members have nitro
aight, and why do you want it as a file?
Not a file as an image
same thing, why?
But it always returns the default avatar
I'm not too sure if they won't ban you if you'd do that frequently, just saying
you think that can get you banned?
Is there a way to retrieve the avatar a user has set in the current guild
can you show me your code? I'm not sure if you have a member object or a user object, since there's a difference
Idk, read the ToS there xd
@potent spear do you think it would be easier to link Tradingview or excel to discord because I can also code in excel
!d discord.Member.guild_avatar
property guild_avatar```
Returns an [`Asset`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Asset "discord.Asset") for the guild avatar the member has. If unavailable, `None` is returned.
New in version 2.0.
and use .read() method
what does excel have to do with this?
aight, so it's not display_avatar apparently
I can instead of using tradingview I can use excel to send the information to discord
How can I turn into pil
either way is fine Im just looking to do what is easier
no idea, this isn't very discord bot related lol vinny
it technically is
display avatar works in this order
- a guild_avatar, if set
- an avatar, if set
else it will return the default avatar
discord/member.py line 592
return self.guild_avatar or self._user.avatar or self._user.default_avatar```
clean line
would it be possible to create a discord bot that on command can grab this chart and post it in discord?
you're asking too many questions in 1
you got the bytes, use io.BytesIO ,
image = PIL.Image.open(io.BytesIO(bytes))
Will I have to await it
the docs will tell
😂
unsure,most probably yeah
property guild_avatar
Returns an Asset for the guild avatar the member has. If unavailable, None is returned.
This is not good
Because it means I have to check for none
how would i get a user object just from someone's tag? ie: my user object from walker#1693
typehint
!d discord.ext.commands.UserConverter.convert
await convert(ctx, argument)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The method to override to do conversion logic.
If an error is found while converting, it is recommended to raise a [`CommandError`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError") derived exception as it will properly propagate to the error handlers.
probably not even need explicitly ^
async def shit(ctx, member: discord.Member)
!shit @radiant junco
now
member = <your member object>
this happens thanks to dpy internally converting names, IDs and mentions to member objects
Note: will raise error if it couldn't convert it, so having a default value like None and checking if the member isn't None is an easy fix
the error will always be raised if the argument was provided and the member object couldn't be get/fetch-ed
None just helps with the MissingRequiredArgument error
^^
Ideas on why "Should print" doesn't print?
any error?
Not in output or console or anything
Unless Im missing it somewhere, still a noob
No errors in any of these tabs lol
do you have an on_command_error event?
I do but it would return it on discord and I haven't gotten any message return
oh wait
I guess it would be because I didn't put whatever error it is in this list?
hm, add else: raise error
And using elif is better than ifs in your case
Because the flow control doesn't stop at the matching condition but keeps checking all the conditions
Oh alright I'll change it and yes now I'm getting an error, it says "cogs.general" has not be loaded
I had it listing when a cog was loaded so I guess because it has "cmds" in it, thats why it was giving an error
there should be more stuff there, may k see thr complete traceback?
I got error
User object has no attribute guild_avatar
But I already updated discord.py to 2.0
cogs.general was never loaded, and you tried to unload it
because its a property of Member, not User
they are different
How can i get member from user
Ive solved it ty! Its a lot easier when it tells you whats wrong with it lol
may i see your code, it can be much easier to get a Member directly instead of converting a User to Member @digital mason
gg
Code is too long
i just need the async def line
change the discord.User to discord.Member are you're good to go
I wish it was that easy
it is :D
But im using a regex to match user
!d discord.Guild.get_member well then use this
get_member(user_id, /)```
Returns a member with the given ID.
Changed in version 2.0: `user_id` parameter is now positional-only.
So I have a command in one of the cog files and it uses latency which is a attribute of discord.Client, but people tell me doing discord.Client.Latency for example is bad? So how would I get the client then because I have it inside the main file but I dont know if theres a way to pass it into other files
may i see your cog structure
indeed thats as easy
from http import client
from discord.ext import commands
import discord
class General(commands.Cog):
def __init__(self, client):
self.client = client
## [COMMANDS] ##
# Event on [ping] command usage
@commands.command(aliases = ['latency'])
async def ping(self, ctx):
await ctx.send(f'{round(client.latency * 1000)}ms')
def setup(client):
client.add_cog(General(client))
self.client.latency
Oh self is discord
notice that you defined self.client as your client in the init dunder
oo
Can someone give me an code example of using Buttons(send through slash command + embed)?
Thank you very much you are saving my life rn 🙏
self is your General class
you set a client property to it inside the def __init__ which is equal to your client
now you can access the client using self.client anywhere
what library?
This is my current code but dunno how to use buttons
Rapptz (discord.py 2.0)
you can create a view, and add a url style button to it
Good to know ty,
async def ban(self, ctx, member: commands.MemberConverter = None, *, reason = None):
if reason == None or member == None:
await ctx.send(f'Incorrect Syntax:\n.ban [User] [Reason]')
else:
Do you think doing something like this to check if they put in the parameter is efficient or should I just let the command error catch it
view = discord.ui.View()
view.add_item(discord.ui.Button(style = discord.ButtonStyle.url, url= "link", label="label"))
``` and then you can use the view kwarg in send to send the view
i used to use on_command_error for that, its easier
alrighty ty
async def command_dashboard(interaction: discord.Interaction, suggestion: str) -> None:
value=suggestion
embed = discord.Embed(
colour=58111, title="Dashboard", description="Drück den Button, um zum Dashboard zu gelangen."
)
view = discord.ui.View()
view.add_item(discord.ui.Button(style = discord.ButtonStyle.url, url= "link", label="label"))
Like this?
bad indents but yes
Ye not on my pc currently
!eval ```py
if 1==2:
apple = "bananas"
print (apple)
you did something like this
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 3, in <module>
003 | NameError: name 'apple' is not defined. Did you mean: 'tuple'?
basically, you used a variable before actually it having a value
Oh
wtf what py version is this
Well how can I fix this to get the server roles
is that user in your server?
And do you have member intents
your get request condition has a sql query which is returning None
Yes but it's me, could that be the problem
Member intents ?
The server has roles tho
I guess yes
prolly like 3.10
where can I hire people for coding for me? send link in dms pls
sir that's why i am not doing in this server, i am looking for a server to hire people @fading marlin
async def botstatus(self, ctx, stat= 'online', *, activity = 'Working'):
await self.client.change_presence(
status = discord.Status.stat,
activity = discord.Game(activity)
)
How would I get discord.Status to use the value of "status" as a argument, because now it thinks "status" is an attribute
status=status?
Oh I need to change that variable name too
status requires discord.Status, not string though
how can I Check if user running command as administrator permissions?
!d discord.ext.commands.has_role
Well I'm trying to do the equivalent of
discord.Status.idle w/ stat being equal to idle
Unless its just not possible
wrong one
Because maybe idle is a attribute ?
ugh
uh, getattr maybe?
I know of that alraedy, just is there a administrator=True ?
You need to map different values to their statuses (stati?):
mapping = {
"online": discord.Status.online,
"idle": discord.Status.idle,
... # fill in the others
}
and while you're at it you also might wanna typehint your stat argument to a typing.Literal["online", "idle", ...]
File "c:\Users\idiot\Desktop\Other\Python\NcZ Discord Bots\Banana Bot\main.py", line 3, in <module>
with open("token.txt") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'token.txt'``` can anyone help me rq
graci, i will look up what some of that means
the token is in same dir
yes
same folder?
administrator has all permissions?
yes
How do I create roles and set there permissions?
@slate swan I could only find server members intent and message content intent and presence intent
In developer portal
!d discord.Guild.create_role
await create_role(*, name=..., permissions=..., color=..., colour=..., hoist=..., display_icon=..., 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/latest/api.html#discord.Role "discord.Role") for the guild.
All fields are optional.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/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.
New in version 2.0: The `display_icon` keyword-only parameter was added...
@slate swan ^
what are all the permissions you can add
?
read the docs
All the permissions there are
The file was not found
Is it in the same folder?
look at my picture and messages under that message
Go to file explorer and copy the full path
Use that instead. It isn't in the same folder if it doesn't find it
Do I need to make a function to do this
"stat argument to a typing.Literal["online", "idle", ...]"
like a check
nope, just typehint
if i use my whole path i cant put my file on my host with these lines
Send pic of both files in same folder in file explorer
Ok, are you in the right directory when running ur bot?
its running one folder behind
Can anyone tell why ctx.guid.get_member(user.id) returns None when intents are already enabled and user is not None
Then there u have ur explanation
and how do i fix this lol
if u use token.txt, it will look in the folder where u ran it.
Cd to the right directory and run it after
have you explicitly enabled them in your bot constructor?
Not a function:
async def botstatus(self, ctx: commands.Context, stat: typing.Literal['online', 'idle', ...] ='online', ...):
...
if i run my file by double clicking it how do i change it there
Oh so I keep stat:, I was close alright
I'm using the elipsis here because I can't think of the other statuses off the top of my head
cd "NcZ Discord Bots/Banana Bot" in ur retinal
Send me the path of the txt file first, gonna help me a lot
Yes intents.members = True
@commands.command()
async def botstatus(self, ctx, stat: typing.Literal['online', 'idle', 'dnd'] = 'online', *, activity='Working'):
mapping = {
"online": discord.Status.online,
"idle": discord.Status.idle,
"dnd": discord.Status.do_not_disturb
}
await self.client.change_presence(
status = mapping[stat],
activity = discord.Game(activity)
)
boom :D
C:\Users\idiot\Desktop\Other\Python\NcZ Discord Bots\Banana Bot\token.txt
Type this in terminal and run after
in my vsc treminal ?
Yes
are they enabled in the dashboard too?
and how do i change it if i run my file by double clicking
U cant I think.
Anyways, it's time for me to go to bed, almost 3 am
My friend @slate swan might be able to help you further🙂
im just lurking

you shouldn't really be running your script by double clicking it, it's best practice to just open up the console and run it from there
How can I edit channel permissions after I create it?
also btw @slate swan the problem with my code before was I had 2 instances running of the code.🤣
🛌
I know
!d discord.TextChannel.edit
await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
Changed in version 1.3: The `overwrites` keyword-only parameter was added.
Changed in version 1.4: The `type` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead...
Yes, I think I'll use fetch_member because I saw that get_member only looks in cache
all get_* methods look up in cache btw!
its a good thing to know
So is there a way to build on mapping to assign to variables to it? Like this maybe
stat = "online"
mapping = {
"online": discord.Status.online, "Working"
"idle": discord.Status.idle, "Updating"
"dnd": discord.Status.do_not_disturb, "Offline"
}
mapping[stat[1]] would return "Working"
mapping[stat] would return discord.Status.online
discord.Status.do_not_disturb "Offline" you forgot a comma here
Well that wouldn't work would it?
does editing category permissions cause all channels in that category to have the same perms?
What exactly are you trying to do here? Why's it got the quotations after the key-value pair?
Im basically trying to get rid of the "activity" parameter from the command function by just having a preset one that is tied w/ the status
you're probably trynna use a tuple here too. What you've got here will raise a SyntaxError
So if the status is online, I can reference both discord.Status.online and "Working" separately
Right, I was just tryna give a visual of what I was trying to do
Then in that case you could use a tuple
so would I need a different list for that then
How do I resolve this?
TypeError: GuildChannel.set_permissions() missing 1 required positional argument: 'target'
depends if the channel has all its settings set to 'same as category' or the / thingamajig
mapping = {
"online": (discord.Status.online, "Working"),
"idle": (discord.Status.idle, "Updating"),
"dnd": (discord.Status.do_not_disturb, "Offline")
}
status, activity = mapping.get("online")
print(status) # discord.Status.online
print(activity) # Working
Oh you should just put () around it, that makes sense
Appreciate you guys 🙏
Cause I was just gonna make another list lol
!d discord.abc.GuildChannel.set_permisions
._.
lol
screw that, here's the link for the docs: https://discordpy.readthedocs.io/en/stable/api.html?highlight=set_permissions#discord.abc.GuildChannel.set_permissions
I don't see target arg on there though
?

How do I make it the @ everyone role?
you want TextChannel.edit for that
Howd I do it then?
.
I dont see any permissions edit?
@bot.slash_command()
@commands.guild_only()
async def spotify(ctx, user: discord.Member = None):
user = user or ctx.author
spot = next((activity for activity in user.activities if isinstance(activity, discord.Spotify)), None)
if spot is None:
await ctx.send(f"{user.name} is not listening to Spotify")
return
embedspotify = discord.Embed(title=f"{user.name}'s Spotify", color=0x1eba10)
embedspotify.add_field(name="Song", value=spot.title)
embedspotify.add_field(name="Artist", value=spot.artist)
embedspotify.add_field(name="Album", value=spot.album)
embedspotify.set_thumbnail(url=spot.album_cover_url)
await ctx.respond(embed=embedspotify)
Discord Py 2.0
I get no errors but it always shows "is not listening to Spotify" .... what is god damn wrong
The Bot CANT get what the ppl are listening to
it's called overwrites
can I see an example of it used
@bot.slash_command() that doesn't look like dpy 2.0 
it is 😉
why're you using next here?
I don't have any at hand atm
what else should I use ?
I figured it out
just a normal list comp?
2.0s implementation doesnt have slash commands bound to the Bot class
Finally worked thanks everyone
only forks have such an implementation
How do I edit the permissions for a certain channel?
I think you've asked this like 3 times already
I figured out how to do it for a whole category not a specific channel
I don't know if typing.Literal works for parameters bc it always returns that its not the correct amount no matter how many I type in
TextChannel.edit -> pass in overwrites kwarg with PermissionsOverwrite instance -> when you instatialize PermissionsOverwrite, pass in key-value pairs with the permissions you want to overwrite
turn it on, and in ur code too
!intents exactly the piece of code you need
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
wdym?
async def botstatus(self, ctx, stat: typing.Literal['online', 'idle', 'dnd'] = 'online'):
What is the one called to enable attachments?
add_attachments=True ?
im pretty sure thats not how you use typing.Literal
How do you use it?
!d discord.Permissions for a list
class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.
The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.
Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.update "discord.Permissions.update").
hey you got one right for once
lmao hush 😂
thats not how typing.Literal works + thats not how discord.py argument parsing works
hows it work
what you wanna do?
attach_files is all files not just images?
no no it is
!d typing.Literal
typing.Literal```
A type that can be used to indicate to type checkers that the corresponding variable or function parameter has a value equivalent to the provided literal (or one of several literals). For example:
```py
def validate_simple(data: Any) -> Literal[True]: # always returns True
...
MODE = Literal['r', 'rb', 'w', 'wb']
def open_helper(file: str, mode: MODE) -> str:
...
open_helper('/some/path', 'r') # Passes type check
open_helper('/other/path', 'typo') # Error in type checker
```...
😅
Just trying to pass a parameter using typing literal since someone said I shoud
@commands.command()
async def botstatus(self, ctx, stat: typing.Literal['online', 'idle', 'dnd'] = 'online'):
mapping = {
"online": (discord.Status.online, "Working"),
"idle": (discord.Status.idle, "Updating"),
"dnd": (discord.Status.do_not_disturb, "Offline")
}
await self.client.change_presence(
status = mapping[stat],
activity = discord.Game(mapping[stat])
)
its just for this command
correct
ah
I dont see any for just images?
there's no perm for just images
maybe its the converter
you can just ```
async def command ( context, arg ):
if not arg in ("idle", "online", "dnd") :... # wrong argument
Yeah, I just thought the typing literal thing was more efficient
idk tho
ill do that
it is, its just maybe the converter cant parse that type
Discord.py won't parse it that way though,
I'd use slash command with choices instead
I haven't learned slash commands yet, should I just figure that out now so Im not going back on myself later
or just ```py
if not hasattr(discord.Status, stat):
return await ctx.send("wrong arg")
await self.client.change_presence(status=getattr(discord.Status, stat), ...)
this allows you to also pass in do_not_disturb which is equivalent to dnd
remember that the internal converter can only convert certain types!
imagine someone entering __init__, __str__ or __repr__
well too bad
try/except then cause getting anything else would error out 
it would be a waste-ful api call
ig lol
Whenever I try to install aiohttp, it says its the wrong version, so I download the version it says I need and then it says its still the wrong version and go back to the last version lol
ignore that lol
Set created role color and view above other roles?
thats just some dependency shit, that too with the macro part
@slate swan How can I find a certain role with utils?
utils.get(Guild.roles, **attrs)
reload ur tab and try again maybe
ill check, brb
ye it works
gg
Hey everyone! I am trying to recreate the famous dank memer basketball work command and I need some help with the code, I have been trying to find a way in discord.py to be able to wait for the person's message, while also changing the basketball front end and making it look good as well because sometimes the basketball doesn't align with the baskets.
If someone can help me out that would be much appreciated.
btw im not using discord buttons, I am making the user type "left" "middle" or "right"
Please ping if you can help, ty guys.
anyone know why the command won't work for this?
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='.')
@bot.event
async def on_ready():
print("Online!")
@bot.command()
async def ping(ctx):
await ctx.send("Pong! Your ping is " + str(bot.latency) + ".")
token = 'mytoken'
bot.run(token)
you did use
The actual token right?
when you ran it
yes
what is the error
hmm
oh wait
try editing your @bot.command line to @bot.command(pass_context = True)
alright
you haven't passed in the bot's context so its probably why it did not work
hmm still no luck
yeah i do
oh wait
I know lmao
edit your @client.event to @client.event()
you forgot to define the method
@foggy latch
ye i did
yeah that's working fine
hmm
it's just the .ping command that won't return anything
oh yea
i just tried adding that rn
it didn't seem to do anything, let me get an updated version of the code
intents=discord.Intents.default()
bot.event or bot.listen(), not bot.event()
import discord
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix='.', intents=intents)
@bot.event
async def on_ready():
print("Online!")
@bot.command(pass_context = True)
async def ping(ctx):
await ctx.send("Pong! Your ping is " + str(bot.latency) + ".")
token = '(token)'
bot.run(token)
then you could pass in intents as a second argument into your commands.Bot
hmm
pass_context isn't a thing, and what dpy version are you using?
default intents don't include message_content, which you need
it does because I could access it with default
not really sure why it does not work
>>> list(discord.Intents.default())
[('guilds', True), ('members', False), ('bans', True), ('emojis', True), ('integrations', True), ('webhooks', True), ('invites', True), ('voice_states', True), ('presences', False), ('guild_messages', True), ('dm_messages', True), ('guild_reactions', True), ('dm_reactions', True), ('guild_typing', True), ('dm_typing', True), ('message_content', False), ('guild_scheduled_events', True)]
just try intents.message_content = True
dpy version is 1.7.3 i believe
alright
could you check?
oh i see
yeah
sorry i assumed 2.0
could work
hooray \o/
it was its just deprecated
How can I enable this for a new role I create
hoist
role.hoist = True ?
i guess role.edit(hoist=True)
stackoverflow:
role = await message.guild.create_role(name=rolename)
role.hoist = True```
yes same thing
ok I also need help with something
trying to recreate the famous dank memer basketball work command and I need some help with the code, I have been trying to find a way in discord.py to be able to wait for the person's message, while also changing the basketball front end and making it look good as well because sometimes the basketball doesn't align with the baskets.
btw im not using discord buttons, I am making the user type "left" "middle" or "right"
!d discord.Client.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.10)"). 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.10)") 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.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
yep i used that
but I cant figure out a way
to make it so that the basketballs move
and when the user inputs, if its incorrect then it exits otherwise it continues
!d discord.ext.tasks.loop try this maybe
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
so thats something i have been having trouble with
um
yea idk
how i would use that exactly
try:
inp = client.wait_for('message', check=check, timeout=25)
except:
await ctx.send(
"HORRIBLE WORK! You didn't even respond in time, such a lazy bum. I honestly might fire you. :disappointed:")
return
for i in range(10):
time.sleep(random.randint(1, 3))
random_position = random.choice([
':wastebasket::wastebasket::wastebasket:\n\n:basketball:',
':wastebasket::wastebasket::wastebasket:\n\n :basketball:',
':wastebasket::wastebasket::wastebasket:\n\n :basketball:'
])
await msg.edit(content=random_position)
if random_position == ':wastebasket::wastebasket::wastebasket:\n\n:basketball:':
answer = 'left'
elif random_position == ':wastebasket::wastebasket::wastebasket:\n\n :basketball:':
answer = 'middle'
elif random_position == ':wastebasket::wastebasket::wastebasket:\n\n :basketball:':
answer = 'right'
if inp == answer:
await ctx.send(f"Congrats! You won $ `{jobs[index]['pay']}`.")
await self.account_updater(ctx.author, jobs[index]['pay'])
else:
continue```
iirc it's something like this ```py
from discord.ext import tasks
@tasks.loop(...)
async def my_task(...):
move basketball
my_task.start(...)
hmmm
thats my code rn
but it doesn't really work
start the tasks before you call wait_for
so when you say
"tasks," you are referring to the movement of the balls right?
in this particular scenario ofc
no, I'm referring to the function that has a tasks.loop deco
yes
so in the async function for the task loop should I just paste
the code for the moving balls?
what does it block?
oh i understand now
ok ty lemme try it to see if it works
for the loop I dont need to pass any arguments right? into the task.loop
you can if you need to
i mean its mainly .sleeps
i'm not trying to get that from mention, i'm trying to get it from their actual tag like walker#1693, (!shit walker#1693)
so it shouldnt matter i would figure
if you decorate your argument with discord.Member it should accept mention, partial name (sans decorator), the name with decorator, and i think id too
the Member converter is clever 🙂
i'm not trying to get a mention, i'm trying to send a mention using webhooks but i need to get an id to do that since mentions are like @<id>
i'm not doing a command
i'm sending a webhook but i'm trying to mention someone through that
i'm trying to convert walker#1693 to @<id> so that it turns into a mention
ah okay
!d discord.ext.commands.UserConverter.convert use this
await convert(ctx, argument)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The method to override to do conversion logic.
If an error is found while converting, it is recommended to raise a [`CommandError`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError") derived exception as it will properly propagate to the error handlers.
and you can get the ctx by simply fetching any message from that server
i can't use discord py
because then i would need a bot
@radiant junco what are you trying to do?
why don't you just copy the Id manually?
yeah..
Is there any event for bot like
When the bot joins a guild do stuff
Which server i can hire people
@slate swan , how can I copy an image link and the text provided with that image?
on_guild_join
Will work for bot right?
You can't hire anyone here
yes it does!
I personally do not know of any.
there are definitely tons of websites.
um im missing some context i guess, can you elaborate?
So, a user uploads and image with a message. I want to get that images link and the message aswell
Hello
I want to get the image I attached and the message
message content would be message.content
the image url will be message.attachments.[0].url
!d discord.Attachment.url
The attachment URL. If the message this attachment was attached to is deleted, then this will 404.
message.content contains just the url of image or both the url of image and message?
only message
the "hello" part here
so I can save the message.content as a string
yes indeed
and for the image url?

_ = message.attachments
if _:
__ = _[0]
you forgot to assign the var
and the underscore vars😔
phone 😔
attachment = message.attachmentd[0] if message.attachments else "No"
```? 
of?
Edited
a new keyword😳
im on phone too
kek
just use or
😔
huh, mind showing how?
that's the same thinh
just a one liner
its just like having an if-else but in single line
yeah this would just be the string for the image url ?
it would be an attachment object if theres an attachment, else it would be a string "No"
the object would be the string or the actual iamge?
yes
you can change it to message.attachments[0].url to convert it to url
Oh I see.
its just like a normal if statement
neither an string, nor an image
its an Attachment object
its pretty useful
attachment = message.attachments[0].url if message.attachments else "No image provided"
yea?
sure
would I need an event or just on message to watch for it in a certain channel
wait no on message is in an event
note that if the user would provide an txt or any attachment it will take its url then
so make sure to check the url's extension too
How do I check that?
its usually png/jpg/jpeg or webp
||message not found||
!d str.endswith
str.endswith(suffix[, start[, end]])```
Return `True` if the string ends with the specified *suffix*, otherwise return `False`. *suffix* can also be a tuple of suffixes to look for. With optional *start*, test beginning at that position. With optional *end*, stop comparing at that position.
||gif||
that too 😔
lmao
try:
if message.author.bot:
return
for attch in message.attachments:
if (
attch.filename[-4:] in ['.jpg', '.png', '.jpeg']
and str(message.channel.id) == str(cahnnelid)
):
this too no?
just check for https
🗿
@shrewd apex
❓
kinda overkill, not sure if it works
isn't that what u want to check attachment and it's extension
you can always say protocol 😔
Would I need an event or listen?
Rules👀
no not that
Y not 
an*
because https is a internet protocol
um? lmao
Protocol means rules 
not always!
It does here 
æhttps 
no!
wat does protocol mean according to you 
can mean allot of things
Lol I studied bout that in my 12th grade book👀
just add another and to it
Protocol is a process based on some rules

