#discord-bots
1 messages · Page 637 of 1
jesterbot is a discord-bot coded in discord.py with over 180 commands and 15 cogs. - JesterBot/Store.json at main · CaedenPH/JesterBot
i literally put my token in a json like 8 months ago
forgot it was there
pushed it straight to github
Same
stupid shit…lots of stupid shit xD
Whos that if you dont guys mind me asking 
It’s an automated message from discord when GitHub notifies them of a valid bot token on its platform
i accidentally pushed the token when i was on holiday for a couple weeks when it was about to be verified on top.gg - i host it locally so i was a bit panicked lol
Ah i see
oh i thought discord just was webscraping 24/7
Nope GitHub partnered with discord in a way and GitHub scans repos for tokens
oh cool
How to save transcript like ticket bot?
Once the bot’s done w a conversation in dms, it saves the transcript of the chat and posts it in a specific channel
I have this:
channel = client.get_channel(914409887948222494)
messages = await dm.history().flatten()
with open(f'{channel}_messages.txt', 'a+', encoding='utf-8') as f:
print(f"\nTranscript Saved.\n\n", file=f)
for message in messages:
embed = ""
if len(message.embeds) != 0:
embed = message.embeds[0].description
print(f"{message.author.name} - {embed}", file=f)
print(f"{message.author.name} - {message.content}", file=f)
await channel.send(f"{message.author.mention}, Transcript saved.")
history = discord.File(fp=f'{channel}_messages.txt', filename=None)
await channel.send(file=history)
But it’s all messed up, it saves a local file on computer and pastes it in the channel, however, only works when I have a conversation and if someone else has a conversation w the bot, it still sends back my conversation:
Here’s the docs:
https://discordpy.readthedocs.io/en/latest/api.html#discord.DMChannel.history
await ctx.send(f"{len(bot.users)}") this sends the count of users that are used by the bot right? like the total count of all members in all servers that the bots in?
I think that sends the amount of bots
its in 25 servers, and when i make it send that line, the output is 145000 
Idrk 😭
!d discord.ext.commands.Bot.users
property users: List[discord.user.User]```
Returns a list of all the users the bot can see.
Ah i see
i found this on reddit, could it provide an accurate number? sum([len(guild.members) for guild in bot.guilds])

Not if you don’t have member intents, also the bot.users does it for you…. So one is API taxing the other is not…
is there a way to make a superwide embed? cuz i have all my values inline but after 3 values it drops below
ive got all intents enabled
nope
and intents = discord.Intents.all() as well
Just do bot.users
#help-mushroom about discord bots
no len?
just {bot.users}
How to save transcript like ticket bot?
Once the bot’s done w a conversation in dms, it saves the transcript of the chat and posts it in a specific channel
I have this:
channel = client.get_channel(914409887948222494)
messages = await dm.history().flatten()
with open(f'{channel}_messages.txt', 'a+', encoding='utf-8') as f:
print(f"\nTranscript Saved.\n\n", file=f)
for message in messages:
embed = ""
if len(message.embeds) != 0:
embed = message.embeds[0].description
print(f"{message.author.name} - {embed}", file=f)
print(f"{message.author.name} - {message.content}", file=f)
await channel.send(f"{message.author.mention}, Transcript saved.")
history = discord.File(fp=f'{channel}_messages.txt', filename=None)
await channel.send(file=history)
If you want the list of users and not the length of the list yes; doesn't seem like you do, though
But it’s all messed up, it saves a local file on computer and pastes it in the channel, however, only works when I have a conversation and if someone else has a conversation w the bot, it still sends back my conversation:
Here’s the docs:
https://discordpy.readthedocs.io/en/latest/api.html#discord.DMChannel.history
i wanna find the total number of users in all servers that the bots in
so if its in 2 servers with 2 members each, than the output should be 4
You don't need to make a local file for this (and you shouldn't)
Consider io.StringIO
Docs?
!d io.StringIO
class io.StringIO(initial_value='', newline='\n')```
A text stream using an in-memory text buffer. It inherits [`TextIOBase`](https://docs.python.org/3/library/io.html#io.TextIOBase "io.TextIOBase").
The text buffer is discarded when the [`close()`](https://docs.python.org/3/library/io.html#io.IOBase.close "io.IOBase.close") method is called.
The initial value of the buffer can be set by providing *initial\_value*. If newline translation is enabled, newlines will be encoded as if by [`write()`](https://docs.python.org/3/library/io.html#io.TextIOBase.write "io.TextIOBase.write"). The stream is positioned at the start of the buffer.
The *newline* argument works like that of [`TextIOWrapper`](https://docs.python.org/3/library/io.html#io.TextIOWrapper "io.TextIOWrapper"), except that when writing output to the stream, if *newline* is `None`, newlines are written as `n` on all platforms.
[`StringIO`](https://docs.python.org/3/library/io.html#io.StringIO "io.StringIO") provides this method in addition to those from [`TextIOBase`](https://docs.python.org/3/library/io.html#io.TextIOBase "io.TextIOBase") and [`IOBase`](https://docs.python.org/3/library/io.html#io.IOBase "io.IOBase"):
What you had initially was correct
#discord-bots message
use utf-8?
What?
discord.File(io.BytesIO(transcriptstring.encode("utf-8")), "transcript.txt")
I think I got it
lemme try
You can just use StringIO without having to encode the string
But that might work sure
Kk
is it possible to detect if a user is sending an emoji or not
There is an emoji package?
what
!pypi emojis
Hello silly question but ive just started a bot. any ideas why i cant get the command to work?
@client.command()
async def test(ctx):
print("works")
ctx.send("works")```
await ctx.send(“works”)
Ofcourse yes, but also the print isnt working?
I think because it couldnt send the message
How did you define your bot? Can you send the whole file minus your token
sure
It should execute everything up to the problem line
Ah i see
Forgot about that
Maybe the bot isnt online
Or as you said the bot instance
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Where should i got to get help on installing git for linux?
how can I detect who sends a message
!ot
Off-topic channels
There are three off-topic channels:
• #ot2-never-nester’s-nightmare
• #ot1-perplexing-regexing
• #ot0-psvm’s-eternal-disapproval
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.
!d discord.Message.author
@brittle ingot https://paste.pythondiscord.com/rawuhaxeyo.py
You need to process commands in your on_message event
oh damnn ofcourse!!
so
if user = "id"
And why are you changing your bots presence on_ready?
Looks like it.
What are you trying to do?
@brittle ingotcan i not have my commands anywhere in the code with @client.command?
Here is why you shouldn’t do anything in on_ready
reacting to a message if a certain user sends it
You can as long as it’s after you define the bot
if ctx.author.id == id:
#do something
alright, thanks
@brittle ingot```client = commands.Bot(command_prefix='!', intents=intents) like this?````
Yeah
@brittle ingotI have that at the very top of my code. so the command should work how it is?
Its a atom action basically
Seems like your very confused?
Very 🙂
It should yeah.
The READY event dispatched from the gateway only gives user about the current authorised user and presences if intents are enabled really. Most of the important and time consuming data is given in GUILD_CREATE which will be dispatched for every guild the client is in during startup
@brittle ingotAny idea what else could be causing it not to work?
And that's not really a valid reason 2 not do stuff in READY
A good reason would be that it can be dispatched more then ONCE
Or the fact that changing presence during READY dispatch can cause a 1006 websocket error code
you didn’t process commands in your on_message event
On line 126 right after your return and outside the if statements add:
await bot.process_commands(message)
If its a messag event its^
it literally says line 73, in on_message
so its a message event
I didnt knew that?
Thanks
Who are you thanking exactly 😭
no problem man!
What for? I am so confused
is message.react not a thing?
No dont think so
message.add_reaction im pretty sure
You add a message to a var and you do add_reaction
what?
sweet, thanks
now how do I add custom emojis?
msg = await ctx.send("a message")
msg.add_reaction("the reaction")
<:EmojiName:#EmojiID#> just put that instead of the emoji name
Hes trying to do a reaction
You can just paste in the emoji like they’re saying or you can fetch the emojis by it’s ID
Exactly
Mostly use the id for custom emojis
bro what, he already has the message object, what if he uses a converter or a event
yea ids can work as well
||has a stroke||
ok, and if I use a custom emoji will it work in servers that don't have that emoji
Let’s just keep it simple. To the specific application at hand
Yes bots have nitro
once the bot is in the server that the emoji is from, yes
Youll have to use the id
k ty for all the help
Fr?
Yeah
Can u set an animated pfp?
bots dont have nitro lol
Yeah
They have a sorta nitro
Ohh
Not exactly nitro but they have some features of it
They kinda have nitro
It’s like an advanced member state
they just can do extra stuff cause they are a bot account and not a user account
no
Yeah
Well It’ s nice to be able to send emojis from other servers
can a normal user do that?
If u buy nitro yes
Actually?
theres a difference, u cant compare them to user accounts
Alright let’s reign it in
I swear this guy thinks im a beginner 😭
u act like one lmao
Stick to the facts. Bots can send animated emojis and regular custom emojis from other servers as well as sticker.
Dope
Alright we don’t degrade. Assuming someone needs to know everything to help and degrading them for not knowing everything is frowned upon.
I agree
im not but he refuses to listen when i tell him hes wrong, he has a hypocritical attitude which isnt healthy for a community tbh
The entire point of this channel is to help others and learn things yourself. Just because my name is green doesn’t mean I’m better than others. It means I paid money for it.
Can we all calm down pls 😭
I didn’t see it as hypocritical at all. I saw it as stating a fact.
This channel had like 5 arguments in 3 days
Anyways onwards and upwards
Ty
A bot is treated just like a user. However, Discord bots have a limited edition of Nitro.
Ok idc about your opinion?
Scoopy 🤜🏽
Im not here to fight with little kids,only to help others
:left_facing_fist_tone3: Moros
And i will like to keep it civil and to topic so if you dont like that you may leave
Fr
Alright docs challenge again 😄
But he says "they only have the emoji feature"
Yess
Bet
Docs Challenge
Find and post one thing from discord.py docs that was the most challenging thing for you to learn. How did you overcome it and understand it in the end
is it possible to mention another channel in an embed?
Yes
Im trying channel_id.mention but im getting an error with the .mention
You can either send the mention as a string or get the channel object and use .mention on it
So to get the string mention as I call it you just mention the channel here in discord and put a backslash in front of it and hit send
Just get the channel id and put in <#channelid>
how can i uninstall dpy v2 and go to dpy v1.(x)?
https://discordpy.readthedocs.io/en/stable/ext/commands/cogs.html?highlight=ctx cogs due to so much too learn about it
#python-discussion is [#python-discussion](/guild/267624335836053506/channel/267624335836053506/)
channel_id = readsettings('BOT_SETTINGS', 'general_channel'))
embed.add_field(
name="If you need urgent support please open a ticket by reacting below.",
value=f"Before opening a ticket, ask yourself is it urgent? Why not try ask the community to see if they can help? {channel_id.mention}",```
Guess what. I made a repository to explain it.
Yeah i learned it already
And yes i used your repo to learn it
Lmao


So that just gets the channel ID from there you can invade that in <# > to mention the channel
Print channel_id.
@dapper cobalt your repos are very lovely 
Like so
So r u 
<#{channel}> in an f-string
gotchaa
As its async already
Yeah get channel is just getting the channel object from cache isn’t not awaitable
lol
@brittle ingotAwesome dude, never knew that thanks
Np
Wait is it bot.get_channel or guild.get_channel
get_channel(channel_id, /)```
Returns a channel with the given ID.
Note
This does *not* search for threads.
!d discord.ext.commands.Bot.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
I guess so
Read the note, though.
Huh would have thought it the other way around
Voice related stuff, I was doing a music bot some time ago and my code looked like it should have worked, I didnt know the value of reading error messages back then so after some time of debugging I finally installed pynaci and it worked
Lol seems like something I would totally do
I still havent gone to the voice related area lol
Me either
Seems useless to me
Well, that part is easy, the difficult part is getting audio to play and storing it in a queue
I see
Unless your making a music bot I tent to agree
Yeah
U could make a bot that joins vc and screams at ppl
🤷🏼♂️
Useless but funny
Oh my word 😹😹
Lmao fr
Once voice recv becomes a bigger thing you could do an alexa or siri type thing
Or a bot that joins a vc and roasts you or disconnects you
That would be lit
Do you have the resources for such neural network?
I imagine if you had some voice recognizer or some type of AI you could moderate VCs checking words against voice notes stored for certain bad or banned words people may use. How you’d do that I have no damn clue. But an interesting thought
Computation resources maybe? The coding part will take a bit though
I would need to train the machine, otherwise use an already trained machine
Yea, training a model
The hard part first though is actually implementing voice recv
I dont think someone could make a good virtual assistant by themselves
Or it might be easy, I'm not sure, I'm basically gonna let blanket do the voice recv impl for lefi
Yes, I dont think bot can listen to audio in vc
I cba to learn all that byte stuff
I actually follow a guy on TikTok who works in AI. Pretty cool stuff
Did yall see a site where u can type in english what you want your code to do and ai will write the code
It’ s codex or something
😳
Blanket 😮 haven’t seen them in forever
Cause he got banned from pydis
Oof lmfao
What happend their not here anymore
No clue
Would the voice recv actually read and recognize words? Or is that gonna be left to the user
I'm not sure really how that would look. All I know right now is that we can receive the packets needed. We just haven't decoded them yet
Ah
Well that’s freaking cool
I wish I could work on the converters more often but schools been busy unfortunately
yeah ^
By the time I finish docs and you haven't been able to is it fine if I just do them?
I need to do slash command converters either way
Yea that's fine
Ummm so my help command isnt showing anything for my seasonal cog and this is all my code
does anyone know what is causing this
I thought the """
""" was the help description
@ me when you can help
is there any way to get the message history of a specific user without first check the entire message history?
like the usual way i would handle it is iterating over channel history and checking if each message author is the targeted author, but that is super slow
Add a check.
async for i in channel.history(limit=limit, check=check)
i got an error saying check was an invalid keyword
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\thoma\Desktop\discord.py\python\bot.py", line 38, in on_raw_reaction_remove
for key, value in data:
ValueError: too many values to unpack (expected 2)```
anyone?
it means it doesnt exist
hey when using MySQL with discord do i need to open the connection everytime i update something? or can i open the connection once and go from there?
bot.user.id
Is the best way to get when a user stopped boosting the sever through on_member_update for roles and see if he lost the premium role
Idts
hmm?
so im making a discord bot where i want the command to loop something but it continously stops unexpectedly
any way for it to not break? there are no errors in the logs of the cmd so im unsure why its stopping
!d discord.Message.pinned
import requests
how do i do that
how do i detect a pin?
do import requests
type in
import requests
uhh
!d discord.Message.pin
tysm it worked
no worries
hey guys, how can i detect a new pin in a channel
hello, did anyone can help me?. currently im making stats cmd for my bot
im trying make uptime with time and psutil and get error :
An error occurred: Command raised an exception: TypeError: get_uptime() takes 0 positional arguments but 1 was given
code :
ModuleNotFoundError: No module named 'discord'```
and pip install discord.py Requirement already satisfied
Restart your Ide
@client.event
async def on_ready():
print(f"{client.user.name} is online")
DiscordComponents(client)
@client.event
async def on_raw_reaction_remove(payload):
with open('reactrole.json') as react_file:
data = json.load(react_file)
for key, value in data.items():
if value['emoji'] == payload.emoji.name:
role = discord.utils.get(client.get_guild(
payload.guild_id).roles, id=['role_id'])
await client.get_guild(payload.guild_id).get_member(payload.user_id).remove_roles(role)
@client.event
async def on_member_join(member):
guild = client.get_guild(730651046459998218)
channel = guild.get_channel(885464532959526913)
myEmbed = discord.Embed(title = f"Welcome",
description= f"You are member {guild.member_count}, \n Enjoy your stay here and dont forget to read the await [#904279966693355550](/guild/267624335836053506/channel/904279966693355550/)", color=0x0ff00)
await channel.send(embed=myEmbed)
role = guild.get_role(832120561848156180)
await member.add_roles(role)
@client.event
async def on_raw_reaction_add(payload):
ourMessageID = 903210158803537970
if ourMessageID == 903210158803537970:
member = payload.member
guild = member.guild
emoji = payload.emoji.name
if emoji == '✅':
role = discord.utils.get(guild.roles, name="Member")
await member.add_roles(role)
@client.event
async def on_raw_reaction_add(payload):
if payload.member.bot:
pass
else:
with open('reactrole.json') as react_file:
data = json.load(react_file)
for key, value in data.items():
if value['emoji'] == payload.emoji.name:
role = discord.utils.get(client.get_guild(
payload.guild_id).roles, id=['829665222380879912'])
await payload.member.add_roles(role)```
i have this code but this code aint really working its not giving the autorole role
exec executes code directly as if its a part of the script, it doesnt have any return value
you could try doing smth like,
def func(code):
new = "\n".join(["\t" + line for line in code.splitlines()])
exec(f"def _func():\n{new}\nglobals()['_return']=_func()")
return _return
print(func("return 'hi'"))
not sure if it works tho
i did like 10 times
can help mine tho?
eval() instead of exec() if you want return value btw
Do you have multiple versions of python on your device?
You need self arg
Hello
For every functions inside classes
oh so get_uptime(self)
Yes
ok" tq
Then you can call it with self.get_uptime()
yea i forgot add self on class
but on my return value is it true?
try it and see
idk
fine lul
Hello any one?
wht ur problem?
my bot isnt giving the auto role this is my code but it aint giving errors
@client.event
async def on_ready():
print(f"{client.user.name} is online")
DiscordComponents(client)
@client.event
async def on_raw_reaction_remove(payload):
with open('reactrole.json') as react_file:
data = json.load(react_file)
for key, value in data.items():
if value['emoji'] == payload.emoji.name:
role = discord.utils.get(client.get_guild(
payload.guild_id).roles, id=['role_id'])
await client.get_guild(payload.guild_id).get_member(payload.user_id).remove_roles(role)
@client.event
async def on_member_join(member):
guild = client.get_guild(730651046459998218)
channel = guild.get_channel(885464532959526913)
myEmbed = discord.Embed(title = f"Welcome",
description= f"You are member {guild.member_count}, \n Enjoy your stay here and dont forget to read the await [#904279966693355550](/guild/267624335836053506/channel/904279966693355550/)", color=0x0ff00)
await channel.send(embed=myEmbed)
role = guild.get_role(832120561848156180)
await member.add_roles(role)
@client.event
async def on_raw_reaction_add(payload):
ourMessageID = 903210158803537970
if ourMessageID == 903210158803537970:
member = payload.member
guild = member.guild
emoji = payload.emoji.name
if emoji == '✅':
role = discord.utils.get(guild.roles, name="Member")
await member.add_roles(role)
@client.event
async def on_raw_reaction_add(payload):
if payload.member.bot:
pass
else:
with open('reactrole.json') as react_file:
data = json.load(react_file)
for key, value in data.items():
if value['emoji'] == payload.emoji.name:
role = discord.utils.get(client.get_guild(
payload.guild_id).roles, id=['829665222380879912'])
await payload.member.add_roles(role)```
@brave flint
here is my whole code if u want it
I uninstalled dpy .then install pycord 2 days ago. then uninstalled it. and when i was trying to install dpy it said pip command does not exist. so i reinstalled my python. and when i installed dpy. it says import discord, os ModuleNotFoundError: No module named 'discord'
try to screenshot the code not like that
isn't sending better smh
Hey @jade tartan!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
Why do you have 2 on_raw_reaction_add events
.
async def on_raw_reaction_add(payload):
ourMessageID = 903210158803537970
if ourMessageID == 903210158803537970:
member = payload.member
guild = member.guild
emoji = payload.emoji.name
if emoji == '✅':
role = discord.utils.get(guild.roles, name="Member")
await member.add_roles(role)
@client.event
async def on_raw_reaction_add(payload):
if payload.member.bot:
pass
else:
with open('reactrole.json') as react_file:
data = json.load(react_file)
for key, value in data.items():
if value['emoji'] == payload.emoji.name:
role = discord.utils.get(client.get_guild(
payload.guild_id).roles, id=['829665222380879912 '])
await payload.member.add_roles(role)```
there 2 difference reaction codes
You can only have one
But can't you just have both of the code in one event 🙂
i can do that but i cant it separate
Well
It would still be okay if they are in the same function
How would it make any differences
well thx for ur help, now its working
Because you can't have two events with the same name
yeah well that aint a problem in python it kinda still works
could you just help me with question
or concern
ok then i dont think so but okay
That's how d.py works
It's not python
If you want 2 events with the same name you need a listener
async def on_raw_reaction_add(payload):
if payload.member.bot:
pass
else:
with open('reactrole.json') as react_file:
data = json.load(react_file)
for key, value in data.items():
if value['emoji'] == payload.emoji.name:
role = discord.utils.get(client.get_guild(
payload.guild_id).roles, id=['829665222380879912 '])
await payload.member.add_roles(role)
ourMessageID = 903210158803537970
if ourMessageID == 903210158803537970:
member = payload.member
guild = member.guild
emoji = payload.emoji.name
if emoji == '✅':
role = discord.utils.get(guild.roles, name="Member")
await member.add_roles(role)
so its like this
why is ourMessageID inside the for loop lmao
Can this be done
you actually can have the same event twice, use bot.listen("on_raw_reaction_add") then define the function as a different function name.
Yeah that's what I meant a listener
it's kinda short so yeah it's readable
Just use pip install discord or add the package if you are using repklit
i did
yes
So @vagrant brook ?
btw what are these help channels for like #help-apple
local
names are so funny
vscode
Did you install python 3.10?
yes
see I would recommend REPLIT because vs code is kinda complicated
I got the same error
Good luck
i have been using vsc since 3 years
such a bad experience
Dpy works fine with python 3.9s
its good for other languages
i dont like replit
Please don't recommend people replit.
Try installing a lower version of python, some libraries are still not available for python 3.10
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.
^ in regard to replit
3.9?
3.9 should work
ok
Yeah
will try
I personally use 3.9.6 and it works fine
I use 3.9.9
So what now?
Cry
So how will you make your bot 24/7 in other apps . I know replit is pathetic tho
Either a local host or a paid host
proceeds to delete replit account
Heroku?
- Bots are not what the platform is designed for. Heroku is designed to provide web servers (like Django, Flask, etc). This is why they give you a domain name and open a port on their local emulator.
- Heroku's environment is heavily containerized, making it significantly underpowered for a standard use case.
- Heroku's environment is volatile. In order to handle the insane amount of users trying to use it for their own applications, Heroku will dispose your environment every time your application dies unless you pay.
- Heroku has minimal system dependency control. If any of your Python requirements need C bindings (such as PyNaCl binding to libsodium, or lxml binding to libxml), they are unlikely to function properly, if at all, in a native environment. As such, you often need to resort to adding third-party buildpacks to facilitate otherwise normal CPython extension functionality. (This is the reason why voice doesn't work natively on heroku.)
- Heroku only offers a limited amount of time on their free programme for your applications. If you exceed this limit, which you probably will, they'll shut down your application until your free credit resets.
^ In reference to Heroku
how you write this much?
hex
I don't and im not. #discord-bots message
I want to use multiprocessing with discord.py
Wdym
The multiprocessing module
ok well my code works but now its giving me the role when i react to my emoji on the embed message
can someone help
What should it do?
do i have to uninstall 3.10?
!docs multiprocessing
ok hold up so
Good luck, i've never heard of it sorry
@upbeat otter
Better if you do
except it runs on top of each other
so when someone reacts to this emoji it should give them a role that will give access to the rest of the server
Why not use asyncio
instead of like threads
ok
idk how to use asyncio ;-;
use on_reaction_add
@upbeat otter
Its quite simple. A lot easier than multiprocessing or threads
i did here is the code for it
I'm not even sure if making a bot with threads is possible
I see arent u using, message.reactions, inside a command?
alright, I'll like at my last resort to get some information. youtube
Oh hmm, but using asyncio is suggested since the whole lib is based on it
async def on_raw_reaction_add(payload):
ourMessageID = 903210158803537970
if ourMessageID == 903210158803537970:
member = payload.member
guild = member.guild
emoji = payload.emoji.name
if emoji == ':white_check_mark:':
role = discord.utils.get(guild.roles, name="Member")
await member.add_roles(role)
@client.event
async def on_raw_reaction_add(payload):
if payload.member.bot:
pass
else:
with open('reactrole.json') as react_file:
data = json.load(react_file)
for key, value in data.items():
if value['emoji'] == payload.emoji.name:
role = discord.utils.get(client.get_guild(
payload.guild_id).roles, id=['829665222380879912'])
await payload.member.add_roles(role)```
and have this code
async def reactrole(ctx, emoji, role : discord.Role, *, message):
if ctx.author.guild_permissions.manage_roles == True:
if emoji == '☑️':
await ctx.send(embed=discord.Embed(title="Reaction Roles", description="**Syntax** : `gm<reactrole (emoji) (name or role) (message)`", color=discord.Color.blue()))
elif role == None:
await ctx.send(embed=discord.Embed(title="Reaction Roles", description="**Syntax** : `gm<reactrole (emoji) (name or role) (message)`", color=discord.Color.blue()))
else:
emb = discord.Embed(title=f"React for {role.name} Role!", description=message, color=discord.Color.blue())
msg = await ctx.channel.send(embed=emb)
await msg.add_reaction("\U00002705")
with open('reactrole.json') as json_file:
data = json.load(json_file)
new_react_role = {'role_name': role.name,
'role_id': role.id,
'emoji': emoji,
'message_id': msg.id}
data['Member'] = new_react_role
with open('reactrole.json', 'w') as f:
json.dump(data, f, indent=4)
else:
await ctx.send(embed=discord.Embed(title="Missing Permissions", description="You dont have permission to use this command!", color=discord.Color.blue()))
I'm bad with reaction thingies 
thats fine others will help
What's the problem
that its not giving me the role when i react to the emoji on an embed message
also i forgot to add 3.10 to path
i am adding it to path and will try
nvm same problem
will install 3.9.9
I'd recommend 3.9 due to library issues
Why install 3.9 tho. I use Dpy 2.0 with 3.10
i am not able to
What's the error
Module not found
my vps doesn't support 3.10 so...
@maiden fable
Aw
Hello I want to make a work command for my bot like it is in economy bots like dank memer how can I do it
Refresh your terminal and code editors and try again @high pollen
The most common problem is multiple Python versions
Mine does ngl
but much downtime
and here is my bot link do use it https://discord.com/oauth2/authorize?client_id=892376302831677520&permissions=8&scope=bot&applications.commands and test features
how to check how many versions i have?
Rich people 
ikrr
View settings or just check it by clicking on select interpreter in vsc
ok
Pls help me
or print(sys.version)
You need to ask
ok
we help your question/problem but not code it for you
Like a normal command
Thank me later
No I cant understand whether i should use a json file or what
database
i dont have
sqlite3 or something else
Json works too
its built-in
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\thoma\Desktop\discord.py\python\bot.py", line 71, in on_raw_reaction_add
await payload.member.add_roles(role)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\member.py", line 777, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'```
plz
role is None
It came with my command do
Lmao
too i DONT KNOW HOW DO I SOLVE IT
@client.command(aliases = ["lb"])
async def leaderboard(ctx,x = 3):
users = await get_bank_data()
leader_board = {}
total = []
for user in users:
name = int(user)
total_amount = users[user]["wallet"] + users[user]["bank"]
leader_board[total_amount] = name
total.append(total_amount)
total = sorted(total,reverse=True)
em = discord.Embed(title = f"Top {x} Richest People" , description = "This is decided on the basis of raw money in the bank and wallet",color = discord.Color(0xfa43ee))
index = 1
for amt in total:
id_ = leader_board[amt]
member = ctx.get_user(id_)
name = member.id
em.add_field(name = f"{index}. {name}" , value = f"{amt}", inline = False)
if index == x:
break
else:
index += 1
await ctx.send(embed = em)
!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.
async def reactrole(ctx, emoji, role : discord.Role, *, message):
if ctx.author.guild_permissions.manage_roles == True:
if emoji == '☑️':
await ctx.send(embed=discord.Embed(title="Reaction Roles", description="**Syntax** : `gm<reactrole (emoji) (name or role) (message)`", color=discord.Color.blue()))
elif role == Member:
await ctx.send(embed=discord.Embed(title="Reaction Roles", description="**Syntax** : `gm<reactrole (emoji) (name or role) (message)`", color=discord.Color.blue()))
else:
emb = discord.Embed(title=f"React for {role.name} Role!", description=message, color=discord.Color.blue())
msg = await ctx.channel.send(embed=emb)
await msg.add_reaction("\U00002705")
with open('reactrole.json') as json_file:
data = json.load(json_file)
new_react_role = {'role_name': role.name,
'role_id': role.id,
'emoji': emoji,
'message_id': msg.id}
data['Member'] = new_react_role
with open('reactrole.json', 'w') as f:
json.dump(data, f, indent=4)
else:
await ctx.send(embed=discord.Embed(title="Missing Permissions", description="You dont have permission to use this command!", color=discord.Color.blue()))
???
See it raises the same error as @jade tartan
Whats the error?
And If I remove id from member it says None
only 1
@slate swan question: Which is the best way to check for who stopped boosting a server?
show your on_raw_reaction_add
But if your bot has 1000 users.....
AttributeError: 'NoneType' object has no attribute 'id'
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
A full traceback could look like:
Traceback (most recent call last):
File "tiny", line 3, in
do_something()
File "tiny", line 2, in do_something
a = 6 / b
ZeroDivisionError: division by zero
The best way to read your traceback is bottom to top.
• Identify the exception raised (in this case ZeroDivisionError)
• Make note of the line number (in this case 2), and navigate there in your program.
• Try to understand why the error occurred (in this case because b is 0).
To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.
you should be using checks instead of if else with permissions
Let me give you a demo
in an on member update event , you can check if the booster role was removed from them
Traceback (most recent call last):
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\thoma\Desktop\discord.py\python\bot.py", line 72, in on_raw_reaction_add
await payload.member.add_roles(role)
File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\member.py", line 777, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'
``` same error
I'll pass
i heard someone say to use member flags, would this work as well?
async def on_raw_reaction_add(payload):
if payload.member.bot:
pass
else:
with open('reactrole.json') as react_file:
data = json.load(react_file)
for key, value in data.items():
if value['emoji'] == payload.emoji.name:
role = discord.utils.get(client.get_guild(payload.guild_id).roles, id=('829665222380879912'))
await payload.member.add_roles(role)```?
I need some help, the bot will not work, please help me!
if I remvoe id it says none
@visual island
<t:>
id should be int, not str
flags do not include nitro related stuff
wdym?
should be await message.channel.send(file=discord.File(dog_image))
wdym?
Oh
this should be integer
@client.command()
async def ranks(ctx, x=10):
with open('level.json', 'r') as f:
users = json.load(f)
leaderboard = {}
total=[]
for user in list(users[str(ctx.guild.id)]):
name = int(user)
total_amt = users[str(ctx.guild.id)][str(user)]['experience']
leaderboard[total_amt] = name
total.append(total_amt)
total = sorted(total,reverse=True)
em = discord.Embed(
title = f'Top {x} highest leveled members in {ctx.guild.name}',
description = 'The highest leveled people in this server'
)
index = 1
for amt in total:
id_ = leaderboard[amt]
member = client.get_user(id_)
em.add_field(name = f'{index}: {member}', value = f'{amt}', inline=False)
if index == x:
break
else:
index += 1
await ctx.send(embed = em)
``` See this my code
int how?
why not just use on_guild_update pretty sure its dispatched on premium_subscriber change
id=(['829665222380879912']))
oh tysm!
this would work right?
@bot.event
async def on_member_update(before, after):
channel = disnake.utils.get(before.guild.channels, id=880097117803266099)
role = disnake.utils.get(after.guild.roles, id=803191738683621416)
#if role in before.roles and role not in after.roles:
if after.guild.premium_subscriber_role in before.roles and after.guild.premium_subscriber_role not in after.roles:
await channel.send(f"Someone stopped boosting the server")
:D
id=829665222380879912

wait now it says discord is not an import
what, lol
Does your json store ids?
show error?
Yes
{"856787557429018645": {"900992402356043806": {"experience": 1244.0, "level": 5}, "908185207163744297": {"experience": 16, "level": 2}}, "898850971776593930": {"900992402356043806": {"experience": 44.0, "level": 2}, "776867805727031336": {"experience": 3.0, "level": 1}, "871795742589726850": {"experience": 2, "level": 1}, "908185207163744297": {"experience": 1, "level": 1}}, "893770828632719453": {"900992402356043806": {"experience": 182.5, "level": 3}, "908185207163744297": {"experience": 3, "level": 1}, "748500414277877841": {"experience": 75, "level": 2}, "893166314435256401": {"experience": 3, "level": 1}}, "906408723709296681": {"900992402356043806": {"experience": 271.5, "level": 4}, "748500414277877841": {"experience": 48, "level": 2}}, "883572338975715358": {"719112857261965335": {"experience": 130.5, "level": 3}, "775643767943725066": {"experience": 3.0, "level": 1}, "785749328626319360": {"experience": 1.5, "level": 1}, "889834325804195861": {"experience": 26, "level": 2}}, "912559425921892392": {"737946035694993408": {"experience": 532, "level": 4}, "900992402356043806": {"experience": 2556, "level": 7}, "908185207163744297": {"experience": 129, "level": 3}}, "912569937116147772": {"900992402356043806": {"experience": 1202, "level": 5}, "908185207163744297": {"experience": 139, "level": 3}, "748500414277877841": {"experience": 109, "level": 3}, "871795742589726850": {"experience": 64, "level": 2}}, "892238407315619881": {"900992402356043806": {"experience": 116, "level": 3}, "513300232415739904": {"experience": 3, "level": 1}, "748500414277877841": {"experience": 13, "level": 1}}}
client.run(os.environ["Token"]
it is server dependent
install it
i wasnt aware or it , since in the docs its like Changed name Changed AFK channel Changed AFK timeout etc and idk what etc could include
i.e different for eatch server
You need to get the members names first
i cant
yeah ikr, but it's too much to include there
cuz it has to be server idepenedent
what
yea , your logic to check if the role is removed is correct
I'm using replit 😅
missing parentheses
Send a screenshot
?
maybe he/she copied the whole code
EOF also comes when there is unidentied character
show code
@visual island correct?
sure
Here
why do you guys think of some people as your compiler
@upbeat otter pls check you DMs
just run it and see if it works
the @commands.has_perm... decorator is placed in a wrong place for the ping command fyi
it still wouldnt add the role to the member
Perms for what?
oh thats odd
line74.
ik
@unkempt canyon
@bot.event
async def on_guild_update(before, after):
if after.premium_subscribers != before.premium_subscribers:
member = set(before.premium_subscribers) - set(after.premium_subscribers)
# do more stuff
``` this has higher accuracy than your way
sorry?
How do I grow my bot?
dw about it
Only 9 servers and people remove bots in between
you missed 1 )
error?
what where? I'm so sorry
no error but still wont give me the role
why exactly is that?
do you want the whole python file to check out?
I see now
k now only 1 problem, lol
the import discord so odd, why does it not work
premium_subscriber_role could be None
install it from the package manager
so: pip install pyinstaller discord
or no?
!d discord.on_guild_channel_pins_update
discord.on_guild_channel_pins_update(channel, last_pin)```
Called whenever a message is pinned or unpinned from a guild channel.
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
i see. What if I check if it is none, if it is return, otherwise carry out the rest
how do i make a bot that detects if a channel reaches 100+ messages in the past 5 minutes, it sends something?
It sends none of every user except itself
why I want that only to improve
btw 1st is me
does anybody know js here?
this is a python server, maybe go to .gg/javascript
I know I am just asking
k I insalled it but now this is the error
rust :^)
i mean if premium_subscriber_role is None, then on_member_update wouldn't be dispatched cause no roles are removed
!custom-cooldown
Cooldowns in discord.py
Cooldowns can be used in discord.py to rate-limit. In this example, we're using it in an on_message.
from discord.ext import commands
message_cooldown = commands.CooldownMapping.from_cooldown(1.0, 60.0, commands.BucketType.user)
@bot.event
async def on_message(message):
bucket = message_cooldown.get_bucket(message)
retry_after = bucket.update_rate_limit()
if retry_after:
await message.channel.send(f"Slow down! Try again in {retry_after} seconds.")
else:
await message.channel.send("Not ratelimited!")
from_cooldown takes the amount of update_rate_limit()s needed to trigger the cooldown, the time in which the cooldown is triggered, and a BucketType.
environ
i see, but the purpose of the code is just to be alerted if a user stops boosting the server
not enviorn
Hey help me pls
Well Attractive? 
yeah, your code should work if the guild has premium_subscriber_role, but if it doesn't then it wont work. Anyway your code is another way for checking if a user stops boosting the server, but it's not the best way imo
is it not the most efficient because the boost role can be none?
in what context
yes and no
there are many factors
I mean "well attractive" doesnt sound right but...okay
hmmmm so you suggest what you said about comparing the before boosters and after boosters to see who stopped?
?
nothing...
your wish, you can do more with on_guild_update such as seeing the premium_subscription_count
well
I was gonna say the same :)

Good Morning
Morning
idk why I noticed it, but there's a missing curly bracket in your about me 
word limits prolly
Why does literally everyone not see the curly bracketttttttt
lmao
Discord broke 🥲
rate limit
Tf?
Word limit*
Code?
plz someon
same thing, Im stuck in classes from the past hour
😐
Ouch
yeah my code
it shows on mobile
DUDE I mean to give your code
Weirddddddd
lmao
idk which cuz i dont have any error like when u react to the emoji it wont give any error
so
but okay
welp
async def on_raw_reaction_add(payload):
ourMessageID = 914720242297630750
if ourMessageID == 914720242297630750:
member = payload.member
guild = member.guild
emoji = payload.emoji.name
if emoji == '✅':
role = discord.utils.get(guild.roles, name="Member")
await member.add_roles(role)
@client.event
async def on_raw_reaction_add(payload):
if payload.member.bot:
pass
else:
with open('reactrole.json') as react_file:
data = json.load(react_file)
for key, value in data.items():
if value['emoji'] == payload.emoji.name:
role = discord.utils.get(client.get_guild(payload.guild_id).roles, id=829665222380879912)
await payload.member.add_roles(role)```
async def reactrole(ctx, emoji, role : discord.Role, *, message):
if ctx.author.guild_permissions.manage_roles == True:
if emoji == '☑️':
await ctx.send(embed=discord.Embed(title="Reaction Roles", description="**Syntax** : `gm<reactrole (emoji) (name or role) (message)`", color=discord.Color.blue()))
elif role == Member:
await ctx.send(embed=discord.Embed(title="Reaction Roles", description="**Syntax** : `gm<reactrole (emoji) (name or role) (message)`", color=discord.Color.blue()))
else:
emb = discord.Embed(title=f"React for {role.name} Role!", description=message, color=discord.Color.blue())
msg = await ctx.channel.send(embed=emb)
await msg.add_reaction("\U00002705")
with open('reactrole.json') as json_file:
data = json.load(json_file)
new_react_role = {'role_name': role.name,
'role_id': role.id,
'emoji': emoji,
'message_id': msg.id}
data['Member'] = new_react_role
with open('reactrole.json', 'w') as f:
json.dump(data, f, indent=4)
else:
await ctx.send(embed=discord.Embed(title="Missing Permissions", description="You dont have permission to use this command!", color=discord.Color.blue()))
😐
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.
How could I add something like this
Ah buttons
U need to use Discord.py 2.0 or any fork like disnake or nextcord
!d discord.ui.button
discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.
The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View "discord.ui.View"), the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") being pressed and the [`discord.Interaction`](https://discordpy.readthedocs.io/en/master/api.html#discord.Interaction "discord.Interaction") you receive.
Note
Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
!d discord.ButtonStyle
class discord.ButtonStyle```
Represents the style of the button component.
New in version 2.0.
how do i make my embed footer edit after someone presses a button?
like if someone were to press a button the footer would edit to "this user has pressed this button!"?
update the embed instance and then edit the message with the updated embed
code example?
@maiden fable how you add this
do what you did to add the footer to update the footer too
?
There are some examples in the views directory of the discord.py GitHub
man be looking to my git lol
Can I copy your code a bit of welcomer.py mine isnt working @maiden fable
🤣
Which welcomer.py
not yours
Sorry OMG @slate swan
lol
Really sorry I am really mad nowadays
you can use that , but its still under development
you can just set the channel and message for now , im adding color and welcome type options
the bot's meant for multiple servers , and i dont want to use json so yea
as for the database , its sqlite so you wont have to do any setup for it :)
!d discord.ui.button
discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.
The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View "discord.ui.View"), the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") being pressed and the [`discord.Interaction`](https://discordpy.readthedocs.io/en/master/api.html#discord.Interaction "discord.Interaction") you receive.
Note
Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
!dislash
its not documented in the bot
OH
✅ 🔲
ok thank
is discordpy here to stay now? and is discord-py-slash-command the most popular slash command lib?
Discord.py’s library was discontinued. It still works but is missing some key additions. You are welcome to use it as its stable. However you will need to use external libraries to add functionality that is missing. There are other forks that developers are working from to recreate and improve on the current library
no
dislash.py is more preferrable than discord-py-slash_command lib
How to make a slash command and remember I have used discord.py and discord client not bot.
I'm trying to make a discord.py bot and in it I am doing this
return```
To make sure my users have my other bot in the server. The Helper bot is in there, but it isn't seeing it?
Intents is on btw
!d discord.ui.select
hey, is there a way to check for messages sent in a channel
and DM the content of those messages to a user
does anyone have idea how to code bots so they can react, and when user reacts they edit their message? :v
!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.
!d discord.ui.Select
class discord.ui.Select(*, custom_id=..., placeholder=None, min_values=1, max_values=1, options=..., disabled=False, row=None)```
Represents a UI select menu.
This is usually represented as a drop down menu.
In order to get the selected items that the user has chosen, use [`Select.values`](https://discordpy.readthedocs.io/en/master/api.html#discord.ui.Select.values "discord.ui.Select.values").
New in version 2.0.
whats user for?
The user who reacted
hi
U can Right Click the user and Copy ID
oh cool
is there a way to check for message sent in a specific channel only
message.channel.id == id
^
Nope, not without bot
tysm 
how i can make the bot respond depends in member role
I've tried this
if ctx.author.has_role(the role) :
still wont work
u mean like the message up there, bot reacts, then if i react it will do something else
if role in ctx.author.roles
Suppose if I react, then user would be me, if the bot reacts, the user will be the bot and stuff
!d discord.Client.change_presence
await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Changes the client’s presence.
Example
```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
``` Changed in version 2.0: Removed the `afk` keyword-only parameter.
lol didn't worked
ok, so i should mention the bot's name and tag number over there?
???
guys
discord.on_reaction_add(reaction, user)
how do i make the bot in a playing status
this part @maiden fable
user
How to make a slash command and remember I have used discord.py and discord client not bot.
Please tell
🤔
Use a fork of dpy
means
any suggestions on this?
the helper bot wasn't cached
try fetching it I guess
ty
still wont work
rolelist = ['Founder']
if rolelist in ctx. author.roles:
async def on_raw_reaction_add(payload):
ourMessageID = 914720242297630750
if ourMessageID == 914720242297630750:
member = payload.member
guild = member.guild
emoji = payload.emoji.name
if emoji == '✅':
role = discord.utils.get(guild.roles, name="Member")
await member.add_roles(role)
@client.event
async def on_raw_reaction_add(payload):
if payload.member.bot:
pass
else:
with open('reactrole.json') as react_file:
data = json.load(react_file)
for key, value in data.items():
if value['emoji'] == payload.emoji.name:
role = discord.utils.get(client.get_guild(payload.guild_id).roles, id=829665222380879912)
await payload.member.add_roles(role)```
rolelist needs to be discord.Role object
or a list of discord.Role obj
emoji = payload.emoji*
still wont work..
if any(role in ctx.author.roles): get the name of role from role list to get role object and then it should work
I did it that way (read a few lines after) https://github.com/Nipa-Code/Nipa-bot/blob/master/MyBot/cogs/moderation/general.py#L121
MyBot/cogs/moderation/general.py line 121
async def cog_check(self, ctx):```
how to set this
@bot.event
async def on_guild_update(before, after):
channel = disnake.utils.get(before.guild.channels, id=880097117803266099)
#role = disnake.utils.get(after.guild.roles, id=803191738683621416)
if after.premium_subscribers != before.premium_subscribers:
member = set(before.premium_subscribers) - set(after.premium_subscribers)
embed = disnake.Embed(description=f"{member.mention} {str(member)}")
embed.set_author(url=member.avater_url)
embed.set_footer(text=f"{member.id} | {embed.timestamp}")
This would work right?
Teet it?
!d discord.Client.change_presence @zealous dagger
await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Changes the client’s presence.
Example
```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
``` Changed in version 2.0: Removed the `afk` keyword-only parameter.
show full code
!pypi presence and ot
What is this
I can't say, I'm outside
U wanna check for the booster role?
Also the first if statement won't work
no, who stopped boosting the server
Since the booster roles can't be changed
why not?
Then why not use on_member_update
im a bit gay rn, can someone correct this
this works too
role = [roleid]
if any(role in ctx.author.roles):
print("True")
But that should work (sorry I misread premium_subscribers as the premium role before)
Nonono
that's not how it works
use the ```py
@commands.has_permission(manage_messages=True)
im stupid, thanks
discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.
If nothing is found that matches the attributes passed, then `None` is returned.
Examples
Basic usage...
Why not use get?
ohh sorry, thanks
in exchange of what?
emoji = payload.emoji.name
Before u were comparing name with emoji but now u r comparing with emoji
ohh make sense
can i make my bot where members select a role and then they go to another channel and select another role and at the end they type for example agree to gain access to the rest of the channels?
Needa have it with a has_permission decorator
Sure
Does that make sense?
Ig?
ok how do i start with it?
In the on_message event, try to see if the author has those 2 roles
I dont have an on_message_event?
Then make one lol
too much work, no member would want to add roles like that
You're intelligent
Nou
ok so if i have a list of discord id's how can i dm msgs to them
Yeah but i mean idk i want my sever to be much easier to access to my channels once they get verifed
!d discord.Client.get_user
get_user(id, /)```
Returns a user with the given ID.
!d discord.User.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
ty
awkward noises
;-;
Nice
Ok well i guess ill make members write agree once they read the rules of the server
add a button
to agree and disagree
What
if they disagree, redirect them to a channel for help
What if the member wants to agree to disagree or disagree to agree?
:D
I lost two of my brain cells to understand this
🤣
yes thats what i was thinking
Isn't that why I wrote that 🤨
maybe i can let the bot dm something like hey i think you have done verification wrong
please go back to the channel and re verify
Aw 😂
redirect them to another channel for asking questions?
Can someone help me with trying to make my cogs case insensitive when calling them in the help command? I'm following this (https://gist.github.com/InterStella0/b78488fb28cadf279dfd3164b9f0cf96) but I'm not really sure if what I'm doing is right (I'm using the second way). There are no errors, the bot just doesn't recognize the cog and if I do the cog capitalized it works.
nah i think sending a dm is better
What if the person has questions to ask
but any way lets just make the agree thing
i mean they could ask in a support ticket channel
What u even wanna do and why tf u messing with the internals
or make a suggestion
Just use str.lower() on the input and str.lower() on all the cogs' names
That's what I had do
- Make my cogs case insensitive
- The tutorial made me do it
yes that
I'm not getting the cog like that
Then....?
ok how to do the agree thing then?
I'm using this
async def send_cog_help(self, cog):
title = cog.qualified_name or "No"
await self.send_help_embed(
f"{title} Category", cog.description, cog.get_commands()
)
``` I tried getting the cog using `bot` but I kept getting a circular import issue
just give them the required role on button click
Okay
sad
So I guess u can see how @unkempt canyon has implemented it?
just read it's source code lmfao
I was checking if Python bot also has the case thing
oh
who you talking to
@upbeat otter
Was telling Eevee what I was tryna do
oh lol
ic
this ^^
so?
But yea, don't mess with the internals
So cog is a str iirc
could you just help me make the agree thing ?
!d discord.ext.commands.HelpCommand.send_cog_help
await send_cog_help(cog)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Handles the implementation of the cog page in the help command. This function is called when the help command is called with a cog as the argument.
It should be noted that this method does not return anything – rather the actual message sending should be done inside this method. Well behaved subclasses should use [`get_destination()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.HelpCommand.get_destination "discord.ext.commands.HelpCommand.get_destination") to know where to send, as this is a customisation point for other users.
You can override this method to customise the behaviour...
yep
Just do bot.get_cog()?
my bad then
O icy here
im broke on buttons thing
to get the Bot object you can use self.context.bot
I can't, I'm getting a circular import issue
Yea
I don't have a context attribute?
Why u importing bot tho
to define bot in the help class
nvm i can just stick with the emoji reaction
then
Hmmmmmmmmmmmmmmmmmmmmm
the inherited class have it
aight
yes
ok thanks
Buttons are easy once u get the hang of those ngl
this'll work right? ```py
cog = self.context.bot.get_cog(cog.upper() or cog.lower())
My whole bot is based on buttons and nothing else 🤣
Yea
ok do u have the docs for the buttons then? maybe for the future
!d discord.ui.View
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
!d str.title
str.title()```
Return a titlecased version of the string where words start with an uppercase character and the remaining characters are lowercase.
For example:
```py
>>> 'Hello world'.title()
'Hello World'
``` The algorithm uses a simple language-independent definition of a word as groups of consecutive letters. The definition works in many contexts but it means that apostrophes in contractions and possessives form word boundaries, which may not be the desired result:
```py
>>> "they're bill's friends from the UK".title()
"They'Re Bill'S Friends From The Uk"
```...
https://github.com/Rapptz/discord.py/blob/45d498c1b76deaf3b394d17ccf56112fa691d160/discord/ext/commands/help.py#L838-L841 changing this to py cog = bot.get_cog(command.lower()) if cog is not None: return await self.send_cog_help(cog)
and renaming all the cog names in lower can be a solution but its not recommended @boreal ravine
discord/ext/commands/help.py lines 838 to 841
# Check if it's a cog
cog = bot.get_cog(command)
if cog is not None:
return await self.send_cog_help(cog)```
guys, how do I make an nsfw channel?
Hey @pastel cobalt!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
!d discord.Guild.create_channel
!d discord.Guild.create_text_channel
await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel") for the guild.
Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/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/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/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/master/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
nsfw kwarg
ohhh, thank you
hi
@velvet tinsel
😠
why are u creating nsfw it has to follow disc terms of discord
sorry tos
it is
ok
there is no rules against it
https://paste.pythondiscord.com/umitucasay.py
Here button commands working perfectly. If i use the select command it is not updating embed and then button command also stops working is there anyway to fix this
Bro, NSFW channels are not against Discord ToS. If they were, why discord would add support for those
can someone show me an example of discord.py slash commands

