#discord-bots

1 messages ยท Page 811 of 1

slate swan
#

You need to mention someone while running the command...

regal pulsar
slate swan
#

The first argument in commands is context, not message

frail mesa
#

ok, the code is not doing at all what i thought it was then. i thought with the member: Discord.member and using member.remove_roles, it would go through all members

regal pulsar
#

what does that mean

frail mesa
#

is there a way to do that? i want to go through every member in the disc, not just a specific one

regal pulsar
slate swan
#

!d discord.Guild.members

unkempt canyonBOT
#

property members: List[discord.member.Member]```
A list of members that belong to this guild.
slate swan
regal pulsar
#

i see

#

wait

frail mesa
#

ok so dont think im using this right cuz still getting the same error

#

is async def cleanup(ctx, members: discord.Guild.members)correct?

regal pulsar
#
@bot.command()
async def spam(message, text_to_spam, amount_to_spam : int):
    text_to_spam = message.content.split(' ')
    amount_to_spam = message.content.split()[2]
    amount_spammed = 0
    while amount_spammed > amount_to_spam:
        await message.channel.send(text_to_spam)
vale wing
#
async def cleanup(ctx, *members: discord.Member) #args list```
```py
async def cleanup (ctx, members: commands.Greedy[discord.Member])```
#

Notice that both of these don't work in slash commands as discord API doesn't support args list

frail mesa
#

Gotcha

vale wing
#

And args list can only be the last argument (in terms of discord commands), while Greedy can be in the middle

frail mesa
#

while waiting on an answer, also found this on google

for member in guild.members:
    id = member.id

    # Do stuff here
#

would this be better for what im trying to do?

#

or Greedy?

vale wing
#

It gets all the members

#

If you want to provide certain members to a command, then use one of those 2 ways

frail mesa
#

i want it to get all members in the server

vale wing
#

!d discord.Guild.members

unkempt canyonBOT
#

property members: List[discord.member.Member]```
A list of members that belong to this guild.
frail mesa
#

ok gotcha, tyvm

#

so for the arguments line what would i put?

#

seems like (ctx, members: discord.Guild.members) is not correct

torn sail
#

You would have no arguements if ur gonna go through all server members

gleaming barn
#

anyone Know how I would fix this? I think something is wrong with my imports or something like that But I have it correctly installed

#

my friend tested it the same way and got an output

#

when commented out it throws this error

frail mesa
#
@bot.command()
async def cleanup(ctx):
guild = client.get_guild(xxxxxxxxxxxxxx)
  for member in guild.members:
    big_airut_speedrun_1_id = 826189814596108378
    big_airut_speedrun_2_id = 762488902304006174
    big_airut_speedrun_3_id = 757836549361762424
    big_airut_speedrun_1 = ctx.guild.get_roles(big_airut_speedrun_1_id)
    big_airut_speedrun_2 = ctx.guild.get_roles(big_airut_speedrun_2_id)
    big_airut_speedrun_3 = ctx.guild.get_roles(big_airut_speedrun_3_id)
    if member.has_roles(big_airut_speedrun_1):
     await member.remove_roles(big_airut_speedrun_2, big_airut_speedrun_3)
    elif member.has_roles(big_airut_speedrun_2):
      await member.remove_roles(big_airut_speedrun_3)
    else:
      await ctx.channel.send('None found.')

Okay, so I have this now. Is there something wrong with line 3? Cuz line 4 is invoking error "undefined name guild"

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

vale wing
#

Also how did you install it and what did you receive

frail mesa
# vale wing It is not indented
@bot.command()
async def cleanup(ctx):
  guild = client.get_guild(xxxxxxxxxxxxx)
  for member in guild.members:
    big_airut_speedrun_1_id = 826189814596108378
    big_airut_speedrun_2_id = 762488902304006174
    big_airut_speedrun_3_id = 757836549361762424
    big_airut_speedrun_1 = ctx.guild.get_roles(big_airut_speedrun_1_id)
    big_airut_speedrun_2 = ctx.guild.get_roles(big_airut_speedrun_2_id)
    big_airut_speedrun_3 = ctx.guild.get_roles(big_airut_speedrun_3_id)
  if member.has_roles(big_airut_speedrun_1):
    await member.remove_roles(big_airut_speedrun_2, big_airut_speedrun_3)
  elif member.has_roles(big_airut_speedrun_2):
    await member.remove_roles(big_airut_speedrun_3)
  else:
    await ctx.channel.send('None found.')
gleaming barn
frail mesa
#

so like this? still getting same error

gleaming barn
#

all where installed successfully

#

it's displays the same thing if I ran pip freeze on vsc as well

#

I've been at it for hours trying to fix this error

quaint scaffold
#

Are you using a venv?

slate swan
frail mesa
#

ok got all other issues squared away. only thing now is i cant find any objects with a method has_role

#

is there any alternative to this? to check if members in a guild have a specific role?

slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
gleaming barn
#

nope still didn't fix the issue

#

and pip install -U python-dotenv

#

so it should most definitely be working

frail mesa
#

Anyone that can point me in the right direction here? This is the code I got so far, but has_role is not an attribute, so ik i gotta change that. Anything I can find online is for checking one specific, inputted user. Can't find anything to check if all users in a given guild have a specific role

@bot.command()
@commands.has_role('Server Owners')
async def cleanup(ctx):
  guild = bot.get_guild(757463397683036200)
  for member in guild.members:
      big_airut_speedrun_1_id = 826189814596108378
      big_airut_speedrun_2_id = 762488902304006174
      big_airut_speedrun_3_id = 757836549361762424
      big_airut_speedrun_1 = ctx.guild.get_role(big_airut_speedrun_1_id)
      big_airut_speedrun_2 = ctx.guild.get_role(big_airut_speedrun_2_id)
      big_airut_speedrun_3 = ctx.guild.get_role(big_airut_speedrun_3_id)
      if member.has_role(big_airut_speedrun_1):
        await member.remove_role(big_airut_speedrun_2, big_airut_speedrun_3)
      elif member.has_role(big_airut_speedrun_2):
        await member.remove_role(big_airut_speedrun_3)
      else:
        await ctx.channel.send('None found.')
regal pulsar
#
@bot.event
async def on_message(message):
    if client.user in message.content:
        await message.channel.send(f"Meow {message.author} Onii chan! You can type `$help` for more info.")
#

how do i check if the message mentions the bot

rocky trench
#

U would need the bot id

#

<@botid> would be in message content

sudden mango
#

Am I able to put multiple different code for bots from a site like GitHub into one bot and it still work given nothing interfere

rocky trench
#

Don't take code from GitHub.

sudden mango
#

Where would I get code for bots

rocky trench
#

U make it

sudden mango
#

I'm completely new sorry I've messed mainly with lua and kinda been stuck on how to do this

rocky trench
#

Then u learn the basics and the syntaxes etc

sudden mango
#

Where would you recommend I head for a beginner

#

If that's allowed to recommend places here

neat tartan
prime crystal
neat tartan
prime crystal
#

are they not comparable?

neat tartan
#

Lol thats fairly common

neat tartan
#

Im assuming you are cogging the commands using dpy?

tacit storm
prime crystal
#

not really

neat tartan
#

What do your current files look like?

tacit storm
prime crystal
#

if u complete that tutorial, you can easily use any of the discord.py forks

tacit storm
#

Ah

neat tartan
tacit storm
#

ive never learned from anything like that

#

ive really just looked at the docs ๐Ÿ’€

prime crystal
#

i guess pycord has most stars on github for whatever reason

neat tartan
#

I meant the contents of the files. Mainly the parts related to importing and cogging

tacit storm
#

hold on what?

why are you import the main file

#

why are you importing all the cogs?

#

Ah

neat tartan
#

Im lost, this is my bot.py (main.py) folder
bot.load_extension("coggedfilename")
Is all it needs in it to pick up the cog files. Ill grab the cogged files requirements and post them next

#

Sorry for weird cropping its screenshots from my mobile github

#

These go at the beginning and ends of the cogged files.

#

You can ignore the imports portion

#

Im not actually sure

regal pulsar
#
@bot.command()
async def help(message):
    await message.channel.send(f"""
The prefix for the bot is $,
The currently available commands are:
1.) $whoareyou
2.) $whydidyoucry
3.) $doyouhavefriends
""")
#

i have this command here

#

but if i add this

#
@bot.event
async def on_message(message):
    if str(940439223247466516) in message.content:
        await message.channel.send("Meow {} Onii chan! You can type `$help` for more info.".format(message.author.mention))
neat tartan
#

Wdym? Same as what?

dry kelp
#

how can i get the bot to edit the role position -1 from the bot top role

frail mesa
#

Ok so I've worked on my code a bit, have got it to the point where I can run the bot without any errors, and run the command without any errors. But it is not working correctly, I gave myself big_airut_speedrun 1 2 and 3 and ran command, and it still printed "None found". Any ideas?

@bot.command()
@commands.has_role('Server Owners')
async def cleanup(ctx):
  guild = bot.get_guild(757463397683036200)
  for member in guild.members:
    big_airut_speedrun_1_id = 826189814596108378
    big_airut_speedrun_2_id = 762488902304006174
    big_airut_speedrun_3_id = 757836549361762424
    big_airut_speedrun_1 = ctx.guild.get_role(big_airut_speedrun_1_id)
    big_airut_speedrun_2 = ctx.guild.get_role(big_airut_speedrun_2_id)
    big_airut_speedrun_3 = ctx.guild.get_role(big_airut_speedrun_3_id)
    roles = member.roles
    if (big_airut_speedrun_1 in roles):
      await member.remove_role(big_airut_speedrun_2, big_airut_speedrun_3)
    elif (big_airut_speedrun_2 in roles):
      await member.remove_role(big_airut_speedrun_3)
    else:
      await ctx.channel.send('None found.')
neat tartan
#

Weird, and no problem. I think im gonna swap to disnake and slash commands fairly soon but ya this is a nice temporary restructure solution

green bluff
#

pycord

neat tartan
#

Uhhh

#

Im pretty sure it automatically pulls and uses it

#

Then idfk

green bluff
#

any of u guys now pycord slash commands

#

know

neat tartan
#

Oh, no i dont

green bluff
#

i think

#

wait can u try solve this

#

or is it

neat tartan
green bluff
#

too unfamiliar

quick gust
#

fixed

#

i dont even know which line is causing this, it doesn't show in the tb

neat tartan
neat tartan
# quick gust fixed

Put a break in the debugger near the beginning of the command, call it and step through line by line until it errors out

quick gust
#

the thing is, it doesn't even load the cog. it errors while loading it

#

ignore

green veldt
#

how do i put case_insensitive in python bot clients = statement?

neat tartan
quick gust
#

I fixed it! Thanks

neat tartan
#

Ah alright

final iron
neat tartan
# green bluff

The bot doesnt have access. (assuming the ability to ban users)

green veldt
green bluff
#

the user must have permssion to ban members

neat tartan
#

Could be wrong

neat tartan
neat tartan
green veldt
#

where do i put this?

#
    await message.channel.send("*`Jass Is A Thirteen Year Old Coder. To know more about him, visit his discord server!`*")
#

this is one of my commands

#

client = discord.Client()

#

this is my client statement

regal pulsar
#
@bot.event
async def on_ready():
    print('We have logged in as {0.user}'.format(bot))
    await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Furry Pron 3D"))
#

when i add this block to change bot activity all other commands stop working

#

how do i fix that

#

i started learning discord.py today so not great at it yet

green bluff
#

removed that line and still dont work

neat tartan
frail mesa
neat tartan
#

Ctx.guild.member.roles?

frail mesa
#

same error. guild does not have member attribute

neat tartan
#

Fuuu, k hold on

maiden fable
frail mesa
#

sorry misunderstood

#

yes, get that error for guild.member and for ctx.guild.member

#

oh youre saying members plural lol

changed to roles = guild.members.roles but now am getting error "'list' object has no attribute 'roles'

#

can i just not use a list for this?

maiden fable
#

@frail mesa what do you wanna do?

frail mesa
#

So we have a role called "Big Airut Speedrun" that has 3 tiers, bronze silver and platinum. I want a command that will go through every member in the Discord and look for cases of someone with platinum still having bronze and/or silver tags, and if so, removes them. and then same for if silver has bronze tag

maiden fable
#

Then loop through guild.members since it returns a list of discord.Member objects

#

for member in guild.members:
roles = member.roles

frail mesa
#

yea thats what i have

#

it is not working tho

maiden fable
#

Okay....?

#

What's the issue

frail mesa
#

no clue. it just prints out "None found" but doesnt remove the role

#

have double checked all IDs are correct

maiden fable
#

Code

frail mesa
maiden fable
#

Ah

#

member.remove_roles

#

Not remove_role

#

Weird it doesn't show an error. U got an error handler?

frail mesa
#

Not really sure. pretty new to coding

#

i do have a console that gives errors, yea

#

but wasnt giving any errors on that

maiden fable
#

Ah hahaha

neat tartan
maiden fable
#

The problem was, the function name is remove_roles

#

Not remove_role :DDD

frail mesa
#

ok so changed to that, but didnt seem to do the trick

#

still no errors. but just doesnt remove the role

maiden fable
#

Show latest code

neat tartan
frail mesa
neat tartan
#

Try printing out the roles to the console and make sure its actually grabbing the roles based on the ids

neat tartan
frail mesa
#

sorry have posted several times, just gets buried cuz convo

#

this but changed both cases of remove_role to remove_roles

#

but that change doesnt seem to have fixed it

#

I have double checked all IDs. and double checked bot has necessary permissions

frail mesa
#

not getting any errors upon running tho code either

placid skiff
#

i'll check something, What package are you using?

neat tartan
#

It may be the correct id but make sure its grabbing the actual role based on the id

frail mesa
#

idk what that means ๐Ÿ™ˆ

#

sorry very new to coding

placid skiff
frail mesa
#

yes

neat tartan
#

print(big_airut_speedrun_1, big_airut_speedrun_2, big_airut_speedrun_3)
Add this after the channel.send line

placid skiff
#

check if your code runs

#

just print something in the first line of the command

neat tartan
#

It send the message in the server and doesnt error out its just not removing the roles

neat tartan
frail mesa
#

yea just did, seems to work fine

neat tartan
#

It printed the role names?

frail mesa
#

could the issue possibly be because all 3 roles have the same name? theyre just different colors. i figured using the ID would get around that

#

it just prints out Big Airut Speedrun Big Airut Speedrun Big Airut Speedrun

neat tartan
neat tartan
frail mesa
#

big_airut_speedrun_1_id = 826189814596108378
big_airut_speedrun_2_id = 762488902304006174
big_airut_speedrun_3_id = 757836549361762424

#

ye this is what i get when i copy/paste from the console what is printed

#

so its definitely differentiating the roles

placid skiff
#

wait, check better the remove_roles docs

#

!d discord.Member.remove_roles

unkempt canyonBOT
#

await remove_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the removed [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
placid skiff
#

open this link

neat tartan
#

It doesnt reach that portion

#

In the if, elif, else portions check for the role by its id instead

#

Essentially just add "_id" to the end of them so your searching for your preset role ids instead of the obtained names

frail mesa
#

did this. still nothing

neat tartan
#

K

frail mesa
placid skiff
#

he will need to get the id from the list of roles too

neat tartan
#

Next suggestion would be checking for the role in ctx.guild.member.roles instead of roles

frail mesa
#

member is not an attribute of guild

neat tartan
#

Then drop guild and do ctx.member.roles

frail mesa
#

likewise, member is not an attribute of ctx

#

tried this earlier haha

neat tartan
#

:notlikethis:

placid skiff
neat tartan
#

Something is up with the if,elif,else statements

frail mesa
#

I've read the api mate. that is why im here, cuz i couldnt figure it out

#

so if you know, feel free to point it out

placid skiff
#

Parameters
*roles (abc.Snowflake) โ€“ An argument list of abc.Snowflake representing a Role to remove from the member.

reason (Optional[str]) โ€“ The reason for removing these roles. Shows up on the audit log.

atomic (bool) โ€“ Whether to atomically remove roles. This will ensure that multiple operations will always be applied regardless of the current state of the cache

#

read what *roles are

regal pulsar
#
bot = commands.Bot(command_prefix = '$', activity=discord.Activity(type=discord.ActivityType.watching, name="yt))
#

adding this stops any other command from working

#

why is that and how can i fix it

placid skiff
#

then, maybe you will need to use the atomic parameter too

neat tartan
frail mesa
#

yup

placid skiff
#

You just not even listening...

frail mesa
#

I was replying to another person. i am currently doing your changes ;p

#

tho i dont really understand what youre saying to do. i understand youre trying not to spell it out cuz you want me to learn but i also am stupid so pls be patient lol

#

if i understand correctly, youre saying it should be
await member.remove_roles(*big_airut_speedrun_2, big_airut_speedrun_3, atomic = True)
?

slate swan
#

Can anyone recommend me best pythone course roadmap for logics and any software engineer how they learned tell me some best free website to get automatically logic while learning

placid skiff
#

If you open the abc.Snowflake docs you will read this:
So remove_roles method doesn't take a role object, it takes this instead

placid skiff
minor bobcat
#

hey how do u define the person that clicked a button

next iris
minor bobcat
#
pip install discord.py```
#

after u installed pip

#

and python

next iris
#

i installed this python3 -m pip install -U discord.py

#

but it still say pip not found

minor bobcat
neat tartan
minor bobcat
placid skiff
slate swan
#

Can anyone tell me best pythone guide in youtube free

next iris
placid skiff
#

essentially, you are feeding a Role object

neat tartan
#

@frail mesa might be worth opening a help channel for your issue

neat tartan
#

Getting oretty crowded

minor bobcat
frail mesa
#

so i would want the id's in there then instead of what i have?

#

replace big_airut_speedrun_1 with big_airut_speedrun_1_id ?

next iris
#

@neat tartan may I ask how do I install pip ?

placid skiff
minor bobcat
#

ok

brisk zodiac
#

What is the way to learn Python if i have no experience in it?

neat tartan
minor bobcat
#

is good

placid skiff
brisk zodiac
placid skiff
#

i'll send here an example of usage

minor bobcat
tidal hawk
#

Can the bot see how many minutes has a person streamed in a voice channel?

brisk zodiac
frail mesa
brisk zodiac
placid skiff
#

!e

list_1 = [1, 2, 3, 4]
list_2 = [4, 5, 6, 7]

print(True if any(num in list_2 for num in list_1) else False)
unkempt canyonBOT
#

@placid skiff :white_check_mark: Your eval job has completed with return code 0.

True
gusty hatch
#

is it possible for dropdown to edit instead of reply and make it so only you can see it?

frail mesa
#

ok so did all that. so the only other thing is youre saying roles = member.roles is wrong?

next iris
placid skiff
gusty hatch
#

is it possible for dropdown to edit instead of reply and make it so only you can see it?

neat tartan
next iris
regal pulsar
#

control shift `

#

now please

frail mesa
#

now im confused. why would i need two lists?

regal pulsar
#

someone explain to me why setting a bot status breaks all my code

#
bot = commands.Bot(command_prefix = '?', activity=discord.Activity(type=discord.ActivityType.watching, name="Furry Pron 3D"))
slate swan
#

I,think many of them learned python I know basics but I am not getting logics so best way to learn best channel can you guide with your experience

gusty hatch
#

is it possible for dropdown to edit instead of reply and make it so only you can see it?

placid skiff
green veldt
#

hey

neat tartan
green veldt
#

does someone know about the tuesday patch?

gusty hatch
green veldt
#

of windows

slate swan
#

Anyone please respond to my before question ๐Ÿฅบ

regal pulsar
next iris
regal pulsar
#

other commands just dont work

gusty hatch
frail mesa
regal pulsar
#

like this then?

gusty hatch
#

Yes?

regal pulsar
#

that doesnt work either

#

i found this

gusty hatch
#

ignore that

regal pulsar
#

so i changed it to be included in Bot =

frail mesa
#

it compares two lists?

placid skiff
#

it checks if any element is equal to another

frail mesa
#

yea. im not sure how that relates to my case

#

im just checking if a user has 1 specific role, and then if true, doing an action

slate swan
gusty hatch
#

is it possible for dropdown to edit instead of reply and make it so only you can see it?

placid skiff
#

!e

value = 1
list_1 = [1, 2, 3, 4, 5]

print(True if any(num == value for num in list_1) else False)
unkempt canyonBOT
#

@placid skiff :white_check_mark: Your eval job has completed with return code 0.

True
placid skiff
#

Understood now?

green veldt
#

where are you from?

neat tartan
visual island
regal pulsar
unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

regal pulsar
#

lol

neat tartan
frail mesa
#

would i have to use something other than 'num' ? or does that work since its using IDs?

nimble plume
#
@bot.event()
async def on_message_delete(message):
 await logschannel.send(f"Message deleted in {message.channel} by {message.author} message : {message}")

@bot.event()
TypeError: event() missing 1 required positional argument: 'coro'

frail mesa
#

i am getting error 'int' object has no attribute 'id' so im guessing i cant use num

placid skiff
next iris
nimble plume
#
@bot.event()
async def on_message_delete(message):
 await logschannel.send(f"Message deleted in {message.channel} by {message.author} message : {message}")

@bot.event()
TypeError: event() missing 1 required positional argument: 'coro'

frail mesa
neat tartan
nimble plume
#

help me

neat tartan
placid skiff
nimble plume
frail mesa
#

gotcha. but its saying role is undefined

#

one sec, thats prob one i can figure out myself lol

placid skiff
#

lol

next iris
neat tartan
frail mesa
#

ok so here is current code now

#
@bot.command()
@commands.has_role('Server Owners')
async def cleanup(ctx):
  guild = bot.get_guild(757463397683036200)
  for member in guild.members:
    big_airut_speedrun_1 = 826189814596108378
    big_airut_speedrun_2 = 762488902304006174
    big_airut_speedrun_3 = 757836549361762424
    role = discord.utils.get(member.guild.roles)
    roles = member.roles
    if any(role.id == big_airut_speedrun_1 for num in roles):
      await member.remove_roles(*big_airut_speedrun_2, big_airut_speedrun_3, atomic = True)
    elif (role.id == big_airut_speedrun_2 for num in roles):
      await member.remove_roles(big_airut_speedrun_3, atomic = True)
    else:
      await ctx.channel.send('None found.')
#

still getting error "'int' object has no attribute 'id'"

gusty hatch
#

how would i put a custom emoji in a dropdown?

placid skiff
placid skiff
#

roles or member are not Role or Member object

#

print them in the console

#

oh wait

nimble plume
#

how to get a channel

frail mesa
#

yea lol just noticed that

#

fixed but still same error, int has no attribute id

neat tartan
unkempt canyonBOT
#

discord.on_message_delete(message)```
Called when a message is deleted. If the message is not found in the internal message cache, then this event will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.

If this occurs increase the [`max_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") parameter or use the [`on_raw_message_delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_message_delete "discord.on_raw_message_delete") event instead.

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
placid skiff
#

then something in your code is not a discord object, print the member and the roles in the console

nimble plume
gusty hatch
#

love how everyone is ignoring me

nimble plume
frail mesa
#

so i think i see the issue

#

roles is only showing the roles the bot has

placid skiff
frail mesa
#

not all the roles in the server

neat tartan
# nimble plume what is discord here

Sorry thats the wrong one. Bot.event is where the issue is. I am unsure in this situation how to resolve it but the doc covers it under client.event

frail mesa
frail mesa
#

but it does. is what im saying

placid skiff
#

you are iterating through all members, remember?

neat tartan
frail mesa
#

gotcha. so thats not the issue then?

placid skiff
#

you are just doing roles = ctx.guild.roles twice

frail mesa
#

ok ill remove

#

now it gives error "name 'role' is not defined"

placid skiff
#

oh now found something interesting. Let's make better this code, so maybe we will understand something more

placid skiff
# frail mesa ``` @bot.command() @commands.has_role('Server Owners') async def cleanup(ctx): ...
@bot.command()
@commands.has_role('Server Owners')
async def cleanup(ctx):
  roles = ctx.guild.roles
  big_airut_speedrun_1 = 826189814596108378
  big_airut_speedrun_2 = 762488902304006174
  big_airut_speedrun_3 = 757836549361762424
  for member in ctx.guild.members:
    if any(role.id == big_airut_speedrun_1 for role in roles):
      await member.remove_roles(*big_airut_speedrun_2, big_airut_speedrun_3, atomic = True)
    elif (role.id == big_airut_speedrun_2 for role in roles):
      await member.remove_roles(big_airut_speedrun_3, atomic = True)
    else:
      await ctx.channel.send('None found.')
frail mesa
#

yup, this is exactly what i have

#

giving error 'role' is not defined

frail mesa
#

and i thought yea that makes sense

#

cuz i want the guilds roles, not one specific members

placid skiff
#

yes but check it better it should be different

#

from your code

pine crown
#

n

placid skiff
#

you have all your variables put in your for cicle

frail mesa
#

only other difference i see is that your variables and list are outside the for statement

#

does that matter?

placid skiff
#

it's a big difference don't you think?
like you are reassign values every time you loop into that for

frail mesa
#

yea thats a good point haha

#

refer to previous statement: i am stupid

#

ok so yea. got it exactly like yours above

#

but still same error. role is not defined

placid skiff
#

gimme a screen

frail mesa
#
@bot.command()
@commands.has_role('Server Owners')
async def cleanup(ctx):
  guild = bot.get_guild(757463397683036200)
  big_airut_speedrun_1 = 826189814596108378
  big_airut_speedrun_2 = 762488902304006174
  big_airut_speedrun_3 = 757836549361762424
  roles = ctx.guild.roles
  for member in guild.members:
    if any(role.id == big_airut_speedrun_1 for role.id in roles):
      await member.remove_roles(*big_airut_speedrun_2, big_airut_speedrun_3, atomic = True)
    elif (role.id == big_airut_speedrun_2 for role.id in roles):
      await member.remove_roles(big_airut_speedrun_3, atomic = True)
    else:
      await ctx.channel.send('None found.')
#

will that work? app i use for ss is acting up

placid skiff
#

nope a screen, of the console and the code
also remove guild = bot.get_guild() just use ctx.guild

tiny ibex
#
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://some-cool-api.herokuapp.com/recognize_music?url=https://cdn.discordapp.com/attachments/936605187584442461/940532458787586098/2022-01-15T16_01_00_542Z_1_1.ogg')
#

why??????

placid skiff
#

role.id doesn't exists yet when you use the for

#

you are checking if the Role ID attribute is equals to a value and you get the ID by iterating through the roles list

#

is the same thing as this:

for a in b:
  if a.id == c:
    #do something

but written better

frail mesa
#

ok so all that is fixed, no more of that error

#

now we are back to 'int' object has no attribute 'id'

placid skiff
#

so if b is a list of object, a is a single object and a.id is the id attribute of the a object in the b list of object

placid skiff
placid skiff
#

if you made changes, error doesn't appear, means something has changed lol

frail mesa
#

well this error was here before, the role one was just overriding it

#

i can take a screenshot. but im just saying, its the exact same

placid skiff
#

yup, but that is what I wrote, i need what you wrote

frail mesa
#

there ya go. my computer is being weird af and making my screenshots bright as fuck

#
@bot.command()
@commands.has_role('Server Owners')
async def cleanup(ctx):
  big_airut_speedrun_1 = 826189814596108378
  big_airut_speedrun_2 = 762488902304006174
  big_airut_speedrun_3 = 757836549361762424
  roles = ctx.guild.roles
  for member in ctx.guild.members:
    if any(role.id == big_airut_speedrun_1 for role in roles):
      await member.remove_roles(big_airut_speedrun_2, big_airut_speedrun_3, atomic = True)
    elif (role.id == big_airut_speedrun_2 for role in roles):
      await member.remove_roles(big_airut_speedrun_3, atomic = True)
    else:
      await ctx.channel.send('None found.')
#

but this should work the same. i assure you i can copy/paste without error

placid skiff
#

elif any()
you have to call any everytime you do that expression

frail mesa
#

ok but tbf you didnt have the any after elif either

#

๐Ÿ˜‰

placid skiff
#

sure? lol

#

well i copied your code so

#

didn't noticed it xD

frail mesa
#

didnt do the trick tho. still same error :c

placid skiff
#

show again

#

is not the statement which is giving the error

frail mesa
#

huh?

#
@bot.command()
@commands.has_role('Server Owners')
async def cleanup(ctx):
  big_airut_speedrun_1 = 826189814596108378
  big_airut_speedrun_2 = 762488902304006174
  big_airut_speedrun_3 = 757836549361762424
  roles = ctx.guild.roles
  for member in ctx.guild.members:
    if any(role.id == big_airut_speedrun_1 for role in roles):
      await member.remove_roles(big_airut_speedrun_2, big_airut_speedrun_3, atomic = True)
    elif any(role.id == big_airut_speedrun_2 for role in roles):
      await member.remove_roles(big_airut_speedrun_3, atomic = True)
    else:
      await ctx.channel.send('None found.')

current code if thats what you mean

placid skiff
#

wait i'll take a coffe and then I'll answer you, maybe we should move to DM cuz we're taking too long lol

slate swan
#

hi how can i assign role to new member but only for one server (mine)

honest vessel
#

await member.remove_roles(big_airut_speedrun_2, big_airut_speedrun_3, atomic = True)

#

roles are just ints, not roleobjects?

frail mesa
#

hmm. so the big_airut_speedrun_1 = blahblah is just making an int?

#

how do i make it a role object, but using the id?

#

i cant use the role name because all 3 roles have the same name

quick gust
unkempt canyonBOT
quick gust
#

give it the ID

surreal sierra
#

Hi, I saw on a youtube video that you can make custom profile buttons. Just like the "Add to server" button that many bots today have but a custom button that could be anything else than just "Add to server" but the video I saw was in JavaScript. So does anyone have an idea how to do it in Discord.py?

quick gust
#

developer portal

slate swan
#

you cant change name of button

frail mesa
quick gust
frail mesa
#

giving me error "get_role() missing 1 required positional argument 'role_id'

#

i have discord.Guild.get_role(numbers)

frail mesa
#

3am so trying to complete this soon haha

surreal sierra
# quick gust

It is kinda the same way as the "Add to server" button?

quick gust
#

this isn't hard to fix but only problem is I'm in my class rn lol

quick gust
frail mesa
#

big_airut_speedrun_1 = discord.Guild.get_role(826189814596108378) any idea whats wrong here?

surreal sierra
quick gust
#

ctx.guild.get_role()

surreal sierra
frail mesa
#

Ok yea, got that fixed

#

progress. no more errors upon using command

#

but still same issue. prints "None found" and doesnt successfully remove role

#

i feel like this should be such an easy command to make but its proving to be such a headache

placid skiff
quick gust
#

it is very easy, and I can see problems in the code but I'm in class right now

frail mesa
#
@bot.command()
@commands.has_role('Server Owners')
async def cleanup(ctx):
  big_airut_speedrun_1 = ctx.guild.get_role(826189814596108378)
  big_airut_speedrun_2 = ctx.guild.get_role(762488902304006174)
  big_airut_speedrun_3 = ctx.guild.get_role(757836549361762424)
  roles = ctx.guild.roles
  for member in ctx.guild.members:
    if any(role.id == big_airut_speedrun_1 for role in roles):
      await member.remove_roles(big_airut_speedrun_2, big_airut_speedrun_3, atomic = True)
    elif any(role.id == big_airut_speedrun_2 for role in roles):
      await member.remove_roles(big_airut_speedrun_3, atomic = True)
    else:
      await ctx.channel.send('None found.')
honest vessel
#

maybe u now need role.id == big_airut_speedrun_1.id

placid skiff
nimble plume
#

console.log(s)

quick gust
nimble plume
quick gust
#

๐Ÿ˜

frail mesa
#

ok interesting

nimble plume
frail mesa
#

so now it is not giving me the "none found", not giving any errors

#

but also still not working

nimble plume
#
class console:
    def log(other):
        print(other)
quick gust
nimble plume
#

๐Ÿ˜Ž

placid skiff
#

paste them correctly

frail mesa
#

yea ive triple checked em

nimble plume
placid skiff
frail mesa
#

checked again to be sure. id's are correct

frail mesa
placid skiff
frail mesa
#
@bot.command()
@commands.has_role('Server Owners')
async def cleanup(ctx):
  big_airut_speedrun_1 = ctx.guild.get_role(826189814596108378)
  big_airut_speedrun_2 = ctx.guild.get_role(762488902304006174)
  big_airut_speedrun_3 = ctx.guild.get_role(757836549361762424)
  roles = ctx.guild.roles
  for member in ctx.guild.members:
    if any(role.id == big_airut_speedrun_1.id for role in roles):
      await member.remove_roles(big_airut_speedrun_2, big_airut_speedrun_3, atomic = True)
      await ctx.channel.send('Member successfully updated.')
    elif any(role.id == big_airut_speedrun_2.id for role in roles):
      await member.remove_roles(big_airut_speedrun_3, atomic = True)
      await ctx.channel.send('Member successfully updated.')
    else:
      await ctx.channel.send('Command complete.')
nimble plume
frail mesa
#

so here's code now. added the "member successfully updated" line

#

when i run the code, it prints that out "member successfully updated"

#

but no roles actually get changed

nimble plume
frail mesa
frail mesa
nimble plume
placid skiff
frail mesa
#

integrate a webpage and have it ping the bot every 5 mins or so

#

bot gets pinged, it doesnt go down

nimble plume
#

why u use so big name for variable its confusing

frail mesa
#

because thats the name of the roles in the server

placid skiff
#

by the way, I think we have to check what does remove_roles do when it doesn't find the role given

frail mesa
#

makes it easier later down the road

nimble plume
frail mesa
nimble plume
#
@bot.command()
@commands.has_role('Server Owners')
async def cleanup(ctx):
  big_airut_speedrun_1 = ctx.guild.get_role(826189814596108378)
  big_airut_speedrun_2 = ctx.guild.get_role(762488902304006174)
  big_airut_speedrun_3 = ctx.guild.get_role(757836549361762424)
  roles = ctx.guild.roles
  for member in ctx.guild.members:
    if any(role.id == big_airut_speedrun_1.id for role in roles):
      await member.remove_roles(big_airut_speedrun_2, big_airut_speedrun_3, atomic = True)
      await ctx.channel.send('Member successfully updated.')
    elif any(role.id == big_airut_speedrun_2.id for role in roles):
      await member.remove_roles(big_airut_speedrun_3, atomic = True)
      await ctx.channel.send('Member successfully updated.')
    else:
      await ctx.channel.send('Command complete.')
placid skiff
#

HTTPerror maybe

nimble plume
#

now i will see

nimble plume
#

@frail mesa use try excpet and put discord exception to show what error is happening

placid skiff
#

nothing shows in his console so the code should run

#

i say should cuz it is replit D_D

quick gust
frail mesa
#

it does run. its giving me the "members successfully updated" text

placid skiff
quick gust
nimble plume
#

try removing 1 role at a time for easy

quick gust
nimble plume
#

test8

unkempt canyonBOT
#

exception disnake.ext.commands.RoleNotFound(argument)```
Exception raised when the bot can not find the role.

This inherits from [`BadArgument`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.BadArgument "disnake.ext.commands.BadArgument")

New in version 1.5.
nimble plume
#

@frail mesa try removing 1 role

#

sorry to say but never heard of atomic = True

placid skiff
placid skiff
nimble plume
#

atomic bomb

placid skiff
#

is something related to the cache, can't explain it property

nimble plume
#

nvmd

nimble plume
frail mesa
#

split up into separate, same thing

#

removed atomic part, also still same thing

quick gust
#

wrong except

#

you wrote HTPP

nimble plume
slate swan
#

doesnt work

placid skiff
#

HTTP*

nimble plume
frail mesa
#

do i need to import something for this?

nimble plume
frail mesa
#

says undefined name

nimble plume
quick gust
frail mesa
#

ye i figured that much out

slate swan
nimble plume
#

huh

quick gust
#

!d discord.HTTPException

unkempt canyonBOT
#

exception discord.HTTPException(response, message)```
Exception thatโ€™s raised when an HTTP request operation fails.
placid skiff
#

!d discord.HTTPException

unkempt canyonBOT
#

exception discord.HTTPException(response, message)```
Exception thatโ€™s raised when an HTTP request operation fails.
placid skiff
#

you should import this one

nimble plume
#

role2 = discord.utils.get(ctx.guild.roles, name="Muted")

#

@slate swan ```py
role2 = discord.utils.get(ctx.guild.roles, id=1234125326246)

frail mesa
#

how exactly do i import it?

placid skiff
#

like every other import...

frail mesa
#

i would assume from discord import HTTPException

frail mesa
#

but then wouldnt my "import discord" take care of it?

nimble plume
slate swan
#

i can use member tbh

placid skiff
slate swan
#
    @commands.Cog.listener()
    async def on_member_join(self, member):
        try:
        # if member.guild.id == 566648561840685057:
            role = nextcord.utils.get(member.guild.roles, name="Muted")
            member.add_roles(role)
        except Exception:
            print(1)
            return
nimble plume
#

ok got it

frail mesa
#

ah. i thought it would bring everything with it

slate swan
#

switched to member

placid skiff
frail mesa
#

ok so added the try statement

#

same results, nothing prints in console

#

so its not an HTTPException

#

but anyway, it is 3:39am so with that, i must sleep

slate swan
nimble plume
frail mesa
#

if anyone is curious and wants to keep digging, feel free to pm. otherwise will look more tomorrow and might be back here for some more questions

quick gust
placid skiff
#

Importing discord you are just importing all of this, and to access to all of that you will use discord._name_of_package

quick gust
frail mesa
#

so dont do except HTTPException?

placid skiff
#

yes but you will have to access them by refering to the class or file name

nimble plume
#

its not discord exception else it will go on except or error

quick gust
#

i never said that

frail mesa
#

im confused then. i managed to import it just fine

placid skiff
#

import discord
is different from
from discord.ext.commands import *

slate swan
frail mesa
#

yea i understand that

frail mesa
#

like i said. added this, ran the code, same results, nothing prints in console

nimble plume
placid skiff
frail mesa
#

anyway, will be back tomorrow to give another go at this

slate swan
#

@nimble plume this still doesnt work ```py
@commands.Cog.listener()
async def on_member_join(self, member):
try:
# if member.guild.id == 566648561840685057:
role = nextcord.utils.get(member.guild.roles, name="Guest")
member.add_roles(role)
except Exception:
print(1)
return

frail mesa
#

ty for all the help

placid skiff
#

i think that replit is doing something strange at this code

placid skiff
#

i will try it when i finish to work

slate swan
nimble plume
frail mesa
nimble plume
placid skiff
frail mesa
#

it does have some limitations, but not a whole lot for simple commands

slate swan
frail mesa
#

i run far more complicated code on this bot

#

seems to handle everything just fine. zero issues until today

#

this is the first time ive tried to work with roles so idk, ig roles just suck

placid skiff
#

i will DM you when i'll try it xD

slate swan
quick gust
#

@frail mesa before going you can send the final code here?

frail mesa
quick gust
#

I'll take a look afterward

nimble plume
frail mesa
#
@bot.command()
@commands.has_role('Server Owners')
async def cleanup(ctx):
  big_airut_speedrun_1 = ctx.guild.get_role(826189814596108378)
  big_airut_speedrun_2 = ctx.guild.get_role(762488902304006174)
  big_airut_speedrun_3 = ctx.guild.get_role(757836549361762424)
  roles = ctx.guild.roles
  for member in ctx.guild.members:
    try:
      if any(role.id == big_airut_speedrun_1.id for role in roles):
        await member.remove_roles(big_airut_speedrun_2)
        await member.remove_roles(big_airut_speedrun_3)
        await ctx.channel.send('Member successfully updated.')
      elif any(role.id == big_airut_speedrun_2.id for role in roles):
        await member.remove_roles(big_airut_speedrun_3)
        await ctx.channel.send('Member successfully updated.')
      else:
        await ctx.channel.send('Command complete.')
    except HTTPException:
      print("something went bad")
slate swan
frail mesa
nimble plume
quick gust
#

They're in a cog

nimble plume
slate swan
nimble plume
#

role not found

#

try putting role id

slate swan
nimble plume
#

print(role)

#

it will show None

#

print role

slate swan
#

no it prints nothing

nimble plume
#

ur terminal is cursed

slate swan
#
    @commands.Cog.listener()
    async def on_member_join(self, member):
        # if member.guild.id == 566648561840685057:
            role = nextcord.utils.get(member.guild.roles, name=568891254063104011)
            print(role)
            member.add_roles(role)
#

nothing prints

quick gust
#

Do you have another on_member_join event?

slate swan
#

no i have only on_guild_join and on_guild_remove

quick gust
slate swan
quick gust
#

definitely won't work with the ID

slate swan
#

still doesnt work with name

#

i added print(1) and it doesnt even print 1

nimble plume
slate swan
#

maybe its wrong listener

slate swan
slate swan
#

its cog

nimble plume
slate swan
#

what you dont get

nimble plume
#

not working!!!

quick gust
#

they're inside a cog and Cog.listener() is equivalent of bot.listen()

nimble plume
#

idk im done

nimble plume
slate swan
#

i literally added print(1)

#

and i dont see 1 in console

quick gust
#

It isn't, can you check again and make sure you don't have another on_member_join

nimble plume
quick gust
#

weird

slate swan
nimble plume
#

and it is in function

#

how will it will ?/print

slate swan
#

what

nimble plume
#

something with cog probaly

slate swan
#

there is command in this cog

#

and it works

nimble plume
#

show

slate swan
#

so cog also works

nimble plume
slate swan
#

you are the one to help here how can i know

nimble plume
slate swan
#

how there can be problem with cog

nimble plume
#

idk

slate swan
#

its loaded cause command from this cog works

nimble plume
#

i never worked with cog

#

sorry

slate swan
#

so why do you help me

nimble plume
#

so i tryed

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 the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

slate swan
#

Do you have them?

#

yes now added all

#

and i get error ```py
Ready
1
None
Ignoring exception in on_member_join
Traceback (most recent call last):
File "C:\Users\PC\AppData\Local\Programs\Python\Python39\lib\site-packages\nextcord\client.py", line 415, in _run_event
await coro(*args, **kwargs)
File "c:\Users\PC\Desktop\testing\modules\config.py", line 60, in on_member_join
await member.add_roles(role)
File "C:\Users\PC\AppData\Local\Programs\Python\Python39\lib\site-packages\nextcord\member.py", line 898, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'

#

Role is None i dont know why

scarlet aurora
#

i want to make it so that a @bot_command makes it so that if you ! mention a user, it replies with text

scarlet aurora
#

but how do i make it so that if i ping a specific person

#

it only sends that text?

#

like lets say i do ! @nimble plume

#

it replies with ("hello Dyno")

nimble plume
#

ok

scarlet aurora
#

how do i do that

#

help

nimble plume
#

!d

unkempt canyonBOT
scarlet aurora
#

i want to make it so that a @bot_command makes it so that if you ! mention a user, it replies with text

#

so if i ! mention a specific person it replies with text

#

how do i do that

slate swan
#

you need to use an on_message event for that

scarlet aurora
#

ok, so how do i do that

slate swan
nimble plume
scarlet aurora
#
@bot.event
async def on_message(message):
    if message.content == "> <@(number example for ping>":
        await message.channel.send('hello')```
#

do i do it like that?

#

@slate swan

slate swan
#

Ye

slate swan
#

If the user sends a message like > @slate swan

#

it works

scarlet aurora
#

ok

slate swan
#

!d discord.Message.mentions is also an option to check pings

unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

scarlet aurora
#

say less

nimble plume
#

?

scarlet aurora
#

ty

vale wing
#

Galaxygate

#

And check pins

#

This

scarlet aurora
#

i put that block of code in my code, and now nothing works

#

no bot commands, no nothing

slate swan
#

bot.process_commands(message)

#

on on_message events

scarlet aurora
#

wdym

#

how do i do that

quick gust
#

add it at the end of your on message event

scarlet aurora
#

like this?

vale wing
#

And outside of the if

scarlet aurora
#

so like that?

#

ok

#

so like that?

vale wing
#

Also why'd you search for a mention like this

vale wing
#

You should use regex or message.mentions

scarlet aurora
#
  bot.process_commands(message)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```
#

what is a regular message.mentions

vale wing
#

Await it

scarlet aurora
#

so what would i add to my code

slate swan
vale wing
#
await bot.process_commands(message)```
#

But try to figure it out by yourself next time, it's clearly written there

scarlet aurora
#

ok

#

so what is regular message.mentions

#

@ (user) instead of @strange zodiac

vale wing
#

!d discord.Message.mentions

unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

scarlet aurora
#

so if message.contect == '? @vale wing "

#

basically?

vale wing
#

This is equality check

#

You need to check if a member is in message's mentions

#

And it is a list of Member in your case

#

So get member instance and check if it is in mentions

scarlet aurora
#

{user.mention}

#

?

vale wing
#

No

#

You don't need to compare strings that's what I mean

scarlet aurora
#

so what do i do

vale wing
#
if message.guild.get_member(some_id) in message.mentions```
#

I think it's still quite simple

scarlet aurora
#

(some_id) = ??

slate swan
#
@bot.command()
async def test(ctx, user: discord.Member):
  await ctx.send("This command requires you to mention a user!")
vale wing
#

The ID you need

scarlet aurora
#

so the id of the user

vale wing
#

Yeah

scarlet aurora
#

ok say less thank you man

#
@bot.event
async def on_message(message):
    if message.guild.get_member(some_id) in message.mentions
        await message.channel.send('freshman895')
    await bot.process_commands(message)```
#

like so?

#

and then i put the id in

vale wing
#

Yes that should work

scarlet aurora
#

thank you man

slate swan
#

You are using commands extension right?

scarlet aurora
#
                                                                       ^
SyntaxError: invalid syntax```
#

@vale wing

vale wing
#

You forgot the colon

slate swan
#

: at end of if statement

scarlet aurora
#

:

regal pulsar
#

how can i get a mention from a message

scarlet aurora
#

doesn't work

#

i did ? @mentioned user

#

and nothing replied

regal pulsar
#

like if i wanted to do ?hug @Emotional Support#2147

vale wing
unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

vale wing
regal pulsar
scarlet aurora
#

no errors

vale wing
scarlet aurora
#

it just didn't reply

#

message.guild.get_member(569280782753988608)

#

it just didn't reply

vale wing
slate swan
scarlet aurora
#

a person's id

#

someone's discord id

#

and i mentioned the user's id

vale wing
#

Print the message.content and that ID

scarlet aurora
vale wing
#

Isn't simple print simple enough

scarlet aurora
#

i mean what do u want me to do

slate swan
#

He is saying to print the message.content and id

slate swan
regal pulsar
#
@bot.command()
async def hug(message, user: discord.member):
    hug_scenario = "{} gives {} a warm hug!".format(message.author.mention, user.name)
    
    await message.channel.send(hug_scenario)
vale wing
#

Print those values and see if the IDs are the same or not

regal pulsar
#

so like this?

scarlet aurora
#

!e

print("569280782753988608")
unkempt canyonBOT
#

@scarlet aurora :white_check_mark: Your eval job has completed with return code 0.

569280782753988608
scarlet aurora
#

is that what u wanted?

unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

regal pulsar
#

oh yeah im using .format for a different reason

scarlet aurora
#

@vale wing

slate swan
#

f strings are more readable and useful imo, unless your working with {} in the string itself

vale wing
#

@scarlet aurora no, print those values in your code

regal pulsar
scarlet aurora
#

how do i print the values in my code

scarlet aurora
#

WHAT IM CONFUSED

vale wing
#

Erm

quick gust
vale wing
#

It is totally easy?

scarlet aurora
#

sir, you are confusing me

quick gust
#

that's the most basic thing you can understand

scarlet aurora
#

you want me to print values in my code

quick gust
#

yeah

scarlet aurora
#

i cant print values in my code

vale wing
#

Why

quick gust
#

why not?

scarlet aurora
#

because it doesn't have a variable

vale wing
#

Just put the prints to on_message?

scarlet aurora
#

i have nothing to call it by

vale wing
#

You can print the message.content you don't need any variables for that

scarlet aurora
#
print(message.content)```
quick gust
#

yes, simple enough

vale wing
#

So what does it give on mention

slate swan
scarlet aurora
#

it errors

slate swan
scarlet aurora
#
    print(message.content)
NameError: name 'message' is not defined```
quick gust
#

is this not in your on_message event?

slate swan
#

didn't define message in the event loop?

quick gust
#

make sure indentation is correct

regal pulsar
# slate swan try `user.display_name`
raise BadArgument('Converting to "{}" failed for parameter "{}".'.format(name, param.name)) from exc
discord.ext.commands.errors.BadArgument: Converting to "discord.member" failed for parameter "user".
#

doesnt work

vale wing
#

The case matters

#

discord.Member

regal pulsar
#

OH

#

lmfao

scarlet aurora
#

so what should i do

#

print has no indentation

#

it's at the boottttom of the code

quick gust
quick gust
slate swan
regal pulsar
vale wing
regal pulsar
scarlet aurora
#
@bot.event
async def on_message(message):
    if message.guild.get_member(569280782753988608) in message.mentions:
        await message.channel.send('freshman895')
    await bot.process_commands(message)
    print(message.content)```
vale wing
#

Ok so what did you receive

#

When pinging the person with that id

scarlet aurora
#

nothing gets printed

#

i'll be back

vale wing
#

Ok try to put that on top

#

And make sure you have members intent enabled both on dev portal and in code

slate swan
#

I don't understand why his trying to use on_message event for that though lol

#

Does he just wanna get a response upon a users mention?

vale wing
#

Probably

small igloo
#

Interaction type has no attribute author, dpy 2.0, button section

import discord
import database

class shop(discord.ui.Select):
    def __init__(self):
        options = [
            discord.SelectOption(label='Brew Stand', description='A brewer tool', emoji=':brew:'),
            discord.SelectOption(label='Bottle', description='to store water', emoji=':woterbottle:'),
            discord.SelectOption(label='Seed', description='farming is really need this!', emoji=':seed:')
        ]
        super().__init__(placeholder='Shop items', min_values=1, max_values=1, options=options)

    async def callback(self, interaction: discord.Interaction):
        id = interaction.author.id
        coin = database.check_coin(id)
        await interaction.response.send_message(f'{interaction.author.mention}You bought a {self.values[0]}! thanks for shopping with us!')

class shopView(discord.ui.View):
    def __init__(self):
        super().__init__()
        self.add_item(shop())

vale wing
#

!d discord.Interaction.user probably

unkempt canyonBOT
small igloo
#

ow ok thanks

hollow quest
#

hi i want my discord bot to send a message to a channel after the bot has sent an image to a channel, how would i do this? iโ€™ve been stuck on it for a while and any help would be much appreciated

unkempt canyonBOT
vale wing
#

You may check its len

hollow quest
slate swan
#
user = ctx.author
    first = ('Title:', firstresult.raw['data'].get('eng_name', firstresult.raw['data'].get('title')), '\nImage:',
             firstresult.raw['header'].get('thumbnail'), '\nCreator:', firstresult.raw['data'].get('creator', 'unknown'),
             '\nAccuracy:', firstresult.raw['header'].get('similarity'))
    second =('Title:', secondresult.raw['data'].get('eng_name', secondresult.raw['data'].get('title')), '\nImage:',
             secondresult.raw['header'].get('thumbnail'), '\nCreator:', secondresult.raw['data'].get('creator', 'unknown'),
             '\nAccuracy:', secondresult.raw['header'].get('similarity'))
    third = ('Title:', thirdresult.raw['data'].get('eng_name', thirdresult.raw['data'].get('title')), '\nImage:',
             thirdresult.raw['header'].get('thumbnail'), '\nCreator:', thirdresult.raw['data'].get('creator', 'unknown'),
             '\nAccuracy:', thirdresult.raw['header'].get('similarity'))
    await user.send('\n'.join(first) + '\n'.join(second) + '\n'.join(third))

error: raise ApplicationCommandInvokeError(exc) from exc

discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: sequence item 5: expected str instance, list found

#

even after using

await user.send('\n'.join(first))
await user.send('\n'.join(second))
await user.send('\n'.join(third))```
Same error
but if i just send 
`await user.send(first))`
it sends perfectly
honest vessel
#

TypeError: sequence item 5: expected str instance, list found

vale wing
#

!e

a = [1, 2, 3, 4, 5]
print(len(a))```
unkempt canyonBOT
#

@vale wing :white_check_mark: Your eval job has completed with return code 0.

5
honest vessel
#

or length of a string

vale wing
torn pier
#

guys need help in using pycord with pycharm

honest vessel
#

not me thats his error

vale wing
#

Oh

honest vessel
#

basicly he trying to pass a list into join

#

but it only accepts strings

vale wing
#

Yeah so he needs to map it to str

torn pier
vale wing
#

Pycharm uses venv afaik

#

So you have to install it via pycharm's terminal

torn pier
vale wing
#

Idk open the terminal from there, there should be an option

torn pier
#

yeaa

quick gust
torn pier
#

thanks

honest vessel
#

google: how to open console in pycharm

slate swan
maiden fable
#

๐Ÿ‘€

vale wing
#

LIke in java editor from the same developer terminal is here

nimble plume
vale wing
slate swan
#

like every data in 1 line since I wanted it to be like formatted properly i put \n in the line but it wasnt working so i thought using join but its giving error now not sure why it doesnt give error for the first line

nimble plume
vale wing
#

For common java it is pretty good as it has java projects extension, but for android apps the android studio is the only choice

torn pier
#

uh it didnt work

#

installing pycord

regal pulsar
#
@bot.command()
async def hug(message, user: discord.Member):
    hug_scenario = f"{message.author.mention} gives {user.mention} a warm hug!"
    if user != discord.Member:
        await message.channel.send("Mention someone to hug smh")
    elif user.mention in message:
        await message.channel.send(hug_scenario)
    elif user.mention == message.author.mention:
        await message.channel.send("Aw, don't have any friends to hug? Here's one from me :people_hugging:")
#

i need it to send "mention someone to hug smh" if user isnt a person in the server

#

like for ?hug myself

slate swan
#

use an error handler, with MemberNotFound error instance

#

!d discord.ext.commands.MemberNotFound

unkempt canyonBOT
#

exception discord.ext.commands.MemberNotFound(argument)```
Exception raised when the member provided was not found in the botโ€™s cache.

This inherits from [`BadArgument`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BadArgument "discord.ext.commands.BadArgument")

New in version 1.5.
regal pulsar
#

i see

#

ill try that

scarlet aurora
#
@bot.event
async def on_message(message):
    if message.guild.get_member(569280782753988608) in message.mentions:
        await message.channel.send('freshman895')
    await bot.process_commands(message)```
#

why doesn't this work?

#

i want it so that if i use the bot command then mention a specific user, it sends a specific text

torn pier
#

i need help guys pycord is not importing in pycharm

regal pulsar
#

use vsc :/

torn pier
slate swan
#

is there a way to make embed not split words like this

hollow quest
#

ok so i have values stored in a variable that i want the bot to send in a message, but it wont. any help will be appreciated

fresh iron
hollow quest
#

[(72, 83, 90), (237, 146, 86), (35, 232, 191), (152, 143, 139), (93, 119, 211)]

slate swan
#

thats what you wanna send?

hollow quest
#

yeh

slate swan
slate swan
hollow quest
#

specific channel after an image is sent

slate swan
#

you can get channel using