#discord-bots

1 messages · Page 1085 of 1

slate swan
#

read the docs ^ and iirc the reaction argument does have a channel property/attr that does that

#

Ye ye i see ty

slate swan
#

nvm, I figured it out logically, I’m sick rn lol so that’s why I can’t really make up questions

slate swan
unkempt canyonBOT
#

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.
slate swan
#

the return type is well written

spring flax
#

I mean I just want to know if for this event, does it internally fetch the message

formal basin
#

Guys I’m trying to make a server lockdown command but I got an error can someone explain

slate swan
#

!d discord.Embed.set_footer

unkempt canyonBOT
#

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
#

@slate swan is there anyway to get footer like text that supports markdown?

#

Reaction.message.channel would do

#

@spring flax ^

spring flax
#

i don't get what that's for

slate swan
#

question, How would I check if the person running the command has higher roles than the bot?

slate swan
spring flax
#

Yeah but that's not what I want

slate swan
slate swan
dull terrace
#

is there a way to test if discord would be able to embed something

formal basin
dull terrace
#

right now i can check if it's a link to an image but not much else

odd mango
formal basin
slate swan
slate swan
formal basin
#

I want it to lockdown the whole server

spring flax
#

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

slate swan
dull terrace
#

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

slate swan
#

for one server that is

slate swan
spring flax
#

The bot is in 1 server only but 10 polls at a time

formal basin
slate swan
spring flax
#

With 5 reactions on each. Would this be too hard on the bot?

odd mango
formal basin
slate swan
odd mango
#

make sure you have guild defined

formal basin
odd mango
#

guild.text_channels is used to get all channels in the guild

formal basin
odd mango
#

you do want to change permissions of all channels right?

formal basin
#

I’ll show you

odd mango
#

what do you mean by server lockdown then o.0

formal basin
#

I want the bot to go on the role section then change the roles there

slate swan
#

Check if user executing command has permission to ban members?

odd mango
#

so not the channel permissions, but the role permissions instead?

odd mango
formal basin
odd mango
#

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

slate swan
unkempt canyonBOT
#

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!

odd mango
#

oh wait i messed it up lmao

#

okay cool now

slate swan
#
@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

odd mango
#

that should work...

slate swan
#

should it go above my bot.command or below?

odd mango
#

check permissions lmao, perhaps they have kick members and ban members

odd mango
slate swan
slate swan
odd mango
#

nahh

slate swan
#

since the value of one decorator is passed down to the decorator below it iirc

odd mango
#

check the docs

#

it says below

slate swan
#

weird

#

I tried putting it above and same thing

odd mango
#

@slate swan in server role hierarchy, put bot role above all roles

#

then try again

slate swan
#

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?

odd mango
#

what command is it? kick members?

slate swan
slate swan
slate swan
#

@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?

odd mango
# slate swan <@730271192778539078> can I see an example code of it working?
@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.")```
slate swan
#
@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

odd mango
slate swan
odd mango
#

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:")```
odd mango
#

why did you ask for it then

tiny ibex
#

hey uhm can I ask a discord related question? (Not py related)

odd mango
#

yeah go ahed

slate swan
tiny ibex
odd mango
slate swan
tiny ibex
tiny ibex
slate swan
tiny ibex
slate swan
tiny ibex
odd mango
#
@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?
tiny ibex
#

You both just told different ones...

slate swan
slate swan
slate swan
tiny ibex
slate swan
slate swan
odd mango
#

got it tyyy

tiny ibex
slate swan
tiny ibex
slate swan
#

@slate swan It didn't work..

tiny ibex
#

I don't think that's malicious

slate swan
#

well

#

there"s probably an issue within discord then, do all the roles not have the req perm?

odd mango
#

no issue with discord, my bot commands which require permissions work just fine

slate swan
#

No roles in the server have ban permissions @slate swan

#

and the user running the command has no roles at all

odd mango
#

is it the owner of the server?

slate swan
odd mango
#

weird

slate swan
odd mango
#

await ctx.send(f"testset as: {artist}")

slate swan
#

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

odd mango
#

oop

slate swan
#

Could it be something how im using a global var?

simple kettle
#

Can discord bots use custom emojis from other servers?

odd mango
#

yeah its because of the global var

slate swan
#

only if they're in the same server as the emoji

slate swan
#

no

odd mango
slate swan
simple kettle
#

Ooh ok thanks

#

Wait what

odd mango
slate swan
#

they can use from any server

#

they are in

odd mango
#

thats what i told...

simple kettle
#

Do I just need the ID of the emoji?

odd mango
#

yeah

slate swan
#

Savvy do you know how I fix my code?

slate swan
odd mango
#

\![ducky_angel](https://cdn.discordapp.com/emojis/640121935610511361.webp?size=128 "ducky_angel")

simple kettle
#

Thanks

odd mango
slate swan
slate swan
odd mango
#

yeah

slate swan
#

vars*

slate swan
odd mango
#

its cause of the global var, cause if missing permission error is triggered, then permissions are working fine

unkempt canyonBOT
#

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!

odd mango
#

^^

slate swan
#

What

#

wish you could have told that earlier, I'll have a stroke now ig

#

Huh

odd mango
#

ash, can i borrow you for a minute? if you're free

slate swan
maiden fable
#

Nice

odd mango
#

...

maiden fable
#

(I am not here)

odd mango
#

mind out of the gutter

slate swan
#

sure, what is it

odd mango
#

come at asher's server?

slate swan
#

sure

slate swan
maiden fable
#

Those are like globals tho

slate swan
#

@maiden fable How do I use them, like can I see an example command of setting a new text for the bot.test

maiden fable
#

That is what the embed example shows

slate swan
#

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

maiden fable
#

artist isn't defined.....?

slate swan
#

it is though wtf

maiden fable
#

I don't see a var with that name

slate swan
#

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

maiden fable
#

?

slate swan
#

like i did !test name
and it sent as

testset as: name
testset as: name

maiden fable
#

what the

slate swan
#

I know

#

did I do something wring

maiden fable
#

@slate swan can u help him here pls? I am sleepy 😔

slate swan
#

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

unkempt canyonBOT
#

@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").
slate swan
#

mhm ig it is a thing

#

just guild base

#

it should work but it doesn't

slate swan
#

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 😅

odd mango
#

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

odd mango
#

you mean False

slate swan
odd mango
#

would it do 3x10 though

slate swan
#

try it

#

@slate swan where do u check the src? I can probably send u it

odd mango
#

i just know it wont, it will just add fields like that, until the list finishes, wont go to next page

slate swan
#

i would check it im just on mobile and it kinda looks bad and unreadable

slate swan
#

if ctx.author.guild_permissions.ban_members: ?

slate swan
slate swan
#

@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
fading marlin
#

!d discord.ui.View this is what you pass in to view

unkempt canyonBOT
#

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
#

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

odd mango
fading marlin
#

is the list arbitrary? or do you always have the same amount of values in it?

odd mango
#

as the key changes, the list changes too, so does the amount of values in it

slate swan
#

How can i remove this spoiler

#

When bot aend invite

fading marlin
fading marlin
# odd mango arbitrary, its the value to a key

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

fading marlin
#

idk, I don't have any

#

it's not that hard to code either

slate swan
#

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?

potent spear
potent spear
slate swan
#

And I'm asking if Python is good for discord, not claiming it is

potent spear
potent spear
slate swan
frozen patio
#

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

slate swan
#

Hello, just wondering how i can go about downloading a file sent by the user and read it on my computer

potent spear
slate swan
#

yes

potent spear
slate swan
#

yes

potent spear
potent spear
# slate swan yes

when do you want the bot to read the file?
when it's sent in a specific channel? or..

frozen patio
potent spear
slate swan
#

on command if possible so like !test [attachment] and my bot downloads it and reads it if possible

frozen patio
#

Which one would I ask in?

slate swan
#

!d discord.File

unkempt canyonBOT
#

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.
slate swan
#

I've tried to understand the documents lol but can't get my head around it. I don't suppose you have an example?

potent spear
unkempt canyonBOT
#

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!

dull terrace
#

have a pretty basic question, how do you catch a specific error? never needed to do it before

slate swan
#

async def shit lmao

dull terrace
#

specifically this one: urllib.error.HTTPError: HTTP Error 403: Forbidden

dusk tundra
#
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)
dusk tundra
#

why is my bot not telling me F off?

#

its saying hello?

potent spear
potent spear
dusk tundra
slate swan
potent spear
dull terrace
slate swan
potent spear
dull terrace
slate swan
#

@potent spear I have another question, How do I actually read and save the contents of the file to a variable or something?

slate swan
dusk tundra
#

if I program a bot to say hi then change it to fuck off do I have to make a whole knew bot

potent spear
dusk tundra
odd mango
potent spear
dusk tundra
#

fixed it

slate swan
dull terrace
#

403 specifically?

potent spear
dull terrace
#

urllib.error.HTTPError: HTTP Error 403: Forbidden

rocky trench
#

Hi btw sniper, long time ago

rocky trench
slate swan
#

@potent spear what am I doing wrong?

rocky trench
potent spear
slate swan
#

ahh thanks

potent spear
#

also, a file is a kwarg in send

#

file=...

rocky trench
#

^^

potent spear
#

the file doesn't even have to be read first...

#

lastly, if you were to read it, that's async

rocky trench
#

And u gave 2 positional arguments, use file.read() or read(file) (not sure about the last one)

dull terrace
#

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?

potent spear
rocky trench
potent spear
rocky trench
#

Ah, I didn't get former. English giving me a hard time sometimes in coding terms

potent spear
#

the former = het eerstgenoemde
the latter = het laatstgenoemde

rocky trench
potent spear
#

yup

rocky trench
#

Completely forgot😅 I've advanced since we spoke last time.

potent spear
#

💪

dusk tundra
#

can someone help me code a discord bot

slate swan
potent spear
slate swan
#

yes that doesnt matter '.txt' if possible

potent spear
slate swan
#

ahhh

dull terrace
#
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`
slate swan
#

thank you

potent spear
#

the file will obviously be overwritten once it saves again

dull terrace
#

oh okay, that worked thanks

potent spear
#

you should also catch specific errors, not just Exception

slate swan
fading marlin
#

file = file waitwhat

potent spear
#

^^

#

have you read the docs and checked the methods of discord.Attachment as suggested?
what you're doing can be done in 3 lines

polar scroll
#

i cannot undestand why cant i import it even tho i did "pip install discord"

uneven plank
#

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

potent spear
polar scroll
potent spear
#

then type in the terminal python

#

and check which version of python that's on

#

than make sure they're similar

potent spear
slate swan
#

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

potent spear
#

you know basic OOP, right?

slate swan
#

yes

potent spear
#

then you should know what methods are, right?

slate swan
#

yes

potent spear
#

so let's say you have a discord.Attachment object

#

this has different methods, right?

#

!d discord.Attachment

unkempt canyonBOT
#

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.
potent spear
#

check them out ^

uneven plank
#

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

polar scroll
#

cant u just help me out? my vs code is brand new

#

nvm i found it

slate swan
#

ctrl + shift + P

digital mason
#

I need help pls

potent spear
#

we aren't therapists, sorry

digital mason
#

I'm trying to display user avatar in current guild not default guild, I looked everywhere in documentation but could not find anything

potent spear
#

what have you tried?

digital mason
#

display_avatar

#

And anothet property I forgot

dusk tundra
#

how can I create a discord bot that will parse this on command

digital mason
#

Parse what

potent spear
#

don't crosspost in different help servers...

potent spear
dusk tundra
potent spear
polar scroll
stiff fern
#

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

dusk tundra
rocky trench
digital mason
rocky trench
#

pip install aiohttp==3.8.0

potent spear
unkempt canyonBOT
#

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.

rocky trench
#

If you're on mobile:

flat solstice
#

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

potent spear
stiff fern
#

Oh you mean 2 instances of the bot

potent spear
stiff fern
#

Oh that actually might be why lol

potent spear
potent spear
#

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?

dusk tundra
dusk tundra
digital mason
#
def image_from_url(url):
    return Image.open(get(url, stream=True).raw)
.... 
image = image_from_url(user.display_avatar)
.... 
#

@potent spear

potent spear
dusk tundra
potent spear
flat solstice
dusk tundra
digital mason
#

2.0

potent spear
dusk tundra
#

the bot would work by discord user making commands like !ARKK 1d

digital mason
dusk tundra
#

then the bot would send that screenshot or a link

#

whichever is easier to code

digital mason
#

As most members have nitro

potent spear
digital mason
#

Not a file as an image

potent spear
#

same thing, why?

digital mason
#

That's just a part of the code

#

The image is placed on a frame with pil

potent spear
#

image = await member.display_avatar.read()

#

that's basically the bytes image...

digital mason
#

But it always returns the default avatar

potent spear
dusk tundra
digital mason
#

Is there a way to retrieve the avatar a user has set in the current guild

potent spear
potent spear
dusk tundra
#

@potent spear do you think it would be easier to link Tradingview or excel to discord because I can also code in excel

slate swan
unkempt canyonBOT
#

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.
slate swan
#

and use .read() method

potent spear
#

aight, so it's not display_avatar apparently

dusk tundra
digital mason
dusk tundra
#

either way is fine Im just looking to do what is easier

potent spear
#

no idea, this isn't very discord bot related lol vinny

digital mason
#

😅

#

Ok, it's not hard brb

#

Time to test some stuff

slate swan
unkempt canyonBOT
#

discord/member.py line 592

return self.guild_avatar or self._user.avatar or self._user.default_avatar```
dusk tundra
potent spear
#

clean line

dusk tundra
#

would it be possible to create a discord bot that on command can grab this chart and post it in discord?

potent spear
#

you're asking too many questions in 1

slate swan
potent spear
dusk tundra
slate swan
digital mason
#

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

radiant junco
#

how would i get a user object just from someone's tag? ie: my user object from walker#1693

potent spear
#

typehint

slate swan
#

!d discord.ext.commands.UserConverter.convert

unkempt canyonBOT
#

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.
potent spear
#

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

slate swan
#

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

potent spear
#

^^

stiff fern
#

Ideas on why "Should print" doesn't print?

slate swan
#

any error?

stiff fern
#

Not in output or console or anything

#

Unless Im missing it somewhere, still a noob

#

No errors in any of these tabs lol

slate swan
#

do you have an on_command_error event?

stiff fern
#

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?

slate swan
#

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

stiff fern
#

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

slate swan
stiff fern
#

If thats hard to see lmk

digital mason
#

I got error

#

User object has no attribute guild_avatar

slate swan
# stiff fern

cogs.general was never loaded, and you tried to unload it

slate swan
#

they are different

digital mason
#

How can i get member from user

stiff fern
slate swan
#

may i see your code, it can be much easier to get a Member directly instead of converting a User to Member @digital mason

digital mason
#

Code is too long

slate swan
digital mason
#

I have user as object

#

And ctx too

slate swan
#

change the discord.User to discord.Member are you're good to go

digital mason
#

I wish it was that easy

slate swan
#

it is :D

digital mason
#

But im using a regex to match user

slate swan
#

!d discord.Guild.get_member well then use this

unkempt canyonBOT
#

get_member(user_id, /)```
Returns a member with the given ID.

Changed in version 2.0: `user_id` parameter is now positional-only.
stiff fern
# slate swan gg

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

digital mason
#

Ok will try

#

ctx.guild.get_member(id)?

slate swan
stiff fern
#
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))

stiff fern
#

Oh self is discord

slate swan
#

notice that you defined self.client as your client in the init dunder

stiff fern
#

oo

slate swan
#

Can someone give me an code example of using Buttons(send through slash command + embed)?

stiff fern
#

Thank you very much you are saving my life rn 🙏

slate swan
# stiff fern Oh self is discord

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

slate swan
slate swan
#

you can create a view, and add a url style button to it

stiff fern
slate swan
# slate swan Rapptz (discord.py 2.0)
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
slate swan
stiff fern
#

alrighty ty

slate swan
#
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

unkempt canyonBOT
#

@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'?
slate swan
#

basically, you used a variable before actually it having a value

frozen patio
#

Oh

digital mason
#

@slate swan ctx.guild.get_member(user.id) returned None

frozen patio
#

Well how can I fix this to get the server roles

slate swan
#

And do you have member intents

slate swan
digital mason
#

Member intents ?

frozen patio
digital mason
#

I guess yes

fading marlin
slate swan
#

where can I hire people for coding for me? send link in dms pls

fading marlin
slate swan
#

sir that's why i am not doing in this server, i am looking for a server to hire people @fading marlin

stiff fern
#
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

fading marlin
#

status=status?

stiff fern
#

Oh I need to change that variable name too

stiff fern
#

still doesn't fix the error tho

fading marlin
#

status requires discord.Status, not string though

slate swan
#

how can I Check if user running command as administrator permissions?

fading marlin
#

!d discord.ext.commands.has_role

stiff fern
#

Well I'm trying to do the equivalent of

discord.Status.idle w/ stat being equal to idle

#

Unless its just not possible

fading marlin
#

wrong one

stiff fern
#

Because maybe idle is a attribute ?

fading marlin
#

ugh

slate swan
#

I know of that alraedy, just is there a administrator=True ?

sick birch
desert badger
#
  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
stiff fern
desert badger
desert badger
slate swan
fading marlin
slate swan
#

How do I create roles and set there permissions?

digital mason
#

@slate swan I could only find server members intent and message content intent and presence intent

#

In developer portal

fading marlin
#

!d discord.Guild.create_role

unkempt canyonBOT
#

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...
fading marlin
#

@slate swan ^

slate swan
#

what are all the permissions you can add

fading marlin
rocky trench
rocky trench
#

Is it in the same folder?

desert badger
rocky trench
#

Use that instead. It isn't in the same folder if it doesn't find it

stiff fern
#

like a check

fading marlin
#

nope, just typehint

desert badger
rocky trench
desert badger
rocky trench
#

Ok, are you in the right directory when running ur bot?

desert badger
digital mason
#

Can anyone tell why ctx.guid.get_member(user.id) returns None when intents are already enabled and user is not None

rocky trench
desert badger
rocky trench
#

if u use token.txt, it will look in the folder where u ran it.

#

Cd to the right directory and run it after

fading marlin
sick birch
desert badger
stiff fern
#

Oh so I keep stat:, I was close alright

sick birch
#

I'm using the elipsis here because I can't think of the other statuses off the top of my head

rocky trench
#

cd "NcZ Discord Bots/Banana Bot" in ur retinal

#

Send me the path of the txt file first, gonna help me a lot

digital mason
stiff fern
#
    @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

desert badger
rocky trench
desert badger
rocky trench
fading marlin
desert badger
rocky trench
#

Anyways, it's time for me to go to bed, almost 3 am

#

My friend @slate swan might be able to help you further🙂

slate swan
#

pWut im just lurking

fading marlin
slate swan
#

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.🤣

#

🛌

slate swan
fading marlin
unkempt canyonBOT
#

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...
digital mason
slate swan
#

its a good thing to know

stiff fern
#

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
fading marlin
#

discord.Status.do_not_disturb "Offline" you forgot a comma here

stiff fern
#

Well that wouldn't work would it?

slate swan
#

does editing category permissions cause all channels in that category to have the same perms?

sick birch
stiff fern
fading marlin
stiff fern
#

So if the status is online, I can reference both discord.Status.online and "Working" separately

stiff fern
sick birch
#

Then in that case you could use a tuple

stiff fern
#

so would I need a different list for that then

slate swan
#

How do I resolve this?
TypeError: GuildChannel.set_permissions() missing 1 required positional argument: 'target'

fading marlin
sick birch
#
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
stiff fern
#

Oh you should just put () around it, that makes sense

#

Appreciate you guys 🙏

#

Cause I was just gonna make another list lol

fading marlin
#

._.

stiff fern
#

lol

fading marlin
slate swan
fading marlin
#

?

slate swan
#

Oh I see it

#

it has to be member or a role

fading marlin
slate swan
#

How do I make it the @ everyone role?

fading marlin
#

you want TextChannel.edit for that

slate swan
#

Howd I do it then?

fading marlin
slate swan
silver agate
#
@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

fading marlin
slate swan
fading marlin
silver agate
#

it is 😉

fading marlin
silver agate
slate swan
fading marlin
slate swan
digital mason
#

Finally worked thanks everyone

slate swan
#

only forks have such an implementation

#

How do I edit the permissions for a certain channel?

fading marlin
#

I think you've asked this like 3 times already

slate swan
stiff fern
#

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

fading marlin
slate swan
#

!intents exactly the piece of code you need

unkempt canyonBOT
#

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.

stiff fern
#
async def botstatus(self, ctx, stat: typing.Literal['online', 'idle', 'dnd'] = 'online'):
slate swan
#

add_attachments=True ?

slate swan
stiff fern
fading marlin
unkempt canyonBOT
#

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").
stiff fern
fading marlin
slate swan
slate swan
#

what you wanna do?

slate swan
unkempt canyonBOT
#

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
```...
slate swan
#

😅

stiff fern
#

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

fading marlin
slate swan
slate swan
fading marlin
#

there's no perm for just images

slate swan
#

maybe its the converter

slate swan
stiff fern
#

idk tho

#

ill do that

slate swan
slate swan
stiff fern
#

I haven't learned slash commands yet, should I just figure that out now so Im not going back on myself later

fading marlin
#

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
slate swan
#

remember that the internal converter can only convert certain types!

slate swan
fading marlin
#

well too bad

slate swan
#

kek

#

all of these are possible

fading marlin
#

try/except then cause getting anything else would error out verycool

slate swan
#

it would be a waste-ful api call

fading marlin
#

ig lol

stiff fern
#

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

slate swan
#

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

fading kestrel
#

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.

foggy latch
#

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)
fading kestrel
#

The actual token right?

#

when you ran it

foggy latch
#

yes

fading kestrel
#

what is the error

foggy latch
#

there's no error

#

the command simply won't work

fading kestrel
#

hmm

#

oh wait

#

try editing your @bot.command line to @bot.command(pass_context = True)

foggy latch
#

alright

fading kestrel
#

you haven't passed in the bot's context so its probably why it did not work

foggy latch
#

hmm still no luck

fading kestrel
#

umm

#

are you sure you are running it correctly? do you have discord.py installed?

foggy latch
#

yeah i do

fading kestrel
#

oh wait

#

I know lmao

#

edit your @client.event to @client.event()

#

you forgot to define the method

#

@foggy latch

foggy latch
#

ooh

fading kestrel
#

ok then remove that lol

#

get rid of the method

foggy latch
#

ye i did

fading kestrel
#

thats really weird

#

is it printing online atleast?

foggy latch
#

yeah that's working fine

fading kestrel
#

hmm

foggy latch
#

it's just the .ping command that won't return anything

heavy shard
#

what about intents?

#

is that entire code?

fading kestrel
#

oh yea

foggy latch
#

i just tried adding that rn

#

it didn't seem to do anything, let me get an updated version of the code

fading kestrel
#

intents=discord.Intents.default()

fading marlin
foggy latch
#
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)
fading kestrel
#

hmm

fading marlin
heavy shard
#

default intents don't include message_content, which you need

fading kestrel
#

not really sure why it does not work

heavy shard
#
>>> 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

foggy latch
#

dpy version is 1.7.3 i believe

foggy latch
fading marlin
#

could you check?

heavy shard
#

oh i see

foggy latch
heavy shard
#

sorry i assumed 2.0

fading kestrel
foggy latch
#

yeah its 1.7.3

#

yooo it worked!

#

tysm :D

heavy shard
#

hooray \o/

slate swan
#

How can I enable this for a new role I create

heavy shard
#

hoist

slate swan
heavy shard
#

i guess role.edit(hoist=True)

fading kestrel
slate swan
#

yes same thing

fading kestrel
#

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"

unkempt canyonBOT
#

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**...
fading kestrel
#

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

fading marlin
#

!d discord.ext.tasks.loop try this maybe

unkempt canyonBOT
#

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").
fading kestrel
#

so thats something i have been having trouble with

fading kestrel
#

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```
fading marlin
#

iirc it's something like this ```py
from discord.ext import tasks

@tasks.loop(...)
async def my_task(...):

move basketball

my_task.start(...)

fading kestrel
#

but it doesn't really work

fading marlin
#

start the tasks before you call wait_for

fading kestrel
#

so when you say

#

"tasks," you are referring to the movement of the balls right?

#

in this particular scenario ofc

fading marlin
#

no, I'm referring to the function that has a tasks.loop deco

fading kestrel
#

oh ok

#

like do the .start method before I call the wait for

fading marlin
#

yes

fading kestrel
#

so in the async function for the task loop should I just paste

#

the code for the moving balls?

fading marlin
#

yes

#

also, don't use time.sleep as it's blocking, use asyncio.sleep

fading kestrel
fading kestrel
#

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

fading marlin
#

you can if you need to

fading kestrel
#

i mean its mainly .sleeps

radiant junco
fading kestrel
#

so it shouldnt matter i would figure

heavy shard
#

the Member converter is clever 🙂

radiant junco
heavy shard
#

so if you have argument user: discord.Memeber just use user.id

#

or even user.mention

radiant junco
#

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

heavy shard
#

ah okay

slate swan
unkempt canyonBOT
#

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.
slate swan
#

and you can get the ctx by simply fetching any message from that server

radiant junco
#

because then i would need a bot

slate swan
#

@radiant junco what are you trying to do?

slate swan
slate swan
#

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?

slate swan
slate swan
slate swan
slate swan
#

But do you know any server?

slate swan
#

there are definitely tons of websites.

slate swan
slate swan
#

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

unkempt canyonBOT
#

The attachment URL. If the message this attachment was attached to is deleted, then this will 404.

slate swan
#

only message

slate swan
#

so I can save the message.content as a string

#

yes indeed

#

and for the image url?

shrewd apex
slate swan
slate swan
#

and the underscore vars😔

#

phone 😔

#
attachment = message.attachmentd[0] if message.attachments else "No"
```? ![Kannakillyourself](https://cdn.discordapp.com/emojis/975719421291167764.webp?size=128 "Kannakillyourself")
slate swan
#

Edited

#

a new keyword😳

#

im on phone too

#

kek

slate swan
slate swan
slate swan
#

what

slate swan
slate swan
slate swan
slate swan
#

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

slate swan
#

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 pBear so make sure to check the url's extension too

slate swan
#

its usually png/jpg/jpeg or webp

keen talon
slate swan
unkempt canyonBOT
#

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.
shrewd apex
slate swan
shrewd apex
#

lmao

slate swan
#
  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?

shrewd apex
slate swan
#

🗿

shrewd apex
#

oh ok

#

check for https then split at . and get last element

slate swan
#

an attachment will always have an https though

#

*a https

slate swan
#

kinda overkill, not sure if it works

shrewd apex
#

isn't that what u want to check attachment and it's extensionpithink

slate swan
#

Would I need an event or listen?

keen talon
slate swan
keen talon
slate swan
slate swan
slate swan
keen talon
slate swan
keen talon
slate swan
slate swan
slate swan
keen talon
slate swan
slate swan
slate swan
keen talon
#

Protocol is a process based on some rules