You could do something like this :
import discord
import os
from discord.ext import commands
bot = commands.Bot(command_prefix="!", help_command=None)
@bot.command()
async def help(ctx):
sent_msg = await ctx.send("An great help command")
await sent_msg.reply("this message is now inactive")
bot.run(os.getenv("DISCORD_TOKEN"))
Which would result in :
Bot replies to its own help command
--- Answer to new edit ---
I have made a function to do this. It is stripped from my older project so you may remove the unnecessary features you don't need :
import discord
import os
import asyncio
import typing
from discord.ext import commands
bot = commands.Bot(command_prefix=">")
@bot.event
async def on_ready():
print(f"Sucessfully logged in as {bot.user}")
async def paginate(
ctx: discord.ext.commands.context.Context,
*embed_pages: typing.Union[discord.Embed, list[discord.Embed]],
content=None,
overwrite_footer=True,
timeout=None,
):
if isinstance(embed_pages[0], list):
embed_pages = embed_pages[0]
every_embed = list()
if overwrite_footer:
for index, each_embed in enumerate(embed_pages):
each_embed.remove_footer()
each_embed.set_footer(text=f"Page {index + 1} of {len(embed_pages)}")
every_embed.append(each_embed)
else:
every_embed = embed_pages[:]
sent_embed = await ctx.send(
content=content, embed=every_embed[0]
) # Send the first page
page_index = 0 # Set the starting index
reactions = ["1️⃣", "2️⃣", "3️⃣"]
for each_reaction in reactions:
await sent_embed.add_reaction(each_reaction)
while True:
try:
payload = await bot.wait_for(
"raw_reaction_add",
check=lambda payload: payload.message_id == sent_embed.id
and not payload.member == bot.user
and payload.member.id
== ctx.author.id, # Do this if you want it to be author-only
timeout=timeout,
)
except asyncio.TimeoutError:
# timeout has been hit
await sent_embed.reply("This message is now inactive")
try:
await sent_embed.clear_reactions()
except discord.Forbidden:
# No perms
pass
return
else:
try:
await sent_embed.remove_reaction(payload.emoji, payload.member)
except discord.Forbidden:
# Bot does not have permission
pass
if (
str(payload.emoji.name) not in reactions
): # Some user reacted with something else
pass
elif str(payload.emoji.name) == reactions[0]: # One
page_index = 0
await sent_embed.edit(embed=every_embed[page_index], content=content)
elif str(payload.emoji.name) == reactions[1]: # Two
page_index = 1
await sent_embed.edit(embed=every_embed[page_index], content=content)
else:
page_index = 2
await sent_embed.edit(embed=every_embed[page_index], content=content)
@bot.command(aliases=["start",])
async def start_pages(ctx):
await paginate(ctx, discord.Embed(title="Abc", description="sdknfe"),
discord.Embed(title="idk", description="something else"),
discord.Embed(title='(¬_¬")', description="We really need 3 pages"),
timeout=10)
bot.run(os.getenv("DISCORD_TOKEN"))
This code will result in this