問題描述
所以,我目前有一個使用 discord.py 運行的 discord 機器人,如您所知,discord.py 帶有自己的幫助命令(所以我不必自己制作).它非常有用,我將我的命令分成了 cogs/categories.它確實有助于簡化,因為現在我不必編寫自己的幫助命令.
So, I currently have a discord bot running with discord.py, and as you know, discord.py comes with its own help command (so I don't have to make my own). It's very useful, and I have my commands separated into cogs/categories. It really helps with simplicity, because now I don't have to write my own help command.
問題是,當我運行幫助命令時,它出現在一個巨大的代碼塊中,如下所示:我聽到一些用戶抱怨說這在視覺上并不吸引人,當我添加更多命令時,它會填滿屏幕.有沒有簡單的方法(無需編寫我自己的幫助命令)將所有這些移動到嵌入中?也許復制此幫助命令的輸出,并將其移動到嵌入中?如果沒有,沒關系,我會編寫自己的幫助命令,但我只是想尋找一種簡單的方法來做到這一點,而不會弄臟我的代碼.與往常一樣,提前感謝您.
The problem is, when I run the help command, it comes to me in a giant code block, like so: I have heard some complaints from users that this isn't exactly visually appealing, and as I add more commands, it fills up the screen. Is there simple way (without writing my own help command) to move all of this onto an embed? Maybe copy the output of this help command, and move that onto an embed? If not, it's ok, I'll write my own help command, but I'm just trying to look for a simple way to do this without getting my hands dirty coding. As always, thank you in advance.
如果需要,這里是我的代碼示例:
In case it is needed, here is sample from my code:
import discord
from discord.ext import commands, tasks
TOKEN = "INSERT TOKEN HERE"
client = commands.Bot(command_prefix="wurf ", case_insensitive=True)
#Utility Category
class Utility(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command(
help="Shows the ping/latency of the bot in miliseconds.",
brief="Shows ping."
)
async def ping(self, ctx):
if round(client.latency * 1000) <= 50:
embed=discord.Embed(title="PING", description=f":ping_pong: Pingpingpingpingping! The ping is **{round(client.latency *1000)}** milliseconds!", color=0x44ff44)
elif round(client.latency * 1000) <= 100:
embed=discord.Embed(title="PING", description=f":ping_pong: Pingpingpingpingping! The ping is **{round(client.latency *1000)}** milliseconds!", color=0xffd000)
elif round(client.latency * 1000) <= 200:
embed=discord.Embed(title="PING", description=f":ping_pong: Pingpingpingpingping! The ping is **{round(client.latency *1000)}** milliseconds!", color=0xff6600)
else:
embed=discord.Embed(title="PING", description=f":ping_pong: Pingpingpingpingping! The ping is **{round(client.latency *1000)}** milliseconds!", color=0x990000)
await ctx.send(embed=embed)
client.add_cog(Utility(client))
client.run(TOKEN)
推薦答案
您必須使用 Bot.help_command
這是一個簡單的嵌入實現,我繼承自 MinimalHelpCommand
Here is a simple embed implementation I threw together inheriting from MinimalHelpCommand
class MyHelpCommand(commands.MinimalHelpCommand):
async def send_pages(self):
destination = self.get_destination()
e = discord.Embed(color=discord.Color.blurple(), description='')
for page in self.paginator.pages:
e.description += page
await destination.send(embed=e)
client.help_command = MyHelpCommand()
這篇關于如何將 discord.py 幫助命令放入嵌入中?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!