#discord-bots
1 messages · Page 557 of 1
member_counts = self.get_member_counts(ctx.guild)
member_info = "\n".join(f"{role}: {count}" for role, count in member_counts.items())
embed.add_field(name=f"Members: {total_members}", value=member_info)
returns the everyone role too, how can I remove it?
then idk 
Hmmmm
I got no idea
oh no
in your .join check if the role's name is @@everyone and if it is don't add it
they are typing
del member_counts[guild.default_role]
example code?
guessing member_counts is a mapping of Role and something else
member_counts = self.get_member_counts(ctx.guild)
?
thats not the issue tho
for role, count in member_counts.items() if role.name != '@@everyone'
its in the member_info
my role
he wants to remove the @@everyone role when you get someone's roles or the guild's
not u
i was talking to him
alr
@slate swan what does the if role.name != @@everyone do here? I need to delete @@everyone?
dude
i can't
why am i even helping you
learn python
when you use ctrl+c & ctrl+v and then u go unga bunga
learn python list comprehensions
ok after im done with this one
@client.event
async def on_message(message):
if message.content == "What are some things you can do GHP Bot?":
channel = client.get_channel(id)
await channel.send("I can interact with users who call me! Ask me some things!")
This is not running when I say the message
What is wrong with it
what is id
id is a built in function if you haven’t defined it
Here, ill put it with the id
member_info = "\n".join(f"{role}: {count}" for role, count in member_counts.items())
embed.add_field(name=f"Members: {total_members}", value=member_info)```
so what I want to do here is that I want to remove the `@@everyone` role in member_info, how would I do this?
It has to be integer
@client.event
async def on_message(message):
if message.content == "What are some things you can do GHP Bot?":
channel = client.get_channel(901637744743313488)
await channel.send("I can interact with users who call me! Ask me some things!")```
Were you afraid of sharing a channel's ID?
There
What does
The everyone role is always the first in the index, so start from the index 1.
you cant with a dict
its a list
membe_counts
So?
is something else
!d dict.items
items()```
Return a new view of the dictionary’s items (`(key, value)` pairs). See the [documentation of view objects](https://docs.python.org/3/library/stdtypes.html#dict-views).
member_counts is a dict, not member_info
member_info isn’t a list either
It's a str
^^
try my first suggestion, del the guild.default_role key
what
what?
wdym
do you know what del is
yes
then it should be easy to do
It's a keyword, just like if. (Or at least similar)
i don’t see what’s confusing
why would i do that
what…
...
I thought patrons are smart.
same ngl
are you fucking kidding me
@slate swan Remove the guild.default_role from the member's roles dict because this is the everyone role.
but how can it change the other variable
learn python
What other variable?
by learning python
It changes it, by changing it. 
ohhhhh
ty now i get it

no shot
@client.event
async def on_message(message):
if message.content == "What are some things you can do GHP Bot?":
channel = client.get_channel(901637744743313488)
await channel.send("I can interact with users who call me! Ask me some things!")```
What is wrong????
dont ask them
they will make fun of you
any errors?
I'll ask you a question, is channel the same as the channel that the message was sent in?
Nope
no, just you, you're a little "special" that's all
ahh youre like me !!!
are you typing exactly whats there?
yes
yes
Just do await message.channel.send().
^
ik i am, im smart otherwise i wouldn't be able to solve it, i used del
no you're delusional 😂
we appreciate you
by far prolly the most braindead person i've talked to 😂
yep you used del because we told you to
sorry patreon 2
what is it
It's II not 2. Sorry.
still doesnt work
Show me your new code.
are you running the bot?
features = f"\nFeatures: {', '.join(ctx.guild.features)}"
this, when features is empty, i want it not to get printed in:
embed.description = (
f"Created: {created}"
f"\nVoice region: {region.title()}"
f"{features}"
f"\nRoles: {num_roles}"
f"\nMember status: {member_status}"
)
how do i do that
@client.event
async def on_message(message):
if message.content == "What are some things you can do GHP Bot?":
await message.channel.send("I can interact with users who call me! Ask me some things!")```
check if the list is empty
@dapper cobalt
and if it is?
dont add it to the description?
example code?
And are you sending the same exact message?
@bot.command()
async def ping(ctx):
embed = discord.Embed(
title = (str("**Pingim**"), int(bot.latency*1000), str("**MS**"))),
description = ""
)
await ctx.send(embed = embed)
i don't want to see ' and (
nope
why
learn python
its a single if statement
checking if the list is empty is
What the heck is that code? Ever heard of an f-string?
ikr
btw isn't KeyError: 'life' syntax error?
yes
?
this is why we're telling you to learn python, because no, it's not
KeyError it is
KeyError is what's printed in the console when a key you're trying to access inside a dict isn't there (and if you're using dict[key])
^
That's just like asking "isn't 1 same as 100?".
😂
well logically it is
because 0 is nothing
is your bot running more than once?
That's in case it was at the start of the number.

You are bad at maths too??
is one hundred the same as one
this guy is 9 i bet
btw i fucking solved my issue
features = f"\nFeatures: {', '.join(ctx.guild.features)}"
if features == "\nFeatures: ":
features = ""
WOAH NO WAY
everytime i change the code
i kill the terminal and run it
I want to learn about this logek
hmm 
nice code
ok I can teach u, but remember this information is only for people who have alot of iq
so
i'm disqualified?☹️
It literally doesn't respond
1 equal 1 (something). 0 equals 0 (nothing). 100 (something, nothing, nothing) technically equals to (something), which means 100 = 1
Try printing message.content.
alr
0 is nothing if it's at the start of the number.
!e
print(001)
@dapper cobalt :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | print(001)
003 | ^^
004 | SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
its always nothing
See.
no its always nothing
no point arguing
^
leave the troll be
No.
What’s even going on here??
I'd like to say paid troll
what really is 0?
alright shit that hurt fr
come on now, isn't it more fun helping out someone like me, or someone who just says "ok, understand, ill fix it myself, bye"
Isn’t this channel supposed to not bash beginners and not gatekeep “intelligence” in Python
It’s in the pinned messages I think
read the whole conversation please
Not sure whatever’s going on though
Just read the part about “use an f-string not whatever that ugly code is”
That's my bad.
You’re good
Shouldn't have that said tbh.
I think you just got worked up over the argument
What’s going on in here tho, like a TLDR
if you think about it, "pinned messages" are atoms, and atoms can also be something blank, so no pinned messages doesn't exist
Oh, that’s what’s going on
!ot
Off-topic channels
There are three off-topic channels:
• #ot0-psvm’s-eternal-disapproval
• #ot1-perplexing-regexing
• #ot2-never-nester’s-nightmare
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
anyway back to topic
Sir, we do respect your intelligence
Any of you all making discord bots right now, if so what kind of bot?
I am 😄
DPY 2.0?
im struggling with implementing voice
idk, just the master one
Ohh, lefi Right?
yesh
hey sir how do i install master discord.py like u guys told me so i can use discord.utils.format_dt()
pip install discord.py
i got opus and stuff done, but i have to use ffmpeg and some other bullshit
no that's the pypi version
pip install -U git+https://github.com/Rapptz/discord.py
I don't have git?
install it
can I do this without installing git? i dont like git
nope
Ah, also what’s a good place to understand websockets and that crap, I never really understood the web sockets part of the discord API wrappers
what happens if i remove git after i installed it
It should already exist in your IDE
I mean you could download to code on the website and the manually put it in the modules folder
Then it won’t be there.
uh, the way i understood stuff about them is just testing what works and what doesn’t and docs
It will be removed. 
Ah alright. Thank you!
you sure this is not a virus? doesn't look official?
git is a renowned tool.
if you want a full detailed implementation on the websockets protocol read the RFC for it
Check the repo. then
Discord.py isn't made by Discord. It's made by Rapptz.
Do you not like git or do you not like using git? If it's the latter then just don't use it when installed, if it's the former, why?
ohhh, is rapptz here in the server?
No
no
why?
Because he hasn't joined
Alright, I’ll probably do that. Thank you! ^^
Is it necessary?
isnt this the official discord.py server?
ok dud
Oh my god
No this is, as the name suggests, the python discord server

(2)
I'm this 🤏 close to losing it.
^
wait so it's just a random person who created discord.py?
Some random dude also decided to make python
Discord has an official RESTAPI, and this "random" person has made a Python wrapper for it that made him 'famous'.
In the same way as anyone good at something who ends up being notable is random
rapptz, imagine how many bots he can hack
Some random dude made Discord.
About, 0.
none?
why? he's the owner of discord?
Omegalul
A few poorly designed ones
I'm done
He can’t actually hack any - he’s just someone who made the wrapper
what exactly is a wrapper btw
ah i see
Oh yeah, doesn’t discord now tell if you if you send a valid discord token?
its a wrapper
Pretty cool feature
in github yea
Something that wraps. 
like the ones, car wrappers?
Like a nice blanket over some ugly things
Troll
It warns you if you send something that could potentially be a token yes
ah so, discords language was ugly so they wrapped around it with discord.py and it has a module called balnket?
...
Fuck sake. Stop it.
.topic
Suggest more topics here!
ok ok sry
Well, on forks, full support for slash commands
!pypi disnake
I think pycord is in the midst of doing that
patreon troll
coming up on lefi!!
disnake :)
Disnake is pretty good
Currently making an open source disnake bot :D
Oh yeah aren’t you all starting to work on the gateway for the interactions?
do i remove discord.py to install the master branch version?
-U should automatically do that for you
andy did a small implementation of the interactions shit with an HTTP server
but he removed it
Yeah I heard, I think he’s making a gateway for it now
I don't think Andy is doing anything relating to Discord anytime soon.
btw, what do I change in my code when changing from discord.py to master?
Nothing, its fully compatible
git?
fronto just joined ffrom what i can tell
A few changes
Like avatar.url instead of avatar_url
ah I see, i just installed git and I run the command but it says there is no command called "git"
Oh yeah, some things got removed and deprecated I’m guessing
pip install -U git+https://github.com/Rapptz/discord.py
i have my own fork
Are you working from an IDE?
yes
Yep — still trying to find my way around the codebase but I’m pretty excited and I hope I don’t mess things up lmao hence I’m doing smaller things rn like converters and what not
Which IDE?
pycharm
oh well good luck
Thank you!
i just installed master one
f"\nVoice region: {region.title()}"
i get an error in title()
what is the error
that’s not an error, send the traceback
ok wait
f"\nVoice region: {region.title()}"
AttributeError: '_EnumValue_VoiceRegion' object has no attribute 'title'
it had before i installed the git version of discord.py
try str(region).title() instead
ok ty
btw this is a complete guess so lmk if it's still producing an error
it worked 😄
ayyyy
@client.command()
async def queue(ctx):
print(ctx.message.channel)
``` How would I get the name of the category that the command was sent in (discord.py)
!d discord.TextChannel.category
property category: Optional[CategoryChannel]```
The category this channel belongs to.
If there is no category then this is `None`.
ctx.channel.category (see above)
Thanks!
I told u send their github
I did
can you help?
it heroku hosting
Anyways, I already got support now
async def user_info(self, ctx: Context, mentioned):i want mentioned to be either a member or a user being mentioned
Still thanks
Ok
Yea
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
Use that
ty
So mentioned: discord.Member
so it could be, mentioned_user: Union[discord.Member, discord.User] = None
someone help?
It's not related to #discord-bots
Ye
Search it up maybe
the moderators told me to write here for help with heroku hosting
I was looking.
<VoiceState self_mute=False self_deaf=False self_stream=False suppress=False requested_to_speak_at=None channel=<VoiceChannel id=901627304265007114 name='General' rtc_region=None position=0 bitrate=64000 user_limit=2 category_id=None>>
``` How do I get `category_id` from this?
What is that
Voice channel
It says what's wrong in the error, no default language could be detected for this app
No like what did you add in .send so that the bot sends that
@client.command()
async def queue(ctx):
print(ctx.message.author.voice)
``` This?
okay ty :)
Ignoring exception in command queue:
Traceback (most recent call last):
File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\chia\Downloads\bot\test.py", line 21, in queue
print(ctx.message.author.voice.category_id)
AttributeError: 'VoiceState' object has no attribute 'category_id'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'VoiceState' object has no attribute 'category_id'
``` Rip I get this now 
rip ok
Get the category from the VoiceState.channel
And the id from that
Thank youu
Anyone have a tutorial for using dbs for discord.py
No
Not really discord bots related, that's databases related stuff
badges = []
for badge, is_set in user.public_flags:
if is_set and (emoji := getattr(constants.Emojis, f"badge_{badge}", None)):
badges.append(emoji)
what does the getattr() do here? I don't have the constants class but I was thinking of downloading every discord badge a user can have and put them as a emoji in my server and use it like that, but since I don't know what getattr() is doing idk if this would be possible?
!d getattr
getattr(object, name[, default])```
Return the value of the named attribute of *object*. *name* must be a string. If the string is the name of one of the object’s attributes, the result is the value of that attribute. For example, `getattr(x, 'foobar')` is equivalent to `x.foobar`. If the named attribute does not exist, *default* is returned if provided, otherwise [`AttributeError`](https://docs.python.org/3/library/exceptions.html#AttributeError "AttributeError") is raised.
Note
Since [private name mangling](https://docs.python.org/3/reference/expressions.html#private-name-mangling) happens at compilation time, one must manually mangle a private attribute’s (attributes with two leading underscores) name in order to retrieve it with [`getattr()`](https://docs.python.org/3/library/functions.html#getattr "getattr").
As it says
me no ingliz
pls try to explain that to me
Even the name of the func is pretty obvious, get attribute
it grabs an attribute of an object by its name
It basically tries to get the attribute of an object and if it's not found it returns None
you can also pass in a default if the attr is not found, if no default is passed in and the attr is not found it raisrs AttributeError
so lets say
getattr("", f"badge_{badge}", None)``` would work?
Didn't it return None? 
it’s useful if the name of the attribute you’re getting might change based on some other variable
nope, you have to explicitly pass None
I don't use it that much so I thought it works similarly dict.get
no
I see 🤔
actually yes
ahh then what can I do instead of constans.Emojis?
Ah I see
but alternatively what could I do instead of getting the attribute of constants.Emojis i want to use server emojis
How do i get the amount of people in a vc with the vc id
how can I add my color: 0x2f3136 to the Cogs code?
so do we just have to use discord.js or discord.cs or discord.java now that discord.py is gone?
@command(name="user", aliases=["user_info", "member", "member_info", "u"])
async def user_info(self, ctx: Context, user_or_message: Union[discord.Member, discord.User, Message]):
"""Returns info about a user."""
if isinstance(user_or_message, Message):
user = user_or_message.author
else:
user = user_or_message
if user is None:
user = ctx.author
embed = await self.create_user_embed(ctx, user)
await ctx.send(embed=embed)
async def create_user_embed(self, ctx: Context, user: Union[discord.Member, discord.User]) -> Embed:
discord.ext.commands.errors.MissingRequiredArgument: user_or_message is a required argument that is missing.
how come?
You did not include the argument when actually calling the command like
[prefix]command [argument]
but what if I don't include a argument, it's supposed to give me my information, hence "if user is None:"
delete in aliases user_info
why?
-_- you want your code to work, don't you?
You set it to a default argument
why would I deletet that?
^
That’s not why it’s erroring I think.
I won't be able to explain through a translator
Got it working, i forgot to add = None to the Union[]
Ahh, got you.
You could use Optional[type] too
Any of you seen PEP 671 yet?
!pep 671
I can imagine how this could be useful for discord bots
Ask away!
example
async def warnings(ctx: commands.Context, member: discord.Member => ctx.author)
badges = []
for badge, is_set in user.public_flags:
if is_set and (emoji := getattr(constants.Emojis, f"badge_{badge}", None)):
badges.append(emoji)
this is not my code, constants https://github.com/python-discord/bot/blob/3b846ae86dc0268661a54f42edca6a037b97d153/bot/constants.py#L270 is this class
I don't want to make that class since it won't work for me unless i write another 1000 lines of codes
it''s supposed to check if the user has any badge
atm i have the hypesquad badge
i was thinking of make all the badges in discord into server emojis in my server
and do it that way, but idk how I could use that in the code
?
right but, I also need to check if the user has a badge
Ah, I’ve honestly never worked with checking if the user has a badge so I will not be of much help, sorry!
nvm I think I found a solution
for badge, is_set in user.public_flags:
if is_set:
print(is_set, badge)
returns
True hypesquad_brilliance
using this, i could do if statements and check what the badge is, and depending on that ill append that emoji to badges 🙂
@novel cipher?
Say someone is using my bots commands and it is unable to process it due to 'skipping a beat'/lag
How can I make a global handler for an error like discord.errors.NotFound: 404 Not Found
So when it occurs I can send them a message saying please re-try?
-Hi.How can i make the bot use do not disturb status and also having a status like
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.competing,name=f'-help'))
await client.change_presence(status=discord.Status.dnd
-But after this i can only get the bot status dnd but activity does not presence
How do you send a message to another channel by the id
if i fetch a user do i have to use get right after?
bot.get_channel(channelid)
set that to a variable and then do await variable.send(blah)
you have to set them in the same function
Ifht thanks
eurm means that i need to combine this two?
mhm
@bot.command()
async def add(ctx, bott: discord.User = None, *, reason=None):
l = await bot.fetch_user(bott.id)
b = bot.get_user(bott)
if b is None:
embed = discord.Embed(description="please provide a bot id!",color=discord.Color.from_rgb(62,173,255))
mes = await ctx.reply(embed=embed)
await asyncio.sleep(5)
await ctx.message.delete()
await mes.delete()
else:
if l.id in db.find_one({"bot_id": bott.id}):
embed = discord.Embed(description="your bot is still being reviewed. Please be patient!",color=discord.Color.from_rgb(62, 173, 255))
mes = await ctx.reply(embed=embed)
await asyncio.sleep(7)
await ctx.message.delete()
await mes.delete()
else:
db.insert_one({"bot_id": bott.id,
"author": ctx.author.id,
"reason": reason})
embed = discord.Embed(description="Your bot has been entered to the queue. Be patient and wait for your bot to get accepted or declined.",color=discord.Color.from_rgb(62, 173, 255))
await ctx.reply(embed=embed)
okay thanks for helping
await ctx.delete.message(ctx.message)
``` why does this not delete authors command message?
ctx.message.delete()
I don't want it to delete the bots message
no this is delete the author message
bruh wth
!d discord.Message.delete
if i wanted my bot to send a message in a random time between 30 minutes and 5 hours
what method do i use?
if isinstance(relationship.type, discord.RelationshipType.incoming_request):
TypeError: isinstance() arg 2 must be a type, a tuple of types, or a union
any1 know how to fix this?
bots don't revive frq so this is leading me to thinking your trying to make a selfbot..
convert the time to seconds
and make a tasks or asyncio.sleep(dont recommend)
@slate swan how do i find an emoji's id
do \emoji
so type a \ then go to the emoji selector and just click on ur emoji
it should look like !Heart
@final pumice
\🍌
it doesnt work for default emojis as they can be used everywhere
how do i find the id of default emoji then?
then how do i use get_emoji()
that will return 🔥
if i need an id
\banana
so do i say get_emoji(\banana)?
banana is a default emoji you just have to do :banana:
so if i wanted to store it in a variable, would i say banana = :banana:
banana = ":banana:"
async def random_banana():
channel = client.get_channel(774468047846768640)
hasBanana=True
while True:
if hasBanana:
sec = random.randint(1,60)
print(sec)
time.sleep(1)
await channel.send("where banana? :(")
hasBanana=False
else:
@client.event
async def on_message(message):
banana = ":banana:"
if message.content == banana:
await channel.send(":O BANANA! OOOO A A AAA *smiles*")
hasBanana=True
asyncio.run(random_banana())```
whats wrong with this
File "c:\Users\white\VS Practice\monki_bot.py", line 29, in random_banana await channel.send("where banana? :(") AttributeError: 'NoneType' object has no attribute 'send'
you can put an event like that
this is my error
Hi, my bot has recently hit 28,000 guilds and when sharding some of the shards are beginning to disconnect? Not sure why, I googled and apparently it can be caused due to no RAM but my ram isnt even getting fully used up
an event has to align with the async function
thats alot of guilds lol
what event do i put in
@client.event
async def on_message(message):
if LOL:
stuff
else:
return
Yhh 😅 just dont know if this error is anything to do w discordpy
happens on startup
all shards are ready and bot is ready
shards slowly disconnect
thats an example on how to use a variable in a on_message
and reconnect
all different shards
i fr dont know much about ShardedClients
what im trying to do is that at a random time, the bot will send a message. when the user puts the banana emoji, the bot responds and the entire thing restarts
i don't think an on_message() will fit into that
do you know any python?
ehh, debatable your trying to make a function inside of one..
u probably want a command and wait_for
or use a on_ready
???
when the bot runs it will stary cycling thru random times
oh shoot
and will randomly send
uhhuh
@rain olive can you help me with this
@bot.command()
async def add(ctx, bott: discord.User = None, *, reason=None):
l = await bot.fetch_user(bott.id)
b = bot.get_user(bott)
if b is None:
embed = discord.Embed(description="please provide a bot id!",color=discord.Color.from_rgb(62,173,255))
mes = await ctx.reply(embed=embed)
await asyncio.sleep(5)
await ctx.message.delete()
await mes.delete()
else:
if l.id in db.find_one({"bot_id": bott.id}):
embed = discord.Embed(description="your bot is still being reviewed. Please be patient!",color=discord.Color.from_rgb(62, 173, 255))
mes = await ctx.reply(embed=embed)
await asyncio.sleep(7)
await ctx.message.delete()
await mes.delete()
else:
db.insert_one({"bot_id": bott.id,
"author": ctx.author.id,
"reason": reason})
embed = discord.Embed(description="Your bot has been entered to the queue. Be patient and wait for your bot to get accepted or declined.",color=discord.Color.from_rgb(62, 173, 255))
await ctx.reply(embed=embed)
it always says please provide a bot id
what exactly is this command
its supposed to get a bot id outside of the server and insert it into the db
you probably dont have intents
i do
show me how u set it
wym
show me what u define ur intents as
because the problem is that ur variable b is none
bot = commands.Bot(command_prefix="b!", intents=discord.Intents.all())
i should be using the variable l rather b?
hm okay
nope
hi
i'm providing a id..
i dunno about numbers as variable names
eh
there's a few other stuff wrong there too
you're trying to invoke bot.fetch_user(bott) when bott is already a commands.Bot instance
there's really no point behind it
and also if you're gonna check if b is none, don't make it optional in the first place
sorry, it's a discord.User instance
catch the error that's thrown from the command, and send an embed that way
yep, what robin said
and again consider naming ur vars better so u wont confuse urself
you also don't need to do bot.fetch_user(bott.id), you can just use bott
it's needless complication
How do I get a user's permissions without the has_permissions() decorator?
the user isn't in the guild
ohh i get what your saying
Doesn't send message
No errors
ctx.channel.send
no
Ope mb
i'm not confused abt the variable at all
@client.command()
async def add(ctx, link, reason=None):
if reason == None:
reason = 'No reason provided'
else:
return
embed = nextcord.Embed(title='Link Request', color = nextcord.Color.blurple())
embed.add_field(name='**Link**', value=f"{link}")
embed.add_field(name='**Reason**', value=f"{reason}")
channel = client.get_channel(902013562438975498)
await ctx.send("Our team has been notified about this link Join our support server")
await channel.send(embed=embed)
nextcord??
this is for discordpy
There is very to little difference
still a difference tho
and your error is indentation
no it's the return
if a reason isn't providing it's stopping the function
i have no clue what he's saying tbh
what dont u understand
discord.User returns a user object so it's already fetched
fetching it again is redundant
ure doing extra steps
?
code
@bot.command()
async def add(ctx, bott: discord.User, *, reason=None):
b = bot.get_user(bott)
if b is None:
embed = discord.Embed(description="please provide a bot id!",color=discord.Color.from_rgb(62,173,255))
mes = await ctx.reply(embed=embed)
await asyncio.sleep(5)
await ctx.message.delete()
await mes.delete()
else:
if b.id in db.find_one({"bot_id": b.id}):
embed = discord.Embed(description="your bot is still being reviewed. Please be patient!",color=discord.Color.from_rgb(62, 173, 255))
mes = await ctx.reply(embed=embed)
await asyncio.sleep(7)
await ctx.message.delete()
await mes.delete()
else:
db.insert_one({"bot_id": b.id,
"author": ctx.author.id,
"reason": reason})
embed = discord.Embed(description="Your bot has been entered to the queue. Be patient and wait for your bot to get accepted or declined.",color=discord.Color.from_rgb(62, 173, 255))
await ctx.reply(embed=embed)
that error has always been there
Also that was why it wasn't working, I think. @slate swan
bot.get_user() returns a user object, from their ID.
and it's already a user
Ye
i get it..
Wtf
yh = yea
async def add(ctx, bott: discord.User, *, reason=None):
if bott is None:
embed = discord.Embed(description="please provide a bot id!",color=discord.Color.from_rgb(62,173,255))
mes = await ctx.reply(embed=embed)
await asyncio.sleep(5)
await ctx.message.delete()
await mes.delete()
else:
if bott.id in db.find_one({"bot_id": bott.id}):
embed = discord.Embed(description="your bot is still being reviewed. Please be patient!",color=discord.Color.from_rgb(62, 173, 255))
mes = await ctx.reply(embed=embed)
await asyncio.sleep(7)
await ctx.message.delete()
await mes.delete()
else:
db.insert_one({"bot_id": bott.id,
"author": ctx.author.id,
"reason": reason})
embed = discord.Embed(description="Your bot has been entered to the queue. Be patient and wait for your bot to get accepted or declined.",color=discord.Color.from_rgb(62, 173, 255))
await ctx.reply(embed=embed)
updated ^^
so it returns none, because bott is something like <discord.User object at *some memory location*>
That's not gonna work either
Ok
Also bott will never be None, because it's a required argument. So it just raises an error
i'm guessing yk how to fix @kindred epoch
i had it = to None
then he told me to remove it
if you want a custom thing to show if they didn't mention a bot
then yeah I would add it back
Yea I do
oh
so help?
What do u need help with
It is
then do
async def add(ctx, bott: int=None, *, reason=None):
if bott==None:
embed = discord.Embed(
description="please provide a bot id!",
color=discord.Color.from_rgb(62,173,255)
)
mes = await ctx.reply(embed=embed, delete_after=5)
await mes.delete()
else:
if bott in db.find_one({"bot_id": bott}):
embed = discord.Embed(
description="your bot is still being reviewed. Please be patient!",
color=discord.Color.from_rgb(62, 173, 255)
)
mes = await ctx.reply(embed=embed, delete_after=7)
await mes.delete()
else:
db.insert_one({"bot_id": bott,
"author": ctx.author.id,
"reason": reason})
embed = discord.Embed(
description="Your bot has been entered to the queue. Be patient and wait for your bot to get accepted or declined.",
color=discord.Color.from_rgb(62, 173, 255)
)
await ctx.reply(embed=embed)
try this
bot == None isn't valid
Huh
it's if bott is None:
I prefer ==, same thing
thought so
also what I did is just cause if you're already giving the bot id, you don't need to get their ID. If your db functions only take the ID anyways, then it should be ok
What does it return now?
same as before
only need the bots id, authors id and the reason that is auto set to None
Reason is probably the problem, you can't add nothing to the db
try adding this to the first line after you define the function, before if bott==None
reason=reason if reason else 'No reason given'
Maybe the None in reason is causing it? Other than that, I'm not totally sure
remove reason i feel like it wasn't needed for what i was doing but it still ain't work
is that a command?
@bot.command()
async def add(ctx, bott: int=None):
if bott==None:
embed = discord.Embed(description="please provide a bot id!",color=discord.Color.from_rgb(62,173,255))
mes = await ctx.reply(embed=embed, delete_after=5)
await mes.delete()
else:
if bott in db.find_one({"bot_id": bott}):
embed = discord.Embed(description="your bot is still being reviewed. Please be patient!",color=discord.Color.from_rgb(62, 173, 255))
mes = await ctx.reply(embed=embed, delete_after=7)
await mes.delete()
else:
db.insert_one({"bot_id": bott,
"author": ctx.author.id})
embed = discord.Embed(description="Your bot has been entered to the queue. Be patient and wait for your bot to get accepted or declined.",color=discord.Color.from_rgb(62, 173, 255))
await ctx.reply(embed=embed)
just dont set a default value for member and stuff , use the error handler for the 'MissingRequiredArgument'
@client.command()
async def add(ctx, link, reason=None):
if reason == None:
reason = 'No reason provided'
embed = nextcord.Embed(title='Link Request', color = nextcord.Color.blurple())
embed.add_field(name='**Link**', value=f"{link}")
embed.add_field(name='**Reason**', value=f"{reason}")
channel = client.get_channel(902013562438975498)
await ctx.send("Our team has been notified about this link Join our support server")
await channel.send(embed=embed)
I have this command everything works fine but how would I add a reaction to the embed
fix the format pls
It wasn't formatted wrong
message=await ctx.send('message')
message.add_reaction('my reaction')
you can use unicode emojis in a string, or a format that I don't remember for custom emojis
What's the problem again?
Nonetype
\
sumn like <a:emojiid:>
?
And also how would I get if someone reacted to a message
The argument of nonetype is iterable
not*
@bot.command()
async def mycommand(ctx , argument):
await ctx.send(argument)```
so if you want to show an error if no argument is provided
you can actually use `on_command_error` event ( use `!d discord.on_command_error`) for better explanation
Link must start with http or https
msg=await bot.wait_for('reaction_add')
For what
with checks and whatnot
ik how to use that
why dont you do that then>
@slate swan
instead of setting value as None
if bott in db.find_one({"bot_id": bott}):
Lol
And then could I get the id of the person
i'm so noob
You could just check if it returned something, you don't need to check if the id is in the result
@slate swan try to add this
print(db.find_one({"bot_id": bott}))
send the result here
cause it could be in that
It is
Also I'm sorry if I'm asking to many questions is there a way to tell what emoji was reacted with
okay so
wym
that can be done in the check, I think
one sec
Define find_one as something and then check if it returned something, do you know how to do that?
You don't even need to define it
i mean you can do msg.reactions to return all the reactions on the message, or could can add check=(lambda r: r=='whateverreactionyouwanttocheckfor') @slate swan
Just check if it returned something or not
check this out for all of the message attributes and methods returned by the wait_for thing https://discordpy.readthedocs.io/en/master/api.html#message
no i'm so bad at py i don't understand
ik basic py but
basically saying i don't understand
!e
hi = ["hi"]
if hi:
print("it has something")
else:
print("None")
@kindred epoch :white_check_mark: Your eval job has completed with return code 0.
it has something
@slate swan add this before if bott in ... db.find_one...
Do you get what I mean after that?
what db r u using it seems lightweight
mongo
discord.ext.commands.errors.ExtensionFailed: Extension 'commands.help' raised an error: CommandRegistrationError: The command help is already an existing command or alias. I get this even tho "help" is not even a thing in a single line in any of my files
how?
add this to your bot=statement
help_command = None
bot = commands.Bot(command_prefix=ctx_prefixes,case_insensitive=True,intents=intents, help_command = None,activity=activity) like this
ah I see, ty
np
Yes
how can I do that? any tutorial?
Yes let me find it
ok ty
.
ty
user.ban
!d discord.Member.ban
await ban(*, delete_message_days=1, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Bans this member. Equivalent to [`Guild.ban()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.ban "discord.Guild.ban").
or , you can have discord.Guild.ban( user/member , reason = reason)
How do you check for a specific reaction
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
Has examples for the thing ur looking for
how to do commands.has_permissions but with a role
bruh
How can i do a cooldown for a command? For example, the bot do that action but later don't do that action
@slate swan
@slate swan
@slate swan
?
how to build a discord bot?
and even i tried it on repl
when pc shutdowns!
it will be stopped even
please help me @slate swan
U can see tutorials for begginers in YouTube
dm me here it will be chaostic
okfine
either commands.cooldown() or commands.max_concurrency()
@slate swan stop mass pinging people pls
!d discord.ext.commands.BucketType
class discord.ext.commands.BucketType```
Specifies a type of bucket for, e.g. a cooldown.
!d discord.ext.commands.has_any_role
@discord.ext.commands.has_any_role(*items)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has **any** of the roles specified. This means that if they have one out of the three roles specified, then this check will return True.
Similar to [`has_role()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.has_role "discord.ext.commands.has_role"), the names or IDs passed in must be exact.
This check raises one of two special exceptions, [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") if the user is missing all roles, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
In embed descriptions and field values, [text](link)
how do i fix this? @bot.command() async def av(ctx, *, user: discord.Member=None): if not user: user = ctx.message.author userAvatar = user.avatar_url embed=discord.Embed(title=f"{user.name}'s avatar", colour = colour) embed.set_image(url=userAvatar) await ctx.send(embed=embed)
Again, what's the issue? Are you getting any errors?
Yes i am.
when i run it, it works, but when i do !av, it doesn't wokr.
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'color' is not defined
That doesn't look like anything related to your snippet
Preferences
Define color before whenever it's used
how?, sorry btw i'm very new to coding
We have no idea what you want color to be, and your snippet doesn't use it anywhere
classmethod random(*, seed=None)```
A factory method that returns a [`Colour`](https://discordpy.readthedocs.io/en/master/api.html#discord.Colour "discord.Colour") with a random hue.
Note
The random algorithm works by choosing a colour with a random hue but with maxed out saturation and value.
New in version 1.6.
random-
Oh that exists, right
As your variable value
anywhere above your embed
i'm very sorry, i just started coding 3 days ago.
okay
still in the function
with the right scoping
Why don't you start with Python itself before getting to complex libraries?
idk
i watched some tutorials
!resources yes
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
it seemed easy 
it's not, that's why there aren't many programmers
ok so i'm pretty dumb but, where do i put the "colour = discord.Colour.random()"?
above embed=....
directly
under userAvatar=....
Where you wrote colour=colour

raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: UnboundLocalError: local variable 'colour' referenced before assignment
now it says that 😭
you put it after the embed
Because you never defined a colour variable but tried to use it
put it above
@slate swan no
Just stop
??
It's at the right place
Just look by yourself
The issue is that they're trying to use a non declared colour variable
yes
Nothing else
how do declare it?
he should indeed put the definiton above the using time
Just directly write it
After colour
....
ok
we already have what we're trying to define colour as

Then just write it
Instead of making
color = color1
Embed(color=color)
Useless declaration and code
Both are fine
You should limit variable declarations when not needed
Of course they're both fine...
what is the color blue
like what is the specific name
poor 0.2ms
Just get a hex value
hello
And write as 0xValue
discord.Colour.blue()
!d discord.Colour.blue
classmethod blue()```
A factory method that returns a [`Colour`](https://discordpy.readthedocs.io/en/master/api.html#discord.Colour "discord.Colour") with a value of `0x3498db`.
okay thanks
now it says invalid syntax :/
i'm very new to coding and odon't really understand anything
discord.colour.blue
no
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
ok
Color is a class
You should start by learning Python before doing a project like that
ok thanks
now i gotta go, ty all so much for helping.
I can't see what you even entered
You forgot to close the arguments with a closing parenthesis
Since you don't need the random color, feel free to ditch your colour variable
omg it works, thank you so much!
Take some time to get used to basic Python first for a starter
okay, thank you so much!
👍
i changed the colour to randomized btw.

Nice
give me a discord py bot example please
@lament oaronegive me a discord py bot example please
i am idiot
help me
@slate swan
learn python first
https://vcokltfre.dev/ good tutorial
Just do it then?
what
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
show ur user.nick thing
not that
wdym
the
show that part then
from discord import Attachment
from discord.ext import commands
from translate import Translator
from orc import run_ocr
class DevCommands(commands.Cog, name='Developer Commands'):
'''These are the developer commands'''
def __init__(self, bot):
self.bot = bot
@commands.command()
async def t_to(self, ctx, lang, *, arg):
await ctx.send(Translator(to_lang=f"{lang}").translate(f"{arg}"))
@commands.command()
async def t_from(self, ctx, lang, *, arg):
await ctx.send(Translator(to_lang="en", from_lang=f"{lang}").translate(f"{arg}"))
@commands.command(name="ocr")
async def ocr_(self, ctx, image):
await ctx.send(run_ocr(img_url=image))
def setup(bot):
bot.add_cog(DevCommands(bot))
print('Loaded!')
#^ cogs/homework.py
import ocrspace
import aiohttp
import os
api = ocrspace.API(api_key=os.environ['ocr_key'])
def run_ocr(img_url):
print('running ocr')
return api.ocr_url(url=img_url)
# ^ orc.py
hm
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Does discord now allow custom statuses for bots?
activity yes custom statuses no
what happened to bot.pool?
whats that
Sorry I fell asleep yesterday, I tried this but it doesn't work either even a print after the checker.start doesnt fire
nvm I think it's some other issue
Why i cant make for loop to ctx.guild.members
you can
what's wrong with your nickname 😭
oh
why so many cats 💀
Lmfao
I have a modmail code and everything works fine but it keeps saying this in the console and idk why
mod.py: https://hastebin.com/fokevekaqo.py
member.py: https://hastebin.com/etojicapeg.py
'spam' can't be converted to a number, because well it aint
I cant
why not
@outer violet here too
what do I do ¯_(ツ)_/¯
also .fetch methods are awaitables
you get the user's id
but not with the channel's name
Why not ctx.author
coroutines*
also having your close command the way it is currently, you'll have people delete random channels
same thing
discord.py is similar to discord.js 
dpy is outdated asf
Wym?
people will be able to delete any channel using the close command
Will setting it only people that have the perms to delete it prevent random people from deleting it?
how to check if the channel id provided is valid or not
does anyone have a list of all the command deco's
oops nvm i found a gist about it
await ctx.send ("https://cdn.discordapp.com/attachments/884636730945314847/901406494111727666/IMG_7080.jpg") ```
wrong one.
how do u get animated emoji code without using \name or copying the link from someone else sending it
@slate swan like
@bot.command(aliases=['Mrworldwide', 'MrWorldwide','mrworldwide'])
async def mrworldwide(ctx, arg1, arg2):
await ctx.send ("https://cdn.discordapp.com/attachments/884636730945314847/901406494111727666/IMG_7080.jpg")```
!d discord.ext.commands.Bot.get_emoji
get_emoji(id, /)```
Returns an emoji with the given ID.
thx
where do i put it
At the place u want to use that emoji....?
?
nvm
ill do smthing else
im new to code that's why
It's fine
Im gonna create a discord bot with 3 languages lmao
You should add a function by which people can change the language of the bot
Noo i mean programming languages like python java and c++
Just for fun
great!!
there are many libraries that are active currently, but I prefer disnake
@lusty swallow
yes disnake ftw 😫
not discord bots related
try ctx.author.avatar_url
