#discord-bots
1 messages ยท Page 811 of 1
The first argument in commands is context, not message
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
what does that mean
is there a way to do that? i want to go through every member in the disc, not just a specific one
i started leaning discord.py today so.
!d discord.Guild.members
property members: List[discord.member.Member]```
A list of members that belong to this guild.
you can get arguments in command itself py async def command(context , number_to_do_work :int): #do your stuff
ok so dont think im using this right cuz still getting the same error
is async def cleanup(ctx, members: discord.Guild.members)correct?
wait so like this?
@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)
If you want to provide argument list you should use argument list or Greedy
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
Gotcha
And args list can only be the last argument (in terms of discord commands), while Greedy can be in the middle
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?
It gets all the members
If you want to provide certain members to a command, then use one of those 2 ways
i want it to get all members in the server
Then this is what you need
!d discord.Guild.members
property members: List[discord.member.Member]```
A list of members that belong to this guild.
ok gotcha, tyvm
so for the arguments line what would i put?
seems like (ctx, members: discord.Guild.members) is not correct
You would have no arguements if ur gonna go through all server members
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
@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"
It is not indented
!indents
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
Have you restarted your IDE?
Also how did you install it and what did you receive
@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.')
I did multiple times
so like this? still getting same error
This is all pip installations
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
Are you using a venv?
Are you sure you have the right library installed?
Plus this channel is about discord bots only
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?
hes importing a dotenv file and you mostly use those to hide your discord bot token
But it isnt related to discord bots-
yes it is. Hes having a problem coding a discord bot, yes its a slight problem but still related
But the issue is related to environment variables
and hes using it for discord bot purposes so, its in the right channel
Well, still not reasonable, but fine
I removed all the that was Installed using pip and reinstalled them
nope still didn't fix the issue
i have pip install discord.py installed
and pip install -U python-dotenv
so it should most definitely be working
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.')
@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
If role in ctx.author.roles
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
Don't take code from GitHub.
Where would I get code for bots
U make it
I'm completely new sorry I've messed mainly with lua and kinda been stuck on how to do this
Then u learn the basics and the syntaxes etc
Where would you recommend I head for a beginner
If that's allowed to recommend places here
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
is there any mainstream fork of discord.py now?
Wdym? If you mean a continuation of dpy then no but there are off branches of it such as disnake
disnake looks fine, how does it compare to pycord, nextcord etc?
are they not comparable?
Lol thats fairly common
Yes and no, i only use dpy currently so im not the one to ask about differences and similarities. All i know is disnake is closest to dpy afaik
Im assuming you are cogging the commands using dpy?
i think thats outdated
not really
What do your current files look like?
Ah i see.
if u complete that tutorial, you can easily use any of the discord.py forks
Ah
Its been fairly relevant for me. Ive been just selectively using it for broader ideas but its still a useful starting point nonetheless
ah lol
ive never learned from anything like that
ive really just looked at the docs ๐
i guess pycord has most stars on github for whatever reason
I meant the contents of the files. Mainly the parts related to importing and cogging
hold on what?
why are you import the main file
why are you importing all the cogs?
Ah
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
@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))
then this one stops working
Wdym? Same as what?
how can i get the bot to edit the role position -1 from the bot top role
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.')
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
Ill take a look in a moment. Any chance i can get a screenshot? Mobile discord code formatting is ass
too unfamiliar
I could try if i knew what the issue was
Put a break in the debugger near the beginning of the command, call it and step through line by line until it errors out
how do i put case_insensitive in python bot clients = statement?
Something is wrong with the cog formatting then
I fixed it! Thanks
Ah alright
You just set the kwarg to True/False
The bot doesnt have access. (assuming the ability to ban users)
here ya go
how
this is users permission
the user must have permssion to ban members
I think that means the bot needs the perms to ban users to run this command
Could be wrong
Nah it's for the user
case_insensitive = <True/False>
Ah, then im not sure but the bot doesnt have access to something it needs
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
@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
nope
removed that line and still dont work
Roles = ctx.member.roles
I think
if i change to this, i get error when i run command "'context' object has no attribute 'member'
Ctx.guild.member.roles?
same error. guild does not have member attribute
Fuuu, k hold on
guild.members?
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?
@frail mesa what do you wanna do?
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
Then loop through guild.members since it returns a list of discord.Member objects
for member in guild.members:
roles = member.roles
no clue. it just prints out "None found" but doesnt remove the role
have double checked all IDs are correct
Code
.
Ah
member.remove_roles
Not remove_role
Weird it doesn't show an error. U got an error handler?
Not really sure. pretty new to coding
i do have a console that gives errors, yea
but wasnt giving any errors on that
Ah hahaha
The server id is the correct one right? If its wrong it wont be able to access it because it thinks its a different server
ok so changed to that, but didnt seem to do the trick
still no errors. but just doesnt remove the role
Show latest code
Are you asking where to put this command or were you just showing a sample command?
the exact same. i just changed remove_role to remove_roles in both await statements
where is the code?
Try printing out the roles to the console and make sure its actually grabbing the roles based on the ids
This is the code
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
Try this
not getting any errors upon running tho code either
i'll check something, What package are you using?
It may be the correct id but make sure its grabbing the actual role based on the id
are you using discord.py?
yes
print(big_airut_speedrun_1, big_airut_speedrun_2, big_airut_speedrun_3)
Add this after the channel.send line
It does
It send the message in the server and doesnt error out its just not removing the roles
@frail mesa once you add this and run the command it will print the values of the roles into the console
yea just did, seems to work fine
It printed the role names?
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
Id's should get around it especially if your pulling the role based on id not name
Ok, that seems to be good then
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
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.
open this link
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
did this. still nothing
K
discord.py is fun ๐
he will need to get the id from the list of roles too
Next suggestion would be checking for the role in ctx.guild.member.roles instead of roles
member is not an attribute of guild
Then drop guild and do ctx.member.roles
:notlikethis:
open this link and read this .-.
Something is up with the if,elif,else statements
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
lol i don't think so, and don't be rude
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
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
then, maybe you will need to use the atomic parameter too
Youve tried members aswell?
yup
You just not even listening...
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)
?
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
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
that's one of the change but is the less important one
hey how do u define the person that clicked a button
may i ask how do i download discord.py?
do this
Youll have to install pip
can some1 help with that
If the button creates with a command, views objects needs the context too in their method, if not, probably you will find your answer to the Button class
Can anyone tell me best pythone guide in youtube free
how do i install pip ? i thought this helped me to install pip?
glowstik
essentially, you are feeding a Role object
@frail mesa might be worth opening a help channel for your issue
wheyo now more simple
Getting oretty crowded
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 ?
@neat tartan may I ask how do I install pip ?
check the Interaction class on the docs
ok
What is the way to learn Python if i have no experience in it?
Finding it, one moment
sololearn
is good
not only that, you have to iterate through member roles list and get their ids too so you will check their ID instead of their name, you can use the any() builtin method to do this
for completly beginner like me?
i'll send here an example of usage
yes
Can the bot see how many minutes has a person streamed in a voice channel?
ty
ok. so then should i just get rid of the 1,2,3 variables? can i just use the id variable in the if statements?
Is it free?
!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)
@placid skiff :white_check_mark: Your eval job has completed with return code 0.
True
is it possible for dropdown to edit instead of reply and make it so only you can see it?
yes
ok so did all that. so the only other thing is youre saying roles = member.roles is wrong?
thanks! where should i type this if i use code on vsc?
yup, you have to check the id using this, i'm sure you will figure it out how
is it possible for dropdown to edit instead of reply and make it so only you can see it?
Open a terminal in vsc and put it in there
how do I open a terminal ?
now im confused. why would i need two lists?
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"))
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
is it possible for dropdown to edit instead of reply and make it so only you can see it?
i used two list, but you can add every expression in the first element, like a == b for a in c
hey
What error is it throwing?
does someone know about the tuesday patch?
bot status isnt supposed to be there ...? just put it in a on_ready sir
of windows
Anyone please respond to my before question ๐ฅบ
it isnt throwing anything
what
dam it say error 
other commands just dont work
This one
I just helped u.. Status doesn't go there kiddo
you lost me. there is no comparison. its just if something is true, then do something
@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="Youtube"))
like this then?
Yes?
ignore that
so i changed it to be included in Bot =
lol and what does this do?
it compares two lists?
it checks if any element is equal to another
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
Anyone please respond ๐ฅบ
is it possible for dropdown to edit instead of reply and make it so only you can see it?
!e
value = 1
list_1 = [1, 2, 3, 4, 5]
print(True if any(num == value for num in list_1) else False)
@placid skiff :white_check_mark: Your eval job has completed with return code 0.
True
um
Understood now?
where are you from?
This channel is for discord bots. Its not a very python beginner friendly channel. Id suggest taking a look in the other channels and in the pins. They usually contain resources
you can just print any() directly though
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
lol
Id suggest googling or going to youtube and searching how to install pip and follow the videos. They will be easier. Pip is a pain in the ass to install
so like if any(num == big_airut_speedrun_1 for num in roles): ?
would i have to use something other than 'num' ? or does that work since its using IDs?
@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'
i am getting error 'int' object has no attribute 'id' so im guessing i cant use num
if any(role.id == big_whatever for role in roles)
ya i searched alrdy but it didnt work 
@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'
#editors-ides might be a better place since your trying to do it through vsc
help me
Its just as the error says. Its missing coro
role are equals to an element from the list of roles, so role is a Role object which has the id attribute
how to fix
gotcha. but its saying role is undefined
one sec, thats prob one i can figure out myself lol
lol
oh you are not using vsc? what do you use?
I am i just dont remember how to install pip on it. That other channel is specifically about ides this one is about discord bots. They will know more about installing pip to vsc
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'"
how would i put a custom emoji in a dropdown?
well, then we find the problem with your code
aright tahnsk
thanks
how to get a channel
why for num in roles?
!d discord.on_message_delete
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.
then something in your code is not a discord object, print the member and the roles in the console
what is discord here
love how everyone is ignoring me
same
ok did print(member, roles)
the result:
Raid Pet Farm#5711 [<Role id=buncha numbers name = '@everyone'>, <Role id=buncha numbers name='Bot'>, <Role id=buncha numbers name='Admin'>, <Role id=buncha numbers name='Raid Pet Farm'>]
so i think i see the issue
roles is only showing the roles the bot has
also remove role = discord.utils.get(member.guild.roles), is useless for you
not all the roles in the server
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
well, i need something? removing this and it says role is undefined
it will not lol
but it does. is what im saying
probably your bot is the first member in your guild
you are iterating through all members, remember?
Everyone here either is too busy or probably doesnt know how to help with your request
gotcha. so thats not the issue then?
just remove it and we will see what it does
you are just doing roles = ctx.guild.roles twice
oh now found something interesting. Let's make better this code, so maybe we will understand something more
@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.')
haven't you this?
just changed cuz you mentioned here
and i thought yea that makes sense
cuz i want the guilds roles, not one specific members
n
you have all your variables put in your for cicle
only other difference i see is that your variables and list are outside the for statement
does that matter?
it's a big difference don't you think?
like you are reassign values every time you loop into that for
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
gimme a screen
@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
nope a screen, of the console and the code
also remove guild = bot.get_guild() just use ctx.guild
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??????
well of course it says role is not defined
is for role.id _statement_here for ROLE in roles
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
ok so all that is fixed, no more of that error
now we are back to 'int' object has no attribute 'id'
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
screen again
it is this mate, i promise
if you made changes, error doesn't appear, means something has changed lol
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
yup, but that is what I wrote, i need what you wrote
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
elif any()
you have to call any everytime you do that expression
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
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
hi how can i assign role to new member but only for one server (mine)
await member.remove_roles(big_airut_speedrun_2, big_airut_speedrun_3, atomic = True)
roles are just ints, not roleobjects?
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
!d discord.Guild.get_role
get_role(role_id, /)```
Returns a role with the given ID.
give it the ID
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?
developer portal
Check the dm
you cant change name of button
does the id need wrapped in ' ' or somethin?
no because its an INT
giving me error "get_role() missing 1 required positional argument 'role_id'
i have discord.Guild.get_role(numbers)
Check the dm bro
i saw. just waiting for you to return. tho im welcome to other help aswell
3am so trying to complete this soon haha
It is kinda the same way as the "Add to server" button?
this isn't hard to fix but only problem is I'm in my class rn lol
thats how u add the "add to server" button
big_airut_speedrun_1 = discord.Guild.get_role(826189814596108378) any idea whats wrong here?
Yeah I already got that button on my bot, but a custom button on the bot profile is what I am talking about.
ctx.guild.get_role()
you cannot as far as i know
Oh okay
is ctx.guild.get_role
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
paste the if-elif-else statement
it is very easy, and I can see problems in the code but I'm in class right now
@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.')
add .id to your big_whatever
console.log(s)
wrong server?
no
๐
ok interesting
python has console.log๐
so now it is not giving me the "none found", not giving any errors
but also still not working
class console:
def log(other):
print(other)
also ctx.channel.send is equivalent to ctx.send
๐
it really founds nothing then, check again the ID of the roles
paste them correctly
yea ive triple checked em
console.log("hello python")

what IDE are you using?
checked again to be sure. id's are correct
am using replit.com
D_D
@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.')
its bad for everything
what error
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
ok wait lemee se code
meh. theres a trick so i can host it for free with no time limit. 0 issues so far, have used for over a year
literally just posted above
woah how
telling wait leme see code
check pinned message, you will figure out why it is bad
integrate a webpage and have it ping the bot every 5 mins or so
bot gets pinged, it doesnt go down
why u use so big name for variable its confusing
because thats the name of the roles in the server
by the way, I think we have to check what does remove_roles do when it doesn't find the role given
makes it easier later down the road
use some keywords
i'd assume it would give an error
@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.')
HTTPerror maybe
now i will see
HTTPException when it fails
@frail mesa use try excpet and put discord exception to show what error is happening
nothing shows in his console so the code should run
i say should cuz it is replit D_D
RoleNotFound when role isn't found
it does run. its giving me the "members successfully updated" text
nope just checked, HTPPException for remove_roles
do the members even have the roles?
try removing 1 role at a time for easy
!d disnake.ext.commands.RoleNotFound
test8
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.
add this before removing the role:
try:
#remove the roles
except HTPPException:
print("something went bad")
is used when you have to delete more roles
thats what i say
is something related to the cache, can't explain it property
nvmd
sigh
ยฏ_(ใ)_/ยฏ
split up into separate, same thing
removed atomic part, also still same thing
in conclusion, i hate discord.py
.
this?

doesnt work
HTTP*
first get role
do i need to import something for this?
no
says undefined name
wow
HTTPException, Not HTPPException
ye i figured that much out
how can i
huh
!d discord.HTTPException
exception discord.HTTPException(response, message)```
Exception thatโs raised when an HTTP request operation fails.
!d discord.HTTPException
exception discord.HTTPException(response, message)```
Exception thatโs raised when an HTTP request operation fails.
you should import this one
role2 = discord.utils.get(ctx.guild.roles, name="Muted")
@slate swan ```py
role2 = discord.utils.get(ctx.guild.roles, id=1234125326246)
how exactly do i import it?
like every other import...
i would assume from discord import HTTPException
i dont have ctx in cog listener
but then wouldnt my "import discord" take care of it?
yes
show full code
i can use member tbh
Nope, you are importing just the package discord
@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
ok got it
ah. i thought it would bring everything with it
switched to member
it's not how it works
try
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
still doesnt work
except discord.DiscordException
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
it will, but you will need to do discord.HTTPException
Importing discord you are just importing all of this, and to access to all of that you will use discord._name_of_package
importing discord will import the complete package
so dont do except HTTPException?
yes but you will have to access them by refering to the class or file name
its not discord exception else it will go on except or error
i never said that
im confused then. i managed to import it just fine
import discord
is different from
from discord.ext.commands import *
at the top do from discord import HTTPException and then do except HTTPException:
yea i understand that
yea done ;p
like i said. added this, ran the code, same results, nothing prints in console
my vs code auto import ยฏ_(ใ)_/ยฏ
pycharm too lol
anyway, will be back tomorrow to give another go at this
@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
ty for all the help
i think that replit is doing something strange at this code
what error
i will try it when i finish to work
problem is there are no errors
for all timepass
i dont think replit is it ;p
L
wanna bet? xD
it does have some limitations, but not a whole lot for simple commands
dam
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
i will DM you when i'll try it xD
why u put nextcord there
cause i use nextcord
@frail mesa before going you can send the final code here?
sure
I'll take a look afterward
remove self ยฏ_(ใ)_/ยฏ
@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")
huh
why should it work
someone asked for current code
we need ERROR
ye role is None type for some season
it still doesnt give error
nope
listen then try printting role
print(role)
it will show None
print role
@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
Do you have another on_member_join event?
no i have only on_guild_join and on_guild_remove
name should be the name, not the id
didnt work with name so tried id
definitely won't work with the ID
how tf it print ready 100% cursed
maybe its wrong listener
on_ready?
use @bot.listen()
its cog
ik i was kidding
what you dont get
not working!!!
they're inside a cog and Cog.listener() is equivalent of bot.listen()
idk im done
100% its not calling the function
It isn't, can you check again and make sure you don't have another on_member_join
show
weird
i said function not calling
and it is in function
how will it will ?/print
what
something with cog probaly
show
so cog also works
so why function is not working
you are the one to help here how can i know
thats what i said
how there can be problem with cog
idk
its loaded cause command from this cog works
so why do you help me
!intents
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.
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
great
i want to make it so that a @bot_command makes it so that if you ! mention a user, it replies with text
ctx.reply("text")
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")
ok
!d
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
you need to use an on_message event for that
ok, so how do i do that
There's no role named Guest in the server
thats what i said but he say im wrong
@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
Ye
solved already thanks
If the user sends a message like > @slate swan
it works
ok
!d discord.Message.mentions is also an option to check pings
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.
say less
?
ty
i put that block of code in my code, and now nothing works
no bot commands, no nothing
you need to add
bot.process_commands(message)
on on_message events
add it at the end of your on message event
like this?
Nope, just like this @scarlet aurora
And outside of the if
Also why'd you search for a mention like this
bot.process_commands(message)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```
what is a regular message.mentions
Await it
so what would i add to my code
process_commands is a coroutine ;-;
await bot.process_commands(message)```
But try to figure it out by yourself next time, it's clearly written there
!d discord.Message.mentions
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.
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
so what do i do
if message.guild.get_member(some_id) in message.mentions```
I think it's still quite simple
(some_id) = ??
@bot.command()
async def test(ctx, user: discord.Member):
await ctx.send("This command requires you to mention a user!")
The ID you need
so the id of the user
Yeah
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
Yes that should work
thank you man
Question
You are using commands extension right?
You forgot the colon
: at end of if statement
:
how can i get a mention from a message
like if i wanted to do ?hug @Emotional Support#2147
!d discord.Message.mentions
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.
Errors?
ah
no errors
Typehint the argument with discord.Member
it just didn't reply
message.guild.get_member(569280782753988608)
it just didn't reply
What ID did you put to there and what user did you mention
@bot.command()
async def hug(ctx, user: discord.Member):
await ctx.send(f"Hugged {user.name}!")
Print the message.content and that ID
ah ty
?
Isn't simple print simple enough
i mean what do u want me to do
dont give the code?
He is saying to print the message.content and id
I apologise
@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)
Print those values and see if the IDs are the same or not
so like this?
!e
print("569280782753988608")
@scarlet aurora :white_check_mark: Your eval job has completed with return code 0.
569280782753988608
is that what u wanted?
!f-strings
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.
oh yeah im using .format for a different reason
huh
@vale wing
f strings are more readable and useful imo, unless your working with {} in the string itself
@scarlet aurora no, print those values in your code
nvm
how do i print the values in my code
user.name doesnt work
WHAT IM CONFUSED
Erm
... just print it
It is totally easy?
sir, you are confusing me
that's the most basic thing you can understand
you want me to print values in my code
yeah
i cant print values in my code
Why
why not?
because it doesn't have a variable
Just put the prints to on_message?
i have nothing to call it by
You can print the message.content you don't need any variables for that
print(message.content)```
yes, simple enough
So what does it give on mention
try user.display_name
it errors
What's the error
print(message.content)
NameError: name 'message' is not defined```
is this not in your on_message event?
didn't define message in the event loop?
make sure indentation is correct
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
discord.member is not a thing
The case matters
discord.Member
...
to on_message
We're asking you to print the message.content from the on_message event
hmm now it gets their display name but how do i get it to ping them
user.mention
Does anybody know why does this exec command eat all the errors https://paste.pythondiscord.com/edubosazox.py
๐
@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)```
Ok try to put that on top
And make sure you have members intent enabled both on dev portal and in code
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?
Probably
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())
!d discord.Interaction.user probably
The user or member that sent the interaction.
ow ok thanks
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
!d discord.Message.attachments
A list of attachments given to a message.
You may check its len
yes โlenโ is included within the code though i have no idea what that means
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
TypeError: sequence item 5: expected str instance, list found
The length of an iterable object
!e
a = [1, 2, 3, 4, 5]
print(len(a))```
@vale wing :white_check_mark: Your eval job has completed with return code 0.
5
or length of a string
You are trying to join something aren't you?
guys need help in using pycord with pycharm
not me thats his error
Oh
Yeah so he needs to map it to str
soo when i ran pip install pycord it worked alright but when i try to import it in pycharm it doesnt work
like how?
Idk open the terminal from there, there should be an option
yeaa
yep
thanks
google: how to open console in pycharm
what should I do to fix it basically
when i tried using formatted strings it sends all the data in 1 line which is the problem
๐
LIke in java editor from the same developer terminal is here
vs code for all
For all except android apps on java
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
oh yea sorry
For common java it is pretty good as it has java projects extension, but for android apps the android studio is the only choice
@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
use an error handler, with MemberNotFound error instance
!d discord.ext.commands.MemberNotFound
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.
@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
i need help guys pycord is not importing in pycharm
use vsc :/
it didnt work
uhh yea i dont like it as much
i need help
heelp
is there a way to make embed not split words like this
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
code?
well atm 'color' = a bunch of RGB values
[(72, 83, 90), (237, 146, 86), (35, 232, 191), (152, 143, 139), (93, 119, 211)]
thats what you wanna send?
yeh
somebody ran command afk that doesnt exists
you want it to be command or specific channel
specific channel after an image is sent
you can get channel using
