#discord-bots
1 messages Β· Page 519 of 1
It can't happen, as I showed u in this picture lol. It raises an error
You are mistaken lul
Don't ever doubt kylee lmao
who knows
and hunter *
@bot.command()
async def clear(ctx, amount= 1):
if ctx.author.id == 760010546728402975 or ctx.message.author.guild_permissions.administrator:
await ctx.channel.purge(limit=amount+1)```
this always works for me
Which Hunter?
u
it works only if some uses a number
If a person tries
<prefix>clear q , you'll get an error
yeah
No, hunter can only print hello world.
weird, I am wrong many times
YESSSS
YOU KNOW ME PERFECTLY
oh, hes that noob?
but why anyone will want to clear q?
you can simply typehint the amount variable to avoid it..
Yes. Yet a solid contributor in a fork of dpy!
yeah and you even make 70 guilds bots
I copy pasted all the code Eh, no comments
but he only make the docs
Cz I added a print statement :D

well just for u to know i am not the one who is in the trouble
In programming, you never ask "why would someone do x", you just think that everyone using your bot is so stupid, so you gotta guide them.
π whos in trouble
class WIP(commands.Cog, name='WIP (SOON)'):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def getrole(self, ctx):
message = await ctx.send("De bot is de reactions aan het laden, even geduld aub. Zodra de embed gestuurd wordt kan je je roles kiezen!")
await message.add_reaction("π§")
await message.add_reaction("β")
await message.add_reaction("π")
await message.add_reaction('π')
await message.add_reaction('π’')
await message.add_reaction('π€')
embed = discord.Embed(title='Rol Keuze Menu', description='Klik hieronder om een rol te kriigen, als je eentje weg wilt moet je opnieuw klikken!')
embed.add_field(name=':construction:',value='Development')
embed.add_field(name=':star:',value='Free Release Ping')
embed.add_field(name=':scroll:',value='Payed Release Ping')
embed.add_field(name=':confetti_ball:',value='Giveaway Ping')
embed.add_field(name=':new:',value='Update Ping')
embed.add_field(name=':loudspeaker',value='Mededelingen Ping')
embed.add_field(name=':robot:',value='Bot Development Ping')
await message.edit(embed=embed)
def check(reaction, user):
return user == ctx.message.author and str(reaction.emoji) in ['π€', 'π’']
try:
reaction, user = await bot.wait_for('reaction_add', timeout=300.0, check=check)
if reaction.emoji == 'π€':
if ctx.author.has_role("Bot Development Ping"):
await ctx.send("U had de bot updates ping al, U wordt ervan verwijderd.")
await message.delete()
else:
await ctx.send("U wordt geranked met de bot updates rank!")
await message.delete()```
I dont get an error or output
the kids in my basement
the lost programmer
is the cog being loaded?
Yes
you didnt show the setup func so just incase you don't have one, you need it
Everything else In the cog works
ah right okay
riad , if @unkempt canyon bot worked that way the server would already have been nuked
but without the if ctx.author.has_role() it does work
!e
ctx.channel.purge(limit=4)
No such thing.
is that the whole command or is it cut off?
Though, you can do if role in ctx.author.roles.
Yeah its the hole system
its in a wip cog xd
well you have an open try block with no except
role being a discord.Role obj
role = "894910761669906432"
if role in ctx.author.roles```
this
!e
def calculate(x, y):
return x/y
print(calculate("q", "a"))
@dapper cobalt :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 4, in <module>
003 | File "<string>", line 2, in calculate
004 | TypeError: unsupported operand type(s) for /: 'str' and 'str'
First, the role's ID should be an int.
Second, get the role with ctx.guild.get_role(role_id_here).
you'll need to compare it with a role object or you could do some hacky comprehension stuff like py role = 894910761669906432 if role in [x.id for x in ctx.author.roles]
probably shouldn't do that though lol
use this
Im ok with the basic
xd
Or, get the role:
role = ctx.guild.get_role(894910761669906432)
if role in ctx.author.roles
That worked! Thanks π
@dim cedar Do you have any idea what could happen if what you're trying to do is actually possible?
eh
what?
Is there a thing like ctx.author.roles.remove also or?
ctx.author returns a discord.Member object.
!d discord.Member.remove_roles
await remove_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the removed [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
what are u saying?
remove_roles is not defined
You're trying to create a command in @unkempt canyon.
ctx.author.remove_roles()
ah ok
it's a method of discord.Member
ctx.author is your discord.Member instance.
That was just mistake
Copied too many lines
@client.command()
async def unmute(ctx, user):
await user.edit(mute=False)``` trying to make a server mute/unserver mute command get error message 'str' object has no attribute 'edit'
def bid(self, userid, bid):
self.bids[str(userid)] = bid
if datetime.datetime.now() > (self.endtime - datetime.timedelta(seconds=3600)):
self.endtime += datetime.timedelta(seconds=3600)```
i have this code, when anyone does `?bid` it adds 3600seconds to the end time. what should i do so that it maintains the `?bid` current time and the endtime as 3600?
Hmm
you need a member object for that
typehint user to discord.Member
huuuuh
kinda new, wym
You see ctx, user in the parenthesis they are called objects
typehint user to discord.Member
So basically you need to add member there
where would i paste that
no those are args
Ohh
how to check for multiple messages in bot.wait_for ?
typehint it*
what is typehint
use asyncio.wait
hmm
!d asyncio.wait
coroutine asyncio.wait(aws, *, timeout=None, return_when=ALL_COMPLETED)```
Run [awaitable objects](https://docs.python.org/3.10/library/asyncio-task.html#asyncio-awaitables) in the *aws* iterable concurrently and block until the condition specified by *return\_when*.
The *aws* iterable must not be empty.
Returns two sets of Tasks/Futures: `(done, pending)`.
Usage:
```py
done, pending = await asyncio.wait(aws)
``` *timeout* (a float or int), if specified, can be used to control the maximum number of seconds to wait before returning...
!type hint user to discord.Member
no in bot.wait_for()
i know
!hint user to discord.Member
you use asyncio.wait and bot.wait_for to achieve what you want
i want to check multiple messages
!e
def typehint(arg: int) -> int:
return arg
print(typehint(5))
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
5
yes i know
pages = ["1","2","3","4","5","6","7","8"]
def check(message):
return message.author.id == user.id and message.channel == reaction.message.channel and message.content == any(pages)
done, pending = await asyncio.wait([bot.wait_for('message', check=check), bot.wait_for('message')], return_when=asyncio.ALL_COMPLETED)
just lmk how i can correct the code
i told u
read this plz
kk
Hey my code is not preventing the mute
pages = ["1","2","3","4","5","6","7","8"]
def check(message):
return message.author.id == user.id and message.channel == reaction.message.channel and message.content == any(pages)
this?
what
how i can check for multiple words?
im confused on what you want now
use the discord.ext.commands extension and not the events for commands pls
i mean i want all the numbers in pages list
i dont understand how this can solve my issue
:/
can you give an example
@hasty iron this
im like very new
again
and i need to make an unmute
how i can wait for 1to9 numbers in chat
you want to check if a user's message is one of the page numbers?
typehint user to discord.Member obj
ok then just do message.content in pages
ok
yes but where, in the client.command() or
anywhere
lol it was silly
typehint user
i understand that, But where in my file do i place that snippet of code
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.
^
a typehint is where you specify the type of something, so in your case you'd need async def unmute(ctx, user: discord.Member):
oooh
very new to it
then you should learn more python
discord.py is an advanced library for beginners
although it's a good idea to give variables meaningful names, a user and member are different things and in this case it'd be safe to assume you will only be using members, so name the param member not user
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
worked thank you
Can u explain me more?
How do I remove all reactions from the bots own message , if thats possible
In one code, if possible
!d discord.Message.clear_reactions
await clear_reactions()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Removes all the reactions from the message.
You need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to use this.
[**{auction.itemname}**]({msgurl.jump_url})```
this gives me this, why? `[qwe]([#893075969261305897 message](/guild/722342386164039793/channel/893075969261305897/))`
i dont think u can use ** in hyperlinks (not sure tho)
you can@boreal ravine
Yes you can
i mean in the brackets
You can
im new to progamming
jut a question....
how do i code a ludo bot?
Is this in an embed or a normal message?
Whats ludo?
Yeah this ^ If it's a normal message it won't make it as hyperlink
^
normal , figured it wont work ,
If you want to make it as a normal message, webhook is your only solution
lol
ok nvm how do i programme a chess bot?
;-;
If you're new you shouldn't start with this type of idea
And learn Python before that
ur asking for complicated stuff?
ohh
uhh... google
how bot can send its prefix when mentioned?
send the msg
?
fetch the prefix from where you are storing it
i have setprefix command so different servers and different prefixes
then fetch from db
i can fetch but it sends something else also with prefix
something like Request prefix = "!"
webhook = await ctx.channel.create_webhook(name=ctx.author.name, avatar=ctx.author.avatar.url) #doesnt work as of now
``` how would I set the avatar if I have no pfp?
show your code
define it
maybe
Python 3.10 Build Wheels Sucks with Windows XD
define what
hm
your code?
current_prefix = await bot.pg_con.fetchrow("SELECT prefix FROM prefixes WHERE guild_id = $1", message.guild.id)
?
is there any way to take the letters after ' and before '
in python
slice it
ok
Don't slice it
Do you even know what this type of output means?
is there any way to get words after ' and before '
Change those numbers depends on the string char
prefix = f"{current_prefix}"[15:-2]
idk didn't got meaning in docs
No
Don't mislead people
i think it is saying the recorded prefix
That's completely wrong
than tell pls what is the way?
bruhh what mislead?
i would do that method cuz its simple and easy
Ever seen this?
It's a custom type of the library
Which means it's not a string
no i never use postgres
And you can't slice it
It's Python knowledge
its a class object
And you want to slice a class
for words in that:
if words == "'":
length = len(words)
idk wht to do now :|
```something like this will work π
after ' and before '
is there any way to get letters between that?
It's a class
hm
Stop trying to extract things inbetween the ''
Basic python class knowledge Β―_(γ)_/Β―
then get data from that class
i thought it returns str like that
Just like you get the name or anything else from a discord.Member object
bruhh i thought that postgres package return str like that
i think i forgot π
never seen this package before
i use redis as my db

cuz its fast as fuk
why they never show examples π
Never said the opposite
Learn to read the documentation by using your Python knowledge
:/
Don't expect to always be given the code to copy paste
Then read this
And you will understand what to do
To get the value in the prefix field of the class
can u solve this ?
#python-discussion message
but that link has no downloadable software
when i click on it nothing download
and it shows ur download started if not click retry but still not downloading
downgrade python
or install the build tools
anyother way
hmm
install the build tools
but only happens with windows
There's literally a download button
shit windows
then dont use windows
nothing downloading for me when i click
but i paid for it

What browser you're using?
brave
Imagine paying for shits
lol
Disable the useless shield temporarily
Then click on download agian
k leme try
you'll have to install VS either way
anyone knows how to make embed color random :))
yay after disabling it worked
!d discord.Colour.random
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.
or make a custom hex color generator if you don't want to use the default available colors
ok ok i shall loose more brain cells making one ty
will python release a fix for it?
if you wait some time, and try again it should work
and by some time, i mean a couple of weeks
am blaming on python windows installers
not on python
way too long
Then you're blaming on yourself
downgrading is the easier option
that's what happens when you use the newest version
Deal with it or downgrade
how to make uptimer for a bot
Uptimer?
ill downgrade
amm like to keep the bot running
You don't?
Just run the script and it keeps running

And if you're using replit, stop it and change to a vps
buy a vps
lol i mean without clinking that run button
hmm
As I said, don't use replit
hehe i m new to coding so i thought its easy to use replit
You should not use Repl.it to host your bot.
While this may seem like a nice and free service, it has a lot more caveats than you might think, such as:
-
The machines are super underpowered.
-
- This means your bot will lag a lot as it gets bigger.
-
You need to run a webserver alongside your bot to prevent it from being shut off.
-
- This isn't a trivial task, and eats more of the machines power.
-
Repl.it uses an ephemeral file system.
-
- This means any file you saved via your bot will be overwritten when you next launch.
-
They use a shared IP for everything running on the service.
This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you.
Please avoid using repl.it to host your bot. It's not worth the trouble.
ya this thing again
If you already got told to stop using it then maybe you should really think about changing
):

why do you even need 3.10
YESSIR
People who want the lastest version on everything for no reason 
for that speed they told it has speed optimizations
discord bot speed
yea i feel better when i stay updated in everything
There's nothing about performance in the change logs, just as side note
Just a very few things that are a little bit faster
but they told in tweet
Which won't affect a lot
hmm
!d discord.ext.commands.Exceptions
Whats the file for the documentation command on the github for @unkempt canyon?
It's really spread everywhere
In 1 folder tho, but all those files contribute for the docs command
!source d
Look up documentation for Python symbols.
guys, im getting error code 400 while trying to send a message to a discord webhook, any solutions? (doesn't matter the code, i get a code 400 error code)
or can someone tell me what causes the error?
You can't send message to a discord webhook , there is no option
you can send message to a channel using webhook
@ client.command(pass_context=True) async def calculator(ctx): global times_used await ctx.send(f"xxxxxxxx") try: msg = await client.wait_for("message", check=check, timeout=30) except asyncio.TimeoutError: await ctx.send("Sorry, you didn't reply in time!") I'm getting error with check
what would be the problem?
Not sure but don't u need a def check
Before check=check
!pypi master branch
Eh
whats the difference between if member is None and if not(member)
if member is None will check if the object is None, and if not(member) will check if member is a falsy value
if not(member) doesnt check if its a falsy value, it just flips the boolean value of member right? maybe im wrong
member = ctx.guild.get_member(int(auction.get_highest_bid()[0]))
if member is None:
auction_list += f"**{counter}.** `Auction ID:` **{auction.auctionid}** | `Item Name:` **{auction.itemname}** | `Sold By:` {self.bot.get_user(auction.seller).name} | `Ends in:` **{retryMessage}**\n **Highest Bid:** `None`.\n\n"
else:
auction_list += f"**{counter}.** `Auction ID:` **{auction.auctionid}** | `Item Name:` **{auction.itemname}** | `Sold By:` {self.bot.get_user(auction.seller).name} | `Ends in:` **{retryMessage}**\n **Highest Bid:** `{auction.get_highest_bid()[1]}` **by** `{member.name}`.\n\n"
```
well this gives`TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'`
auction.get_highest_bid()[0] is None so it can't be converted to an int
if not member is the opposite of if member which is checking if it's True, so it's checking if it's False, if member is None is checking if it's None
How can i make generic conventer?
yeah, but in this case there is an if statement so i said "check" instead of "flipping the value"
so i should check for it instead ?
check for what? In order to get the guild member, you need to pass a valid argument, such as an int, what you're passing is NoneType so it can't be casted to an int
if auction.get_highest_bid()[0] is "305573693134733313" for example then what you have is fine, however it's not "305573693134733313", it's None
How can i make generic conventer?
a generic converter? why?
.bid 16334615530 your dad woody Converting to "float" failed for parameter "amount".
how should i raise the error if this is the case
and send in the ctx chan
value error?
Hello all, is there any bot source code for discord.py because i need for my server
!src
did u install it?
repaired already
@commands.command()
async def nuke(self, ctx, channel: discord.TextChannel = None):
channel = channel or ctx.channel
if channel is None:
await ctx.send("You did not mention a channel!")
return
nuke_channel = discord.utils.get(ctx.guild.channels, name=channel.name)
if nuke_channel is not None:
new_channel = await nuke_channel.clone(reason="Has been Nuked!")
await nuke_channel.delete()
await new_channel.send(f"{utily.done} Successfully Nuked this channel by {ctx.author}")
else:
await ctx.send(f"No channel named {channel.name} was found!")
```this works good but i just want to know that is this method safe?????
doesnt seem like since anybody can do it
also what even is this nuke_channel = discord.utils.get(ctx.guild.channels, name=channel.name)
are you thinking with your brain
people canβt help with nuke bots/commands
thats not the nuke you have in mind
ig you should add a role required to use the command
other than that it seems to be fine
and that part is kinda messed up
wait nvm its fine its utils.get not find
Iβm on mobile so I canβt tell I just saw the command name lol
oh I see it just clones the channel and deletes it ty
bruh
why when i say nuke u guys think like banning all users in a guild and deleting everything
FIRST READ THE CODE AND THEN REPLY
sheesh chill

Why this error?```py
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/bot.py", line 1460, in _load_from_module_spec
setup(self)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/jishaku/cog.py", line 55, in setup
bot.add_cog(Jishaku(bot=bot))
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/bot.py", line 1328, in add_cog
raise TypeError('cogs must derive from Cog')
TypeError: cogs must derive from Cog
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "main.py", line 94, in <module>
client.load_extension("jishaku")
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/bot.py", line 1520, in load_extension
self._load_from_module_spec(spec, name)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/bot.py", line 1465, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
disnake.ext.commands.errors.ExtensionFailed: Extension 'jishaku' raised an error: TypeError: cogs must derive from Cog
why this gives an error?
Ignoring exception in command help:
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\ATKDJ\Desktop\programs\cogs\General.py", line 30, in help
@help.error
AttributeError: '_Helper' object has no attribute 'error'
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: '_Helper' object has no attribute 'error'
import discord
import random
import json
from discord.ext import commands
class Money(commands.Cog):
def init(self, client):
self.client = client
@commands.command()
async def balance(self, ctx):
await open_account(ctx.author)
user = ctx.author
users = await get_bank_data()
wallet_amt = users[str(user.id)]["wallet"]
bank_amt = users[str(user.id)]["bank"]
embedVar = discord.Embed(title=f"{ctx.author.name}'s balance", color = discord.Color.red())
embedVar.add_field(name = "Wallet Balance",value = wallet_amt)
embedVar.add_field(name = "Bank balance",value = bank_amt)
await ctx.send(embed=embedVar)
async def open_account(self, user):
users = await get_bank_data()
if str(user.id) in users:
return False
else:
users[str(user.id)] = {}
users[str(user.id)]["wallet"] = 250
users[str(user.id)]["bank"] = 0
with open("mainbank.json","w") as f:
json.dump(users,f)
return True
async def get_bank_data():
with open("mainbank.json","r") as f:
users = json.load(f)
return users
async def beg(self, ctx):
users = await get_bank_data()
user = ctx.author
earnings = random.randint(1,500)
await ctx.send(f"WOAW someone just gave u {earnings} coins!!" )
users[str(user.id)]["wallet"] += earnings
with open("mainbank.json","w") as f:
json.dump(users,f)
def setup(client):
client.add_cog(Money(client))
your cog isn't subclassed from commands.Cog
help() is a built in python function and cannot be used as a function name
!code please. I cannot read your code like this
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.
import random
import json
from discord.ext import commands
class Money(commands.Cog):
def init(self, client):
self.client = client
@commands.command()
async def balance(self, ctx):
await open_account(ctx.author)
user = ctx.author
users = await get_bank_data()
wallet_amt = users[str(user.id)]["wallet"]
bank_amt = users[str(user.id)]["bank"]
embedVar = discord.Embed(title=f"{ctx.author.name}'s balance", color = discord.Color.red())
embedVar.add_field(name = "Wallet Balance",value = wallet_amt)
embedVar.add_field(name = "Bank balance",value = bank_amt)
await ctx.send(embed=embedVar)
async def open_account(self, user):
users = await get_bank_data()
if str(user.id) in users:
return False
else:
users[str(user.id)] = {}
users[str(user.id)]["wallet"] = 250
users[str(user.id)]["bank"] = 0
with open("mainbank.json","w") as f:
json.dump(users,f)
return True
async def get_bank_data():
with open("mainbank.json","r") as f:
users = json.load(f)
return users
async def beg(self, ctx):
users = await get_bank_data()
user = ctx.author
earnings = random.randint(1,500)
await ctx.send(f"WOAW someone just gave u {earnings} coins!!" )
users[str(user.id)]["wallet"] += earnings
with open("mainbank.json","w") as f:
json.dump(users,f)
def setup(client):
client.add_cog(Money(client))```
that's still not what i asked for
at least i can see now that the issue is indentation
anyone have any working eval commands?
amm it shows no error with that
well it's correct syntax
but it's very much wrong indentation
oooooo ok
!s e
!site
Can also use: s
Commands for getting info about our website.
Subcommands:
!site faq
Info about the site's FAQ page.
!site help
Info about the site's Getting Help page.
!site home
Info about the website itself.
!site resources
Info about the site's Resources page.
!site rules [rules]...
Provides a link to all rules or, if specified, displays specific rule(s).
!site tools
Info about the site's Tools page.
!source e
Run Python code and get the results.
@valid niche can u rectify how to do it?
i'm not spoonfeeding
oki srry
if you are doing discord bots you are expected to have a good basic understanding of python
if you have this knowledge you can easily solve this on your own
i am confused my this
@help.error
AttributeError: '_Helper' object has no attribute 'error'````
if you don't well good lukc
because help is a built in python function that cannot be overwritten
you have a command named help, which is a function, but it's denied from overwriting the built in help
so i can not add help error?
you can add this, but you cannot have a command function named help, and also not a help.error, you must use a different name
help is a reserved name in python
Ok why am I getting this error Positional argument cannot appear after keyword arguments for FS. I am trying to send select menu with an embed and buttons but it gives me the following error. Here is the script py #feedback @client.group(invoke_without_command=True) async def feedback(ctx, *, text = None,): try: text = text.split("|") report=discord.Embed(color=0xfff868) report.add_field(name='Pending Confirmation', value=f"{text[1]} #Tittle \r {text[2]} #Description") FB=[[Button(style=ButtonStyle.red, label="Discard", custom_id="n"), Button(style=ButtonStyle.green, label="Send", custom_id="y")]] FS=Select(placeholder = 'Where to post',options = [SelectOption(label="Bugs", value="value1"),SelectOption(label="Commands", value="value2"),SelectOption(label="Suggestions", value="value3"),SelectOption(label = "Other", value = "value4")]) await ctx.channel.send(embed=report, components=FB, FS) except: await ctx.reply("Please enter `/feedback format` to check how to format.") To check if the button variable works I did components=FB and it works perfectly fine but when I checked the select menu it gave me this object of type 'Select' has no len() . To solve the first error I did view=FS but that only gives me the error send() got an unexpected keyword argument 'view' why just why
you already have the embed= and components = kwargs
so you cannot have a positional argument FS
that must also be a kwarg then
also that code is EXTREMELY difficult to read
Ok I will try that
I will format/ clean it later first priority debug
the thing is, making clean code is purely so it's easier to debug and maintain
if you clean up your code debugging is 300 times easier
everytime i run the code back the bot stop
hi, could someone please help? why does it return this error;
client.default_color = discord.Color(int(get_dominant_color(client.user.avatar.url), 16))
AttributeError: '_MissingSentinel' object has no attribute 'avatar'
...on trying to access the client instance that way?
how do i test whether or not the ctx of a command is a specific phrase?
me too
@bot.event
async def on_message(message):
if message.content == "!mute @dim cedar":
user = message.guild.fetch_member(760010546728402975)
guild = message.guild
mutedrole = discord.utils.get(guild.roles, name = "Muted")
await sleep(5)
await user.remove_roles(mutedrole)
await message.channel.send("Did you just escaped a Mute @dim cedar")```
after including this to the code none of the cmds of my bot are working
you have to put "return" at the end
i think your client is defined as something else due to the _MissingSentinel part
what exactly do you mean?
i've told you many times how to solve it
if you are ignoring it, i'm not going to tell you again
it works now
im trying to figure out a simple rps command, and i want to test if the ctx in the command is "rock", any way to do that?
especially since you're doing it using bot.event aka you're overwriting the internal on_message, and thus you are sleeping for exceptionally large amount of times
!d discord.ext.commands.Context.content
No documentation found for the requested symbol.
lol
hmm one second
lmao
also ctx is the entire context
actually where?
it's a HUGE class, it's a GIANT pile of information
it shows invalid syntex
so what part of ctx should be whatever you want?
the line below the command
mhm
because you are overwriting the internal on_message
!d discord.ext.commands.Context
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.
This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.
This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
invalid syntex
ok, so the command would be A!rps [ctx], and i want to test whether or not the ctx is rock, paper or scissors
idk then
ctx isn't just something the user passes
ctx is a HUGE ball of information generated by the library
i dont use bot_events much, bot,command works better imo
you can pass your own arguments after that
ok
i thought so too so i put in a print(client) right above that line, and it returns the bot object <disnake.ext.commands.bot.Bot object at 0x000001DCA301FFD0>, rightly so
it seems like the problem only arises when i try to access an attribute from the client without an async function, that's when it throws the _MissingSentinel error which is strange. it works as intended when done inside an async function.
but ctx is a huge pile of information
right it's disnake, idk that library
thanks but it is showing await bot.process_commands(message) an invalid syntex.
then fix the syntax
how?
oh itβs a discord.py 2.0 maintained fork, but iβll see if i can reproduce this issue with the actual discord.py library
well 'tuple' object does not support item assignment I know I probably did this wrong but is this how your supposed to do it ? py @client.group(invoke_without_command=True) async def feedback(ctx, *, text = None,): try: text = text.split("|") report=discord.Embed(color=0xfff868) report.add_field(name='Pending Confirmation', value=f"{text[1]} #Tittle \r {text[2]} #Description") FB=[[Button(style=ButtonStyle.red, label="Discard", custom_id="n"), Button(style=ButtonStyle.green, label="Send", custom_id="y")]], Select(placeholder = 'Where to post',options = [SelectOption(label="Bugs", value="value1"),SelectOption(label="Commands", value="value2"),SelectOption(label="Suggestions", value="value3"),SelectOption(label = "Other", value = "value4")]) FS=FB await ctx.channel.send(embed=report, components=FS) except: await ctx.reply("Please enter `/feedback format` to check how to format.") also please forgive me for the sin I have just committed NOT Formatting the code
you are trying to do item assingment on a tuple, which isn't possible because a tuple is immutable
tho idk where because the code is quite a mess
I know sorry
Ok great to know but how would one solve it
by first fixing the formatting, making your code readable
and then there's a good chance the issue will just present itself for you
discord.py is ded?
no
-_-
because its not defined
u use discord.py ?? :/
im making my own wrapper with a friend
hmm
you realize ur saying that in a python server, of course people are gonna use python
you should probably learn more python then
!resources
-_-
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
?
there are many other libraries too in python
like pycord
i am thinking to switch in pycord :/
if discord.py is dead
thats not a library, thatβs just trash
yes
:/
blanket any good forks or libraries then?
idk about libs, but no good forks rn
anyother option?
rahh i wanted to put slash commands
yeah, but i don't know what to lol
you wont need to change syntax
nope
you can't, you'll have to switch to another fork or library
you can
using slash commands and app commands are too easy in pycord
wat
you can make it on your own
how?
all the http endpoints are already there
and you can use on_interaction
!d discord.on_interaction
discord.on_interaction(interaction)```
Called when an interaction happened.
This currently happens due to slash command invocations or components being used.
Warning
This is a low level function that is not generally meant to be used. If you are working with components, consider using the callbacks associated with the [`View`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View "discord.ui.View") instead as it provides a nicer user experience.
New in version 2.0.
idk yt says that
which are shittier
wym d.py was the best lol

but even google is showing that d.py is dead
so what
now they will not add in it
dead = not usable?
idk
yes it is because it's stopped being working on but that doesn't mean it wasn't good before
it won't end, you can use it
it will stop getting updates
it just won't be maintained
ok
yeah
can i convert my commands to slash commands or i should make every command again as a slash command?
why though
The second one
:/
nextcord.py is a maintained fork based on d.py
If you want to use it into your bot the only thing u need to convert it is to change the discord package into the nextcord package
I never used pycord so i don t have an answer to that
disnake
what?
!pypi disnake
what is this :/
something better than those 2 forks you mentioned
u can't use dpy for slash commands
and if new features come you won't be able to use them either
and message commands?
iirc dpy only had buttons and select menu
Can i use regular commands and slash commands together with this?
yes
app commands?
Well, it s time to convert my code
yeah disnake has that too
Just wanted to ask if this code is goodly formatted ```py
feedback
@client.group(invoke_without_command=True)
async def feedback(
ctx,
*,
text=None,
):
try:
text = text.split("|")
report = discord.Embed(color=0xFFF868)
report.add_field(
name="Pending Confirmation",
value=f"{text[1]} #Tittle \r {text[2]} #Description",
)
FB = [
[
Button(style=ButtonStyle.red, label="Discard", custom_id="n"),
Button(style=ButtonStyle.green, label="Send", custom_id="y"),
]
], Select(
placeholder="Where to post",
options=[
SelectOption(label="Bugs", value="value1"),
SelectOption(label="Commands", value="value2"),
SelectOption(label="Suggestions", value="value3"),
SelectOption(label="Other", value="value4"),
],
)
FS = FB
await ctx.channel.send(embed=report, components=FS)```
What are app commands?
and i heard it is in top in github
if u will right click on anyones name
it will show Apps
the only reason pycord is on top is because the owner of it is a yt
yeah it looks good
Thanks
That's true. Most rilevant doesn t mean better
exactly
then what i should use now ?
disnake
is the syntax different?
its a fork so no
the syntax is dpy 2.0's syntax
:/
I discovered nextcord searching by buttons
Now i will try disnake and if i can get used to it probably i will use it
i dont know what they even added in nextcord
i literally found nothing source code diving
which is mostly used?
Lol almost nothing, nextcord is pretty a copy of dpy
When i converted to nextcord i didn t changed nothing to my code, only the package
Because its a fork lol
if i switch?
All the code is the same unless they change it
but i have 54 commands so i have to change all?
It s a fork bro
i will try disnake
i will try to convert my code to disnake tomorrow :/
hey uh how can I get a command to loop given a certain number and how can I also limit the amount of times it preforms it
i.e like a roll command where id do like !roll 10
Rip yt is not showing a single word named disnake :/
discord.ext.Task
You can pass in the count parameter
If I want to make slash commands and put each of the guild IDs the bot is in in the guild_ids parameter, is it a good thing, and how exactly is the best way to do so?
just use global slash commands?
I did but for some reason it isn't showing up when i removed the guild_ids parameter..
the command doesn't show up after /command name
it takes an hour for global commands to sync iirc
I see
I tried iterating through each of the guilds the bot is in and got the ID but well that didn't work
probably not a good thing to do though
doesnt seem too efficient to me
this is annoying me, "[pyflakes] local variable 'choice' defined in enclosing scope on line 40 referenced before assignment"
By the way blanket is there any guide or doc to what you said before about putting slash cmds into d.py yourself?
no
ew slash commands
wym
i dont like them
you'll have to switch to them at a point
i dont want to
harumph
idk
its not that hard
you just need to implement the classes
you could use global choice
i don't really like em too, but it isn't like i have a choice
or use class variables
someone help pls
oh, you turned off ping so i didnt see it
what do you mean global choice?
ive never used that
scoping in python

seriously? :/
ive never used it, you realize ive only been using python for like 2 weeks right?
i use it everyday i thought it is basic if u use functions :/
u can change or make a global variable by that
how?
ahh i don't really know and i don't wanna spend time on it if i don't end up doing it π
functions do not recognise global variables defined in the root code
that's how you can take variables into functions
#global variable
a = 1
def add():
#local variable
a = 2
!d global
7.12. The global statement
global_stmt ::= "global" identifier ("," identifier)*
``` The [`global`](https://docs.python.org/3.10/reference/simple_stmts.html#global) statement is a declaration which holds for the entire current code block. It means that the listed identifiers are to be interpreted as globals. It would be impossible to assign to a global variable without `global`, although free variables may refer to globals without being declared global.
Names listed in a [`global`](https://docs.python.org/3.10/reference/simple_stmts.html#global) statement must not be used in the same code block textually preceding that `global` statement.
Names listed in a [`global`](https://docs.python.org/3.10/reference/simple_stmts.html#global) statement must not be defined as formal parameters, or as targets in [`with`](https://docs.python.org/3.10/reference/compound_stmts.html#with) statements or [`except`](https://docs.python.org/3.10/reference/compound_stmts.html#except) clauses, or in a [`for`](https://docs.python.org/3.10/reference/compound_stmts.html#for) target list, [`class`](https://docs.python.org/3.10/reference/compound_stmts.html#class) definition, function definition, [`import`](https://docs.python.org/3.10/reference/simple_stmts.html#import) statement, or variable annotation.
ok then how fix?
use class variables is the second option
#global variable
number = 1
class myClass():
#class variable
classNumber = 2
print(myClass.classNumber)
useful in cogs... I think
i seriously have no idea how id put that into the code
pretty sure you'll want to learn cogs once
cogs...
isnt that a thing thats used a lot but nobody has ever told me to use before
ok...
youre using choice as both your ['rock', 'paper', 'scissors'] list and also the choice you randomly select
just change the first choice to choices or something and then do random.choice(choices) or you could just remove the list entirely and just do random.choice(['rock', 'paper', 'scissors'])
@bot.command()
async def guessgame(ctx):
embed=discord.Embed(title=':thinking: The Emoji Guess Game', description='Guess an emoji out of the 5 that the bot added as reaction and tap it.', color=0xfbe79f)
choices=[':tennis:', ':baseball:', ':softball:', ':volleyball:', ':rugby_football:']
bot_choice = random.choice(choices)
message = await ctx.send(embed=embed)
for __choice in choices:
await message.add_reaction(__choice)
def check(reaction, user):
return user == ctx.author
reaction = None
while True:
if str(reaction) == bot_choice:
embed=discord.Embed(color=0xfbe79f)
embed.add_field(name=':win: You won!',value=f'you guessed my choice!')
await message.edit(embed=embed)
else:
embed=discord.Embed(color=0xfbe79f)
embed.add_field(name=':lose: You lost!',value=f'you didnot guessed my choice!')
await message.edit(embed=embed)
try:
reaction, user = await bot.wait_for('reaction_add', timeout=30.0, check=check)
await message.remove_reaction(reaction, user)
except:
break
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji
what is the invalid emoji? i copied every name of the emojis from discord
oh
maybe you cannot add :emoji:
thank you thank you thank you so so so so much, it works now yay yay yay
you can
no, you donβt.
if you're using it in a message you dont but when you're adding a reaction yeah you do
embed fields need values
all of them
np
how do i import 'bot'?
!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/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
why command doesnt work : ```py
@bot.command
async def game(self, ctx):
number = random.randint(0, 100)
for guess in range(0, 5):
await ctx.send('guess')
Message = await self.bot.wait_for('message')
Message = int(Message)
if Message.cleant_content > number:
await ctx.send('bigger')
elif Message.cleant_content < number:
await ctx.send('smaller')
else:
await ctx.send('true')
This is an almost identical question to https://stackoverflow.com/questions/62075804/number-guessing-game-with-discord-py-rewrite
its exact isnt it
Different first line
its broken code lol
And that first line introduces an extra bug, since with Cogs you should be using commands.command() instead
Is there a way to use a local image on an embed's thumbnail?
The number of bot members is 500 thousand, and when I restart it, it is delayed because of its assembly of members. What is the solution?
Anyone?
wait
what?
@ripe jackal we aren't going to help with a nitro-gen brute forcer here
what is brute forcer?
this is something stupid and fun, there is no way to get that lucky to get a real nitro lol
i though it can be fun :/
to have a command like it
First of all which server you running on ?
sorry π
Dpy , visual studio
Yeaahh, but I'm still not sure Discord would be happy about it @ripe jackal π
okay, did not know that. Sorry about it ! Thank you for telling me! Is it bannable btw?
By Discord, or by us?
both
I'm sure generating nitro gift links is against Discord's ToS.
Within this server, we usually give people a chance to learn the rules. It would only be an issue if you continued to ask for help with something after being told not to by a moderator.
oh, then I guess I won't be using the command π Thank you for telling me! Again!
I mean, it's not the worst thing in the world, but we don't want to help with or encourage anything that would make Discord unhappy.
As we are a partnered server.
yeah, I got it
hello
hi
Dpy ? never really heard of it
I mean discord.py
I mean are you running the bot locally or on a server ?
Server
which one ?
Vps

isn't a vps local 
no...
I think so atleast
but it could be anything lmao
from heroku and replit to some official google stuff
which one aws, linode or replit just specify which hosting service ?
@strong kettle
hello
Ok I want to send a message with a embed, select menu and buttons but I got the error 'tuple' object does not support item assignment to solve this I did this ```py
feedback
@client.group(invoke_without_command=True)
async def feedback(
ctx,
*,
text=None,
):
try:
text = text.split("|")
report = discord.Embed(color=0xFFF868)
report.add_field(
name="Pending Confirmation",
value=f"{text[1]} #Tittle \r {text[2]} #Description",
)
FB =[ [
[
Button(style=ButtonStyle.red, label="Discard", custom_id="n"),
Button(style=ButtonStyle.green, label="Send", custom_id="y"),
]
], Select(
placeholder="Where to post",
options=[
SelectOption(label="Bugs", value="value1"),
SelectOption(label="Commands", value="value2"),
SelectOption(label="Suggestions", value="value3"),
SelectOption(label="Other", value="value4"),
],
)]
FS =FB
await ctx.channel.send(embed=report, components=FS)``` but now I am getting a error 'list' object has no attribute 'to_dict' How do I solve this ?
Any help
traceback?
no more like Exception also it a AttributeError
just ctrl+f to find to_dict attribute
but the list doesn't have to_dict or in other words 'list' object has no attribute 'to_dict'
@cloud dawn :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | AttributeError: 'list' object has no attribute 'to_dict'
yes but why is it happening ?
Because you are using to_dict on a list
so to solve do FS.to_dict right ?
i have no idea what datatype FS is but if you tried FB.to_dict then it won't work
what will then ?
FS is a list
trying to solve a error and also read the message again: #discord-bots message
Yeah you told you wanted to create a message with embed and buttons but that's not what you currently want.
Why do you want to convert it to a dict?
FS is actually a list inside a list
Also saw that don't know why though.
thats the cause
components expects a list
iterates through it and calls to_dict
but here it found another list
thus raising AttributeError
ok thanks
:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1633466265:f> (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).
Fine I solved that but now it gives me the error 'Select' object is not iterable here is the new line of code ```py
FB = [
[
Button(style=ButtonStyle.red, label="Discard", custom_id="n"),
Button(style=ButtonStyle.green, label="Send", custom_id="y"),
]
]
FA=Select(
placeholder="Where to post",
options=[
SelectOption(label="Bugs", value="value1"),
SelectOption(label="Commands", value="value2"),
SelectOption(label="Suggestions", value="value3"),
SelectOption(label="Other", value="value4"),
],
)
FS=zip(FB,FA)```
Hi, could you please help me with getting list of channels in specified category?
just wait maybe I know how to solve it
!d discord.CategoryChannel.channels
property channels: List[GuildChannelType]```
Returns the channels that are under this category.
These are sorted by the official Discord UI, which places voice channels below the text channels.
Where do you learn slash.py in (I'm not talking about youtube wise) I'm talking about reading it not listening
dislash?
mhm
There are examples on their GitHub
a little question
new_channel = await after.channel.clone(name=f'Squadra di {member.name}') can i set the category where it will be created?
What is yalls opinions on bdfd(bot designer for discord)
position kwarg
!d discord.abc.GuildChannel.clone
await clone(*, name=None, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Clones this channel. This creates a channel with the same properties as this channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to do this.
New in version 1.1.
huh
guess not
you have to edit the category once cloned
clone -> edit position
?
ok
so is it possible to move to other category after cloned?
probably not
the change for intents only affects verified bots and bots planning to get verified
oh ok
cus people in the bdfd server were saying that "d.py would be useless after 2022"
no
thatβs not true
discord.py will keep working until it stops working
we donβt know when it will break but the intent change wonβt break it
In the future it might break but the beauty of the MIT license and an open source repo. Allows users to edit the library in the future to fix their own problems and distribute to other users as well
total_users = len(guild.members)
total_bots = len([member for member in guild.members if member.bot == True])
total_humans = total_users - total_bots
``` what is the issue with this command, its such a pain
Hi, im trying to check how can i make users can't mention guild.roles or guild.members, how can i make it?
unrelated topic, but python is not installing a discord module why
I basically ran this on heroku
it says installed, then when I run pip freeze it doesn't display the new module why
and it doesn't have the new module downloaded, because it states "invalid module" when I try to run import on it
I have this metod in my code, maybe can help you```
list_of_bots = len([bot.mention for bot in ctx.guild.members if bot.bot])
true_member_count = len([m for m in ctx.guild.members if not m.bot])
totalmember = list_of_bots + true_member_count
I think you can do total_bots = len(discord.utils.find(ctx.guild.members, bot=True)). Not very sure about that.
Yeah, it won't work.
discord.utils.find doesn't have a bot attr.
bot = commands.Bot(command_prefix=[':banana:', ':banana: '], help_command=None)```
so, i have my bot prefix as the banana emoji, but for discord convenience, i want it to accept the emoji with a space after it (bc discord automatically adds the space after when you type an emoji), but it doesn't actually take ```:banana:(imagine there's a space here)```
as an input. only ```:banana:```
how would i make it accept the space after? or is there not a way to
find takes in a func and an iterable
Can it take a check?
!d discord.utils.find
discord.utils.find(predicate, seq)```
A helper to return the first element found in the sequence that meets the predicate. For example:
```py
member = discord.utils.find(lambda m: m.name == 'Mighty', channel.guild.members)
``` would find the first [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") whose name is βMightyβ and return it. If an entry is not found, then `None` is returned.
This is different from [`filter()`](https://docs.python.org/3/library/functions.html#filter "(in Python v3.9)") due to the fact it stops the moment it finds a valid entry.
But that returns only the first result found.
Is there a way get the channels a member is able to see?
then use the builtin filter
!d filter
filter(function, iterable)```
Construct an iterator from those elements of *iterable* for which *function* returns true. *iterable* may be either a sequence, a container which supports iteration, or an iterator. If *function* is `None`, the identity function is assumed, that is, all elements of *iterable* that are false are removed.
Note that `filter(function, iterable)` is equivalent to the generator expression `(item for item in iterable if function(item))` if function is not `None` and `(item for item in iterable if item)` if function is `None`.
See [`itertools.filterfalse()`](https://docs.python.org/3.10/library/itertools.html#itertools.filterfalse "itertools.filterfalse") for the complementary function that returns elements of *iterable* for which *function* returns false.
Yeah, I've already checked that out.
await ctx.send("This message won't ping", allowed_mentions=discord.AllowedMentions.none())
How can i check if in the message.content has a guild.roles, I try
If guild.roles in message_components:
But nothing
What do you mean by check if the message has guild.roles?
Or when anyone ping a guild.roles in the message, the bot dont ping and say (only if has a guild.roles mention) This Message Won't ping
Check if user ping for example @calm sparrow in the command say
You need to check the message.role_mentions
Im trying to make a discord bot, but when I send something it doesnt do anything. Code: https://replit.com/@joecooldoo/discybot#main.py
'str' object has no attribute 'role_mentions'
Don't check the message.content.role_mentions
How can I do it then?
Check if the role was mentioned in message.role_mentions
Still the same
Rather, how can I do so that if someone mentions a server role in the command, that above the message they put a message saying "This messages won't ping". Only when someone does the command mentioning a role
Hey, how can I get the ID of a user when they add a reaction to a message
!d discord.on_reaction_add
discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.
Note
To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").
This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
Note
This doesnβt require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message itβs required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
the 2nd param. is the user reacting to a message
Code:```py
async def on_raw_reaction_add(reaction, user):
try:
db[f"{reaction.message.id}"]
thing = True
except KeyError:
thing = False
if thing == True:
current = db[f"{reaction.message.id}"]
db[f"{reaction.message.id}"] = f"{current}, {user.id}"
Error:
```diff
-Ignoring exception in on_raw_reaction_add
-Traceback (most recent call last):
- File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
- await coro(*args, **kwargs)
- TypeError: on_raw_reaction_add() missing 1 required positional argument: 'user'```
no I am not
+did you use the event decorator
Client.event
On on_raw_reaction_add only takes payload
on_reaction_add is reaction and user
These are two different events
ok
Use this ^
You can add a kwarg to your bot constructor to make it only able to ping certain stuff
!d discord.ext.commands.Bot.allowed_mentions
property allowed_mentions: Optional[discord.mentions.AllowedMentions]```
The allowed mention configuration.
New in version 1.4.
that or you can use clean_content iirc to remove any mentions for a specific situation.
hm
!d discord.Message.clean_content
A property that returns the content in a βcleaned upβ manner. This basically means that mentions are transformed into the way the client shows it. e.g. <#id> will transform into #name.
This will also transform @everyone and @here mentions into non-mentions.
Note
This does not affect markdown. If you want to escape or remove markdown then use utils.escape_markdown() or utils.remove_markdown() respectively, along with this function.
AttributeError: 'int' object has no attribute 'get_role'
grabrole = payload.guild_id.get_role(rolefromdb)
get_role is a method of discord.Guild
guild_id attr of payload is an int, not a discord.Guild instance
You can pass payload.guild_id to Bot.get_guild to get the instance
!d discord.ext.commands.Bot.get_guild
get_guild(id, /)```
Returns a guild with the given ID.
anyone know how to keep my bot file alive using digitalocean host? whenever i close my ssh client the terminal, along with the script, kills itself
Missing Permissions
nickname = thing pulled from db
await payload.member.edit(nick=nickname)
bot has administrator and manage nick perms, and is above @ everyone
is the bot's highest role above the user's highest role?
yes
also, the bot cannot change the server owner's nickname
perhaps is the reason, ill get a friend online. thank you
Is it a good option to make a remind command with asyncio?
What do I do with this then .-.
@commands.command(aliases=['rem'])
async def remind(self, ctx, time, task):
def convert(time):
pos = ['s', 'm', 'h', 'd']
time_dict = {"s": 1, "m": 60, "h": 3600, "d": 3600*24}
unit = time[-1]
if unit not in pos:
return -1
try:
val = int(time[:-1])
except:
return -2
return val * time_dict[unit]
converted_time = convert(time)
if converted_time == -1:
await ctx.send("You didn't answer the time correctly.")
return
if converted_time == -2:
await ctx.send("The time must be an integer.")
return
embed = discord.Embed(title=f"Your reminder has been set!", color=0x000100)
await ctx.send(embed=embed)
await asyncio.sleep(converted_time)
embed = discord.Embed(title="Reminder π",
description=f"{task}",
color=0x000100
)
await ctx.author.send(embed=embed)
your wish, you can stay with it if you dont have too much traffic with it. Or if your bot is used by many users, you can migrate to tasks.loop
Oh okay thank you
hi, how can i make a command not case sensitive so the help command can also he HeLp
pass case_insensetive=True in commands.Bot()
case_insensitive ^
Put case_insensitive=True in your bot constructor variable
Does anybody know how to code an application bot?
The bot recieves applications from members for staff to read
do i need to use the os module to make discord bots?
Nope, only the discord and discord.ext.commands modules
sick
How long does the discord api take to update a bots name?
have been stuck on this for 12hrs!
post code
How can i change help command in discord.py
In your constructor you can add help_command=None but itβs better to subclass the default help command