#discord-bots
1 messages · Page 333 of 1
It's self explanatory
You don't receive the messages content unless it's enabled
does this intent affect your slash command messages if it is disabled?
Like my bot does this function you attach a .mp4 file to it and it then does transcription for it. Will disabling it affect my command in any way?
Which slash command messages
2024-01-04 22:02:47 WARNING discord.ext.commands.bot Privileged message content intent is missing, commands may not work as expected.
2024-01-04 22:02:47 | WARNING | discord.ext.commands.bot | Privileged message content intent is missing, commands may not work as expected.
i see this on screen
That is a warning, yes
so i should have it enabled then?
Not unless you need it
read the second line that's how my command works
so that does not require it?
you can see the various exceptions in the API docs:
https://discord.com/developers/docs/topics/gateway#message-content-intent
Apps without the intent will receive empty values in fields that contain user-inputted content with a few exceptions:
- Content in messages that an app sends
- Content in DMs with the app
- Content in which the app is mentioned
- Content of the message a message context menu command is used on
in short, the message content intent only affects messages your bot sees from other users, so if your slash command takes an Attachment parameter it won't be affected by the intent
Slash command invocations are not messages
You won't need the messages content to invoke them
oh i read a few documentation and it was a bit confusing stating that bot will receive empty values so i thought it was necessary for my bot
i understand it now thanks guys
in other words just to develop an understanding of the intent, it might be useful in case if a bot monitors users message to see any racial or harmful words and then takes actions like banning or time out
Also one more thing my hosting server memory goes beyond its limit when i run my bot like it is 75/52 GB RAM and then bot crashes and i have to restart again
i've searched on internet and it is maybe called as memory leak
anyone can recommend any solution for this?
Do you mean MB?
Is that a question sorry?
Phrasing just confused me a bit
Yea i'm asking if i made a correct logic out of it. My english is not that good so i appologize
That could be a way to learn it, but in my opinion it’s a bit overkill
It’s pretty straightforward
Honestly I don’t know how to interpret this. I doubt you have 52GB of memory unless you’re paying hundreds, or even thousands of dollars a month
Could you show the entire screenshot
that's a gpu server on hourly basis from vast.ai
Are you sure that’s the memory reading?
Are you paying 0.405/hour?
yes
That’s almost $300 monthly
yup
Why
When you have money, you can do whatever you want
the discord bot is not the main usage on it, its being used for some other stuff as well
the bot keeps on increasing the usage memory i've also tested it on another cloud server
and it gradually increases it by 2 GB after each usage
Sounds like a memory leak
Do you know the part of the code that’s causing it?
If not, there’s some profilers you can use
not yet thats what i'm trying to identify
cProfile is a good option
ok ill check it rn
yeah cprofile is more for checking performance, in your case you might be interested in memray
https://github.com/Bloomberg/memray
alright
How can I run a command that deletes the message before it before responding?
Look nice until I read it doesn't support Windows and I cannot afford another computer 💀
huh
You want to delete the message invoking the command?
no I just want to delete the message before any command then the response is stull visible
im using / commands too
Slash commands don’t have invocation messages
no heres what I want to do.
- RANDO test I want to delete
- Command/response
I want to delete 1. the rando text in the channel before the response
how do I fetch the message then delete it
!d discord.TextChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator) that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history) to do this.
Examples
Usage...
You’d want to have a limit of 2
On the second one you’ll call
!d discord.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 must have [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages).
Changed in version 1.1: Added the new `delay` keyword-only parameter.
awesome thanks
How can I add pictures to an embed in discord.py?
set_image method
Or set_thumbnail
Okay
how to execute some code when the server logs in new participant?
How could I create a certain amount of buttons without knowing beforehand?
!d discord.on_member_join
discord.on_member_join(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member) joins a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild).
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members) to be enabled.
Thanks
@final iron sorry for ping but you got an idea?
Loop through a list of x amount of times creating instances of the buttons and append them to a list. Loop through that list and add them to a view
Should be pretty straightforward
I have a system to do the same thing for modals
can you show an example Im a bit slow
Honestly I can't be bothered to create a whole example right now
https://mystb.in/ReaderRecommendsEyes
This is my code I was talking about
self._modals = [InformationModal(chunk) for chunk in chunked_inputs]
This is the relevant part for you
InformationModal is my discord.ui.Modal subclass
You would then loop through that list, in my case self._modals and use
!d discord.ui.View.add_item
add_item(item)```
Adds an item to the view.
This function returns the class instance to allow for fluent-style chaining.
To add them to a view
Does anybody have documentation for discord.py slash commands?
https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord-app-commands
and some examples too, and a guide: https://about.abstractumbra.dev/dpy
Thank you
discord.py already support slash commands why use that library
what's the difference between Modal and View?
also see #discord-bots message
discord-py-slash-command==3.0.3 is the latest version of
discord_slash, but they've since moved on to interactions.py which no longer monkeypatches discord.py
so for new bots, you should either use discord.py 2.0's native slash commands (example, API reference), or switch to the successor of discord_slash
Do you know what a modal is
never seen it no
See what it is
oh modals are the list things you can choose from?
those are selects
google what a modal is lol
this is a discord modal
ah I see it
I want to create a class that'll accept a list and create buttons for each item with a value of it's appropriate item, can someone lead me in the right direction?
pep's earlier answer about add_item() is definitely what you want to use, but if it helps, you can think of a view as simply a list of buttons, and .add_item() is how you add a new button to that list
so the idea would be to loop through the values in your list, create buttons with the desired value, and add it to your view
Could you give some sort of psuedocode?
class BtnInfo(discord.ui.View):
def __init__(self, resp_list) -> None:
super().__init__(timeout=None)
for line in resp_list:
self.add_item(label=line, custom_id=f'button_{line}')
Something like this?
almost, you instantiate a Button class with the parameters you want and use add_item() with that
e.g. ```py
class MyButton(discord.ui.Button):
def init(self, my_value):
super().init(label=f"Here is {my_value}", ...)
self.my_value = my_value
async def callback(self, interaction):
await interaction.response.send_message(f"You clicked on {self.my_value}!")
class BtnInfo(discord.ui.View):
def init(self, resp_list) -> None:
super().init(timeout=None)
for line in resp_list:
button = MyButton(line)
self.add_item(button)```
technically you could also write button = discord.ui.Button(label=...), but it doesn't have any way to define a callback function to run when the user clicks it, hence why its helpful to define your own Button subclass
what're the other values for the button besides label again?
Documentation is your friend
The docs also have a helpful search function if you can't remember the exact path
yeah I just hope you guys have what Im asking memorized lol you guys are geniuses
It's a lot easier than you think
You'll eventually just intuitively learn discord.py's structure
Learning why something is how it is, is very helpful
yes https://discord.com/developers/docs/interactions/message-components#buttons
label? string Text that appears on the button; max 80 characters
thanks
@hushed galleon I'm currently building a table to showcase the different implementations of features across different libraries, what features do you think I should cover? Currently Im looking to do Views(Buttons, Selects, Modals), App Commands (Slash and Context), Documentation, Support community, coverage of the API, Voice Support and updates
[Stands around ominously]
Work on those for now and come back later.
fairs
those will take a bit
currently I'm just going to do discord, nextcord, pycord and disnake
why is there so many versions?!
discordpy best imo
and not because I am biased or anything.
Oh there's much more
forks = [
"nextcord", # fork of dpy
"py-cord", # fork of dpy
"py-cord-dev", # py-cord but updated on PyPi
"interactions.py", # another py bots library
"disnake", # fork of dpy
"dislash", # extension but then discontinued and replaced by "disnake"
"dislash.py", # extension but then discontinued and replaced by "disnake"
"discord-py-slash-command", # package pointing to "interactions.py"
"discord.py-message-components", # fork of dpy
"enhanced-discord.py", # discontinued fork of dpy
"novus", # fork of dpy
"hata", # another py bots library
"discord-interactions", # official tool by discord to work with interactions
"discord.py-self", # self-bot lib
"discord.py-self.embed", # discontinued self-bot lib to send embeds
"discord2", # package that leads to "py-cord" but is not owned by them
"python-discord", # package pointing to a years old clone of dpy
"discord_py_buttons", # extension, was renamed twice and discontinued as "discord-ui"
"discord_slash", # extension, doesn't exist anymore(?)
"discord.py", # actually dpy
"discord", # official dpy package pointing to (a potential outdated version of) dpy
"discord-ext-forms", # discontinued extension to make a Modal
"discord-ext-alternatives", # discontinued extensions package by previous dpy regulars
"dpy-appcommands", # discontinued extension for app commands
"discord-ext-slash", # unmaintained(?) extension for slash commands
"discord-buttons-plugin", # discontinued extension for.. buttons
"discum", # self-bot lib
]
This is not a Modmail thread.
That's forks alone, there's also other libraries like hikari
They're mainly forks
There were already a few forks, but when Danny ceased development many forks were created as alternatives
If we're being real though, nextcord is really the only competitor
All the other ones are way less popular than the two
competitor is a strong word. considering it's free.
alternative?
competitor can still be used
Alternative sounds better.
its not exclusive to paid products
D:
can someone help me with a bot please 🙂
ty
hmm cant think of any other major differences, but perhaps you might want to include minor stuff like async cog/extension loading
i remember when i used enhanced-discord.py, a bit odd that discord-interactions is included in that forks list given that its merely a 60 line module
60 lines, the best 60 there is
Failed to load extension cogs.SlashCommands.SCInfo.
ExtensionFailed: Extension 'cogs.SlashCommands.SCInfo' raised an error: AttributeError: module 'discord.ext.commands' has no attribute 'tree'
Yes it worked in the main.py but became a problem in a cog.```
its discord.py 2.0
but did it?
What worked? discord.ext.commands.tree literally doesn't exist
lmao it did
I dont even know what scinfo is
Show it
ok let me recreate it.
I mean I deleted that main.py code and transfered it direcetly into a cog with the correct syntax changed
Alright
Can we see your code?
#!------Run These When Needed------
#? .venv\Scripts\activate
#!------Imports------#
import discord
from discord.ext import commands, tasks
import os
import asyncio
from itertools import cycle #For status
import random # For eightball
import json
#?LocalImports
from cogs.Utility import Utility
#!------Bot Prefix's------#
def get_server_prefix(bot, message):
with open('prefixes.json', 'r') as f:
prefixes = json.load(f)
return prefixes[str(message.guild.id)]
#!------Essentials------#
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix=get_server_prefix, intents=intents)
bot.remove_command('help') # This line removes the default help command
utility = Utility(bot)
prefix = utility.get_server_prefix
#!------Guild Specific Event------!#
#?------Sets Default Prefix, Allows 4 Custom Prefix------?#
#!------Status------#
bot_status = cycle(["type '!help' for help", "You can make a custom prefix!", "I :heart: Biscuits!"]) #Available Statuses
@tasks.loop(seconds=10) #Changes Status Every x Seconds (Can use minutes and hours too)
async def change_status():
await bot.change_presence(activity=discord.Game(next(bot_status))) #Changes Status from bot_status
@bot.event
async def on_ready():
await bot.tree.sync() # Syncs Slash Commands
print('------------------------------------------------------------')
print('Logged in as', bot.user.name)
print('------------------------------------------------------------')
change_status.start()
@bot.tree.command(name="ping", description="Returns the bot's latency.")
async def ping(interaction: discord.Interaction):
bot_latency = round(bot.latency * 1000)
await interaction.response.send_message(f'*Pong! __{bot_latency * 1000}ms__*')```
Where is the discord.ext.commands.tree?
doesnt need to be their
Also, if you want to have a rotating status you should start the loop in the setup_hook event, not on_ready
on_ready isn't what you think it is
k
are you trying to define slash commands in a cog? if so, you want to use @discord.app_commands.command() as the decorator, rather than tree.command()
yes that is what I am trying to do
@discord.app_commands.command(name="ping", description="Returns the bot's latency.")```?
sure
sure?
what should I change here? I am unfamiliar with slash commands. py async def ping(self, interaction: discord.Interaction): bot_latency = round(self.bot.latency * 1000) await interaction.response.send_message(f'*Pong! __*{bot_latency * 1000}ms*__')
Looks fine
ok
Just try it and see
sure as in it would work, no sarcasm about that
though you'll see in the documentation that the app_commands module is usually imported directly using from discord import app_commands (or at least implied), making it a bit shorter to write out @app_commands.command(...)
Read through the error please. It'll be clear what the issue is
The slash command isnt working in discord and no error messages are occuring.```py
import discord
from discord.ext import commands
from discord import app_commands
class SCInfo(commands.Cog):
def init(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print('[SC COGS] - SCInfo cog loaded successfully.')
@app_commands.command(name="ping", description="Returns the bot's latency.")
async def ping(self, interaction: discord.Interaction):
bot_latency = round(self.bot.latency * 1000)
await interaction.response.send_message(f'*Pong! __*{bot_latency * 1000}ms*__')
async def setup(bot):
await bot.add_cog(SCInfo(bot))```
Have you synced?
Does it show in your servers integration tab?
hold on
yes it does
Restart your discord client
ok
@hushed galleon This is how the current setup is, what do you think? I'm going to change the Buttons, those are just placeholders for now
can voice support be subdivided into voice send/receive? also instead of doing the pseudo - sub-header, it might be easier to understand if the points were presented across many tables, e.g. ```md
Voice Support
| Feature | discord.py | nextcord | pycord | disnake |
|---|---|---|---|---|
| Send | Yes | ... | ||
| Receive | Yes (with an extension) | ... |
Buttons
...```
I was trying to format the Views and App Commands like that, but each heading would be too nested
ill try again tomorrow and see what i can do
So discordpy can send audio? 🤔
With an extension, yes
If a bot joins vc can it hear the other speakers, so in theory you could somehow record the vc no?
whats the extension?
Recording the VC is possible and actually extremely easy
Whenever a bot is in a VC I always deafen it if I can because who knows what the owners are doing
Voice receive extension package for discord.py. Contribute to imayhaveborkedit/discord-ext-voice-recv development by creating an account on GitHub.
Ok i know it is possible to send slash command like that:
</command:469569755461925990263140>
But can is send like, with filled arguments, so it would be
/command arg1:value1
Ah
With positional is just space amd it works
Like that
</tag regex:123>
nice
Oh that’s interesting
uhh dpy had native send capabilities for a long time (see basic_voice.py from 7 years ago), but not receive
ah, fair enough
hey, i tried this this morning and implemented an on_command_error function in my main bot class file:
async def on_command_error(self, ctx: Context, error: Exception):
ignored = (
commands.CommandNotFound,
commands.NotOwner,
commands.CheckFailure,
commands.DisabledCommand,
commands.UserInputError
)
if type(error) in ignored:
return
if isinstance(error, commands.MissingRequiredArgument):
return await ctx.send_help()
elif isinstance(error, commands.BadUnionArgument):
if error.converters == (Member | User):
return await ctx.warn(
"Unable to find that **member** or **ID**"
)
elif isinstance(error, commands.MemberNotFound):
return await ctx.warn(
"Unable to find that **member** or **ID**"
)
elif isinstance(error, commands.UserNotFound):
return await ctx.warn(
"Unable to find that **user** or **ID**"
)
however now when i run the avatar command and supply a user that doesnt exist, i get no output from the bot and no output in my console? the other errors i have accounted for work fine (like in my ban command)
i thought it might have to do with the member: Member | User = None or member = member or ctx.author in my avatar command
add an else statement also otherwise you're going to be eating your errors
ah i fixed it
had to make it if error.converters == (Member, User): instead of if error.converters == (Member | User):
dWZhaDQtcWZiYjMtd29hbGctaWFidWItbGFhNGEtdGJmbngtY3h4aWgtaTVzd3Item1rcjItZWlraWwtYnFlOlFYTE9XVkFF
?
Hello there
i start to build my own bot on discord and i get an error when i call the external command "XXX"
2024-01-05 09:22:25 ERROR discord.ext.commands.bot Ignoring exception in command None
discord.ext.commands.errors.CommandNotFound: Command "get_bitcoin" is not found```
import os
from dotenv import load_dotenv
import discord
from discord.ext import commands
# Initialisation des intentions
intents = discord.Intents.default()
intents.messages = True # Assurez-vous que les intentions nécessaires sont activées
intents.typing = False
intents.presences = False
bot = commands.Bot(command_prefix='!', intents=intents)
# Événement lorsque le bot est prêt
@bot.event
async def on_ready():
print(f'Connecté en tant que {bot.user.name}')
extensions = ['commands.bitcoin', 'commands.direBonjour']
for extension in extensions:
try:
bot.load_extension(extension)
print(f'Extension {extension} chargée avec succès.')
except commands.ExtensionError as e:
print(f'Erreur lors du chargement de l\'extension {extension}: {e}')
# Démarrer le bot
load_dotenv()
bot.run(os.getenv("TOKEN"))
import requests
from discord.ext import commands
# URL de l'API CoinGecko pour obtenir le prix du Bitcoin en USD
bitcoin_api_url = "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd"
class Bitcoin(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(name='get_bitcoin')
async def bitcoin(self, ctx):
response = requests.get(bitcoin_api_url)
if response.status_code == 200:
data = response.json()
bitcoin_price_usd = data["bitcoin"]["usd"]
await ctx.send(f"Le prix du Bitcoin est actuellement de {bitcoin_price_usd} USD.")
else:
await ctx.send("Désolé, je ne peux pas obtenir le prix du Bitcoin en ce moment.")
def setup(bot):
bot.add_cog(Bitcoin(bot))
/home/ubuntu/Dev/Bot_Discord_BlockchainSpot/init.py:21: RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
bot.load_extension(extension)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Extension commands.bitcoin chargée avec succès.
Extension commands.direBonjour chargée avec succès.
async def setup in cogs
await bot.load_extension in bot
yes i tried to do that but : ```
/home/ubuntu/Dev/Bot_Discord_BlockchainSpot/commands/bitcoin.py:23: RuntimeWarning: coroutine 'BotBase.add_cog' was never awaited
bot.add_cog(Bitcoin(bot))
await add_cog(cog, /, *, override=False, guild=..., guilds=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Adds a “cog” to the bot.
A cog is a class that has its own event listeners and commands.
If the cog is a [`app_commands.Group`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Group) then it is added to the bot’s [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree) as well.
Note
Exceptions raised inside a [`Cog`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Cog)’s [`cog_load()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Cog.cog_load) method will be propagated to the caller...
u need to await the add_cog also btw
yes 🙂 thanks @shrewd apex
ok so the good way is :
async def setup(bot):
await bot.add_cog(Bitcoin(bot))
Sorry for asking a question that's probably been asked a billion times, but what's the best library for making discord bots? (never made them before) It seems like discord.py is the most popular, but then some say it's been abandoned, but then it's had a comeback..¿ Is it currently maintained? Is it good, or would u recommend something else? Thx
yeah discord.py is currently maintained and up to date with discords apis also has one of the largest communities out there
few other notable mentions are
- disnake
- hikari (kinda more advanced)
- nextcord/pycord
I wonder why the last two are on the same line
how to make a global app_command_error handler like on_command_error
Overwrite your CommandTree.on_error method
how?
The approach I take is to subclass CommandTree, do what I want in there and then set tree_cls keyword argument in the Bot constructor to my new tree class
class Bot(Bot):
def __init__(self):
super().__init__(intents=Intents.all(), help_command=None, command_prefix="!")
self.testing_guild = discord.Object(id=1169236151467511822)
async def setup_hook(self):
self.add_view(Invite())
print(f"Loaded Views For {self.user}")
for cog in cogs:
await self.load_extension(cog)
print(f"Loaded Cogs For {self.user}")
self.tree.copy_global_to(guild=self.testing_guild)
await self.tree.sync(guild=self.testing_guild)
print(f"Synced slash commands for {self.user}.")
async def on_ready(self):
activity = discord.Game(name="/help | Made By FedxD", type=3)
await self.change_presence(status=discord.Status.online, activity=activity)
print(f"Logged in as {self.user}.")````
I have this
Bot(Bot) 🤔
Another way could be to just make your own on_app_command_error method inside Bot and then something like self.tree.on_error = self.on_app_command_error inside Bot.__init__
Essentially yes
But I would read the docs on on_error to make sure your function has the correct signature and stuff
what should be the variables i take in my function
Read through the link I sent, it'll answer your question
This is part of why I prefer the subclassing approach, many editors will warn you when a child class's overridden method signature is incompatible with that of the parent class
same, I dom't wanna be on the same line as pycord 
Error:
Command raised an exception: AttributeError: 'Shoya' object has no attribute 'top_role'
Shoya is my bot class
I tried self.client.top_role.position
you need the member object
hey guys, can someone please tell me why this error handler isnt working?
Why don't you make universal error handler
HOW CAN I DO THAT?
pls i need that
on_command_error
That's a event
but how can i add event to app_commands Group?
That's how i handle errors
Events is not part of a command it's separate
ohh, i forgot that its that cog listener ._.
even after that im still getting this
2024-01-05 14:11:20 ERROR discord.app_commands.tree Ignoring exception in command 'set'
Traceback (most recent call last):
File "C:\Users\danie\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\tree.py", line 1248, in _call
await command._invoke_with_namespace(interaction, namespace)
File "C:\Users\danie\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 849, in _invoke_with_namespace
if not await self._check_can_run(interaction):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\danie\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 987, in _check_can_run
return await async_all(f(interaction) for f in predicates)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\danie\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\utils.py", line 703, in async_all
for elem in gen:
File "C:\Users\danie\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\commands.py", line 987, in <genexpr>
return await async_all(f(interaction) for f in predicates)
^^^^^^^^^^^^^^
File "C:\Users\danie\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\app_commands\checks.py", line 232, in predicate
raise MissingRole(item)
discord.app_commands.errors.MissingRole: Role 1154457410677788732 is required to run this command.
Unhandled error
how can it be unhandled
on_command_error is for message commands tree.error is for slash commands
so like how can i fix that?
how many context menus can i add into my message
is it ok if i post here ads? or nah
discord.Message is unsupported annotation in commands
i have used Messaeg before with hybrid commands and it converted the message id auto to message
@bot.hybrid_command(name="reactionrole", description="Create a reaction role")
@commands.has_permissions(manage_roles=True)
async def reactionrole(
ctx,
message: discord.Message,
role: discord.Role,
emoji: discord.Emoji = "✅",
limit=10000,
):
db.execute(
"INSERT INTO reaction_roles VALUES (?, ?, ?, ?, ?, ?, ?)",
(
ctx.guild.id,
message.channel.id,
message.id,
role.id,
emoji,
limit,
dt.datetime.now(),
),
)
main_db.commit()
await message.add_reaction(emoji)
await ctx.author.send(
embed=Embed(
title="Reaction Role",
description=f"Reaction Role Created\nRole: {role}\nEmoji: {emoji}\nLimit: {limit}",
color=Color.green(),
)
)
main_db.commit()
One of my prevous commands
hybrid converts unsupported annotations for slash into the regular converter, but plain app commands doesnt support it
so how do i do it
you can't, for discord.Message annotation, only that is for context menus specifically
any other way i can get a message?
class EmbedSender(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot
async def send_embed(self, discord_id: str, embed_type: str = "login") -> None:
channel_id = settings.PLAYERS_LOG_CHANNEL_ID
if channel_id is None:
return
channel = self.bot.get_channel(int(channel_id))
if embed_type == "login":
embed = await login_embed(discord_id)
elif embed_type == "logout":
embed = await logout_embed(discord_id)
await channel.send(embed=embed)
logger.info(f"Message {embed_type} embed has been sent successfully")
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(EmbedSender(bot))
i made this cog in cogs folder
how to get this function outside bot files
(i have function out side discord bot i need here to send embed message)
either use a context menu or make a message transformer, convert them from str to Message
ok
cant i use int?
ok got t
you can only use it in cogs i think you need to create a seperate function or a @staticmethod
if all you do is send a message, maybe use a webhook? you dont need the bot for that
webhooks are slow
err i dont know about that, i mean webhook has it's own ratelimit independent of bot
is channel.get_partial_message corontine?
no
ok
btw how many context menus can i make?
i alr have 3
- Translate
- Bookmark
- Report
i want to make more but idk if i can
do you know the limit?
no they are dynamic, but i've heard it's lower than bot's
maximum of 5
that one i've no clue
ok
well what should i use then
fetch_message, get_partial_message is only used for calling another method related to the message but they aren't filled with message values
ok
ok one more question how do i get to know who deleted the message in on_message_delete
async for ... in audit_logs(*, limit=100, before=..., after=..., oldest_first=..., user=..., action=...)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator) that enables receiving the guild’s audit logs.
You must have [`view_audit_log`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.view_audit_log) to do this.
Examples
Getting the first 100 entries:
```py
async for entry in guild.audit_logs(limit=100):
print(f'{entry.user} did {entry.action} to {entry.target}')
```...
do i need the async for i the limit is only 1?
ye
any tutorials to get started with discord bots,i know the basics of python but all of the tutorials go straight to making a discord but none i found that thoroughly explain the discord module
i started by just asking/chatting with ppl and reading the docs
!d discord
ty for sending this, i think it'll help tremendously
will do, thanks for the offer
the docs u sent actually explain the module
well there is a lot more
do you want prefix command or app_commands?
you can make prefix app and hybrid(both prefix and hybrid)
for start, I would probably choose prefix commands
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin) to provide the functionality to manage commands.
Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree) and is automatically set upon instantiating the class.
async with x Asynchronously initialises the bot and automatically cleans up.
New in version 2.0.
yea that's why i would use it first but I would want to learn both after i get fairly good at it
class discord.Intents(value=0, **kwargs)```
Wraps up a Discord gateway intent flag.
Similar to [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.
To construct an object you can pass keyword arguments denoting the flags to enable or disable.
This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client).
New in version 1.5.
!d discord.ext.commands.Bot.command
@command(*args, **kwargs)```
A shortcut decorator that invokes [`command()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.command) and adds it to the internal command list via [`add_command()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin.add_command).
that should get you started
ty a lot
np
Is there any way to get the count of all the messages a user has sent in the server without looping through the ctx.channel.history(limit=None) async generator?
class DevTools(commands.Cog):
def __init__(self, bot) -> None:
self.bot = bot
@commands.Cog.listener()
async def on_message(self, *_):
print('msg got')
@commands.Cog.listener()
async def on_ready(self):
print('bot up')
```I have this cog. the `on_message` event runs, but the `on_ready` event does not. The cog is loaded from the bots `on_ready`, which I assume is the problem. Is there some on_cog_loaded event? Or should I move the bot ready notification (it will send a msg to a log channel) to the bot itself. I don't want to bloat the bot class too much.
you should move your startup code to setup_hook event
that sadly doesn't work, the bot uses entirely guild-specific slash commands - it only needs to work in one guild, and each add_cog is passed guild=bot.guilds[0]. This list seems to be empty if the cogs are loaded in setup_hook.
isnt bot.guilds always the same guild hence can be hardcoded?
!d discord.ext.commands.Cog.cog_load
await cog_load()```
This function *could be a* [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A special method that is called when the cog gets loaded.
Subclasses must replace this if they want special asynchronous loading behaviour. Note that the `__init__` special method does not allow asynchronous code to run inside it, thus this is helpful for setting up code that needs to be asynchronous.
New in version 2.0.
and also cog_unload, it's sister method
i would say easiest way would be to just len(list(ctx.channel.history(limit=None))) but actually i dont know if you can do that with async generators
(also you shouldn't do startup stuff in on_ready as it can fire many times lol, best to create_task a coroutine with a await bot.wait_until_ready() call as the first thing)
then everyone who ever wants to develop the bot needs to configure a guild id somewhere, which seems remarkably avoidable seeing as the bot knows which guild it is in. It would be fine IG, just more annoying.
how is the main on_ready event defined?
we do already have a .env file, I will just add a bunch of sanity checks and call it a day
it's more or less
await self.load_extension('cogs.reaction_utils')
```in a loop with various cogs.
we have a subclass of the bot, so its
class CustomBot(commands.Bot):
async def on_ready(self):
pass
ok actually i see the self here so i assume you subclass the Bot and override the method
yup
Oh wait, the guild id is already in here, just unused
yeah, I will just use that then.
ty
it doesn't work
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
if you're using discord.py, there's a utility for converting datetimes to timestamp markdown
!d discord.utils.format_dt
discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime) for presentation within Discord.
This allows for a locale-independent way of presenting data using Discord specific Markdown...
One message removed from a suspended account.
you er, give it a datetime and the style that you want to show and it formats it into the correct string for showing the timestamp py my_time = datetime.datetime.now() timestamp = discord.utils.format_dt(my_time, "R") await ctx.send(timestamp) which results in <t:1704480462:R> (<t:1704480462:R>)
One message removed from a suspended account.
One message removed from a suspended account.
Doesn't discord py allow you to iterate over a single member's message history?
One message removed from a suspended account.
i believe member.history() iterates through their DMs rather than every channel in a server
afaik discord has no public API for retrieving all messages from a user efficiently, so the best choice for bots would be to track message counts for some time via gateway events
One message removed from a suspended account.
markdown formatting gets ignored if you wrap it in backticks, so er don't use that
One message removed from a suspended account.
Makes sense, but the method feels slightly misleading to me in the specific case of Member objects
trying to just send a message when the on_presence_update occurs to get a test message to go through for a possible logging channel setup. why doesn't this send a message?
i'm using a CHANNEL_ID and using the self.fetch_channel(CHANNEL_ID) I also tried self.get_channel(CHANNEL_ID)to get the discord channel to do channel.send, but it doesn't send a message? I'm using this as an example because I'm trying to make custom messages to be sent when events happen from outside discord api events. So I can log those in a certain channel.
if after.activity is not None:
print(after.guild.id)
channel_id = CHANNEL_ID
channel = self.fetch_channel(channel_id)
await channel.send(f"<t:{int(unix_time)}:T> After:\n{after.activity.type} || {after.activity.name}")
do I have to like... check and see if user is in that guild.id first, then use guild as my base? like this...?
guild = self.get_guild(GUILD_ID)
channel = guild.get_channel(CHANNEL_ID)
does the print statement show up in your console? are there any errors as well?
if no to both, you might be missing the members/presences intent which are both needed to receive on_presence_update(), but otherwise get_guild()+get_channel() is the most optimal way to retrieve the channel
I have intents.all on currently.
it's wrapped in my super().__init__()
would that be an issue?
sounds fine... what about the print statement and errors?
does the guild ID get printed though?
hmm, i would suspect that there was an error, but it got suppressed by either your try/except clause or an on_error handler
probably on_error.
cause I setup all the cog listeners as tests in their own cog so I can import controllers later.
(as a sidenote, client.get_channel() can be more convenient if you only have a channel ID, but dpy has to loop through all guilds to find the correct channel object; alternatively you can use get_partial_messageable() if you can't go the get_guild() route)
what does your on_error handler look like?
so pass the bot through as client instead of commands.Bot?
class OnError(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot= bot
self.message = None
@commands.Cog.listener()
async def on_error(self, event, *args, **kwargs):
""" Usually when an event raises an uncaught exception, a traceback is logged to stderr and the exception is ignored. If you want to change this behaviour and handle the exception for whatever reason yourself, this event can be overridden. Which, when done, will suppress the default action of printing the traceback.
The information of the exception raised and the exception itself can be retrieved with a standard call to sys.exc_info().
Changed in version 2.0: The traceback is now logged rather than printed.
Parameters
event (str) – The name of the event that raised the exception.
args – The positional arguments for the event that raised the exception.
kwargs – The keyword arguments for the event that raised the exception."""
print(f"On Error: \nEvent: {event}\nArgs: {args}\nKwargs: {kwargs}")
pass
async def setup(bot: commands.Bot):
await bot.add_cog(OnError(bot))
print('OnError loaded')
legit bare minimum right now lol
commands.Bot already inherits discord.Client so you don't have to change anything about that
actually based on their source code and docs, on_error doesn't support listeners so the cog doesn't have any effect
if you didn't define on_error in your Bot subclass, it's likely using the default handler which logs the exception according to the logging configuration
how do you start your bot, using bot.run() or await bot.start()?
if it's the latter and you haven't already set up logging yourself (docs), you should call discord.utils.setup_logging() before starting it, otherwise it won't print any exceptions from your on_presence_update()
await bot.start(settings.DISCORD_API_TOKEN, reconnect=True)
I tried to setup logging, but I'm assuming I did it wrong in the setup_hook.
async def setup_hook(self) -> Coroutine[Any, Any, None]:
await self.load_modules()
discord.utils.setup_logging(
level=logging.INFO,
handler=MyFileHandler('D:\\Discord\\Logs\\info_discord.log'),
formatter=logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')
)
discord.utils.setup_logging(
level=logging.DEBUG,
handler=MyFileHandler('D:\\Discord\\Logs\\debug_discord.log'),
formatter=logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')
)
discord.utils.setup_logging(
level=logging.WARNING,
handler=MyFileHandler('D:\\Discord\\Logs\\warning_discord.log'),
formatter=logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')
)
discord.utils.setup_logging(
level=logging.ERROR,
handler=MyFileHandler('D:\\Discord\\Logs\\error_discord.log'),
formatter=logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')
)
discord.utils.setup_logging(
level=logging.CRITICAL,
handler=MyFileHandler('D:\\Discord\\Logs\\critical_discord.log'),
formatter=logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')
)
print(f"Bot is online.")
return await super().setup_hook()
uhh the lowest level captures everything above that level, so debug_discord.log would contain INFO, WARNING, ERROR, and CRITICAL logs
but regardless that should write any on_presence_update errors to your log files...
are you still running the event handler with try/except blocks? if so, can you show that part
if after.activity is not None:
print(after.guild.id)
print(after.guild.name)
print(after.activity)
if after.guild.id == GUILD_ID:
channel_id = CHANNEL_ID
channel = self.fetch_channel(channel_id)
if channel is None:
channel = self.get_channel(channel_id)
print(channel)
if channel:
try:
await channel.send(f"<t:{int(unix_time)}:T> After:\n{after.activity.type} || {after.activity.name}")
except Exception as e:
print(e)
seems okay for debugging purposes, what did it print for the channel?
also .fetch_channel always returns the channal as it calls the api .get_channel on the other hand looks in cache and if not found then returns None so you swaped the methods
oh i didnt notice you were attempting to use both methods at the same time
self.fetch_channel() is an asynchronous function, so not awaiting it merely gives you a coroutine object rather than None
oh yeah you need to await the fetch_channel
ah thats why it didnt error, you unintentionally invoked coroutine.send() which is a valid method
ohhhhhhhhhh
i suggest sticking with get_channel() because once your bot is ready, all guilds/channels should already be cached (except if you use AutoShardedBot or you turn off the guilds intent, in which case it's safer to use get_partial_messageable() as linked earlier)
so then can i still do await channel.send()? if it's only return an int, can I still have it send a message that way?
uhh if what returns an int? you can still use .send(), it was just getting the channel that needs to be fixed
!paste
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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
What can this be?
https://paste.pythondiscord.com/RVJA
who knows, discord disconnected your bot for some random reason
https://github.com/Rapptz/discord.py/blob/v2.3.2/discord/client.py#L700-L701
discord/client.py lines 700 to 701
# sometimes, discord sends us 1000 for unknown reasons so we should reconnect
# regardless and rely on is_closed instead```
Is there any way to check why?
I just run it on a VPS with PM2
afaik no, but its probably not something you can do anything about anyway
code 1000 is simply a clean websocket closure, it doesnt mean that discord is conveying any error status
the other close codes discord could send is documented here
https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-close-event-codes
Well I have never seen it before. Maybe I could ask my VPS provider if they are having any uptime issues/or change VPS location?
if you want to sure, but receiving a close code is unlikely to suggest that there's an issue with the connection itself, because that normally results in disconnecting without any close code
I mean what else could it be, since I never received this message with my other VPS provider for 12 months? As soon as I changed to this provider, I received the message
could be some engineer at discord making changes to the gateway and forcing bots to reconnect... or perhaps they have some automated system to close connections that behave a certain way
whatever the cause might be, it was an intentional action by discord's servers to end your gateway connection with code 1000
i wouldnt worry that much about it given the downtime was 1 second
This error legit just appears sometimes
I got it once while polling history on every channel of a server
is commands the only way for a bot to store data in a database?
This question is confusing
databases are independent from commands
In the case of sqlite, they're just files
So I don't really understand what you're asking
thanks bro
https://discord.com/channels/267624335836053506/1193001243300352150
Anyone able to provide insight on what is going on?
howdy gents its me borger
im proud to annouce that my bot is now functioning as intended
i'd like to thank the people that have helped me with coding it by providing reasorces and insight
yall really did me a solid
welp
back to the void
https://paste.pythondiscord.com/R3IQ
idk at this point
I need some help
I know its basically all wrongt but im unfamiliar with sql, also add the id and prefix does work but can be built upon better.
Please dont tell me you have a 3 letter username and password
I dont lol
its just blurred, the info is correct
My table in sql has guild.id and newprefix
nvm
How can i get reason of ban of banned user?
If it's about SQL then #databases
Guys do disnake have cogs watching enabled by default?
Error:
Command raised an exception: TypeError: object of type 'async_generator' has no len()
line: len(ctx.guild.bans())
!d discord.Guild.bans
async for ... in bans(*, limit=1000, before=..., after=...)```
Retrieves an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator) of the users that are banned from the guild as a [`BanEntry`](https://discordpy.readthedocs.io/en/latest/api.html#discord.BanEntry).
You must have [`ban_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.ban_members) to get this information.
Changed in version 2.0: Due to a breaking change in Discord’s API, this now returns a paginated iterator instead of a list.
Examples
Usage...
See the example 2
So i can't get a length?
Literally look at the second example....
I can't see examples in embed
Come on.... Use at least a little bit of common sense and click on the link on "discord.Guild.bans" - it's not blue for decoration

hi, I tried to install the fivem library in the terminal and since I installed it, everything in visual studio stopped working, can anyone help me?
Thank you
!dash-m use that
When trying to install a package via pip, it's recommended to invoke pip as a module: python -m pip install your_package.
Why would we use python -m pip instead of pip?
Invoking pip as a module ensures you know which pip you're using. This is helpful if you have multiple Python versions. You always know which Python version you're installing packages to.
Note
The exact python command you invoke can vary. It may be python3 or py, ensure it's correct for your system.
and install discord.py not discord
A mirror package for discord.py. Please install that instead.
hello
I was wondering how would you check the perms of the user who triggered (used) the command
in an if block
i was using if ctx.message.author.guild_permissions.administrator: because I found it in stackoverflow but I noticed it doesn't work and it's obsolete
For what do you need to check the permissions
a ban command
For what
to ban users
Doesn't answer the question, to send a message? To warn you? To mention the user? To send a nice gif?... ...
I had planned that if the user has enough permission to ban, it would send an embed containing who banned and who got banned
Then use the decorator instead, will prevent unnecessary code
!d discord.ext.commands.has_permissions
@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check) that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions).
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingPermissions) that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure).
which example
^
But click on the blue discord.ext.commands.has_permissions title instead
ohh
There it's for manage_messages but you can do for anything and add multiple as well
ohhh
is there a list to the permissions?
or they're just the same name as the ones in roles
indifferent
!d discord.Permissions
class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.
The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.
Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions) similar to [`update()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.update).
There's the entire list
How would you send something if he doesn't have the permission?
@slate swan
Handle the error
Start your bot with python file_name.py
doesn't work, the terminal closes
@slate swan
In your terminal, you open it and use the command above
It won't just close
And no point in pinging for every message you send
sorry
every command I try gives me various errors
Show them then
Can someone help
i get this error when running my code
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
that's not an error, you launched python
It doesnt run my bot though
because you didn't pass the file to run
wdym
python file.py will run the file called file.py
oh
just executing python will just launch python interactively
Trying to run a bot on a vps, but getting this problem, how do i solve?
this command is not working its showing interaction didnot respond and it has no errors
What os is the vps?
Cause you are missing SSL certificates
not really its more of an internet issue if he is connected to some sort of vpn
How to pair discord bot with Flask app
suppose i hit route /say_hello/<name>
i want bot to send Hello <name> in channel
that would require quite a different custom setup ur bot will be running a webserver and u will have another webserver in the form of flask app and any request to this flask app will be forwarded to the bot where the request will further be processed a more hacky way would be you run both the flask and bot from the same program that way a single web server should suffice since you would have access to both instances
Sounds like im heading to very niche approch, what is common setup for such task, im trying to create a todo app using flask and saving data on discord server
i did mention how u would setup the project above and how the bot and the website would interact
i didn't understand by single program did you mean using threading?
yes kind of u would start the bot and start the flask server in another thread
i got this error called Run time error Timeout context manager should be used inside a task
Windows 10 1809
Is it?
code?
Hey it was problem with asyncio it's resolved now
Can someone help with this
i see, alright, you can't really mix flask with dpy
Yea it's working fine with threading so far
is spotipy a library you're trying to import?
yes
I also installed it with pip
you should rename your file spotipy.py to another name, since that's shadowing the package
It worked
But I have another problem
err, full traceback please i can't rly see why it's pointing at that
thats true, but i wouldn't recommend mixing wsgi with dpy, i mean what if you want to spawn multiple workers, etc, it do be better if you separate them in a separate project with proper ipc
IPC? What is it?
TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'
interprocess communication, it's a way to communicate to another process, it's a general concepts, but you can use websocket/db/ and other ways
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.
There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.
Afterwards in your code, 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
# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.
see the last line there
This is a Python server
https://discord.com/channels/267624335836053506/1193414717314711582
If anyone has anything that could be causing this it would be greatly apreicated
Can discordbots issue timeouts?
await timeout(until, /, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Applies a time out to a member until the specified date time or for the given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta).
You must have [`moderate_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.moderate_members) to do this.
This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.edit).
yeah that's what the / means in the function signature
means "positional only"
Neat
So does it mean everything before the / has to be in that order?
or just the immediate one?
that's uh, good question actually
I'll get back to you on that
Coz I know the * means everything after has to be specified, so if you got my_func(*,a,b,c) it doesnt matter order, but you still have to say my_func(b=1,c=3) for example. u cant just do 1,3
@drifting arrow you're right:
The following would apply:
- All parameters left of the / are treated as positional-only.
Show some code
just noticed i had old code
that could be making it longer then 3 seconds
How many buttons are possible to add on one interaction?
Clicking a button, using an application command, choosing an option in a select menu, etc. is an interaction, so the question doesn't make much sense
If you mean how many per message, 25 (5 rows with each 5 buttons)
i am making a giveaway command what is the best way to make the waiting system
cause if i just use ayncio.sleep than it can go off when i restart the bot
store times in your database
hours
i aint running the loop every minnute
i was thinking about doing an hour but it was the offset
so i set it to 10 minutes
no like
compute the time left and put that into the tasks.loop
wdym?
@tasks.loop(minutes=10)
async def giveawayloop(self):
db.execute(
"SELECT * FROM giveaways"
)
giveaways = db.fetchall()
for giveaway in giveaways:
time = giveaway[8]
minspent = giveaway[7]
if minspent < time:
minspent += 10
db.execute(
"UPDATE giveaways SET minspend = ? WHERE message_id = ?",
(minspent, giveaway[3])
)``` i have this
usually you'd store the time when the giveaway will start
calculate when that'll happen and put that into tasks.loop
cancel the task when it gets run
what is the point of asking for help then
what i told you is the easiest way
load the giveaway time from the db
then schedule that in your bot
The thing with that is that if a giveaway ends at e.g. 0830 and your last task run was at 0828, your next task run will be 8 minutes after the end, and if someone joined the giveaway after the end and won.. pretty unfair
What interrrp said is definitely the way to go
i dont understand the method @rugged shadow is suggesting
for example, you have your giveaway time as 0800, so you store that in your db
then in your bot, you load that time (0800) and schedule the event on that time
howww
show like a code example or something please
DECLARATION--- IM NEW TO CODING - WHAT I TELL YOU MIGHT BE "WRONG" BUT THIS HOW I WAS TOLD TO DO IT BY SOME PEOPLE HERE AND SOME INDEPENDENT RESEARCH i just finished giveaway commands for my bot bro. i have my check giveaway function (which calls the end giveaway function) task to run every 1 second. and the key to getting to work between bot restarts is i call check_giveaway function when my giveaway commands cog loads. thats where i was told to put it in here when i asked. also i saved the end time when the giveaway was created. my check giveaway function just first looks for any giveaway that current time is not past end time, if none return the loop stops. if any return, the loop continues running and when the current time reaches the end time its calls my end giveaway function. oh also the check giveaway function is called and started when the start giveaway function.
only thing im still having issues with is getting my buttons to still work after bot restarts. i got it for the original message but i also have repost giveaway commands and that messages doesnt lol. i just need to do some debugging and figure out where the mistake is. other than that, this room helped tremendously getting my bot up adn running with giveaway commands
resources usage goes brrrrr
u can just add the vutton
yea right
every secound is just way to much]
and that's why you start a task for x seconds until the giveaway ends on the bot's start
i am using 10 minutes cause that just giives my peace
yea i know, i made a mistake somewhere, ill find it.
you need to add the view to your bot
i know. i had it working perfectly but added a new command and just need to fix the new command
if it's not a multipurpose bot like 6472927 other bots but a giveaway bot then it's fine.
if it's multipurpose having a giveaway feature is pretty painful to have if you have lots of people that create a giveaway and other features which will use lots of resources in the end
lol exactly why only admin is setup to create and start giveaways
who can help me about code
weill only have 1 or 2 giveaways running at the same time. have our first giveaway running for the past 50some hours
doesn't change a thing, i can create a server and create hundreds of giveaways in your multipurpose bot and then it may not have enough resources for other features for other users
its not a multipurpose bot and it wouldnt do shit because my server info is hard coded lol. my bot will only work in my server
Just make it private in the dev portal, don't need to make it work only in your server if people can't invite it
ill be honest, i didnt do that on purpose. just thats how the setup video i watched did it haha didnt even realize i was doing it when i did it haha
¯_(ツ)_/¯
but curious, how do you do it for the giveaway to end when its suppose to if you dont check every second?
can someone help me?
hiring python developer 200$ weekly
lol
need help about code
i am in lol
with discord ?
in anyways i am in i was looking for a job anyway
@fiery girder can you help me?
yeh sure
just need a simple error fix
ill just pay 20$ for that
that ll take ur 5 minutes max
sure i can help you
you either use tasks.loop or schedule a task yourself using the asyncio api
i did a task loop. but people were commenting it shouldn't be every 1 second. so how else do you do it for the giveaway to end when its suppose to? exactly the length of teh set duration?
i guess i schedule the task to run for the last minute of the giveaway or something instead of the whole time?
what i did in the past was to:
check every 30 minutes / 1 hour the database for near ending giveaways (so giveaways that will end in 30 minutes / 1 hour) and schedule the ending actions through the creation of tasks using the asyncio api, when these tasks are completed they push the final state of the giveaway to the database (so e.g ended, etc...)
the post task run logic is important because if your Bot shuts down exactly when running the tasks to end a giveaway it'll know in the next restart if it missed some giveaways, at least, it should (never happened on production)
Wha
i see. so basically its 1 task set to run not that oftne (30 mins to an hour) to check for giveaways about to end that then schedules the next task which runs more often to start the eng giveaway functions?
well firstly, this ins't even related to discord bots.
there is no telegram bot section in this discord thats why i sent here
yeah, the task.loop task checks ending giveaways and schedule them, if there are multiple ending giveaways it'll schedule the end for them all
thank you for explaining. ill update now
note that this logic works well only if you're using a database
post loop you mean after_loop?
i am using a sqlite3 database
!d asyncio.Task.add_done_callback I'm talking about this
add_done_callback(callback, *, context=None)```
Add a callback to be run when the Task is *done*.
This method should only be used in low-level callback-based code.
See the documentation of [`Future.add_done_callback()`](https://docs.python.org/3/library/asyncio-future.html#asyncio.Future.add_done_callback) for more details.
or you can just call a function at the end of the giveaway ending function ig
gotcha. thanks bro
you're using an async driver right?
!pypi aiosqlite
Like this one
no im not using asiosqlite. should i be?
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!
hmm
@timber lotus can you help me?
Sataru Gojo
Extension 'ext.antinuke' raised an error: TypeError: object NoneType can't be used in 'await' expression
TypeError: object NoneType can't be used in 'await' expression
pls fix it i will provide the required code
We can explain what's wrong, we won't fix it for you
okay bro pls explain me where i am doing wrong
Could you provide the code where the issue is occuring.
!paste
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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
and the error is occuring on which line @gray mantle
let me show u
class MyBot(commands.Bot):
async def setup_hook(self):
for p in Path("./ext").glob("*.py"):
await self.load_extension(p.as_posix()[:-3].replace("/", "."))
its last line
maybe its a cog issue
could u help me fix it?
send the error msg
there isnt a error
the commands just dont show up when trying to use them
send the code
!paste
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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
hmm, considering documentation states it's a Coroutine 🤔
@gray mantle
What’s the full traceback
wha'ts the issue?
Are the commands being synced
That’s not the full traceback
one of the two commands doesnt show up when trying to use it
I belive so
actually Id take that back
I belive they dont
sync returns a list of AppCommand objects, which have a name attribute
Loop through it and print the names
@final iron print("Logged in as {0.user}".format(bot)) try: synced = await bot.tree.sync() print(f"Synced {len(synced)} command(s)") except Exception as e: print(e) this?
Nothing is printing?
yeah
Well yeah…
maybe because of the statuses I added
You have a while loop
@final iron so how do I make the sync do itself once and then let the while loop go on?
You shouldn’t be looping through presences.
but I want it to have 3 and to loop through them every 10 seconds
how could I separate the two?
You shouldn’t be looping through presences.
why is that
@final iron so I updated the code and still doesnt update it
I am working no a project. But i cant figure out how can i work with my friends. How can we work together is a same project. Can anyone help me out. I am new to these all !
Are you looking for a live coding environment, or just somewhere to host your code, like GitHub
im new probably not
not sure if this is the appropriate channel, but I think this guide should be updated as repl.it no longer has free hosting as of jan 1st 2024
This article lists recommended VPS services and covers the disasdvantages of utilising a free hosting service to run a discord bot.
Can make a PR on GitHub
Actually even Heroku doesn't provide free hosting, so the entire section can be removed
hello i'm neew in python, acn you please explain me why it does that when i install discord with pip
Python 3.12 is not supported yet, downgrade to 3.11
thanks
Good afternoon my fellow friends, I'm looking to make buttons for my embeds, and was wondering how to do it?
There's some examples in the Github
that helps alot, dosent provide any help
How are examples not helpful
It would help if I had a link to said GitHub examples
You haven't said which library you're using, so it's literally impossible to give a link
In the repository there's an examples folder
what repository
discord.py...
I had a look at the repo, and it wasn't much use.
Which part of the example didn't you understand?
Well, I'm using cogs, so I'm not sure how much it will change when using them
Just try it and see
There's like 10 different examples, so you're not really being specific enough for me to be able to comment on any changes
Well, what I'm wanting is 2 buttons for confirmation of deleting a channel, that can only be used my people with a certain permission, and only the author of the one who called the command
Take it one at a time
Just create the two buttons at first
Then, implement the permissions check
Guys can we override the default help command in disnake like we do in discord.py?
yes. disnake is a fork of discordpy so most things are similar
I assume it's the same way too - pass in the custom help command instance to the client or bot instance
using text commands, is there a way to get just the message that was sent?
message = ctx.message.content
Partial of my function:
@commands.command(name='m')
@commands.guild_only()
async def text_reply(self, ctx):
author_roles = ctx.author.roles
for role in author_roles:
if role.id in self.roles:
database_data = await database.search_for_channel(channel_id=ctx.channel.id)
message = ctx.message.content
i havent used text commands in a while lol
I usually use slash commands.
nvm. i needed anoter paramater lol
async def text_reply(self, ctx, response_message): XD
is there a way to make ctx.reinvoke() not mess up the rest of my custom error handling? everything after await ctx.reinvoke() gets cancelled out in my on_command_error handler
What is against terms of service
Turns out this doesnt work 😄
Why not?
I needed an asterisk (*) before "response_message"
chatgpt helped out. i really didnt want to have to google that issue lol
I rarely use text commands so it's not worth spending forever trying to figure out
Did chatgpt tell you whats "*" for?
Question:
Right now I have a Folder containing all my code, inside that folder I have a functions folder, containing several functions I use in the code. Now I want to make a cogs folder so I can store individual commands because my code is 1500 lines long. But I also want to use the functions in the Functions folder in my cogs, that I will import to my main.py code. Everytime I try to import a function from my functions folder it gives me a error. IDK why.
-Main Folder
-- Main.py (My Bot)
-- Functions Folder
---All my functions
-- Cogs Folder
---All my cogs
Show error pls?
Traceback (most recent call last):
File "c:\Users\djfau\OneDrive\Desktop\Beta UN Bot Version 0.1.5\0_1_6.py", line 50, in <module>
from Cogs_Folder.Donate_Cog import Donate_Cog
File "c:\Users\djfau\OneDrive\Desktop\Beta UN Bot Version 0.1.5\Cogs_Folder\Donate_Cog.py", line 5, in <module>
from Functions_Folder.Check_File_Exists import check_file_exists
ModuleNotFoundError: No module named 'Functions_Folder'
What's you folder name? Show image pls
I mean image of the your file structure
So how you importing the functions? Btw you should organise your files
import discord
import json
from discord.ext import commands
from discord import app_commands
from Functions_Folder.Check_File_Exists import check_file_exists
from Functions_Folder.Unformat_Number import unformat_number
from Functions_Folder.Check_Player_Budget import check_player_budget
from Functions_Folder.Format_number import format_number
from Functions_Folder.Check_Player_Resource_Quantity import check_player_resource_quantity
class Donate_Cog(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
...```
This is my cog
continues on but not important
Add a . before the Functions_Folder
Thats giving me a bunch of errors
Try organising your code in a folder called src and make it a module and use relative imports
Show errors?
PS C:\Users\djfau\OneDrive\Desktop\Beta UN Bot Version 0.1.5> & C:/Users/djfau/AppData/Local/Programs/Python/Python310/python.exe "c:/Users/djfau/OneDrive/Desktop/Beta UN Bot Version 0.1.5/Cogs_Folder/Donate_Cog.py"
Traceback (most recent call last):
File "c:\Users\djfau\OneDrive\Desktop\Beta UN Bot Version 0.1.5\Cogs_Folder\Donate_Cog.py", line 5, in <module>
from .Functions_Folder.Check_File_Exists import check_file_exists
ImportError: attempted relative import with no known parent package
Like do like this
src--|
Cogs
Functions
bot.py
init.py(makes it module)
so the your import the files like
from src.Functions import ...
Await it
alright dont really know what all that means but Ill figure it out thanks
Make it async function and run it
Lemme get you an example, 2 mins
Try loading extensions in setup_hook which is called before starting bot
Like
async def setup_hook():
load here
bot.setup_hook = setup_hook
!d discord.ext.commands.Bot.setup_hook
await setup_hook()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A coroutine to be called to setup the bot, by default this is blank.
To perform asynchronous setup after the bot is logged in but before it has connected to the Websocket, overwrite this coroutine.
This is only called once, in [`login()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.login), and will be called before any events are dispatched, making it a better solution than doing such setup in the [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready) event.
Warning
Since this is called *before* the websocket connection is made therefore anything that waits for the websocket will deadlock, this includes things like [`wait_for()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.wait_for) and [`wait_until_ready()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.wait_until_ready)...
can you show me yoru all code?
main
which intents do i need for a bot that only does giveaways, send messages in channels and dms?
intents = discord.Intents.default()
intents.message_content = True
intents.guilds = True
intents.guild_messages = True
intents.guild_reactions = True
intents.members = True
this is what i think i need after reading the documentation but i never understand teh documentatioon correctly
!paste can you send in text form?
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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
copy code from you main file and paste in the https://paste.pythondiscord.com/, click save and send me link
Yes i am looking for live coding environmet.
I want to code together with my friend.
How can i do that
iirc there are extensions on VSCode for this but live coding is very unusual and would not recommend doing
you most likely want git/github
HOw can i do with intellij IDE
i mean i have no idea about it
How can i get started
There might be an extension but I doubt it's built in - it's not a feature most people would use
try this
import discord
from discord.ext import commands
import os
from keys import *
class Client(commands.Bot):
def __init__(self, *args, **kwargs):
intents = discord.Intents.default()
intents.guilds = True
intents.members = True
intents.message_content = True
super().__init__(command_prefix="()", intents=intents, *args, **kwargs)
async def setup_hooks(self):
initial_extensions = []
for filename in os.listdir('Discord/cogs'):
if filename.endswith('.py'):
initial_extensions.append("cogs." + filename[:-3])
print(initial_extensions)
for extension in initial_extensions:
try:
await self.load_extension(extension)
except Exception as e:
print(f'Failed to load extension {extension}: {type(e).__name__} - {e}')
async def on_ready(self):
await self.change_presence(status=discord.Status.online, activity=discord.Game('Under-Development'))
print('Active')
print('-------------------------------')
client = Client()
client.run(BOTTOKEN)
this uses concepts of OOPS
thank you
kk
is hello command in cogs?
looks like cogs are not being loaded properly
show me your bot logs?
i mean logs
fyi using discord.Intents.default() enables all the non-privileged intents so if you really only want those intents, you should write discord.Intents(message_content=True, guilds=True, guild_messages=True, members=True) instead
logs are shown in terminal
im not sure which intents i need. its just a giveaway bot that sends a dm to the winner, post to a text channel, edits and deletes its own messages. with embeds
if its a small bot where discord doesn't need to send that many events, you don't need to care that much about non-privileged intents and can just leave them all on with default(), but regardless what you have selected might work depending on what exactly your code does (for example, if people have to enter the giveaway using reactions, you'll need the reactions intent)
These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.
Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.
Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.
Use cases
- Decorators (see
/tag decorators) - Inheritance (overriding methods)
- Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
- Flexibility (writing functions that behave like
dict()orprint())
See /tag positional-keyword for information about positional and keyword arguments
anyone here experienced with on_command_error handlers?
np
async def on_command_error(self, ctx: commands.Context, error: commands.CommandError):
self.logger.warning(f"{ctx.author} ({ctx.author.id}) in {ctx.guild.name} ({ctx.guild.id}) | {ctx.invoked_with}-{type(error).__name__}: {error}")
if type(error) in (commands.NotOwner, commands.CheckFailure, commands.DisabledCommand, commands.UserInputError):
return
elif isinstance(error, commands.CommandNotFound):
await ctx.warn(f"Command `{ctx.invoked_with}` doesn't exist")
elif isinstance(error, commands.MissingRequiredArgument):
await ctx.send_help(ctx.command)
elif isinstance(error, commands.MissingPermissions):
if ctx.author.id in self.owner_ids:
await ctx.reinvoke()
else:
await ctx.warn(f"You're **missing** the `{', '.join(error.missing_permissions)}` permission")
elif isinstance(error, commands.BotMissingPermissions):
await ctx.warn(f"I'm **missing** the `{', '.join(error.missing_permissions)}` permission")
on_command_error handler isn't triggering elif isinstance(error, commands.CommandNotFound): triggers everything else properly tho.
Is your ctx a custom context?
yeah it is
Hey, I've been working on a way to do permissions in a more custom way that allows me to add permissions to sub-commands. I want to be able to do:
class RacoonCommand(commands.Cog):
def __init__(self, client: nextcord.Client):
self.client = client
@register_pizza_command(permission=Rank.MEMBER)
@nextcord.slash_command(
name="racoon",
description="🦝"
)
async def racoon(self, interaction: Interaction):
return
def setup(client: nextcord.Client):
client.add_cog(RacoonCommand(client))
My issue is the @register_pizza_command decorator. I am using nextcord and whenever I load the cog, I get no error however, the command does not load client side. When I add the decorator, the command is no longer visible.
This is my current code for the decorator:
def register_pizza_command(permission: Rank):
def decorator(func):
async def wrapper(self, interaction, *args):
print(interaction)
return wrapper
return decorator
Is anyone able to point me in the right direction with this? I'm not very experienced with decorators as you can probably tell.
depends on error which is raised
how do u mean
the commands.CommandNotFound is raised when command is not found, it it will be raised when command in not found
What
yeah but that's the whole problem, it's not doing that
did you try by running a command which is not present?
I suggest that you should add a else block that raise possible uncatched errors
yeah...?
hmm weird
that is literally the whole problem
it's not triggering on none existing commands
it's not triggering the whole commands.CommandsNotFound
so all i do is an try except
but not even sure if that would work
try this?
you are suppressing errors, add a else block too
how do u expect me to print errors when it's not being triggered.
if it isn't triggered, it's pretty difficult to print errors from it
bro i mean comment your if/else and debug by printing error
Your handler is probably just not catching the error, so just try it
🤷
ye, you are right
wdym?
ah i see. thank you. im using buttons so i think im good on reactions.
that is just part of my error handler, my whole error handler is mad long and i also have a part that it should catch an error and print it, but it isn't printing anything which means there aren't any errors
let me disable logging to see if it does ANYTHING at all
even with logging disabled it doesn't put anything in console
there are various nuances to decorators here that make it difficult to use correctly, but basically the command decorators in discord.py and its forks will turn the function into some Command object which has some incompatibilities with decorators one might typically write, so i would highly recommend using nextcord's check function which handles making it work correctly:
https://docs.nextcord.dev/en/stable/ext/application_checks/index.html#nextcord.ext.application_checks.check ```py
from nextcord.ext import application_checks
def is_me():
def predicate(interaction: Interaction):
return interaction.user.id == 85309593344815104
return application_checks.check(predicate)
@bot.slash_command()
@is_me()
async def only_me(interaction: Interaction):
await interaction.response.send_message('Only you!')```
ok?
that's the entire on_command_error handler. it catches anything atp
I even changed it earlier to made it print any other errors but it doesn't, which means nothing is getting surpressed
That's what happens if you've got a proper bot and you need proper error handling for basically everything
It's organised lol
This is a global error handler bro, I need to do elif isinstance for those or else it won't catch shit
Oh I see, that might be something worth looking into. Let me try that really quickly
just my main file is almost 2k lines already, and i have 10 cog files, which are all files with commands and events
and then i have a whole folder with helpers
wait so CommandNotFound isnt even being logged at the top?
nope
it's not getting triggered anywhere, but everything else after that is getting triggered just fine
had to triple debug to make sure i wasn't tweaking
if you want you can test for urself, just dm me and i'll send you a invite to the cord and i'll let you debug it as much as u want
if the error handler works with other errors, that would suggest the bot didn't actually raise a CommandNotFound error, perhaps from an early return in processing the command
that's what i figured, but then again i can't seem to figure out why
do you have an overridden on_message?
if not ctx.command: is probably why
oml im fucking blind holy shit.
yeah ok that was the problem. jesus christ im fucking blind
Hmm, so I have this so far and it does print interaction but the command itself fails and just returns "The application did not respond"
def register_pizza_command(rank: Rank):
def predicate(interaction: Interaction):
print(interaction)
return application_checks.check(predicate)
@nextcord.slash_command(
name="racoon",
description="🦝"
)
@register_pizza_command(rank=Rank.MEMBER)
async def racoon(self, interaction: Interaction):
await interaction.response.send_message("🦝")
i been overlooking that code for the past 30mins and i missed that the whole time LOL
right, checks need to return True for the command to be allowed to run
oh I see
Im pretty sure you have saved me HOURS. I have asked nextcord support this question and they havent found a solution for 3 days now which is rather questionable. A lot of my friends didnt know either
I LOVE YOU
Can I send a video as part of an embed?
If I have a URL?
!rule 7 | Don't post irrelevant polls or surveys
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
Just gonna drop this cursed piece of art here for you guys 
average discord bot code id say
god i wish
nobody seems to stray off the beaten path
oh boy, youre gonna love this
@commands.group("log")
Creates a log group
who would've guessed
and then the actions lol
oh shit
thats the reason why it doesnt look like discord.py or pycord at all lol
can you show the first method that appears on the pic

