#discord-bots
1 messages · Page 445 of 1
that was a joke
my question wasn't
and yes probably
i mean
wait
did you have to ask here if you knew already
yes
well that explains a lot to me
how do you make a text channel with a bot
!d discord.Guild.create_text_channel
await create_text_channel(name, *, overwrites=None, category=None, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.TextChannel "discord.TextChannel") for the guild.
Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.
The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/stable/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
With 18, but for some reason if one of them needs one more digit, the others must go up.
how can I make it so anyone can message my bot even if they dont share a server with it?
You can't.
wouldn't I need guild how would I define guild
It can be ctx.guild or you can get a guild using bot.get_guild.
!d discord.ext.commands.Bot.get_guild
get_guild(id)```
Returns a guild with the given ID.
I can't?
Remember that the bot must have manage_channels permissions.
Yes. A bot cannot accept friend requests.
The only way a user can dm a user (a bot is considered a user) while they don't share a server with them is to add them as a friend.
so there's no way to like change settings to accept all dms?
Nope.
oh
hey how do i put an emoji thats just in one server into my embed
\:emoji:
Now that discord.py is ceasing development what is a good alternative?
!pypi disnake it's in beta and very soon will be out. It has the same syntax and also includes slash commands, buttons, user commands, etc.
!pypi dislash.py is made by the developer of disnake.
cant they just port dislash to disnake
ah is that for server only emojis
and remove the monkeypatching
because when I used the universal, it worked fine
Yes. If you want a unicode of a normal emoji you can use !charinfo :emoji:.
!charinfo 👋
\U0001f44b: WAVING HAND SIGN - 👋
ok ty let me try it
This looks cool/useful, thanks!
No problem.
if str in message.content
ty
if "word" in message.content
appreciate it
@commands.Cog.listener(name='on_message')
async def NoBadWords(self, message):
if message.guild is None:
return
if message.guild.id == 871629438952022076:
if "BadWord" in message.content:
await message.author.ban()```
Would this work? Im pretty sure banning like this doesnt work but feel free to let me know how to do it
how do you create a webhook inside a chanmel
its not sending the in server emoji with the ":emoji:"
is it supposed to be the emoji ID
so I have this event for a starboard which works for the most part except it sends a new msg for every user that reacts rather than editing the existing msg. I'm not sure where I'm going wrong so does someone mind pointing out my mistake. here is my code: https://sourceb.in/je3f7lYMNw
I suggest making it check in the lower case of the message.content (message.content.lower()).
i didnt anderstand the problume
Full traceback?
what?
\
without the space will be !python
The full error.
send
You send it..
here it is
can inserver emojis be used in title
Embed title?
yes
Let me have a look.
someone told me it doesnt work in titles
yes it doesn’t
It does.
huh
AYO
ah thank you
No problem.
that’s a modified discord client isn’t it?
THATS KINDA SUS
Yeah, but I use it just for the theme.
that could be why it works
!e
!eval [code]
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code
block. Code can be re-evaluated by editing the original message within 10 seconds and
clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an
issue with it!*
also they’re all against ToS
I'm aware of that. However, I don't do anything harmful or stupid with it, so I should be clear.
I only give my eyes a better experience, and that doesn't bother anyone, does it?
Discord cares if you use plugins that let you see certain things / do certain things you shouldn't, other than that if you use themes they could't care less
I'm agreeing with you btw^
someone knows?
I'm not sure what package is that, but I think that "ZeroNodesConnected" means that whatever you are doing requires nodes and there are none connected.
we cant help with anything involving lavalink
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
wavelink is a wrapper for it
What's lavalink?
a music player specifically made for discord bots
Oh ok
Yes. And it violates YouTube's ToS since it downloads audio from videos.
is that why groovy is ending its service
yes
Yes
Yep.
You can't use markdown in an embed's title.
Says who?
wdym
AYO
Does it?
Yeah
Huh, then how'd I use it?
unless you have a modified client
It does.
what should i change the title to to contain the emoji
Embeds are weird.
you have a modified client
why is mine not working
we’re talking about normal discord
I don't think that matters...
What do you mean by this.
It doesn't
it does normally it shouldn’t work
I didn't touch my discord.py in anyway other than installing it, and I can put emojis in my title
I will check it on Discord from the web.
He doesn't have any plugins to affect the client to my knowledge
Only a theme
which uses CSS, not JS
It does.
@bronze wigeon what should i change my title to
thats kind of sus
@covert igloo does it work for you
I need to test this theory
let me try it
Are they in the server..?
The bot may need to be in the server(s)
Hm
Haven't tried it out.
It does for me.
ah yes, thank you
its not working for me
Same here.
Try it in the description and not the title
not sure why it isnt working for me
Discord is really weird.. try seeing it on the web? Maybe you are missing an update. I'm not sure.
@commands.Cog.listener(name='on_message')
async def AutoBanNWord(self, message):
if message.guild is None:
return
if message.guild.id == 871629438952022076:
if "BadWord" in message.content.lower():
reason = "[AutoBan] Racism / Hard R"
await message.author.guild.ban(reason=reason)
```
Does this look good?
Emojis work too.
wtf
i could swear this didnt work before
Yeah, but just make sure that the string you are looking for in the message.content.lower() is also in lowercase.
it must be some new thing
Well, yes it didn't work before.
yep of course
that’s why i was confused
ok so emojis do actually work on titles?
Lmao gotcha.
Is your emoji animated btw?
Try another emoji.
probably the ID is wrong
Then you probably got the ID wrong.
Is your bot in the same server as the emoji?
ok let me try it
yes
Note: you can't directly copy the id of an emoji from a message
where is it then
i was right clicking the emoji after sending it and copying the ID
No. Do like in that image.
\ :emoji: and remove the space between :emoji: and \ .
I'm actually very interested in seeing the actual emoji.
Thank you.
@dapper cobalt @visual island thank you, it was just an ID issue


this is what i have for unbans rn
it doesnt unban when you use ID
hold on let me try it
typehint it
Use discord.User.
where
you can directly do await member.unban() instead of making 10 lines of code
async def unban(self, ctx, user: discord.User):
try:
await ctx.guild.unban(discord.Object(id=user.id))
except:
return await ctx.send(f"**{user}** is not banned!")
await ctx.send(f"**{user}** has been unbanned.")
why discord.Object
you have a User object
pass that in directly
It will take an ID, or a username#discriminator
?
Some people don't know how to get an ID.
How do i check if the message author is the bot
if message.author == client.user
just pass in the User object directly
Its in an event
Oh right. I didn't understand what you meant.
Guild.unban takes in an abc.Snowflake
why do you have self running through
would it work without it
I don't know why I use it, I just like it there, 
Yes.
ok
Because that's a class.
I was replying to @hasty iron btw.
ah ty

i realize
I just yoinked the code from my bot.
no reason argument lolololoollol so bad
Imagine unbanning for a reason.
yeah true
@commands.Cog.listener(name='on_message')
async def AutoBanNWord(self, message):
if message.guild is None:
return
if message.guild.id == 871629438952022076:
if "badword" in message.content.lower():
reason = "[AutoBan] Racism / Hard R"
me = self.bot.get_user(101118549958877184)
other = self.bot.get_channel(873078748847669259)
try:
await message.author.send(f"You have been banned from {message.guild.name} for being a racist.")
except:
pass
await message.author.guild.ban(reason=reason)
if message.author == self.bot.user:
return
else:
await me.send(f"{message.author.name} was just banned in {message.guild.name}\n**Message Content**{message.content}")
await other.send(f"{message.author.name} was just banned from this server for being racist {me.mention}")```
Would this completely ignore its self? i may be overthinking this but i really dont wanna fuck anything up lmao
ah
Put the if message.author == self.bot.user at the top.
Its been a while since ive made anything automated using on_message events
@hasty iron How's the progress on your discord.py fork? 
Understandable.
How can i ignore a whole channel category?
like
if message.category.id == ID:
return```
would it work like this?
category = self.bot.get_channel(category ID)
if message.channel in category.text_channels:
return
ahh
Does a discord.Message object have a category attribute?
How could I forget about that.
yoink me a mute and unmute rq og 💀
ty
I use a mongo database for that tho.

I store mutes so if a user rejoins they would get muted again too.
oo
why do everyone uses Mongo tho..
I didn't see any bot that has that, so I didn't have hope to be the first one to do it.
It looks pretty cool and easy to remotely control.
it isn't async isn't it
!pypi motor
oh
(I don't use motor, but I make async functions myself)
Is anyone able to help me troubleshoot these errors?py Ignoring exception in on_raw_reaction_add Traceback (most recent call last): File "/home/snowyjaguar/.local/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event await coro(*args, **kwargs) File "/home/modmail/cogs/events.py", line 331, in on_raw_reaction_add if len(stared_message.reactions.count) == stars[1]: TypeError: object of type 'builtin_function_or_method' has no len() Ignoring exception in on_raw_reaction_add Traceback (most recent call last): File "/home/snowyjaguar/.local/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event await coro(*args, **kwargs) File "/home/modmail/cogs/events.py", line 319, in on_raw_reaction_add embed.set_footer(text = f"Stars: {len(stared_message.reactions.count)}") TypeError: object of type 'builtin_function_or_method' has no len() Ignoring exception in on_raw_reaction_add Traceback (most recent call last): File "/home/snowyjaguar/.local/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event await coro(*args, **kwargs) File "/home/modmail/cogs/events.py", line 319, in on_raw_reaction_add embed.set_footer(text = f"Stars: {len(stared_message.reactions.count)}") TypeError: object of type 'builtin_function_or_method' has no len() Ignoring exception in on_message_delete Traceback (most recent call last): File "/home/snowyjaguar/.local/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event await coro(*args, **kwargs)my code is https://sourceb.in/AgbveWoyoz
async def get_balance(user_id:int):
economy.find_one({"_id": ctx.author.id})
#some more stuff
On line 331, I assume that stared_message.reactions.count returns an integer, and you are trying to get the len() of an integer?
user = member.mention
Hope you know that this doesn't randomly make blocking code asynchronous.
for channel in ctx.channel.category.id == 873078702861336606:
print(channel.name)```
how could i do this properly lmfao, im trying to print all of the channels under the category
I thought it did.. Well, I will move to motor eventually. Thanks for the info.
word, thanks

thats kinda what i thought but im autistic so i couldnt think lmao
.count()
so am i lmao
but yeah it already returns int
twins, lmaooooo
A love story is about to start, I guess.
LMFAO
anyone?
@dapper cobalt how can i get the bot to send a ban dm to the user thats banned
it's a bit of a rabbit hole tbh. discord.Message returns a list of reactions. each reaction then has it's own count of how mnay times it apears
Send it before banning.
i gotchu
okay thanks I'll try this
ill send u my code
plug 
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
count = 0
for reaction in message.reactions:
count += reaction.count()
I think this would work? I never tried this.
await member.send(f"You were muted in the server {guild.name} for {reason}")
whoops
await member.send(f"You were muted in the server {guild.name} for {reason}")
Is it guild or ctx.guild?
well it says muted but just changed it to banned
Do you have guild defined?
!d discord.CategoryChannel
class discord.CategoryChannel```
Represents a Discord channel category.
These are useful to group channels to logical compartments.
`x == y` Checks if two channels are equal.
`x != y` Checks if two channels are not equal.
`hash(x)` Returns the category’s hash.
`str(x)` Returns the category’s name.
You can check for the CategoryChannel object's attributes there.
yea it aint work for me with just guilded
Guilded..?
try what he's saying then
That's Discord.
yk what he meant lol
guild i mean
try ctx.guild
ok
import discord
import asyncio
import random
import keep_alive
import json
import os
import re
from discord.ext import commands
if you put that at the top of allllllll of your code then it should automatically define guild
from discord.ext import commands
What? 
i put that too
i didnt have guild defined
yes
thats why it wasnt working
I called it.
it should at least 🤷♂️
im glad
i honestly dont know how i defined guild so i apologize for that
Where did you define it?
guild = ctx.guild?
but when you do the "import discord" im ALMOST certain that it defines it
no
Back up.
What is going on here?
You can highlight "guild" and see where you defined it.
They're saying that import discord will automatically define guild.
i said i think nowhere did i say it does lol
import discord
@bot.command()
async def guildname(ctx):
await ctx.send(guild.name)
and by "they" you mean me
Yeah, I didn't want to assume your gender.
@crude crater ayo u got mute and unmute fo me 💀
like as in you're asking?
because if you are then yeah ofc lmao
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
@client.command(description="Mutes the specified user.")
@commands.has_permissions(manage_messages=True)
async def mute(ctx, member: discord.Member, *, reason=None):
guild = ctx.guild
mutedRole = discord.utils.get(guild.roles, name="Muted")
#Mute---------------------------------------------------------Start
if not mutedRole:
mutedRole = await guild.create_role(name="Muted")
for channel in guild.channels:
await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=False)
await member.add_roles(mutedRole, reason=reason)
await ctx.send(f"Muted {member.mention} for reason {reason}")
await member.send(f"You were muted in the server {guild.name} for {reason}")
or not
@client.command(description="Unmutes a specified user.")
@commands.has_permissions(manage_messages=True)
async def unmute(ctx, member: discord.Member):
mutedRole = discord.utils.get(ctx.guild.roles, name="Muted")
await member.remove_roles(mutedRole)
await ctx.send(f"Unmuted {member.mention}")
await member.send(f"You were unmuted in the server {ctx.guild.name}")
async def mute(ctx, member:discord.Member):
muterole = discord.utils.get(ctx.guild.roles, name="muted")
if muterole == None:
muterole = await ctx.guild.create_role(name="muted", permissions=discord.Permissions(send_messages=False)
await member.add_roles(muterole)
this is the unmute
Both mute commands could be better.
Where can I find documentation for different versions of the Discord API?
why?
That's more basic but simpler.
You'll realize when people start using the command.
Oh don't make me send my bot's mute command.
I could send mine too.
show me lmfao
bro nobody cares, i dont mean to be rude but like seriously
Bet.
ugh
Hey @dapper cobalt!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
It does matter though.
LMAO
Damnit.
ong as long as it works idc
One second.
lol
Dm's
yes
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.pydis.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.
@vale pendant https://paste.pythondiscord.com/aguhojuxes.py
can u dm it to me
don’t think there is
That's my mute command.
so i have it
190 lines.
I'll send mine.
dog what
Hold, that's the mute and unmute, I didn't realize.
and you say this when mine does what its supposed to, it mutes them and then sends a message to the channel and them
Ah no, really?
useless
190 lines for a mute comand???
151*
151 for a mute command is wasting your time lmfaooo
Read the code.
its literally for a MUTE
@dapper cobalt https://paste.pythondiscord.com/iyocaxutit.less
Advanced.
what do you need it for
@crude crater dm me the mute and unmte
The heck is this? 
its a discord bot 🤣
?
Advanced discord bot.
and?
You could make it better.
how much money do you make off of your discord bot?
Better than normal.
Don't want it timed.
I don't make money from my public bot, but I make from making custom bots.
- I already have logs for muted command.
yikesss
Erm, just trying some stuff out. Making some HTTP requests. I'm finding that I get back json with fields that are not in the docs. But it's not clear to me which version of the API those docs document.
Nor do I care about people having their own mute role.
bro i dont mean to be rude but you're cringe asf
exactly
@crude crater That is actually quite rude.
well iirc sometimes the docs aren’t accurate and it takes some time for them to update
I was going to show you how much I made since you've brought that up.
arent always*
i dont wanna see, idc
@crude crater does ur mute have a timer
- the bot that I made is strictly for anti-nuke.
or do you need to unmute manually
Okay then.
no, i was thinking about putting it in but my bots only been made for like 2 days
i do have a tempban though
so ill just do the same thing with that but with the mute
Ah right. Thanks anyway. I'll probably go and bother the people in the API server now 😄
does it just take away viewing that channel
or any channels for that matter
when i used it, it removed the person i muted from the channel list
like you couldnt see them in the right
you also have to fix the perms in your server
i did read_messages=True
Then they didn't have send messages permissions nor read messages.
fixed read messages
what perms do u have it as
What about view_channel?
idk ill have to look
you dont need to do it in code lmfao
you can just do it in the discord server
in the role perms
!d discord.Permissions
class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.
The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.
Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.update "discord.Permissions.update").
You can do it in both code and through the server.
its easier to do it in the server
Are there any good alternative Reddit API wrappers from asyncpraw
!pypi reddit-easy
doing it in code just clutters stuff more when you can just click a button
!pypi redditeasy
So does send messages and read messages tho. 
what?
You can set the send_messages and read_messages from the server too.
@crude crater i have read_messages=True but it still is removing them from the channel member list
thats why im saying do it through the role perms
Check if the role has access to the channels.
channel perm or actual role perm
both
Channel permissions.
so I'm not sure where I'm going wrong but every time a new user reacts on a msg that is already stared it sends the msg to the starboard again. I want it to only send to the starboard once and then every other time it should update the footer of the first msg. this is my code https://sourceb.in/rLvSvU6yRd
Don't ask to ask, just ask.
im asking blanket, because blankets a friend and i know he will be able to help
I'm sorry but that seems a little too complicated so I can't help you.
Ah okay.
@asyncSlot()
async def filter_id(self) -> discord.abc.Messageable:
_id = self.id_edit.text()
try:
_id = int(_id)
try:
channel = await self.bot.fetch_channel(_id)
if channel:
print('z')
return channel
except:
pass
try:
user = await self.bot.fetch_user(_id)
print(user)
if user:
print('x')
return user
print('e')
except:
pass
except Exception as e:
print(e)
users = list(filter(lambda m: m.name.startswith(self.id_edit.text), bot.users))
if len(users) == 1:
return users[0]
return None
finally:
print('f')
return None
@asyncSlot()
async def trigger_message(self):
msg = QMessageBox()
if not self.id_edit.text:
msg.setText('Specificy an id')
msg.exec_()
return
else:
final_object = self.filter_id()
if final_object:
print(final_object)
await final_object.send(self.message_edit.text if self.message_edit.text else 'Hello')
return
msg.setText('Invalid id')
msg.exec_()
why the hell is this erroring? AttributeError: '_asyncio.Task' object has no attribute 'send' it errors half way through filter_id
hello
it errors on the await final_object.send(self.message_edit.text if self.message_edit.text else 'Hello')
PS C:\Users\caede\Desktop\Github\integrated-bot-gui> & C:/Users/caede/AppData/Local/Programs/Python/Python39/python.exe c:/Users/caede/Desktop/Github/integrated-bot-gui/bot-gui/main.py
<Task pending name='Task-72' coro=<MainWindow.filter_id() running at c:\Users\caede\Desktop\Github\integrated-bot-gui\bot-gui\src\Mainwindow.py:97> cb=[asyncSlot.<locals>._error_handler() at C:\Users\caede\AppData\Local\Programs\Python\Python39\lib\site-packages\qasync\__init__.py:775]>
Traceback (most recent call last):
File "C:\Users\caede\AppData\Local\Programs\Python\Python39\lib\site-packages\qasync\__init__.py", line 777, in _error_handler
task.result()
File "c:\Users\caede\Desktop\Github\integrated-bot-gui\bot-gui\src\Mainwindow.py", line 150, in trigger_message
await final_object.send(self.message_edit.text if self.message_edit.text else 'Hello')
AttributeError: '_asyncio.Task' object has no attribute 'send'
final_object is a task
how?
no clue, check your function that returns it
filter_id returns it and its been breaking
send code for that
its in the code above
i print(user) and it shows my name, i return user, it prints the x but not the e, is there some voodoo shit where it cant return in a try except or smthing?
that could be it
you dont return a task anywhere in your function
its worked fine for everything else
i didnt await what?
oh fuck
yea
well at least it gave a different error this time lol
Exception in callback <TaskWakeupMethWrapper object at 0x0000017FDE4A9F40>(<Future finished result=None>)
handle: <Handle <TaskWakeupMethWrapper object at 0x0000017FDE4A9F40>(<Future finished result=None>)>
Traceback (most recent call last):
File "C:\Users\caede\AppData\Local\Programs\Python\Python39\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
RuntimeError: Cannot enter into task <Task pending name='Task-1' coro=<MainWindow.start() running at c:\Users\caede\Desktop\Github\integrated-bot-gui\bot-gui\src\Mainwindow.py:55> wait_for=<Future finished result=None> cb=[asyncSlot.<locals>._error_handler() at C:\Users\caede\AppData\Local\Programs\Python\Python39\lib\site-packages\qasync\__init__.py:775]> while another task <Task pending name='Task-72' coro=<MainWindow.trigger_message() running at c:\Users\caede\Desktop\Github\integrated-bot-gui\bot-gui\src\Mainwindow.py:149> cb=[asyncSlot.<locals>._error_handler() at C:\Users\caede\AppData\Local\Programs\Python\Python39\lib\site-packages\qasync\__init__.py:775]> is being executed.
blanket it gives this error even without the #await final_object.send(self.message_edit.text if self.message_edit.text else 'Hello')
final_object = await self.filter_id()
print(final_object)
if final_object:
print(final_object)
#await final_object.send(self.message_edit.text if self.message_edit.text else 'Hello')
return
msg.setText('Invalid id')
msg.exec_()
``` this raises that error
i think it errors on the msg.setText('Invalid id') msg.exec_()
do you mean what I'm attempting to do is complicated or the way I'm doing it is overly complex?
What I am trying to do is listen for a on_raw_reaction_add event which uses one of the reactions in my list of star_reactions. the db will log the following things:
- the ID of the message which was reacted to
- the amount of reactions it has (the inclusive total of each reaction in
star_reactions) - the id of the msg the bot sends to my starboard channel
I then want the footer of the embed the bot sends to show how many stars the msg has (pulled from the db). The bot should edit the msg each time a new star gets added so as the reflect the db value.
Does that make more sense? Do you think i'm on the right track to achieving my aim or have i gone wrong somewhere.
wtf
@asyncSlot()
async def filter_id(self) -> discord.abc.Messageable:
_id = self.id_edit.text()
main = None
try:
_id = int(_id)
channel = self.bot.get_channel(_id)
if channel:
main = channel
user = await self.bot.fetch_user(_id)
if user:
main = channel
except Exception as e:
print(e)
users = list(filter(lambda m: m.name.startswith(self.id_edit.text), bot.users))
if len(users) == 1:
main = users[0]
finally:
print(main)
return main
``` why is this returning none, im specifying a valid id
I have an error when i tried ban the user and there dms are closed it would not ban the user
@commands.has_permissions(ban_members=True)
@commands.command()
async def ban(self, ctx, user: discord.Member, *, reason="No reason provided"):
if ctx.author.top_role > user.top_role or ctx.author == ctx.guild.owner:
if user == ctx.author:
return await ctx.send("***:no_entry: You can't softban yourself...***")
ban = discord.Embed(color=0x2f3136, title=f":heartbroke_roles: New User Banned", description=f"**```{user} Has Been\nBanned By {ctx.author}```**")
ban.set_footer(text =f"{ctx.author} Has Banned {user}")
ban.set_thumbnail(url = user.avatar_url)
await ctx.channel.send(embed=ban)
embed=discord.Embed (title=f"Banned",description=f":heartbroke_member: **_You have been \nbanned In_\n{ctx.guild.name} _by_** {ctx.author}\n\n:heartbroke_rules: **Reason:** {reason}",color=0x2f3136 )
await user.send(embed=embed)
await user.ban(reason=reason)
@ban.error
async def ban_error(self, ctx, error):
if isinstance(error, (commands.MissingPermissions)):
embed = discord.Embed(color=0x2f3136, title="You Need **Permission** To Ban That User")
await ctx.send(embed=embed)
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=0x2f3136, title="Mention A User To Get Them **BAN**")
await ctx.send(embed=embed)```
how to send a file?
@manic wing Get rid of that bare except, chances are there's another issue you haven't anticipated throwing a different error from the one you expect
await messageable.send(file=discord.File('path/to/dir'))
@dapper cobalt how should i do error messages
Catch whatever specific error you want to catch
okay
like if a command is used wrong
thanks!
If it stores the message's ID then you can do:
- check if there's already an ID stored that's equal to the message's ID
- generate a unique ID for each "starred message" and store it
- put the generated ID in the embed's footer
- check in the channel's history using the
discord.TextChannel.history()and try to see if there's any embed that has the unique ID in its footer - if you find the embed, you now have the embed's object, edit it
(I'm not very familiar with this, but this is all I could think of at 3 AM)
try:
await user.send(embed=embed)
except:
pass
alright
Where It Should Go?
would this be screwing any of it up
the typehint
Replace await user.send(embed=embed) with that.
dude what
class discord.abc.Messageable```
An ABC that details the common operations on a model that can send messages.
The following implement this ABC...
should be fine
this
print(self.bot.get_user(298043305927639041))
print(await self.bot.fetch_user(298043305927639041))
return self.bot.get_user(_id)
``` these 2 print me; ```py
final_object = await self.filter_id()
print(final_object)``` this prints `None`...What?
@asyncSlot()
async def filter_id(self) -> discord.abc.Messageable:
_id = self.id_edit.text()
main = None
if not _id.isalpha():
print(self.bot.get_user(298043305927639041))
print(await self.bot.fetch_user(298043305927639041))
return self.bot.get_user(_id)
print(e)
users = list(filter(lambda m: m.name.startswith(self.id_edit.text), bot.users))
if len(users) == 1:
main = users[0]
@asyncSlot()
async def trigger_message(self):
msg = QMessageBox()
if not self.id_edit.text:
msg.setText('Specificy an id')
msg.exec_()
else:
final_object = await self.filter_id()
print(final_object)
if final_object:
print(final_object)
await final_object.send(self.message_edit.text if self.message_edit.text else 'Hello')
return
ive been stuck on this for an hour and its killing me
What's self.id_edit.text() returning
an str
i spent 10 minutes with it erroring because i didnt put the (), i thought it was a property :/
aren't channel history searches limited to within the last 14 days or am i crossing wires with something else
@dapper cobalt how do i make error message og
Thanks @dapper cobalt
!d discord.Client.get_user
get_user(id)```
Returns a user with the given ID.
Would get_user() throw an error if _id isn't an int?
fetch_user raises error
yes, but im not getting a typeerror
Or, would it just return None
but both
print(self.bot.get_user(298043305927639041))
print(await self.bot.fetch_user(298043305927639041))
``` these both print my user object
its something whack with the returns
It's not being given an int
I'm not sure, but you can try and see if it's in the last 100 messages and if it isn't then just send it again.
@client.command()
async def sp(ctx, user: discord.Member = None):
if user == None:
user = ctx.author
pass
if user.activities:
for activity in user.activities:
if isinstance(activity, Spotify):
embed = discord.Embed(
title=f"{user.name}'s Spotify",
description="Listening to {}".format(activity.title),
color=0xC902FF)
embed.set_thumbnail(url=activity.album_cover_url)
embed.add_field(name="Artist", value=activity.artist)
embed.add_field(name="Album", value=activity.album)
embed.set_footer(text="Song started at {}".format(
activity.created_at.strftime("%H:%M")))
await ctx.send(embed=embed)```
can someone help the command gives no error but the bot would not reply
No problem.
Error message og?
okay thanks for clarification
return self.bot.get_user(int(_id)) I would imagine you'd want to give it an int, if it's not throwing an error otherwise I can only assume that discord.py tries to convert it for you, or it just decides to return None
So it's worth a shot
i made it an int and it worked - do returns not work inside try's and except's? it was int before i think
it was int before and still didnt work
error message that shows how to use a command
lets say someone does ".mute @..." without a reason
it would pop up saying they need to have a reason
Similar to this?
yes
Anyone :(
To get the command's name you can use ctx.command and for the missing argument you can use error.missing_params.name.
ok ill try it
@client.command()
async def sp(ctx, user: discord.Member = None):
if user == None:
user = ctx.author
pass
if user.activities:
for activity in user.activities:
if isinstance(activity, Spotify):
embed = discord.Embed(
title=f"{user.name}'s Spotify",
description="Listening to {}".format(activity.title),
color=0xC902FF)
embed.set_thumbnail(url=activity.album_cover_url)
embed.add_field(name="Artist", value=activity.artist)
embed.add_field(name="Album", value=activity.album)
embed.set_footer(text="Song started at {}".format(
activity.created_at.strftime("%H:%M")))
await ctx.send(embed=embed)```
can someone help the command gives no error but the bot would not reply
ctx.command.name
@dapper cobalt can u help?
ctx.command will be the parent and the command, ctx.command.name will only be the command. So if it has a parent it would be better to show it.
Oh right, my bad.
can anyone help?
But I meant if it's something like this, ctx.command.name will be only "add" and not "filter add".
@manic wing Not entirely sure why the previous version went wrong, in the future try to avoid having bare excepts, since it makes it a lot easier to locate unexpected issues
Sorry but I'm not very familiar with activities.
okay, i dont think await self.bot.fetch_user in a try works...? py Exception in callback <TaskWakeupMethWrapper object at 0x00000149F7EB9DC0>(<Future finished result=N File "C:\Users\caede\AppData\Local\Programs\Python\Python39\lib\asyncio\events.py", line 80, in _run self._context.run(self._callback, *self._args) RuntimeError: Cannot enter into task <Task pending name='Task-1' coro=<MainWindow.start() running at c:\Users\caede\Desktop\Github\integrated-bot-gui\bot-gui\src\Mainwindow.py:55> wait_for=<Future finished result=None> cb=[asyncSlot.<locals>._error_handler() at C:\Users\caede\AppData\Local\Programs\Python\Python39\lib\site-packages\qasync\__init__.py:775]> while another task <Task pending name='Task-71' coro=<MainWindow.trigger_message() running at c:\Users\caede\Desktop\Github\integrated-bot-gui\bot-gui\src\Mainwindow.py:148> cb=[asyncSlot.<locals>._error_handler() at C:\Users\caede\AppData\Local\Programs\Python\Python39\lib\site-packages\qasync\__init__.py:775]> is being executed. Exception in callback <TaskWakeupMethWrapper object at 0x00000149F772AC40>(<Future finished result=None>) handle: <Handle <TaskWakeupMethWrapper object at 0x00000149F772AC40>(<Future finished result=None>)> Traceback (most recent call last): File "C:\Users\caede\AppData\Local\Programs\Python\Python39\lib\asyncio\events.py", line 80, in _run self._context.run(self._callback, *self._args) RuntimeError: Cannot enter into task <Task pending name='Task-9' coro=<ConnectionState._delay_ready() running at C:\Users\caede\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\state.py:415> wait_for=<Future finished result=None>> while another task <Task pending name='Task-71' coro=<MainWindow.trigger_message() running at c:\Users\caede\Desktop\Github\integrated-bot-gui\bot-gui\src\Mainwindow.py:148> cb=[asyncSlot.<locals>._error_handler() atC:\Users\caede\AppData\Local\Programs\Python\Python39\lib\site-packages\qasync\__init__.py:775]> is being executed.
@asyncSlot()
async def filter_id(self) -> discord.abc.Messageable:
_id = self.id_edit.text()
main = None
if not _id.isalpha():
_id = int(_id)
try:
channel = self.bot.get_channel(_id)
if channel:
main = channel
except Exception as e:
print('SAFE', e)
try:
user = await self.bot.fetch_user(_id)
if user:
main = channel
except Exception as e:
print('SAFE ', e)
return main
users = list(filter(lambda m: m.name.startswith(self.id_edit.text), bot.users))
if len(users) == 1:
main = users[0]
return main
i dont get this
i dont see why api calls arent working
yep, and its gonna make me go psycho
i am going mental
@asyncSlot()
async def filter_id(self) -> discord.abc.Messageable:
_id = self.id_edit.text()
main = None
if not _id.isalpha():
print('hi')
_id = int(_id)
channel = self.bot.get_channel(_id)
if channel:
return channel
user = self.bot.get_channel(_id)
if user:
return user
users = list(filter(lambda m: m.name.startswith(self.id_edit.text()), self.bot.users))
if len(users) == 1:
return users[0]
return None
``` this doesnt even work
tf
Traceback (most recent call last):
File "C:\Users\caede\AppData\Local\Programs\Python\Python39\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
RuntimeError: Cannot enter into task <Task pending name='Task-104' coro=<DiscordWebSocket.send_heartbeat() running at C:\Users\caede\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\gateway.py:596> cb=[_chain_future.<locals>._call_set_state() at C:\Users\caede\AppData\Local\Programs\Python\Python39\lib\asyncio\futures.py:391]> while another task <Task pending name='Task-102' coro=<MainWindow.trigger_message() running at c:\Users\caede\Desktop\Github\integrated-bot-gui\bot-gui\src\Mainwindow.py:139> cb=[asyncSlot.<locals>._error_handler() at C:\Users\caede\AppData\Local\Programs\Python\Python39\lib\site-packages\qasync\__init__.py:775]> is being executed.
its
#msg.setText('Invalid id')
# msg.exec_()
``` this is erroring
(when it wasnt blanked out)
that was cuasing the error i think
yeah it was
tf
how can I create a new webhook
await channel.create_webhook
!d discord.TextChannel.create_webhook
await create_webhook(*, name, avatar=None, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a webhook for this channel.
Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.
Changed in version 1.1: Added the `reason` keyword-only parameter.
@sweet pilot
ok so it just gives a really weird error when i use QMessageBox
i can work with that ig
Is it possible to make an if state ment like this for bots:
@bot.command()
async def choose(ctx):
# here the bot asks a questiona and await for three options test test2 test3
# after that it makes an if statement
#example: if choose==test1
ctx.send("cookie")
# or like ctx.role(role) which basically gives a person a role ```
and stuff like that
it was just a random example of giving a person a role:)
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
File "/home/snowyjaguar/.local/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "/home/modmail/cogs/events.py", line 316, in on_raw_reaction_add
embed.set_footer(text = f"Stars: {str(reaction.count())}")
TypeError: 'int' object is not callable```not sure why this is happening as I'm converting it to a string . the codes too long to send here so you ca find it here: https://sourceb.in/R4ha5fuqRt
Ah okay. But to give the author a role it's ctx.author.add_roles(role).
I just want to make 1 little 2 menu option
yeah I got that
and I need help cuz I have no idea how to do that part I said above
I know some of it except the if statements
I haven't gone over those
print(type(str(reaction.count())) == int)
Try to see if it's a string or an int.
count is not a method
await ctx.send()
How do i make my ban command says "you can not ban that person"
yeah as I said It was just an example
like if the try run the ban command on the owner
@commands.has_permissions(ban_members=True)
@commands.command()
async def ban(self, ctx, user: discord.Member, *, reason="No reason provided"):
if ctx.author.top_role > user.top_role or ctx.author == ctx.guild.owner:
if user == ctx.author:
return await ctx.send("***:no_entry: You can't softban yourself...***")
ban = discord.Embed(color=0x2f3136, title=f":heartbroke_roles: New User Banned", description=f"**```{user} Has Been\nBanned By {ctx.author}```**")
ban.set_footer(text =f"{ctx.author} Has Banned {user}")
ban.set_thumbnail(url = user.avatar_url)
await ctx.channel.send(embed=ban)
embed=discord.Embed (title=f"Banned",description=f":heartbroke_member: **_You have been \nbanned In_\n{ctx.guild.name} _by_** {ctx.author}\n\n:heartbroke_rules: **Reason:** {reason}",color=0x2f3136 )
try:
await user.send(embed=embed)
except:
pass
await user.ban(reason=reason)
@ban.error
async def ban_error(self, ctx, error):
if isinstance(error, (commands.MissingPermissions)):
embed = discord.Embed(color=0x2f3136, title="You Need **Permission** To Ban That User")
await ctx.send(embed=embed)
if isinstance(error, commands.MissingRequiredArgument):
embed = discord.Embed(color=0x2f3136, title="Mention A User To Get Them **BAN**")
await ctx.send(embed=embed)```
Make parameters using if elif
Check if the member is == the guild's owner.
What? 
What if its like a user with the same role or higher role
like if "kutie" trys ban an admin
It doesn't really matter for the bot if the author's role hierarchy is higher or lower than the member's role hierarchy, it depends on the bot's role.
how do you make a bot send a message and make it await for messages to go on with the code
!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/stable/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
!ban
alright
!d discord.Reaction.count 
Number of times this reaction was made
does this work? py if ctx.author.top_role > user.top_role or ctx.author == ctx.guild.owner: if user == ctx.author: return await ctx.send("***:no_entry: You can't softban yourself...***")
Oh I got you wrong, my bad.
How is the author's role going to be above their own role?
yeah that didn't help, think the error handler is eating it up bc it just keeps returning the TypeError: 'int' object is not callable error
reaction.count not reaction.count().
As Vaskel said, it's an attribute not a method, so it's not callable.
@bot.command()
async def ifstate(ctx):
await ctx.send("Hi whats your name:")
if ctx.content.startswith("test1"):
await ctx.send("Correct")```
I got the bot to send Hi whats your name atleast... @dapper cobalt I did stuff wrong uh I need help
ctx.content will be starting with [prefix]ifstate.
Use wait_for to make it wait for a message.
so ctx.wait_for("test"):
@bot.command()
async def ifstate(ctx):
await ctx.send("Hi! What's your name?")
name = await bot.wait_for("message", check=lambda m: m.author == ctx.author)
await ctx.send(f"Alright, your name is {name.content}")
How can I loop in a list/text file?
for variable in list:
Oh okay
I'm not sure how can you loop through a text file.
!d discord.Guild
class discord.Guild```
Represents a Discord guild.
This is referred to as a “server” in the official Discord UI.
`x == y` Checks if two guilds are equal.
`x != y` Checks if two guilds are not equal.
`hash(x)` Returns the guild’s hash.
`str(x)` Returns the guild’s name.
ty
so we
- don't need a variable named "name"and 2. whats the point of
py check=lambda m: m.author == ctx.author)?
wait_for is used to wait for a certain Discord event to happen, you can pass a check kwarg to check for certain things.
In your case, check lambda m: m.author == ctx.author will check if the message author is as same as the author of the command, so if someone sends a message in the middle it won't take their message.
oo awesome
Is there a good resource I can look into in terms of methodology for setting server specific custom prefixes?
@dapper cobalt do u have an error or warning symbol i can yoink
If you save prefixes in a database, you can use:
def get_prefix(bot, message):
# get the prefix of the guild (message.guild)
return the_prefix
bot = commands.Bot(command_prefix=get_prefix)

thank you

where should that get_prefix be in terms of the file hierarchy?
Above your bot instance.
hmm I guess I can just call any method that way if it's imported, I'm going to try that out
thank you Key! ❤️
Key... Yeah no problem, X!
is it possible to give webhook a color?
class discord.Embed(**kwargs)```
Represents a Discord embed.
`len(x)` Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
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/stable/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.
@bot.command()
async def ifstate(ctx):
optionembed = discord.Embed(title='Please choose an option', description="Option 1, Option 2, Option 3", color=c.purple())
await ctx.send(embed=optionembed)
options = await bot.wait_for("message", check=lambda m: m.author == ctx.author)
await ctx.send(f"Nice you picked! {options.content}")``` @dapper cobalt
How do I add a statement if it has neither Option 1 Option 2 Or Option 3 It returns Incorrect option as an embed text
@bot.command()
async def ifstate(ctx):
optionembed = discord.Embed(title='Please choose an option', description="Option 1, Option 2, Option 3", color=c.purple())
await ctx.send(embed=optionembed)
available_options = ["option 1", "option 2", "option 3"]
def check(msg):
return msg.author == ctx.author and msg.content in available_options
options = await bot.wait_for("message", check=check)
await ctx.send(f"Nice you picked! {options.content}")
ohh I could have used a list all thattime?
Yeah you can use Python stuff in Python.
Pretty pythonic, innit?
How best do I import methods from within a cog Class? Does it require anything to instantiate or can you just call the class eg example = Example() and access a method via example.test() without any modification required?
well I'm slowly getting there with this event (I think). The number of stars is now increasing correctly however for some reason it keeps sending the star post each time a new reaction is added. My code: https://sourceb.in/86s5I6Nf0L.
tl;dr: event works however it keeps sending a new msg fir each reaction rather than editing the existing msg
hi how do i check my dpy version (not python version)
should just be discord.__version__
in terminal?
indeed
in a python terminal yes, or you could get your bot to either print it or send it to a channel
oh okay
new free hosting method
the host is called || localhost || don't tell this to others
keep the jewel to yourself
nice
i want to make a command called 8ball but i can't create a variable with a number as the first character, how do i fix this? my code is
@bot.command()
async def 8ball(ctx):
await ctx.send("placeholder")```
@bot.command(name="8ball")
async def _8ball(ctx):
await ctx.send("placeholder")```
thanks
ohh tyy
bbed is not defined since you only defined it in the if statement; not the else statement.
is there a way to only edit a embeds footer without having to edit the whole embed?

yea im aware
how would i write it so it is defined
Like I said, it's only defined in the if statement. You would have to put it in the else statement, just cut it and paste.
else:
bbed = discord.Embed(...)
await ctx.send(embed=bbed)```
yea got it
Whats the client.__ for non cog commands?
you can set the function name to something else, and set aliases in the decorator
Ive already tried client.command but it didnt work
What's your bot instance?
@vale pendant how would i go deleting a message after a certain amount of time if its an embed
You can add delete_after
deleting the context message?
delete_after=seconds
client
it just printed it when i tried using that
the .send() method has a delete_after kwarg
That's a method btw.
Have you defined client anywhere else in the same file?
client = discord.Client()
And are you trying @client.command or client.command()?
do not use discord.Client()
That's the error right there.
there’s your issue
Ah yes.
use this ,
How so?
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
It should be client = discord.ext.commands.Bot(command_prefix="prefix").
Ahhh, thanks.
what do u use to make it capital and lowercase letters
@bot.command()
async def ifstate(ctx):
optionembed = discord.Embed(title='Please choose an option', description="hug", "high5", color=c.purple())
await ctx.send(embed=optionembed)
available_options = ["hug", "high5"]
def check(msg):
return msg.author == ctx.author and msg.content in available_options
options = await bot.wait_for("message", check=check)
pickedembed = discord.Embed(title=f"Nicely done you have chosen:", description=f"{options.content}",
color=c.purple())
await ctx.send(embed=pickedembed)```
because I can't have hug and high5 together since its in avaliable_options
why is this giving me "invalid syntax"? (it's in a list defined by answers = [list here])
str.lower() and str.upper().
so
!e
print("heLLo ThErE".lower())
print("heLLo ThErE".upper())
@dapper cobalt :white_check_mark: Your eval job has completed with return code 0.
001 | hello there
002 | HELLO THERE
so..
hmm I wanted to bypass it from giving me this error: optionembed = discord.Embed(title='Please choose an option', description="hug", "high5", color=c.purple())
^
SyntaxError: positional argument follows keyword argument
What is "high5"
nvm apparently it was the ide being weird, a restart fixed it
Then why did you put it in a separate parameter
Wdym
its in desc?
im so damn confused what are you saying rn
Oh, your description is just "hug"
yes
"high5" is separated
yes
That's the error
oh ok
hey this is supposed to send a message to my friend when he messages
it does nothing tho
that id is right click copied on his user
Add an else statement to print the message.author.id.
trying it rn
lol that is like a spam bot
yea
Oh right, I completely forgot, that's considered API abuse.
@bot.command()
async def ifstate(ctx):
optionembed = discord.Embed(title='Please choose an option', description="hug, high 5", color=c.purple())
await ctx.send(embed=optionembed)
available_options = ["hug", "high 5"]
def check(msg):
return msg.author == ctx.author and msg.content in available_options
options = await bot.wait_for("hug", check=check)
hugembed = discord.Embed(title=f"Nicely done you have chosen:", description=f"{options.content}",
color=c.purple())
await ctx.send(embed=hugembed)
options = await bot.wait_for("high 5", check=check)
high5embed = discord.Embed(title=f"Nicely done you have chosen:", description=f"{options.content}",
color=c.purple())
await ctx.send(embed=high5embed)```
I tried to make it 2 different options
this did nothing
wait_for("hug")?
idk if i have a wrong client token
how would I make it check for hug and high 5
"hug" isn't an event.
no we can't help u for that
meaning if the user sends hug
It's wait_for("event").
how come
do u get any errors?
but how would i seperate it from 2 things
It's API abuse.
2 options
nope
that is a spam bot
oh but were really good friends hes watching me do it
huh?
Still, it's API abuse.
Ah, my bad guys. ill read up on that

@dapper cobalt anyways back to my thingy how would I separate it with 2 options if the user sends hug it returns that embed text if the user returns high 5 it returns the other embed
lol what is a hug in dpy
hug and high 5 aren't discord events tho?
wait_for waits for events only.
Examples:
wait_for("message")
wait_for("reaction_add")
wait_for("member_ban")
I mean you can just read until someone sends "hug" or "high 5"
is it a slash command with the options "hug" and "high 5"?
what is high5
nope
High 5 is an option mah god
ITS JUST AN OPTION come on nowWW
Just a simple text
so I can do wait_for("message": "the message here??")
is that a possibility
!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/stable/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
Read that.
got it
I'm reading it alr
def check(m):
return m.content == 'hello' and m.channel == channel
msg = await client.wait_for('message', check=check)
await channel.send('Hello {.author}!'.format(msg))``` "hello" basically is the message being waited
I'm guessing
It checks if the content of the message is "hello", correct.
You can check if the message content is inside a list ["hug", "high 5"].
can I make 2 lists and make it check for that?
@dapper cobalt how do i add a command cooldown
!d discord.ext.commands.cooldown
discord.ext.commands.cooldown(rate, per, type=<BucketType.default: 0>)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.on_command_error "discord.on_command_error") and the local error handler.
A command can only have a single cooldown.
@client.command()
@commands.cooldown(how_many_seconds, how_many_uses, commands.BucketType.user/commands.BucketType.channel/commands.BucketType.guild)
@bot.command()#6600
async def ifstate(ctx):
optionembed = discord.Embed(title='Please choose an option', description="hug, high 5", color=c.purple())
await ctx.send(embed=optionembed)
available_options = ["hug"]
available_options2 = ["high 5"]
def check(msg):
return msg.author == ctx.author and msg.content in available_options
options = await bot.wait_for("hug", check=check)
hugembed = discord.Embed(title=f"Nicely done you have chosen:", description=f"{options.content}",
color=c.purple())
await ctx.send(embed=hugembed)
def check(msg):
return msg.author == ctx.author and msg.content in available_options2
options = await bot.wait_for("high 5", check=check)
high5embed = discord.Embed(title=f"Nicely done you have chosen:", description=f"{options.content}",
color=c.purple())
await ctx.send(embed=high5embed)
failer
bot.wait_for("high 5")..?
oops
bot.wait_for("message")
Why did you make 2 lists each one for a single option?
You can make one list available_options = ["high 5", "hug"].
And make one check to check if the content is in available_options.
well because I didn't really want the same stuff
because for high 5
I would add an image with someone high 5ing
and hug someone hugging
an embed image with text
@bot.command()
async def ifstate(ctx):
optionembed = discord.Embed(title='Please choose an option', description="hug, high 5", color=c.purple())
await ctx.send(embed=optionembed)
available_options = ["hug", "high 5"]
def check(msg):
return msg.author == ctx.author and msg.content in available_options
options = await bot.wait_for("message", check=check)
if options.content == "hugh":
hugembed = discord.Embed(title=f"Nicely done you have chosen:", description=f"{options.content}", color=c.purple())
await ctx.send(embed=hugembed)
if options.content == "high 5":
high5embed = discord.Embed(title=f"Nicely done you have chosen:", description=f"{options.content}", color=c.purple())
await ctx.send(embed=high5embed)
Wouldnt it be better to make a mapping of all the choices?
I don't usually spoonfeed but my brain cannot really explain things at this time.
I.e ```py
CHOICES = {"hug": "hug link", "high 5": "high five link"}
if choice in CHOICES:
....return CHOICES[choice]
You could make a hug command and a high5 command btw.
Ik but I just wanted to do a little fun menu
This could be used for help a custom help later on!
Hmm. Fair enough.
I'm not such a pro with discord.py but I'm trying my best here!
Please don't use wait_for in help commands. Trust me it's not a good idea.
your suggestion?
You can use reactions or buttons.
You can subclass it too.
!d discord.ext.commands.HelpCommand
class discord.ext.commands.HelpCommand(**options)```
The base implementation for help command formatting.
Note
Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).
This means that relying on the state of this class to be the same between command invocations would not work as expected.
I meant waiting for messages.
I should get some sleep, right? Wrong.
@dapper cobalt what is the command to add footer
!d discord.Embed.set_footer
set_footer(*, text=Embed.Empty, icon_url=Embed.Empty)```
Sets the footer for the embed content.
This function returns the class instance to allow for fluent-style chaining.
no suffer and help people
Indeed.
comes back as an error
What is it?
!d discord.Embed you can look at it yourself.
class discord.Embed(**kwargs)```
Represents a Discord embed.
`len(x)` Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
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/stable/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.
unexpected indent
hi
@dapper cobalt
@bot.command()
async def coinflip(ctx):
if random.choice(determine_flip) == 1:
embed = discord.Embed(title="Coinflip | (Bot Name)", description=f"{ctx.author.mention} Flipped coin, we got **Heads**!")
await ctx.send(embed=embed)
else:
embed = discord.Embed(title="Coinflip | (Bot Name)", description=f"{ctx.author.mention} Flipped coin, we got **Tails**!")
await ctx.send(embed=embed)
error is determin_flip isnt defined
It's an attribute not a method.
Where is determine_flip defined?
Since you are using random.choice then I think determine_flip is a list that contains two integers, 1 and 2, right?
right
^
Hey, yall. Just wanted to drop in to show you guys a really cool resource I found:
Then you can define it that way: determine_flip = [1, 2].
Disocrd embed generator
arceeee 
ok let me try that
Yo kyleee sup 
nah just playing some mobile games, hbu
Woke up a minute ago 
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.

ok bot is running time to see iof it works

Sorry. 


Can you show your code again?
defined_flip=
@bot.command()
async def coinflip(ctx):
if random.choice(determine_flip) == [1,2]:
embed = discord.Embed(title="Coinflip | (Bot Name)", description=f"{ctx.author.mention} Flipped coin, we got **Heads**!")
await ctx.send(embed=embed)
else:
embed = discord.Embed(title="Coinflip | (Bot Name)", description=f"{ctx.author.mention} Flipped coin, we got **Tails**!")
await ctx.send(embed=embed)
^
You didn't define it still.
u can do random.range(2) 
Check if statement... I just saw now
Do what this smartie said.
What smarty said but before if Statement
I'm smarty? 


thx for you help
@bot.command()
async def coinflip(ctx):
determine_flip = [1,2]
if random.choice(determine_flip) == [1,2]:
embed = discord.Embed(title="Coinflip", description=f"{ctx.author.mention} Flipped coin, we got **Heads**!")
await ctx.send(embed=embed)
else:
embed = discord.Embed(title="Coinflip", description=f"{ctx.author.mention} Flipped coin, we got **Tails**!")
await ctx.send(embed=embed)
this is the working code for coinflip
how to i check if a channel is nsfw or not? i have this so far: py async def is_nsfw(channel: discord.TextChannel): try: _gid = channel.server.id except AttributeError: return False data = await bot.http.request( discord.http.Route( 'GET', '/guilds/{guild_id}/channels', guild_id=_gid)) channeldata = [d for d in data if d['id'] == channel.id][0] return channeldata['nsfw'] but it returns with <coroutine object is_nsfw at 0x7fe2bc3df340> instead of a boolean
if random.choice(determined_flip) == 1:
!d discord.ext.commands.is_nsfw
discord.ext.commands.is_nsfw()```
A [`check()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the channel is a NSFW channel.
This check raises a special exception, [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`NSFWChannelRequired`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.NSFWChannelRequired "discord.ext.commands.NSFWChannelRequired") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure"). DM channels will also now pass this check.
wouldn't it be easier to do py @bot.command() async def coinflip(ctx): if random.randint(0, 1) == 0: embed = discord.Embed(title = "Coinflip", description = f"{ctx.author.mention} flipped a coin and got **heads**!") await ctx.send(embed = Embed) else: embed = discord.Embed(title = "Coinflip", description = f"{ctx.author.mention} flipped a coin and got **tails**!") await ctx.send(embed = Embed) so you don't need to use a list?
@commands.is_nsfw()
ohhh, thanks a lot
@dapper cobalt how do i add date and time to footer
it works
!d discord.Embed.timestamp
The timestamp of the embed content. This could be a naive or aware datetime.
the problem is, i want the command to work outside of nsfw channels but only with a specific set of responses and using this will only allow it to run in nsfw channels (i think)
!d discord.TextChannel.is_nsfw
is_nsfw()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.9)"): Checks if the channel is NSFW.
You can do
if ctx.channel.is_nsfw():
...
else:
...
oh i see thanks

where would it go
Where do you think? 
idk i just tried to do it in embed.add_footer()
wha
how do i check if a user doesnt have a role


