#discord-bots
1 messages · Page 956 of 1
kind of like that random fact module
blacklist is in database db2, and the item blacklist
it gets blacklist value from the db2 database
so how? do i just create a collection/file named blacklist?
mongodb is json
anyone here
wait let me take a ss on it
Hey @full remnant!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
its still only catching the snipe one
!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.
you didn't save
@commands.Cog.listener('on_message_delete')
async def log_delete(self, message):
print("cought logging")```
```py
@commands.Cog.listener('on_message_delete')
async def snipe_delete(self, message):
print("cought snipe")```this is the part that *should* catch it
still only catches snipe
I've saved it
caught
same thing
do u know why its not working tho
no it's a misspelling
do u know why its not working tho
i don't know
try removing the snipe one
check if the log one works now
not the link the thing around the entire message
its a embed
snipe shouldn't be overriding it anymore
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
thnx
this diagram corresponds to the different attributes that embed has
https://cdn.discordapp.com/attachments/84319995256905728/252292324967710721/embed.png
no clue why it wouldnt work then
so when using it would it be like
await message.channel.embed('this is a message',red,title,rich) ```
is the log one in different cog
yes
did you load that cog in
no, you'd create an embed object and pass it to the send method using the embed= parameter
did you reload it when you added the log one
i restarted the bot so yes
is there an example somewhere I can see of this
embed = discord.Embed(
title='hello world',
description='funny'
).set_author(
name='you'
)
# embed.description = '...' also works
await channel.send(embed=embed)```
oooooh alright now I get it
i like embed.set_author
theres also set_footer
and embed.timestamp
good for you
well i've got no clue
you can share the code of the cog the log listener is in
maybe something there is fucking up your listener
the command i just put in it doesnt work
something is broke with cog setup
class MessageLog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener('on_message_delete')
async def log_delete(self, message):
print("cought logging")
mydb.reconnect()
mycursor.execute("select `message_log` from serversettings WHERE server_id = %s", (message.guild.id, ))
mydb.close()
print(f"2, LOG: {message_log}")
for (message_log) in mycursor:
message_log = int(message_log)
if message_log != 0:
channel = bot.get_channel(message_log)
await channel.send("hi")
@commands.command()
async def tt(self,ctx):
await ctx.send("testingS")
def setup(bot):
bot.add_cog(MessageLog(bot))```
i copied that cog over (or should have) from a working one
ill try to add it into a diffrent one thats working
still doesnt work
im so stupid
** i didnt load the cog**
like this?
db = mongoClient.get_database("value").get_collection("server-data")
db2 = mongoClient['value']
antitoggle = db2['antitoggle']
i dont know
i havent used mongodb
i just know thats how getting json values works
ok
you should ask in #databases
did you move it
if you did then your cog is fucked
it wasnt loading
i forgot to add the part for that category
so it never even attempted to load
well at least you now know what's wrong
using await ctx.invoke(self.bot.get_command('roster'), role=role.name) Could i make this empheral? even if the command is a regular command? Im using the command inside of a interaction
Probably not
is it possible to have aliases for a command in a cog
u mean aliases="foo"
.
@commands.command(aliases=[“foo”])
yea, thats what i meant
user = self.client.get_user(ctx.author.id)
await user.send(embed = timeupEmbed)
error:
AttributeError: 'NoneType' object has no attribute 'send'```
Did you turn on intents?
Also you could just do ctx.author.send
how do i turn on intents
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
thx
hello, some time ago I found out that discord.py had been discontinued, and recently I wanted to make a bot again, but now I find that there are several libraries, such as pycord, discord.py 2.0, another one called discord.py rewrite I don't know if it's the same as 2.0, I want to use buttons and slash commands, so, any specific library you recommend? ,'
discord.py is back
discord.py rewrite is still discord.py
this one here? pip install -U git+https://github.com/Rapptz/discord.py
yes
or you could just install it the easy way
without having to write the github link
discord.py 2.0 is still discord.py with just more features
pretty much ui
what are those features?
buttons and slash cmds?
as i know of
i don't use discord.py anymore
i rewrote my code to disnake
you can use disnake
disnake is better?
i personally use it and haven't gotten any problems
it's mostly same with discord.py because it's a fork of discord.py 2.0
it has buttons, modals, views etc
hmm, don't you think that in a while they could discontinue it?
ngl
disnake?
when danny discontinued development of discord.py in around august
or discord.py again?
there are many forks who are actively working on the project
and there is less chance of them discontinuiing
hmm both
and danny is still not sure if he's gonna discontinue the project, (no assurance)
so i advice u to move to another lib for security
i got no clue about danny
@supple thorn @zenith hare
but with disnake
he said that in his server :'/
coke recommended the disnake, would you recommend that one?
pain
i trust EQUENOS that he won't discontinue disnake
see, ngl.. there are many forks & it could be that disnake is better but I haven't tried it.. I'm using py-cord
he said this in the disnake server
"discord.py announced that it is resuming development as of today, after about a 6-month long hiatus.
While that is certainly a surprise to many, rest assured that disnake is not going to stop development!"
same with many other forks ^^
@zenith hare i advice u to look into docs of the forks & see which one seem more comfortable to u :'/
cuz i've tried py-cord so i'm in favor of it.. & i can't judge disnake because i never tried it
Well, I don't see a problem with comfort, I just want a library that doesn't die, and that can use all the features that discord gives, without much problem
then i recommend u py-cord (personal opinion), it even has the highest number of stars on github compare to other forks
and they're even making their guide for beginners
i suggest disnake
anyway thank you very much, I'll be seeing what library I will use ,'
What's so proiminent about hikari?
It's a statically typed library
And they will eventually be providing compiled components optionally over pure Python ones, so things run faster, I guess
for a api wrapper to be a wrapper it needs to have wrappers right?
the commands are made by on_message event basically right?
And it's not a fork of discord.py
I don't remember
I've tried it exactly once and I don't remember
But I guess so, I don't remember whether it has a command system like discord.py has
This is the example they have put on PyPi
import hikari
bot = hikari.GatewayBot(token="...")
@bot.listen()
async def ping(event: hikari.GuildMessageCreateEvent) -> None:
# If a non-bot user sends a message "hk.ping", respond with "Pong!"
# We check there is actually content first, if no message content exists,
# we would get `None' here.
if event.is_bot or not event.content:
return
if event.content.startswith("hk.ping"):
await event.message.respond("Pong!")
bot.run()
Yeah
Like in discord.js
You'd have to parse commands on your own or use third party libraries
yeah i never used js but i saw it now ```py
@bot.listen()
async def on_message(event: hikari.GuildMessageCreateEvent) -> None:
"""Listen for messages being created."""
if not event.is_human or not event.content or not event.content.startswith("!"):
# Do not respond to bots, webhooks, or messages without content or without a prefix.
return
args = event.content[1:].split()
if args[0] == "image":
if len(args) == 1:
# No more args where provided
what = ""
else:
what = args[1]
glad that i didn't use hikari
but I'm curious to find out why I heard it was a very library
partially true, hikari gives you 2 command handlers, which are quite better than discord.py
!pip hikari-lightbulb
!Pip hikari-tanjun
import lightbulb
bot = lightbulb.BotApp(tokens="", prefix="")
@bot.command
@lightbulb.command("name", "description")
@lightbulb.implement(lightbulb.PrefixCommand, lightbulb.SlashCommand)
async def command(context: lightbulb.Context ) -> None:
...
bot.run()``` a basic bot
oh i see, how would a member argument look like?
@bot.command
@lightbulb.option("member", "mention a member", type=hikari.Member)
@lightbulb.command("name", "description")
@lightbulb.implement(lightbulb.PrefixCommand, lightbulb.SlashCommand)
async def command(context: lightbulb.Context ) -> None:
member = context.options.member
...```
that's a lot of decos lol
thats for a reason, you are implementing the SlashCommand and PrefixCommand within the same function, so parsing of contents in message commands, and in SlashCommand options wont be same without using these
if you're really interested in having arguments inside the function you can just add pass_options=True inside the @lightbulb.command decorator. but that won't save you from using the decorators
disnake's much better hahah
there's no comparison. hikari in general is better than any forks.
hey i was wondering why the roles arent being removed in this code? thanks ```py
@bot.command()
@has_any_role('demand1', 'demand2')
async def demand(ctx):
guild = ctx.guild
self = ctx.author
demand1 = discord.utils.get(guild.roles, name="demand1")
demand2 = discord.utils.get(guild.roles, name="demand2")
role_names = ('example1', 'example2')
if demand1 in self.roles and demand2 in self.roles:
await self.remove_roles(demand2)
roles = discord.utils.get(ctx.guild.roles, name=role_names) #<--line here with problem
await member.remove_roles(roles)
await ctx.send("demanded")
does the member have the role prior to this?
how did you know role wasnt removed
any errors?
yes they do have the role prior, i know by looking at their profile. Odd thing is the 'demand' role im taking away is removed but the roles in role_names arent. No errors
just the problem is none of the roles in role_names are taken away
i use to have it like ```py
roles = tuple(discord.utils.get(ctx.guild.roles, name=n) for n in role_names)
wrong usage of utils.get
!d discord.utils.get
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.
Changed in version 2.0: The `iterable` parameter is now positional-only.
Changed in version 2.0: The `iterable` parameter supports [asynchronous iterable](https://docs.python.org/3/glossary.html#term-asynchronous-iterable "(in Python v3.10)")s...
as you can see it takes an iterable and a kwargs of attributes, you are giving him two iterators, essentially it returns None
when you pass multiple attributes they are checked using logical AND, it means that it will return something only if all the attributes that you've passed in it are resolved
read the documentation before using methods that you don't know, utils.get is pretty hard to understand
!rank
Iterating over range(len(...)) is a common approach to accessing each item in an ordered collection.
for i in range(len(my_list)):
do_something(my_list[i])
The pythonic syntax is much simpler, and is guaranteed to produce elements in the same order:
for item in my_list:
do_something(item)
Python has other solutions for cases when the index itself might be needed. To get the element at the same index from two or more lists, use zip. To get both the index and the element at that index, use enumerate.
How to enable Intents
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
role_names = ('Arizona Cardinals', 'Atlanta Falcons', 'Baltimore Ravens', 'Buffalo Bills', 'Carolina Panthers', 'Chicago Bears', 'Cincinnati Bengals', 'Cleveland Browns', 'Dallas Cowboys', 'Denver Broncos', 'Detroit Lions', 'Green Bay Packers', 'Houston Texans', 'Indianapolis Colts', 'Jacksonville Jaguars', 'Kansas City Chiefs', 'Las Vegas Raiders', 'Los Angeles Chargers', 'Los Angeles Rams', 'Miami Dolphins', 'Minnesota Vikings', 'New England Patriots', 'New Orleans Saints', 'New York Giants', 'New York Jets', 'Philadelphia Eagles', 'Pittsburgh Steelers', 'San Francisco 49ers', 'Seattle Seahawks', 'Tampa Bay Buccaneers', 'Tennessee Titans', 'Washington Commanders')
if demand1 in self.roles and demand2 in self.roles:
# Remove the first one if the author has both roles
await self.remove_roles(demand2)
member = ctx.message.author
roles = tuple(discord.utils.get(ctx.guild.roles, name=n) for n in role_names)
await member.remove_roles(*roles)
await ctx.send("demanded")
``` ok so i got it to remove both of the roles, yeah thats cool, but it doesnt send "demanded" after anymore. Anyway to fix this?
whats self in that class?
author
Hey there I was wondering if there was a good way to make a bot that would get information from a dictionary when the user type a command. For example, I type /name of someone and the bot returns an embed message with the information and pictures associated with that character
most likely look into lists+dict or datamodels
I'm not sure what to look for
Okay so it would be a bot for artists. They can enter information about their characters and then the users can just type a command to get information about them
I thought that dictionary was a good way to store the data so it's normalized
long term project and use?????
My question was how to make the bot access the file containing the dictionary
Yeah that'd be a long term project
hmmmm
hey sometimes when i dump something to a json file sometimes it dump 2 times
maybe look into sqlite3
like
{"926129108696580186": 956133659965005864, "926129108696580186": 956133659965005864}
2 bot instances??? or did u not clear the json
no
no it would just make life easier
i really cant find any helpful website
Oh it's SQL for python?! No way!
because u can store data
and pull it and it is all local and doesn't need much work to implement
I did some SQL at uni
i cleared the json after the bot is online
is that the problem
send the code of where u load and dump the file
Nice!
wait
Well then I'll try to look into that more later I can't access my pc rn
ye i didnt clear the json
things can get more complex thou
especially if u design something like economy
can u give a website where i can learn too
eh? hmmmmm never used that and my system was fine
okay good luck
See you!
Don't use sqlite3 for a discord bot
It's blocking
why
Whilst aiosqlite is asynchronous
!blocking
Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.
What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:
import discord
# Bunch of bot code
async def ping(ctx):
await ctx.send("Pong!")
What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.
async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!
Discord.py is asynchronous so use a async database
eh
Look into documentation
!pypi aiosqlite
There'll be examples
Ho
Meh
That's just an example, there's other libs he can use for that
I see that options are multiple
To be honest I have no idea how that works at all. All I do is science programming
hehe
Hi. Who can advise?
This code not worked with "Manage Roles" permissions but worked with "Administrator"
async def add_role(ctx, role_name):
member = ctx.author
role = discord.utils.get(member.guild.roles, name=role_name)
await member.add_roles(role)
How can I give roles to users without making bot administrator?
the bot needs permission to manage
also with manage roles permission he can set roles on user which are lowest in index on roles list from the role that the bot has
bot have manage roles and i try to give the lowest role
403 Forbidden (error code: 50013): Missing Permissions
give administrative then try 1 time
to make sure whats the problem
that means that the bot doesn't have the permission to change or set that role of that user, example:
list of roles:
a
b
c
d
all of them has the manage roles permission, however, the user with 'd' role can't remove the role 'c' from an user which has that role because it his high on level
with admin permission all work. I do not understand why
^
he said he try to give the lowest role
can u show ur bot role and the role ur giving positions
show us the role list of your server
could be
honestly i always find discord roles a lot confusing, they could be better
Type hint role_name to discord.Role and directly add it.
..
What?
ty. Bot role was lower IN ROLES LIST than the role I wanted to give. Lol
ok/oh/yes = ..
Not sure how but okay
xD
BRUH
just to show that i have read that / im active in the chat
i upped role and all work. Totally non-obvious
And admin perrmission ignore roles list
Do what I said also
how do u add those arrow in ss
okay so i have a message with a button on click which i reply with an ephemeral message with 2 more buttons how to edit the ephemeral message after the second button is press
( disnake )
my snipping dont have that
ShareX
ohk
code of the buttons, both on the ephemeral message and the message
😌
i have done that
show
how to i edit the ephemeral message
you have to send them hahaha
i have done that too
i need to check the context, different context has different methods
idk tbh
no that wont work
i have to see the code to help you D_D
okay 1 sec
*please tell me that he uses type-hints
no he dont
class applyconfirm(disnake.ui.View):
def __init__(self):
super().__init__(timeout=None)
self.add_item(applyselect())
@disnake.ui.button(label="Confirm",style=disnake.ButtonStyle.green,custom_id="confirm_button")
async def confirm(self,button:disnake.ui.Button,interaction:disnake.MessageInteraction):
await interaction.edit_original_message(content="Operation done")
@discord.ui.button(label="Cancel",style=discord.ButtonStyle.red,custom_id="cancel_button")
async def cancel(self,button:disnake.ui.Button,interaction:disnake.MessageInteraction):
await interaction.edit_original_message(content="Operation canceled")
don't break my dreams
alr
i do
he does 😄
typehints are good
ok, one sec
how do i typehint ctx??
commands.Context
alr thanks
those are the two buttons of the ephimeral message?
typehinting ctx make code loke cool
else those white letters
this edit way doesn't work right?
yes
this looks cool
it gives not responded
!d disnake.MessageInteraction.original_message
await original_message()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Fetches the original interaction response message associated with the interaction.
Here is a table with response types and their associated original message...
this methods returns the original interaction sent of the message
essentially it returns a message object of the interaction
how can i giove defaault typehint to ctx instead of adding in each command
i think i should have asked in the disnake server lol
its already done by the lib you use
.
what lib do you use?
snake]
but my ss
dpy does it implies all forks do it
thats a vscode thing it will work without typehint as well
im talking about those coloras
you can't, everytime you declare a command or something else that uses an interaction it is passed in the function as the first argument, so essentially it is a Context object but your code doesn't know that because decorators returns a function, not the type of the parameter that it returns
sry im typing with 1 finger
ok
^^
btw make the intellisense of your IDE working isn't the purpose of type-hints xD, it is just a side effect
type hints make the code more readable for others, with python you don't need to tell the type of a variable so if you don't use type hints other people can not know that type that variable is
this looks beeter than
as i said it is just a side effect xD
now your ide recognize that your ctx variable is a Context object
ye
ok i got it we both were wrong i am not replying to the interaction i am editing the message so its interaction.response.editmessage
ty anyways
lol i'm working so i'm not taking to much time to read everything xD
okay np
@placid skiff congrats on the nitro!
🥲
thanks 
Let's hope you don't over use emojis like a few people, here
*Coff coff Ashley
few*
Won't name anyone since some of them are my friends and also it isn't good to name people, but there are many
i'm just jokin hahaha
how do i edit image color which library i should use?
You might want to use Pillow/PIL for that, and also don't forget to run it with asyncio.loop.run_in_executor() as it is blocking.
docs?
Is there a on_message_sent like:
async def on_message_delete(self, message):
on_message is where the message create event being dispatched.
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
It means that the field 0 (the first field)'s value is required, but you didn't provide it.
I think I did though, want to see my code?
sure, note that discord doesn't allow you to pass an empty string to the value
@commands.Cog.listener()
async def on_message(self, message):
channel = self.client.get_channel(960860760416866335)
sent = Embed(
description=f"Message sent in {message.channel.mention}", color=0x4040EC
).set_author(name=message.author, url=Embed.Empty, icon_url=message.author.avatar_url)
sent.add_field(name="Message", value=message.content)
sent.timestamp = message.created_at
await channel.send(embed=sent)
kind of weird to log all messages
It's just to test atm
regardless consider that the message you send is only an embed
so the event triggers itself again with a message that has no content
The code looks fine, have you enabled message_content intent? Your bot cant see messages content without that intent.
Should be
Yes
not to mention there can also be other sources of content-less messages too
Uhm so what do I do
check if the message content is empty, maybe provide a default and also add a bot user check to prevent infinite recursion
I'll just remove it
though, the message content can't be empty, otherwise wouldn't be a message
It can, if the message has only attachments or an embed.
if you are recording user messages, it won't be an embed, and usually links are embedded so it's still not empty
If you uploaded a file from your local computer, message.content would be an empty string
that and their listener isnt only recording user messages, there's no check on who that message comes from
oh while subclassing commands.HelpCommand, u get the channel by get_destination, how do u get the context?
Can it be that Discord Bots cannot join Voice Chats while being hosted on servers?
If they can join Voice Channels? Yes ofc :)
But what server are you using...
but it doesnt work when im hosting it on my server
Server?
Are you properly configuring your bot? Who is your host.
Hosting Platform
ok 
🗿

Zap hosting

ok
bought a server from there and am now trying to host it on there
Tbh i just googled thats kinda a gaming hoster
but ill look hold on
What's your voice channel join code?
Nah it supports Game servers but it has more
Any errors in the console?
No errors
What's your code
Weird, does the bot respond to any actions? Like ?help
ive noticed though that on heroku i.e it had to have opus to join voice chats or something
i have no idea aswell
Heroku & Replit
#discord-bots message

He's not using heroku
Opus is a codec for interactive speech and audio transmission over the Internet.
perhaps this audio transmission over the internet is what i need
Just saying that he shouldnt use Heroku.
thats why i mtrying to do it on a server i own xd
That shouldn't probably needed to only joina voicr channel
What's your code
K
But yes show your code
And did you configure the server? Like python 3.8 or 3.9
im using 3.10.4 on it
Hm
And what python version do you have installed?
same one
Didn't he just say
On his PC i was talking about
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.
Pretty sure you need PyNaCl for vcs not the opus
opus/ffmpeg is a codec or smth
ive got it in my lib
can it be because of ffmpeg?
And what issues are you having?
Not being able to play music?
yeah
What OS
Do both sudo apt install ffmpeg and pip3 install ffmpeg and you should have no issues with it
ill have to install pip for py 3.10.4 doe
triyng that atm
sudo apt install python3-pip
module 'collections' has no attribute 'MutableMapping' on the pip3 install ffmpeg
im reading it may be an issue with python version 3.10
i guess ill install it through git and transfer it to the server
role_names = ('Arizona Cardinals', 'Atlanta Falcons', 'Baltimore Ravens', 'Buffalo Bills', 'Carolina Panthers', 'Chicago Bears', 'Cincinnati Bengals', 'Cleveland Browns', 'Dallas Cowboys', 'Denver Broncos', 'Detroit Lions', 'Green Bay Packers', 'Houston Texans', 'Indianapolis Colts', 'Jacksonville Jaguars', 'Kansas City Chiefs', 'Las Vegas Raiders', 'Los Angeles Chargers', 'Los Angeles Rams', 'Miami Dolphins', 'Minnesota Vikings', 'New England Patriots', 'New Orleans Saints', 'New York Giants', 'New York Jets', 'Philadelphia Eagles', 'Pittsburgh Steelers', 'San Francisco 49ers', 'Seattle Seahawks', 'Tampa Bay Buccaneers', 'Tennessee Titans', 'Washington Commanders')
if demand1 in self.roles and demand2 in self.roles:
# Remove the first one if the author has both roles
await self.remove_roles(demand2)
member = ctx.message.author
roles = tuple(discord.utils.get(ctx.guild.roles, name=n) for n in role_names)
await member.remove_roles(*roles)
await ctx.send("demanded")
``` this works but why doesnt it send "demanded"
it only works with like 3 roles then it sends it
why the * in remove_roles?
and the member is named as self.
accidental
i didnt bother since it still worked
but still, its doing the command besides for sending “demanded” after. Why so?
You sent the embed object
To be honest i'm questioning my self how that code would even work, remove_roles method doesn't take a tuple but a list, and most of all this list is given with consecutive arguments like: abc, bc, dc
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=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.10)") 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.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
@slate swan
Look at this
Use the embed kwarg rather than the content kwarg
hi
where is the help command in RoboDanny's code?
i want to see how their buttons worlk
odd to ask here but its handled in this file https://github.com/Rapptz/RoboDanny/blob/rewrite/cogs/meta.py
came from running ?source help
thanks
can someone tell me why my slash commands isnt loading its not showing a error either
if you had tried syncing global commands, those take up to an hour for discord to update
Guys Do you know how to make a command that says a message in a channel that we mention in that command??
in Python
helps to see what code you have and know the library you're using, but assuming you are using discord.py you'd add a parameter typed as Optional[discord.TextChannel] to have dpy attempt converting the first channel mention into a channel object
more about them explained here https://discordpy.readthedocs.io/en/stable/ext/commands/commands.html#discord-converters (also see the typing.Optional.section)
what server specifically?
Zap Hosting
Basically an Ubuntu server
Perhaps Migration of Windows to Ubuntu might be a reason
docs guy
to play audio in discord, your server and bot must meet these requirement:
- ffmpeg
- opuslib
- pynacl
(But I suggest you to use lavalink instead of ffmpeg, but it's up to your choice)
So Opus is a must i see
Even though i do not use it anywhere does it still impaxt somethign?
uh so i havent coded in like 4 months um i started a new bot and its not responding to commands i think im dumb tell pls
ffmpeg (in discord.py) uses opus to stream music :)
Bot.command without brackets i zhink
Ahh i See
Might be the problem as to why it didnt work
I guess ill Rennstall the oackages pynacl and ffmpeg just to be Sure they fit right with ubtunu and install Opus aswell
Does Python 3.7 have nextcord?
D_D
O_O
this didnt work uhh i had a momentary lapse there ofc there should be brackets i think
no, because it uses f-string, but f-string only works in python 3.8 and up
it didnt work
Will pip still work the the PATH
Brackets if you add a Name and aliases etc.. i think
But other than thaz
f strings were released in python 3.6 D_D
i don't remember 
Does the on ready work?
yes
Well I need to install nextcord and still be able to use pip as the PATH
there needs to be brackets
But no commands are responding
yes
-hello?
What?
Did the sudo apt install ffmpeg work
Installing a lib won't affect PATH wdym
Yeah a lib was broken so it didnt work but i reinstalled it and kt worked
Ok good
Bjt i guess Opus is whaz i need
yes
just to make sure that kraftykatz typed the right thing :)
its not responding
lmao
I had 3.10 installed and it did not have the path
has anyone else experienced streamhandler logging being duplicated twice with dpy? apparently at least one person has mentioned the same issue 4 years ago, and ill be testing their solution of clearing the handlers later but im thoroughly confused why this only occurs with streamhandler for me, not filehandler
(message: <#help-grapes message>)
uh so i havent coded in like 4 months um i started a new bot and its not responding to commands i think im dumb tell pls
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
Yeah he forgot the intents
If you want all the permissions thefe are just do Intents.all
THX
Intents.all() has less characters so technically, .all() is easier

raise PrivilegedIntentsRequired(exc.shard_id) from None
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
well thats extra processing their bot has to do
what is this
did you read the error?
you have to enable the privileged intents in tthe dev page as described
are using a verified bot user?
because you might not be able to enable some intents.
able, enable, disabled, intents
i think its reasonable to assume their bot is in <100 guilds
Let's say I have a PC that stays on in my dorm room 24/7. I want to code and test the code on my laptop, but have the bot run from my PC so that it doesn't go offline. Is this possible?
I want to be on campus for the day and able to code and test that code while the bot is running from my pc. At the moment, I just have the code running from my laptop, but when that turns off (if I need to change classes) the bot goes offline.
Does anyone know how to add the database to a bot?
@bot.command(aliases=['mp'])
async def mastplan(ctx, user: discord.Member = None):
my_image = Image.open("mast.jpg")
asset = user.avatar_url_as(size=128)
data = BytesIO(await asset.read())
pfp = Image.open(data)
pfp = pfp.resize((150, 150))
my_image.paste(pfp, (450,221))
my_image.save("mastplan.png")
await ctx.send(file=discord.File("mastplan.png"))```
How to make the warns on other servers different, otherwise it issued a varn on one server, and it is shown on all?
Sql
how do i add second image?
you need >python3.8
I have Python 3.10.4
do pip3.10 install nextcord
can I get some help on making a rps command on dpy with buttons?
do you now
i know some about buttons but im not sure how to edit message accordingly with which button they press
set your 3.10 python's pip to path jonathan
you clearly didn't, look which python your command was executed at
?
I do not know what to do with this, uninstall 3.10 then reinstall it?
im going offine now pls dm if have answer
maybe, with pip installed on path
maybe you forgot to click that checkbox
I did install it
.
How do I get a channels overrides and copy it to another?
I will uninstall it all and just reinstall it
Yeah
maybe uninstall that
hello, I have a question : i'm trying to dm user who click on a button but i don't know how to do it and i don't find what I want on internet. please help. thx
Did you check the "Add Python to PATH" at the very start
Ok does py -m pip install ... work?
I haven't tried that
Try and tell me if this does work
Why not do automatic setup
how do i convert this to cog? (bot is undefined in cogs)
bot.sniped_messages = {}
@commands.Cog.listener()
async def on_message_delete(self, ctx):
bot.sniped_messages[ctx.channel.id] = (ctx.content, ctx.author, ctx.channel.same, ctx.created_at)
@commands.command(name="snipe")
@commands.cooldown(1, 5, commands.BucketType.user)
async def snipe(self, ctx):
content, author, channel_name, time = bot.sniped_messages[ctx.channel.id]
snipeEmbed = discord.Embed(description=content, color=discord.Color.red(), timestamp=time)
snipeEmbed.set_author(name=f"{author}", icon_url=author.avatar_url)
snipeEmbed.set_footer(text=f"#{channel_name}")
await ctx.channel.send(embed=snipeEmbed)```
Can I see all of the cog
import discord
from discord.ext import commands
class Snipe(commands.Cog):
def __init__(self, client):
self.bot = client
client.sniped_messages = {}
@commands.Cog.listener()
async def on_message_delete(self, ctx):
client.sniped_messages[ctx.channel.id] = (ctx.content, ctx.author, ctx.channel.same, ctx.created_at)
@commands.command(name="snipe")
@commands.cooldown(1, 5, commands.BucketType.user)
async def snipe(self, ctx):
content, author, channel_name, time = client.sniped_messages[ctx.channel.id]
snipeEmbed = discord.Embed(description=content, color=discord.Color.red(), timestamp=time)
snipeEmbed.set_author(name=f"{author}", icon_url=author.avatar_url)
snipeEmbed.set_footer(text=f"#{channel_name}")
await ctx.channel.send(embed=snipeEmbed)
def setup(client):
client.add_cog(Snipe(client))
print("Loaded snipe.")```
Make sniped_messages a cog var
i dunno how to define client
How do I set a channels overwrites if I have the dict of what I want? (got it from printing overwrites of another channel)
I do bot for cogs, and you do not really need the Listener
It is self.bot in cog
Simple OOP
but can't i jsut use client
No.
Man it's OOP
is there a way to hybrid javascript and python for discord bots?
In cogs it is bot
Do you know about it or just followed youtube tutorial "how to make discord bot" without knowing python
not really, i made some python programs but i dont really follow coding in discordpy
I'd recommend getting to know the basic concept of OOP because without that knowledge you will face some issues you wouldn't even face with that knowledge
alright
hey so ive installed ffmpeg opuslib and PyNaCl and it seems that it still doesnt want to play
@bot.event
async def on_message_delete(message):
print("was deleted")```you have to do it like this
message.author
Yes it did! thanks!
No one has any answer ?
!d discord.Interaction.user
The user or member that sent the interaction.
yo @slate swan
How do i check how many users my bot is watching
hi
nice pfp
!d discord.ext.commands.Bot.members
client..members
do you have knowledge about server hosting?
!d discord.ext.commands.Bot.users
property users```
Returns a list of all the users the bot can see.
i keep forgetting its users
not quite but whats your problem?
so running the bot on my pc working fine i can play audio
now im trying to move it to a server i bought and now im having some small problems
alr
i.E it wont play audio although i have installed everything it needs
from what ive heard ffmpeg, pynacl and opuslib is needed for this
do you have the requirements.txt file?
requirements?
some vps need a requirements.txt files to know what libs te server should install
does add roles need to take a list of objects or can I just pass in a singular object?py await member.add_roles(*Object(role), reason=f"{member} is a bot!", atomic=True)
what does atomic means
atomic (bool) – Whether to atomically add roles. This will ensure that multiple operations will always be applied regardless of the current state of the cache.
it doesn't take a list, it takes a list of arguments as SnowFlake object, they are a whole different things
!e
def test(*args):
print(args)
test(1, 2, 3, 4, 5)
@placid skiff :white_check_mark: Your eval job has completed with return code 0.
(1, 2, 3, 4, 5)
Define user_id
Cz it ratelimits the bot
Wait
so it takes a list 😕 can you explain the difference between a list and a list of snowflakes? I understand it doesn't take a full role object
Make the var name different
@slate swan u can just do ctx, user: discord.User and directly do await user.send()
Oh ya
Yes
No
it is not a list .-. it is a list of arguments
in a function, when you name one of your agument *args this argument will take everything that you will add as parameter when you call the function, if you look at this i'm printing args and it is a tuple of all the arguments that i have added
a snowflake is an abstract class which almost all discord object met
What is the difference between user and a member
member is a subclass of user 
..
you can pass a single role object
atmoic = True
💥 🔥
he can pass even more, but not as a list, but as a single argument
unpack the list
Imagine getting addicted to this channel
atomic will ignore the state of the cache
@client.command()
async def test(ctx, user: discord.User,*,msg):
await user.send(msg)
``` @slate swan

I think I follow, mostly.
i'll show you what will be the issue if you give in it a list
A member is bound to a guild, a user is not
!e
def test(*args):
for arg in args:
print(arg)
test([1, 2, 3, 4], 5)
This is just a stupid example
@placid skiff :white_check_mark: Your eval job has completed with return code 0.
001 | [1, 2, 3, 4]
002 | 5
more like an unknown amount of arguments which would return a tuple and it expects a tuple
!e
a = (1,2,3,4,5)
for x in a:
print(x)
thats just a generator
Also member doesn’t subclass User
!e print(a for a in range(10))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
<generator object <genexpr> at 0x7fd5348cbc30>
as you can see from this, for example, if the function has an iterator it will not iterate through all args element
Range is already a generator
ye
list and list of arguments are completely two different things
English wise, those two are exactly the same except one is more specific
you mean an iterable? and not an iterator?
It would be better to call *args a parameter which takes an arbitrary amount of arguments
yes you can pass an iterator but you gave an iterable
It later then creates a list
yeah sorry
await member.add_roles(role)
await member.add_roles(*roles)
both work
thank you for the explanations and examples, I won't lie and say that I fully understand but I think that's more due to a lack of knowledge elsewhere in python which is having a nock on effect. I do understand it better than better than I did when I first asked my question tho
Blvck ur pfp looks like a panda if not observed carefully
yup, but this:
await member.add_roles([role1, role2, role3])
could give some problem
mines a handsome cat
Raven pfp is anime ig
mines best tho
I hope i dont get a nightmare after seeing ur pfp

on_message event is triggered whenever a message is sent in the presence of the bot
Oh
I'm pretty sure that's against ToS if you just save the messages.
probably .-.
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
Everytime i do it show wrong
capital M.
the command checks the documentation online 
because is a page your search will result in a query
the command will send a get method, if you send !d discord.Member it will search for https://docs.disnake.dev/en/latest/api.html?highlight=member#disnake.Member
if you type !d discord.member instead, it will search for this link https://docs.disnake.dev/en/latest/api.html?highlight=member#disnake.member
if you open the second link it will give you the start page
Hey guys, so I usually use Spyder for my code but right now i'm writing a discord bot, but I don't know how to shut it down. And VSC is really confusing because I don't see how to run command in a terminal like spyder, any idea ?
On message have a message var u can cha k is message.channel is dm or not
Yes good
Idk about processing command
?

Why?
would there be a way to make a command that disconnects the bot from wherever its being ran
does ctx.author.voice.channel.connect() work?
it is not what he asked for 
Only if the user knows about it and u dont save for more than 30 days
that's voice channel connecting...
wdym
!d discord.ext.commands.Bot.close
await close()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Closes the connection to Discord.
Bruh

What, did I ask it wrong?
I thought u were saying to disconnect from a voice channel
no that was my quesiton
Huh
ah nvm
Does anyone know how I can check to see if a user has specific roles? and also adding or removing roles from a specified user?
but basically does ctx.author.voice.channel.connect() work
ok
voice_channel* maybe
If v2 then i think it’s voice.channel
no no it was for the answer that others were giving to you hahaha
🥲
^
Doesn’t sys.exit() also exit the bot

You could use discord.utils.get to check if they have the role if ur looking by name. Otherwise guild.get_role and member.roles
sys.exit will stop the code from running .-.
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.
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 added [`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.
Thanks
it will forcefully stop the bot
@bot.command(name="verify")
async def verify(ctx, arg1):
response = requests.get(f"https://api.slothpixel.me/api/players/{arg1}").json()
if not response["uuid"]:
await ctx.send("You specified an invalid username.")
discord = response["links"]["DISCORD"]
username = response["username"]
if f"{ctx.author}" != f"{discord}":
await ctx.send("Invalid IGN, maybe you picked the wrong IGN?")
else:
await ctx.send(f'Successfully verified as {username}')
verify_role = ctx.guild.get_role(950853490861834370)
await member.add_roles(verify_role)```
hey so basically i'm trying to code a bot that checks if they have their discord linked as same as their discord account using that link
that's not the main issue tho
the main issue is: it doesn't give the role
it says successfully verified but doesn't give the role
anyonek now how to fix??
it stops the code the close coroutine just stops the bot
can u print verify_role?
one second
also u can simply do if str(ctx.author) == discord
yep]
@bot.command(name="verify")
async def verify(ctx, arg1):
response = requests.get(f"https://api.slothpixel.me/api/players/{arg1}").json()
if not response["uuid"]:
await ctx.send("You specified an invalid username.")
discord = response["links"]["DISCORD"]
username = response["username"]
if f"{ctx.author}" != f"{discord}":
await ctx.send("Invalid IGN, maybe you picked the wrong IGN?")
else:
await ctx.send(f'Successfully verified as {username}')
verify_role = ctx.guild.get_role(950853490861834370)
print(verify_role)```
this is the code for now
oh nvm it printed something
Haha
yep
Member
Member
Member
Member this is all it printed
mind showing in a pic?
https://hypixel.net/|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| https://i.e-z.host/
umm can u try to fix the code?
It should print smth like this
oh
what

it just doesnt give the role thats it
everything else works instead of giving the role
that means that something is wrong, you are takin' your data from an api response so to understand what is happening you need to trace your data
there's nothing wrong with the api its just the roles
its not giving the role
how to fetch context on on_command_error?
it already gives u one tho
oh wait you are using an int i thought you were taking the id from somewhere else lol
most probably the role is not in the bot cache
you have to use fetch_roles
!d discord.Guild.fetch_roles
await fetch_roles()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves all [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the guild has.
Note
This method is an API call. For general usage, consider [`roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.roles "discord.Guild.roles") instead.
New in version 1.3.
but verify_role is printing smth else 😔
i thought it was printing nothing
im understanding absolutely nothing
can u guys fix code maybe
async def verify(ctx, arg1):
response = requests.get(f"https://api.slothpixel.me/api/players/{arg1}").json()
if not response["uuid"]:
await ctx.send("You specified an invalid username.")
discord = response["links"]["DISCORD"]
username = response["username"]
if f"{ctx.author}" != f"{discord}":
await ctx.send("Invalid IGN, maybe you picked the wrong IGN?")
else:
await ctx.send(f'Successfully verified as {username}')
verify_role = ctx.guild.get_role(950853490861834370)
await ctx.guild.add_role(verify_role)```
Oh no requests
??
You should check the response code anyways
bro what i literally just said everything works except giving roles doesnt work
what prints verify_role? .-.
Ok didn't see
i removed that
What the hell is ctx.guild.add_role
i think they meant create_role
LOOOL I DIDN'T NOTICED IT
No
!d disnake.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://docs.disnake.dev/en/latest/api.html#disnake.Role "disnake.Role")s.
You must have [`manage_roles`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_roles "disnake.Permissions.manage_roles") permission to use this, and the added [`Role`](https://docs.disnake.dev/en/latest/api.html#disnake.Role "disnake.Role")s must appear lower in the list of roles than the highest role of the member.
^
:)
WAIT IM STUPID ITS ADD ROLES
It's also ctx.author
Hunter we are blind 
or ctx.guild.get_member(await ctx.guild.fetch_member(await bot.getch_user(ctx.author.id).id).id)
just to check :)
😳
@slate swan u have an error handler?

per command or global?
still didnt work
https://hypixel.net/|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| https://i.e-z.host/
This doesn't add roles?
https://hypixel.net/|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| https://i.e-z.host/
any
im making it like this not rlly a error handler
nope
Add py else: raise error
at the end of error handler
bruh why
at the end of the embed?
Current one just eats all unknown errors
Also why not use global

https://hypixel.net/|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| https://i.e-z.host/
ig you can use per command handlers if you want a custom message
For unhandled stuff
Man we told you
await ctx.author.add_roles(...)```
oh
but tbh in my IDE, i don't use a handler, because it prints a more descriptive error on the console than the message. i only use a handler for the bot when i host it, not testing a command or something
You typically have error handlers for giving good messages for the users so they don't end up wondering why tf the bot didn't respond

stop making react to your message with 
okay now how do u delete a certain messages after 3000ms
is it just wait(3000ms)
await ctx.message.delete
3000 / 1000 = 3, so await ctx.message.delete(delay=3)
load_dotenv()
TOKEN = os.getenv("TOKEN")
and from dotenv import load_dotenv
as a import
Wait I have a link to token tips somewhere
Personally I always encrypt it idk what the heck for but I do
One sec
Storing your tokens and application secrets securely is very important. In this bonus tip I'll show the most common ways to do so in Python.
nope doesnt work
error
none
none?
just doesn't delete
really?
yea
!d disnake.Message
class disnake.Message```
Represents a message from Discord.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
hash(x) Returns the message’s hash.
lemme read the docs
i dont use disnake
doesn't matter
ah
dpy and disnake are practically the same
it should've worked idk why
!d disnake.Message.delete
await delete(*, delay=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the message.
Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.manage_messages "disnake.Permissions.manage_messages") permission.
Changed in version 1.1: Added the new `delay` keyword-only parameter.
Trying to get that energy today to work on my bot

so close to being done, a week at absolute most left
Bots are never truly finished
up to 2.6k lines of code
3000 ms as in the ping of the bot?
finished enough to finally release and get reactions
You can pass in delete_after= kwarg
no it deletes the message after 3000ms
where kek
uh....
!d discord.TextChannel.send
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=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.10)") 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.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
see the delete_after= kwarg
message.channel.send(content="sdafgsdfg", delete_after=3)
pass it into that
how do u fetch roles with the name "Member", "Verified", "Muted"
message.content
how can i time how long it takes a user to click a button?
time.time() method is not accurate
discord.utils.get(guild.roles, name=…)
!d time.perfcounter
If ur in a command ctx.guild
Show code
Change the name of where u define discord (right above username)
And also r u trying to search for multiple roles?
im trying to search for verified and member
discord.utils.get(ctx.guild.roles, name=“role name”) then do something with the role. Then get it again and do something with the new role
discord.utils.get(await ctx.guild.fetch_roles(), id=int) (id's are preferred)
role = ctx.guild.get_role(id) is faster
No need to make an API call, guild.roles is fine
.get is a thing?
There, my bad
i know but i just prefer api calls
Always has been

not in ctx.guild lol
wait what..
get in
confuse people
leave
![]()
cool
mmmmmmmmhmmmmm
What is even happening here
no clue
Question on developer portal i need to go under Selected app > Bot > Reset and copy token right? If I do that I get a improper token error in my bot
yes
Yea
maybe XD
Well, mind posting yr token then?
🙂
I can test hehe
eh
