#discord-bots
1 messages Β· Page 156 of 1
yeah 1 hour search google and youtube nothing solution sigh.
sedge
@shrewd fjord oh sorry final last example "delete" error
think is await interaction.response.send_delete?
example maybe.
wdym by delete
await interaction.delete() found maybe is "await interaction.delete()"?
yes..
discord.app_commands.errors.CommandInvokeError: Command 'update-manager-channel-testing' raised an exception: AttributeError: 'NoneType' object has no attribute 'delete'
think is "await interaction.delete()"?
remove successmessage var
await interaction.reponse.send_message(...,delete_after=15)
hmm ok moment think.
delete_after=15 final is?
yes
await interaction.response.send_message("Update Success β " (delete_after=15))
final
maybe?
,instead of ()
await interaction.response.send_message("Update Success β ",delete_after=15)
!d discord.InteractionResponse.send_message
await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False, delete_after=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Responds to this interaction by sending a message.
ahh i see.
@severe mural
@shrewd fjord uhh error
discord.app_commands.errors.CommandInvokeError: Command 'update-manager-channel-testing' raised an exception: InteractionResponded: This interaction has already been responded to before
you can't respond more than once
!d discord.Interaction.followup.send
No documentation found for the requested symbol.
......
Yeah moment...
ok whatever u need to use followup to send another msg
yes
Returns the follow up webhook for follow up interactions.
oh now makes sense aight
@discord.app_commands.checks.has_role("Channels Manager")
async def update_manager_channel(interaction, suggest: discord.TextChannel, giveaway: discord.TextChannel, role: discord.Role):
settingMessage = await interaction.response.send_message("Updating channels....π")
cur.execute("SELECT * FROM x WHERE x = %s",
(str(interaction.guild.id),))
exist_channels = cur.fetchone()
await asyncio.sleep(1)
print(exist_channels)
if not exist_channels == None:
cur.execute("UPDATE x SET x = %s, x = %s, x = %s WHERE x = %s",
(suggest.id, giveaway.id, role.id, interaction.guild.id))
else:
cur.execute("INSERT INTO x (x , x , x , x ) VALUES(%s, %s, %s, %s)", (str(
suggest.id), str(giveaway.id), str(role.id), str(interaction.guild.id)))
con.commit()
#await settingMessage.delete()
settingMessage = await interaction.response.send_message("Update Success β
",delete_after=15)
#await asyncio.sleep(15)
#await successMessage.delete()```
hmmm check.
settingMessage = await interaction.response.send_message("Update Success β
",delete_after=15)
To
await interaction.followup.send("Update Success β
",delete_after=15)
or u can use
await interaction.response.edit_message(content="Update Success β
",delete_after=15)
if this throws up any error use followup
Correct!
and error discord.app_commands.errors.CommandInvokeError: Command 'update-manager-channel-testing' raised an exception: TypeError: send() got an unexpected keyword argument 'delete_after'
Hi. How do I load a cog that contains slash commands in it located in a folder named cogs?
I always get this error:
await self.add_cog(cogs.Slash(self))
NameError: name 'cogs' is not defined
Here's what I tried:
def __init__(self) -> None:
super().__init__(command_prefix=get_prefix, intents=intents, case_insensitive=True, help_command=None)
async def setup_hook(self) -> None:
await self.add_cog(cogs.Slash(self))
self.tree.copy_global_to(guild=discord.Object(id=id))
await self.tree.sync()
follow up?
yes
1 min
try edit_message()
uhmm
sorry think...
settingMessage = await interaction.followup.send("Update Success β ",edit_message())
!d discord.ext.commands.Bot.load_extension - you should use this to load extensions if they're in a different file
await load_extension(name, *, package=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Loads an extension.
An extension is a python module that contains commands, cogs, or listeners.
An extension must have a global function, `setup` defined as the entry point on what to do when the extension is loaded. This entry point must have a single argument, the `bot`.
Changed in version 2.0: This method is now a [coroutine](https://docs.python.org/3/glossary.html#term-coroutine "(in Python v3.11)").
maybe my bad haha
no remember sorry.
.........
is correct??
@severe mural
ahh
but the commands wont register tho
Ok done testing.
What?
!d discord.InteractionResponse.edit_message
await edit_message(*, content=..., embed=..., embeds=..., attachments=..., view=..., allowed_mentions=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Responds to this interaction by editing the original message of a component or modal interaction.
If you loaded it, it will be registered
wait edit_message doesnt have delete_after xddd
OH
a sec lemme try it
damn..
settingMessage = await interaction.response.send_message("Update Success β
",delete_after=15)
To
await interaction.channel.send("Update Success β
",delete_after=15)
error
done
@severe mural π here
heehhe!
oh remove settingMessage ?
correct?
yes
ok
await interaction.channel.send("Update Success β ",delete_after=15)
this has to be work xd
!d discord.Interaction.edit_original_response
await edit_original_response(*, content=..., embeds=..., embed=..., attachments=..., view=..., allowed_mentions=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the original interaction response message.
This is a lower level interface to [`InteractionMessage.edit()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionMessage.edit "discord.InteractionMessage.edit") in case you do not want to fetch the message and save an HTTP request.
This method is also the only way to edit the original message if the message sent was ephemeral.
i see.
moment channel.edit_original_response?
confuse keke
i don't think we can delete it tho
correct
do this
@naive briar sorry is error.
Read
yes already. SAID error
Delete? 

message = await interaction.original_response()
await message.edit(content="blah blah")
await message.delete(delay=15)
now u can do whatever u want
!d discord.Interaction.original_response
await original_response()```
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.
If the interaction response was a newly created message (i.e. through [`InteractionResponse.send_message()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.send_message "discord.InteractionResponse.send_message") or [`InteractionResponse.defer()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionResponse.defer "discord.InteractionResponse.defer"), where `thinking` is `True`) then this returns the message that was sent using that response. Otherwise, this returns the message that triggered the interaction (i.e. through a component).
Repeated calls to this will return a cached value.
ok try
make sure to add something on () xd
oh error hmm
same delete_after"
sigh.
give code
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
~~~~^~~
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
await interaction.original_response("Update Success β
")
await message.edit()
await asyncio.sleep(15)
await message.delete()
probably idea
think error.
u r brilliant
It doesn't take arguments
yeah but error.
Put your things that you want to edit in the edit meth
just copy paste it my guy
Just read maybe
where is code?
@severe mural
edited again check now
Yeah it work thanks a lot
done
nice ig
nope discord.app_commands.errors.CommandInvokeError: Command 'update-manager-channel-testing' raised an exception: TypeError: edit() takes 1 positional argument but 2 were given
content=""
Anyways, spoonfeeding doesn't help anyone
you go sleep, but calm have is okay
edited again check
spooky good.
;-;
No problem you brilliant.
done
nice
done exist!
but he said the right thing
i see "content="..."
You wouldn't learn to solve your own problems by copy pasting
u gotta understand ur self
yeah okay ya done
thanks. no prooblem. check investigate idea and learn.
you rest spooky nd catgal.
always check the docs related to ur problem
okay.
;-;
!d discord.Interaction.user
The user or member that sent the interaction.
ctx.author.id return's prefix command's executor's id
and interaction.user.id returns slash or button or interaction executor's id
ahh
ok!
AttributeError: 'Member' object has no attribute 'avatar_url'
hmmm there is "text=f"BY: {interaction.user} - ID: {interaction.user.id}", icon_url=interaction.user.avatar_url)"

"async def suggestion(interaction, message: str):"
!d discord.User.avatar
property avatar```
Returns an [`Asset`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Asset "discord.Asset") for the avatar the user has.
If the user does not have a traditional avatar, `None` is returned. If you want the avatar that a user has displayed, consider [`display_avatar`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.display_avatar "discord.User.display_avatar").
!d discord.Asset.url
property url```
Returns the underlying URL of the asset.
@naive briar look think is okay?
yep it's ok
i see.
yes have is okay icon_url=interaction.user.avatar_url
is correct but error confuse.
interaction.user.avatar
avatar_url is before v2.0
it has changed to avatar now
The avatar_url was removed
ok thx
await message2.delete(delay=30)
AttributeError: 'NoneType' object has no attribute 'delete'
do not understand but my alredy same before
hmmm!
catglal u tell ;-;
response.send_message doesn't return the sent message
use original_response()
hh
to delete it
ahh i see not response, important "original"?
ahh i see.
@shrewd fjord @naive briar think example first: response.send_message later other all any original_response()
is correct?
first send message with inteaction
then catch the message ussing original_response()
then delete it
yeah kind of like that
π
first send the message
await interaction.response.send_message("your message")
then catch it with message2 variable
like earlier time
message2=interaction.original_response()
kind of like that
;-;
werid hmm
look there is other: message = await suggest_channel.send(embed=imgembed)
"suggest_channel = await client.fetch_channel(str(exist_channels[1]))"
hm?
use get_channel
and then convert exist_channels to int
Nop. is okay
just telling xd
think laast there is problem message2
what have u done in ur new code?
@bot.event
async def on_ready():
print(f"{bot.user.name} is online!")
setattr(bot, "db", await aiosqlite.connect("main.db"))
async with bot.db.cursor() as cursor:
await cursor.execute("CREATE TABLE IF NOT EXISTS bank (wallet INTEGER, bank INTEGER, maxbank INTEGER, user INTEGER)")
async def create_balance(user):
async with bot.db.cursor() as cursor:
await cursor.execute("INSERT INTO bank VALUES (?, ?, ?, ?)", (0, 100, 2736652635562362, user.id,))
await bot.db.commit()
return
async def get_balance(user):
async with bot.db.cursor() as cursor:
await cursor.execute("SELECT wallet, bank, maxbank FROM bank WHERE user = ?", (user.id,))
data = await cursor.fetchone()
if data is None:
await create_balance(user)
return 0, 100, 2736652635562362
wallet, bank, maxbank = data[0], data[1], data[2]
return wallet, bank, maxbank
async def update_wallet(user, amount: int):
async with bot.db.cursor() as cursor:
await cursor.execute("SELECT wallet FROM bank WHERE user = ?", (user.id,))
data = await cursor.fetchone()
if data is None:
await create_balance(user)
return 0
await cursor.execute("UPDATE bank SET wallet = ? WHERE user = ?", (data[0] + amount, user.id,))
await bot.db.commit()
@bot.command(aliases=['bal'])
async def balance(ctx, member: nextcord.Member = None):
if not member:
member = ctx.author
wallet, bank, maxbank = await get_balance(member)
em = nextcord.Embed(title=f"{member.name}#{member.discriminator}'s Balance")
em.add_field(name="Wallet", value=wallet)
em.add_field(name="Bank", value=f"{bank}/{maxbank}")
await ctx.send(embed=em)
error:
read error
i did but there is
await cursor.execute("CREATE TABLE IF NOT EXISTS bank (wallet INTEGER, bank INTEGER, maxbank INTEGER, user INTEGER)")
u sure?
uhhh when u ask that so not rlly '
oh okay
ok moment.
await message.delete(delay=30)
await message.add_reaction("β
")
await message.add_reaction("β")
is_cancelleds = False
message2 = await interaction.original_response(f"{interaction.user.mention}, your suggestion has been successfully submitted! Check <#{exist_channels[1]}>")
if is_cancelleds == True:
return
await message2.delete(delay=30)```
i told u what to do
@severe mural
same but do not understand
hmhm think confuse sigh.
yes there andd no cant full code but is privacy.
have tthink steal code 
await interaction.response.send_message(f"{interaction.user.mention}, your suggestion has been successfully submitted! Check <#{exist_channels[1]}>")
message2=await interaction.original_response()
see not that hard
ye
;-; c ya
n.n
Hi Guys I am currently working on a Discord bot that is communicating with an AI.
After running main.py I am getting redirected in an inkognito browser but always receive an error:
E:\XXX\DiscordBot\XXX>python3 main.py
Traceback (most recent call last):
File "E:\XXX\DiscordBot\XXX\main.py", line 1, in <module>
from src import bot
File "E:\XXX\DiscordBot\XXX\src\bot.py", line 3, in <module>
from src import responses
File "E:\XXX\DiscordBot\XXX\src\responses.py", line 32, in <module>
chatbot = Chatbot(config, conversation_id=None)
File "C:\Users\XXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\revChatGPT\revChatGPT.py", line 112, in init
self.refresh_session()
File "C:\Users\XXX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\revChatGPT\revChatGPT.py", line 358, in refresh_session
raise ValueError(
ValueError: No session_token, email and password or Authorization provided
could someone assist me with that? π
code?
No session_token, email and password or Authorization provided
provide this informations
can anyone help me make database for a bot
π
config.json
{
"discord_bot_token":"XXX",
"session_token": ""
}
and store image on it
btw my new id
bro i cant find any ppl so i came here
ye np
what happened to the old one
?
So for datetime , when doing <t:ββββ> or what ever it is, I put the datetime as utc
So in utc is says in 5 minutes but for me (est) it would say like in 5 hours
Any way to just make it say itβs in 5 minutes for any time zone?
And I have another question, my embed formatting is perfect on computer but it is screwed up on mobile
Try in UTC
The datetime is utc and the bot is hosted in a utc server
Yes
!d discord.utils.utcnow
discord.utils.utcnow()```
A helper function to return an aware UTC datetime representing the current time.
This should be preferred to [`datetime.datetime.utcnow()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow "(in Python v3.11)") since it is an aware datetime, compared to the naive datetime in the standard library.
New in version 2.0.
Try that
Well I canβt use that because I set the datetime value or the user sets it

So like the bot takes date and time and converts that
The timing is correct for utc just the datetime for others like etc is kinda wrong
!d datetime.datetime.astimezone
datetime.astimezone(tz=None)```
Return a [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") object with new [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.datetime.tzinfo "datetime.datetime.tzinfo") attribute *tz*, adjusting the date and time data so the result is the same UTC time as *self*, but in *tz*βs local time.
If provided, *tz* must be an instance of a [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo "datetime.tzinfo") subclass, and its [`utcoffset()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcoffset "datetime.datetime.utcoffset") and [`dst()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.dst "datetime.datetime.dst") methods must not return `None`. If *self* is naive, it is presumed to represent time in the system timezone.
If called without arguments (or with `tz=None`) the system local timezone is assumed for the target timezone. The `.tzinfo` attribute of the converted datetime instance will be set to an instance of [`timezone`](https://docs.python.org/3/library/datetime.html#datetime.timezone "datetime.timezone") with the zone name and offset obtained from the OS.
So if letβs say the datetime for utc is 16726263663 (not real)
Lets say thatβs in 8 minutes for utc
If I use that , will it say in 8 minutes for est?
You wouldn't know without experimenting
Alright I will try it out. If it does work, Iβll let you know. Thanks for the help
The UTC timezone, timezone(timedelta(0)).
Reasons I never made a video is because it's just too much of an effort π and I'm ass lazy
a gist is easier to make π
b64
?
message1
message2
how can get the info of message that replied message1
or the info of message that message2 replied to
!d discord.ext.commands.Bot.wait_for
wait_for(event, /, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.11)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.11)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.11)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
third times the charm
basically bot.wait_for('message', check=?) will wait for the user presumably the author which you add to a check, to send a message which you can take in through something like
msg2 = bot.wait_for...
then ms2.content would be the user response
Do you have a ready main file?
tysm
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='')
@bot.event
async def on_message(message):
if message.content.lower() == "bigger":
await message.channel.send("Please don't say that")
bot.run('token')
Why is this simple code not working at all?
you haven't enabled message content intents
!intents
Using intents in discord.py
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.
Why did they make it more complicated than it used to be?
who is "they"
Whoever makes this
lol
what is "this"
Didn't the stuff i wrote used to work?
are you referring to discord.py or the discord api
Not sure
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
if you're referring to intents - it's because there's no point in having your bot request a bunch of data that it doesn't need as it just unnecessarily eats up resources. It's much better to only request the data you need for the bot to operate, which is done through intents.
intents = discord.Intents.default()
intents.messages = True
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_message(message):
# only respond to messages that are not from the bot itself
if message.author == bot.user:
return
if message.content.lower() == "bigger":
await message.channel.send("Please don't say that")
Its still wrong?
I think you might be after message_content, not messages
intents.message_content = True
AttributeError: 'Intents' object has no attribute 'message_content'
update discord.py; py -m pip install -U discord.py
Man i messed my entire python up trying to install stable diffusion
Its all out of order now and outdated
It works now. Thanks
##Button###
class Button(discord.ui.View):
@discord.ui.button(label="βΆοΈ", style=discord.ButtonStyle.green)
async def resume_button(self, button, interaction: discord.Interaction):
global is_playing
bot.voice_clients[0].resume()
is_playing = True
@discord.ui.button(label="π", style=discord.ButtonStyle.red)
async def pause_button(self, button, interaction: discord.Interaction):
global is_playing
bot.voice_clients[0].pause()
is_playing = False
@discord.ui.button(label="βοΈ", style=discord.ButtonStyle.blurple)
async def skip_button(self, button, interaction: discord.Interaction):
global queue
if bot.voice_clients[0].is_playing():
if len(queue) > 1:
bot.voice_clients[0].stop()
try:
await music()
except:
pass
if bot.voice_clients[0].is_paused():
if len(queue) > 1:
bot.voice_clients[0].stop()
del queue[0]
try:
await music()
except:
pass```
when i press the btn, it says interaction failed but it works
you aren't responding to the interaction
is there something wrong with this command?
use a method of interaction.response
import discord
from discord.ext import commands
from discord import app_commands
class TicTacToeButtons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@discord.ui.button(label="", style=discord.ButtonStyle.gray, emoji='<1052937074015211610>')
async def my_button(self, interaction:discord.Interaction, button:discord.ui.Button):
await interaction.response.send_message(content=f"You clicked me!!")
class TicTacToe(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print('TicTacToe.py is ready!')
@app_commands.command(name='tic-tac-toe', description='Play Tic-Tac-Toe Game!')
async def click(self, interaction: discord.Interaction):
await interaction.response.send_message('Message with a Button', view=TicTacToeButtons())
async def setup(bot: commands.Bot):
await bot.add_cog(TicTacToe(bot))```
!d discord.InteractionResponse
class discord.InteractionResponse```
Represents a Discord interaction response.
This type can be accessed through [`Interaction.response`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction.response "discord.Interaction.response").
New in version 2.0.
?
?
the application doesn't respond
Did you get any exceptions
This isn't valid format
And consider setting up logging if you don't have one or not running by bot.run
is running
in the main.py
discord.InteractionResponse.is_done()
so, what's a valid format?
like this sir?
i don't understand the formats in the docs
name = emoji name
id = emoji id
or you can use (windows key + .) windows emojis
so <:emoji_name:emojiid>
Oh yeah
i understand now dude
thanks you
and you
i'm on windows 7

π
lol
No, that was genuine
Ah
I getting this error now
but i think if i what can it be
Your command is being updated, try a bit later
can we have a custom event for a discord bot?
what im trying to do is make a user pay on my website and then according to the amount paid; give them a role in my server
ya i already solved it
i getting the same error now
"The application did not respond"
That's webhook/API/ws, not an event
i want to add the role when the payment becomes success
What happened to help-cherries or any help- for that matter?
My command
I typically embed API into bot
import discord
from discord.ext import commands
from discord import app_commands
class TicTacToeButtons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@discord.ui.button(label="", style=discord.ButtonStyle.gray, emoji=':heavy_minus_sign:')
async def my_button(self, interaction:discord.Interaction, button:discord.ui.Button):
await interaction.response.send_message(content=f"You clicked me!!")
class TicTacToe(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print('TicTacToe.py is ready!')
@app_commands.command(name='tic-tac-toe', description='Play Tic-Tac-Toe Game!')
async def click(self, interaction: discord.Interaction):
await interaction.response.send_message('Message with a Button', view=TicTacToeButtons())
async def setup(bot: commands.Bot):
await bot.add_cog(TicTacToe(bot))```
can webhooks add roles for users?
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
~~~~^~~
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
Well you can listen for messages from webhook
And then add roles
Although that's kinda bad for security
umm yea
me?
So better to embed API
i don't getting error in terminal
?
.
.
If this error occurs after command usage, this is not the code we need
Nvm
That's just everything in one place I failed to notice
what code do you need then?
main?
You confused arguments order in button callback I believe
verified = ":verified:"
await interaction.response.send_message(f"{verified}Successfully Verified You{verified}", ephemeral=True)
Anyone know why it looks like this?
The button goes first
The emoji is animated
verified = "<:verified: 1050462690700689409>"
looks like this without the space
discord just converted it automatically
You need to bot.get_emoji
bot.get_emoji(id) ?
Yeah
Alright thanks
what's the correct form?
How would I do if len(role.members) > then a variable with a number: do something, when I do that code it doesnβt do anything
Button then interaction
Actually might be different in dpy I am unsure
!d discord.ui.Button.callback
what are you trying to do?
!d discord.ui.button
@discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.
The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View "discord.ui.View"), the [`discord.Interaction`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction "discord.Interaction") you receive and the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button "discord.ui.Button") being pressed.
Note
Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
π§
Trying to put a limit to role
Like an amount of people that can be in it
And if itβs bigger then the limit
Then itβll do something
arguments order?
does role.members actually do that?
Do what
It tells you how many people are in the role
Yeah I am disnake user, there are some small differences between those libs (not really small)
Is emoji intent on
don't have an arguments order
theres an emoji intent?
It's included in defaults
!d discord.Intents.emojis
Alias of emojis_and_stickers.
Changed in version 2.0: Changed to an alias.
intents=discord.Intents(messages = True, guilds = True)
intents.members = True
the way i did it is correct
and you cant
if len(role.members) < 2:
add role
elif len(role.members) > 2:
print('too many people have this role')```
I forgot why I did it like this
@vale wing
@discord.ui.button(style=discord.ButtonStyle.gray, emoji=':heavy_minus_sign:')
async def my_button(self, interaction:discord.Interaction, button:discord.ui.Button):
await interaction.response.send_message(content=f"You clicked me!!")
You either need to list every intent or do this
intents = discord.Intents.default()
intents.members = True```
the messages and guilds intent need to be defined no?
wait nevermind thats message content
!intents
Using intents in discord.py
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.
This is what I have rn, it doesnβt work
if len(role.members) > RC: await ctx.send("Role has too many members")
I still have the same issue while using that
Let's see what we have π
what is RC?
^ RC = 2
where is this? a command or event?
Show your code again please
I put RC = (β2β) at the top of my code where this is no commands, and the code itself is in a command
can you show the whole cmd?
RC should be RC = 2
Man it should be int
an int, not a str
Ohhh
verified = bot.get_emoji(1050462690700689409)
await interaction.response.send_message(f"{verified}Successfully Verified You{verified}", ephemeral=True)
still getting this
Where is this code at
just show all the code
Like when do you define verified
You can't
before any commands
Can't get emoji before bot is ready and got cache
x) , get the emoji at the top of the command
I wouldn't consider it a good idea
alr
still broken
I put it at the top of the command
@tree.command(name = "verify", description = "Verification command", guild = discord.Object(id = bot.guild_id))
async def verify(interaction: discord.Interaction):
verified = bot.get_emoji(1050462690700689409)
user = interaction.user
age = discord.utils.utcnow() - user.created_at
if age.days > 14:
role = interaction.guild.get_role(bot.verified_role)
await user.add_roles(role)
await interaction.response.send_message(f"{verified}Successfully Verified You{verified}", ephemeral=True)
channel = interaction.guild.get_channel(bot.welcome_channel)
ping = await channel.send(user.mention)
time.sleep(5)
await ping.delete()
else:
await interaction.response.send_message("Sorry Your Account Age Is Too Low To Be Verified", ephemeral=True)
Could you like share the whole command and new intents definition
class aclient(discord.Client):
def __init__(self):
intents = discord.Intents.default()
intents.members = True
super().__init__(intents=intents)
async def on_ready(self):
print(f"We have logged in as {self.user}.")
Mk seems legit
maybe i need to sync
But what kind of tutorial uses those naming conventions
tutorial?
Command's behaviour isn't affected by syncing
aclient bad class naming convention
Should be UpperCamel
Articles are rarely included
oh
MyClient better
technically it doesnt matter but its bad practice
ok
but back to the code, still confused on why it doesn't work considering I also get no errors
You either use wrong class for bot or the ID is in correct
checked both
why are you using get_emoji instead of <:name:id> ? did i miss that
i got this when I did that
but I also had emoji intents disabled then
how did you have it?
maybe If I revert back it might work
@winged linden for animated emojis it's <a:name:id> but weird that get_emoji doesn't work
yeah no it still doesnt work using the string
@slash.slash(description='Sign a player.')
async def sign(ctx, user: discord.Member):
FORole = discord.utils.get(ctx.guild.roles, name="Franchise Owner")
GMRole = discord.utils.get(ctx.guild.roles, name="General Manager")
HCRole = discord.utils.get(ctx.guild.roles, name="Head Coach")
Eligible = discord.utils.get(ctx.guild.roles, name="Eligible")
channel = bot.get_channel(Transactions)
teams = discord.utils.find(lambda r: r.name in nflRoleListNames, ctx.author.roles)
signembed = discord.Embed(title='Franchise Signing', description =f'{teams.mention} have **signed** {user.mention}`{user}`\n\n > **Coach:** {ctx.author.mention}`{ctx.author}`\n> **Roster:** {len(teams.members)}/{RC}',timestamp = datetime.datetime.utcnow())
signembed.set_footer(icon_url = ctx.author.avatar_url, text='{}'.format(ctx.author))
signembed.set_author(name=f"{ctx.guild.name} Transactions", icon_url=f"{ctx.guild.icon_url}")
if any(role in [FORole, GMRole, HCRole] for role in ctx.author.roles):
if any(role.name in nflRoleListNames for role in ctx.author.roles):
await user.add_roles(teams)
await ctx.send(f"Signed {user.mention}", hidden=True)
msg = channel.send(embed=signembed)
if len(teams.members) > RC:
await ctx.send(f"You have the maximum amount of players on your team.")
await channel.msg.delete()
await user.remove_roles(teams)```
Why doesnβt the team role remove?
how you read this is astonishing
fr
it shouldnt remove because it doesnt get added?
because len(teams.members) is not greater than RC ?
that and i cant see RC defined anywhere
yeah
presuming its still 2, you just...
I beg of you to add space between your lines
yeah haha lemme clean this real quick
but yeah i dont see RC being defined so thats probably the issue
Because itβs defined at the top of the code
Itβs still detecting thatβs itβs over the limit itβs just not removing the rope
Role
is the amount greater than rc
If itβs over the limit it shouldnβt give the person the role it should remove it but it isnβt
you should run the check prior to adding the role
The rc is 1 and the amount on the role is 2
check if the team is full before adding user to the team
It says itβs over the limit but it still adds the role
if len(teams.members) >= RC:
await ctx.send(f'{ctx.author.mention} You have reached the roster cap of {RC} players.')
return
else:
if any(role in [FORole, GMRole, HCRole] for role in ctx.author.roles):
if any(role.name in nflRoleListNames for role in ctx.author.roles):
await user.add_roles(teams)
await ctx.send(f"Signed {user.mention}", hidden=True)
msg = channel.send(embed=signembed)
oh god discord formatting why
but something similar to this
if the team is max, do nothing, otherwise add the user to the team
no reason in adding the user to the team if youll take them off 2 seconds later
If I donβt put remove itβll still add the role
wdym?
if you are checking prior if the team is full then adding the role should never execute
if you add them then check if the team is full you are just creating more work on yourself
yo guys does anyone know how to purge msgs
!d discord.Text_channel.purge
No documentation found for the requested symbol.
someone explained to u yesterday
!d discord.TextChannel.purge
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=None, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") to delete messages even if they are your own. Having [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") is also needed to retrieve message history.
Changed in version 2.0: The `reason` keyword-only parameter was added.
Examples
Deleting botβs messages...
ik but what he/she explained didnt work
show ur command
show your code
no i have gotten help
π
ty tho
guys if anyone knows blox flip or rblx wild dm me.
Is it related to Discord bots?
o/ we can help even if itβs just api related
Yeah
I need to make the mines predictor better
send what you have, i remember asking you about this and you couldnt really provide me with your method of "predicting"
my timeout command timeouted 1h longer than it should
i wasn't home, it worked thanks, but once more question
@slash.slash(description='Sign a player.')
async def sign(ctx, user: discord.Member):
FORole = discord.utils.get(ctx.guild.roles, name="Franchise Owner")
GMRole = discord.utils.get(ctx.guild.roles, name="General Manager")
HCRole = discord.utils.get(ctx.guild.roles, name="Head Coach")
Eligible = discord.utils.get(ctx.guild.roles, name="Eligible")
channel = bot.get_channel(Transactions)
teams = discord.utils.find(lambda r: r.name in nflRoleListNames, ctx.author.roles)
signembed = discord.Embed(title='Franchise Signing', description =f'{teams.mention} have **signed** {user.mention}`{user}`\n\n > **Coach:** {ctx.author.mention}`{ctx.author}`\n> **Roster:** {len(teams.members)}/{RC}',timestamp = datetime.datetime.utcnow())
signembed.set_footer(icon_url = ctx.author.avatar_url, text='{}'.format(ctx.author))
signembed.set_author(name=f"{ctx.guild.name} Transactions", icon_url=f"{ctx.guild.icon_url}")
if len(teams.members) >= RC:
await ctx.send(f'You have reached the roster cap of {RC} players.', hidden=True)
if Eligible not in user.roles:
await ctx.send("You cannot sign this player, he is not eligible", hidden=True)
if teams in user.roles:
await ctx.send(f"This user is already signed to the {teams.mention}", hidden=True)
return
else:
if any(role in [FORole, GMRole, HCRole] for role in ctx.author.roles):
if any(role.name in nflRoleListNames for role in ctx.author.roles):
await user.add_roles(teams)
await ctx.send(f"Signed {user.mention}", hidden=True)
await channel.send(embed=signembed)```
in the part
`if teams in user.roles:
await ctx.send(f"This user is already signed to the {teams.mention}", hidden=True)`
it only sends the message when he is on your team, how would i make it where it would say it when the user is on any team? Hard to explain
it does that because teams is looking for the teama the author is holding
so how would i make it where it just looks for the teams in generaal
not sure i fully get what you mean
you want to check all teams even if the user doesnt have them?
or you want it to say "the user is already signed to {the users team}"
so pretty much, right now when i run it, if someone else tries to sign him even if hes on a differeent team it'll go through
it only sends the message when the owner of the team hes on tries it
so im trying to make it where the bot says that message when someone tries to sign him when hes already on a team
so you want to make it send that message when someone else tries to add him?
instead of the owner of the team he is currently on
if hes on a team alrrady
yes
yes if hes on a team alreaady send a message and dont give the role
so you can check if he has any of the team roles (presumably through a list) and if one does exist then just send the message
(else: add him)
wait
if teams in user.roles:
await ctx.send(f"This user is already signed to the {teams.mention}", hidden=True)
return```
wouldnt this do that?
i already have that
yeah thats what im saying
it only tells that to the owner
like
it only sends the message if the owner of the team that user is on uses it
if someone else that isnt the owner of the team hes on it'll sign them
ahh i see
teams = discord.utils.find(lambda r: r.name in nflRoleListNames, ctx.author.roles)``` its because you are checking the roles of the message author
so you essentially need to do this but without checking the author
if the user they are mentioning have any of the roles in x (i think nflRoleListNames) then send the message
so just remove ctx.author.roles?
probably make another one for the users roles, and one with the authors role
seeing as you use this to add roles to the user
yea ik i will
teams2 = discord.utils.find(lambda r: r.name in nflRoleListNames)
so like something likee that?
might want to name better x) but sure
wym
yea this didnt work, File "main.py", line 118, in sign teams2 = discord.utils.find(lambda r: r.name in nflRoleListNames) TypeError: find() missing 1 required positional argument: 'seq
well you still want to check the roles of the user
just the user they are trying to sign not the author running sign command
so how would i do that then
well
in py teams = discord.utils.find(lambda r: r.name in nflRoleListNames, ctx.author.roles) you are checking the author
so now, you need to check the user instead
so ctx.user.roles?
so something like
teams2 = discord.utils.find(lambda r: r.name in nflRoleListNames, user.roles)```
async def sign(ctx, user: discord.Member):```
because you are getting the user here
lol that just did the same thing it did befor for some reason
whats the full error?
it only says that if the owner of the team hes on runs it
no error it just doees that
ohhh
nvm im dumb
i didnt change the if teams in user.roles
π
wth, now the eligible part doesn;t work lol
how come when i put that code eligible stopped working
it stopped working?
yes lol
show updated code
@slash.slash(description='Sign a player.')
async def sign(ctx, user: discord.Member):
FORole = discord.utils.get(ctx.guild.roles, name="Franchise Owner")
GMRole = discord.utils.get(ctx.guild.roles, name="General Manager")
HCRole = discord.utils.get(ctx.guild.roles, name="Head Coach")
Eligible = discord.utils.get(ctx.guild.roles, name="Eligible")
channel = bot.get_channel(Transactions)
teams = discord.utils.find(lambda r: r.name in nflRoleListNames, ctx.author.roles)
teams2 = discord.utils.find(lambda r: r.name in nflRoleListNames, user.roles)
signembed = discord.Embed(title='Franchise Signing', description =f'{teams.mention} have **signed** {user.mention}`{user}`\n\n > **Coach:** {ctx.author.mention}`{ctx.author}`\n> **Roster:** {len(teams.members)}/{RC}',timestamp = datetime.datetime.utcnow())
signembed.set_footer(icon_url = ctx.author.avatar_url, text='{}'.format(ctx.author))
signembed.set_author(name=f"{ctx.guild.name} Transactions", icon_url=f"{ctx.guild.icon_url}")
if len(teams.members) >= RC:
await ctx.send(f'You have reached the roster cap of {RC} players.',hidden=True)
if teams2 in user.roles:
await ctx.send(f"This user is already signed to the {teams2.mention}",hidden=True)
if Eligible not in user.roles:
await ctx.send("You cannot sign this player, he is not eligible", hidden=True)
return
else:
if any(role in [FORole, GMRole, HCRole] for role in ctx.author.roles):
if any(role.name in nflRoleListNames for role in ctx.author.roles):
await user.add_roles(teams)
await ctx.send(f"Signed {user.mention}", hidden=True)
await channel.send(embed=signembed)```
you see eligiblee?
that stopped working
wdym by stopped working
does it send the message?

i tried moving the 2 commnds
for some reason the 1st command thats there doesnt work
like in that code that i sent teams 2 didnt work
but if i put eligible first
then eligible doesnt work
thene teams2 does
confusing
add return to bottom of teams2 if
it might be because teams2 is in the role but eligible also isnt
so its firing both of them
py is going through the if statements from top to bottom, if it doesnt have return at the bottom itll simply check the next if
return stops it from running through the if statements
i mean you realistically could add it to all 3 seeing as once one of them is true everything should stop
np
async def dm(ctx, user:discord.Member):
i just came back to edit my code after a long break
what is stored in 'user'?
i want my bot to DM me when a certain member is pinged, so i need to use myself instead of user
hello someone can help me?
ok i have found get_member but it keeps giving None
how do you format different timestamps on discord
eh got it
can you not put a timestamp in an embed footer?
async def on_message(message):
if "poo" in message.content:
S = await message.guild.fetch_member(675798876858482731)
C = await message.guild.fetch_member(687722271225151494)
print(C, S)
STEEL_DM = await S.create_dm()
await STEEL_DM.send(message.author + " pinged C in" + message.channel+ " just now!")```
how do i peacefully get a member π
Where can i host multiple bots for free/cheap price?
!d discord.Embed - see the timestamp kwarg in the constructor
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.
x == y Checks if two embeds are equal.
New in version 2.0...
don't fetch, use get and make sure you've got the correct intents enabled
ok i have used get and i enabled the privileges, now i get this
remember getch?
I dont think bot.listen works lime that
dont you have to specify your event
bot.listen("message")
or just use @bot.event
doesnt async def on_message specify it
nah
or acutally
nvm ur right
discord.py makes stuff so easy
ok
do u think u can help me with this
property display_name```
Returns the userβs display name.
For regular users this is just their username, but if they have a guild specific nickname then that is returned instead.
property name```
Equivalent to [`User.name`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.name "discord.User.name")
leme just send full
async def on_message(message):
if "ok" in message.content:
S = message.guild.get_member(675798876858482731)
C = message.guild.get_member(687722271225151494)
print(type(C), S)
STEEL_DM = await S.create_dm()
await STEEL_DM.send(message.author + " pinged C in" + message.channel+ " just now!")```
property mention```
Returns a string that allows you to mention the member.
instead of what
message.author
it is lmao
i tested it by changing the message to just "hi" and it gave same error
u just gotta share a guild
nvm ur right
ty
np
wait
yup
i shared guild but same error
lmao
use f strings instead of concatenation
^
ok
im not doubting u but can u explain why
its just so i know how my own code works
f strings automatically make whatever object "string compatible"
i dont like having parts of my code where i dont understand why im usin it
ok thx
plus it just looks a lot better than string concatenation, and it's probably more readable
hi
Hi, im making a discord bot with pycord but im running into a weird issue. For some reason the commands do not show and work for all users, its just work to users that have administration perms. Do anyone run into that issue? I can't find the proble
Can you send a code sample?
i was going to say sync but then the admin thing threw me for a loop 
@bot.slash_command(name="status", description="Use this command to verify if your VIP role is registred")
async def status(ctx):
println(ctx.author.name)
await ctx.respond(embed=Responses.place_holder())
oh, it's probably the server integration restricting who can use the slash commands
I check and everything seems to be fine. Do you know what perms i should look?
I did a check and there are a few different perms. But i don't know if they are related to slash commands
How do I make a custom error handler for app commands?
try and catch
or if you want throw new error you can probably do it, and it will be like a normal error
That's not why I need it
I have an app command producing an error and the error gets eaten
!d discord.ui.button
@discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.
The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View "discord.ui.View"), the [`discord.Interaction`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction "discord.Interaction") you receive and the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button "discord.ui.Button") being pressed.
Note
Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
You can assign a new emoji to button.emoji at any time and the new emoji will display when you next update the view.
e.g self.next_page.emoji = ''
Thank you
display_name returns a member's guild-specific nickname, name is just their username
its doesn't work
Oh
Thank you
(Opps sorry for the ping)
Show what you tried then, and any errors you get
lol no worries
π
how would I make a command where i can set channels? Example: /setchannel (channel id) and then I can use the channel for like application commands and stuff
hello i am in need of help. im trying to code a bot for discord but I cannot figure out how to make a /set channel command and /set role command. if someone could help that would be amazing.
for 1 server or for each server?
for multiple
@bot.slash_command(description= "Set Franchise Owner role")
async def foroleset(interaction):
await interaction.send('Successfully set Franchise Owner role', ephemeral=True)```
library?
!pip aiosqlite
i use nextcord
you can use aiosqlite for this simple use
okay
He's talking about database
oh
db = database
so wdym by database
English 100
we need to store theses ids in db
go read how aiosqlite works!
here
okay
i never use asqlite but i will
or which one do u recommend
so go for the aiosqlite for now
so i do pip install aiosqlite
asqlite is from Danny (the developer of discord.py lib)
ok
yes
go read and do some tests how works
how to create your first db file, create tables etc...
you can find everything here!
https://pypi.org/project/aiosqlite/
okay i somewhat understand it now
so ready to answer some questions about this lib?
before we continue
possibly
ok
async with aiosqlite.connect(...) as db:
await db.execute("INSERT INTO some_table ...")
await db.commit()
async with db.execute("SELECT * FROM some_table") as cursor:
async for row in cursor:```
is this how you create it?
so
Your IDE is probably high if there's none
you will need a async function
like
import asyncio
async def main():
async with aiosqlite.........
asyncio.run(main())
ok
but!
you can use this in your on_ready event!
@bot.event
async def on_ready():
async with aiosqlite.connect('database.db') as db:
so lets learn step by step what we are doing
ok
ok
Rule 8
Help people learn how to do the assignment without doing it for them.
understandable
@bot.event
async def on_ready():
async with aiosqlite.connect('database.db') as db:
pass
this will create your database file (if not exist)
okay so i got an error
about the path?
import aiosqlite π
i did
you install it?
wait
run the code (vsc need restart after installing module)
run
no errors
no
in your disk maybe?
can we create a new bot?
yea
remove everything from your bot, lets create it from the start.
keep only the bot = commands.Bot
and bot.run
good
@bot.event
async def on_ready():
async with aiosqlite.connect('database.db') as db:
pass
this will create your database file (if not exist)
it made the file
now install the "Sqlite Viewer" in vsc extensions
for can view the db file (good for tests atm)
installed
no i do not
can i make a command in my code run another command as part of it? like if i have async def question which is its own command, could i create a command which calls that command, then starts a 24h loop and runs it once every 24h
go read it and comeback!
The command has to be a hybrid command or message command.
!d discord.ext.commands.Bot.get_context then get the context
await get_context(origin, /, *, cls=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Returns the invocation context from the message or interaction.
This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.
The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
Note
In order for the custom context to be used inside an interaction-based context (such as [`HybridCommand`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.HybridCommand "discord.ext.commands.HybridCommand")) then this method must be overridden to return that class...
ah so it cant be done with a slash command itd have to by hybrid at least
okay so the table is made to store the data of all the ids people put in there and the other commands they use can be stored in there
i never tried :/
i did and it just printed the command object as text lol
<discord.app_commands.commands.Command object at 0x7fa753849b20>
great
lets create our first table!
okay
take a fast look of how to create a table
No documentation found for the requested symbol.
async with aiosqlite.connect(...) as db:
await db.execute("INSERT INTO some_table ...")
await db.commit()
async with db.execute("SELECT * FROM some_table") as cursor:
async for row in cursor:
...``` this is the code i said earlier
invoked_with?
await ctx.invoke(bot.get_command("help"))
that will run your
async def help command
huh, alright thanks
yea ill play with that lol
are you looking for the slash help command or prefix one lol?
no
take a better look!
this is the signature of an app command
in which section
this is how you run a prefix command
thats not at all it. trying to trigger an app command from another command
this is simple sqlite3! google it "how to create a sqlite table" !
CREATE TABLE [IF NOT EXISTS] [schema_name].table_name (
column_1 data_type PRIMARY KEY,
column_2 data_type NOT NULL,
column_3 data_type DEFAULT 0,
table_constraints
) [WITHOUT ROWID];```
@bot.event
async def on_ready():
async with aiosqlite.connect('database.db') as db:
await db.execute("""
CREATE TABLE IF NOT EXISTS ids(
test TEXT
)
""")
what you think that will do?
it will connect to database and create a table within the folder
i have no clue
run it!
also i might have to go to bed like very soon since i have school tmrw
we can continue tomorrow!
it did not do anything
yea because we must commit our action to db
oh
show me the code please
move commit one tab right
same line with execute
and remove the first on_ready event!
You have w on_ready event
on_ready event can't be 2
Use setup_hook instead
w on ready event πΏ
one by one step please ;P its new!
and dont show bot token!
delete the image and reset token
Setup_hook is the same as on_ready, on_ready can be triggered multiple time on bot's lifespan while setup_hook triggers while bot starts
@bright wedge im going to have to go now. im going to go to bed. i will continue this tmrw. i have spare second period so i can do it then.
thank you for helping me so far
ofc, we are always here to help!
i will dm you tmrw when im ready
also accept my friend request so i can reach out to you more often
O.o
good night sir!
do you still use ctx in a hybrid command
Yes
good night
im trying to invoke a hybrid command from another command, when i try i get a TypeError: argument of type 'HybridCommand' is not iterable my command doesnt ask for any arguments though
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
~~~~^~~
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
easier said than done, cant copy/paste from my vm
Then it's a weird terminal
Eh, just screenshot the traceback or something
You can setup logging that logs the exception to a file later
yea its super annoying. one sec
its telling me the error is in the on_ready, but all im doing there is starting a loop, which i want to run the hybrid command then wait 24 hours
get_command(name, /)```
Get a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list of commands.
This could also be used as a way to get aliases.
The name could be fully qualified (e.g. `'foo bar'`) will get the subcommand `bar` of the group command `foo`. If a subcommand is not found then `None` is returned just as usual.
Changed in version 2.0: `name` parameter is now positional-only.

oh it needs to be a string not the command
hybrid command doesnt exist for some reason
doesnt have to be synced right?
for the text command at least
ok, still cant get it working regardless of syncing
whats the error?
just that it cant be found
show the code
oh thats why