当我键入/ helps时,我只会收到“你好,原始”代码,因为我没有得到反应表情符号,所以代码中是否有任何错误。
输出: 您好Raw#6839
from discord.ext import menus,commands
bot = commands.Bot(command_prefix=('/'))
class MyMenu(menus.Menu):
async def send_initial_message(self, ctx, channel):
return await channel.send(f'Hello {ctx.author}')
@menus.button('\n{TRACK PREVIOUS SIGN}')
async def on_track_previous(self, ctx, payload):
await self.message.edit(content="a")
@menus.button('\n{REWIND SIGN}')
async def on_rewind(self, ctx, payload):
await self.message.edit(content="b")
@menus.button('\n{FAST FORWARD SIGN}')
async def on_fast_forward(self, ctx, payload):
await self.message.edit(content="c")
@menus.button('\n{TRACK NEXT SIGN}')
async def on_track_next(self, ctx, payload):
await self.message.edit(content="d")
@bot.command()
async def helps(ctx):
m = MyMenu()
await m.start(ctx)
bot.run('token')
答案 0 :(得分:0)
您没有使用有效的名称转义符。该语法要求使用大写字母N,并且您需要使用这些字符的精确名称(可以使用"<char>".encode('ascii', 'namereplace')
来获取这些字符)
class MyMenu(menus.Menu):
async def send_initial_message(self, ctx, channel):
return await channel.send(f'Hello {ctx.author}')
@menus.button('\N{BLACK LEFT-POINTING DOUBLE TRIANGLE WITH VERTICAL BAR}\N{VARIATION SELECTOR-16}')
async def on_track_previous(self, ctx, payload):
await self.message.edit(content="a")
@menus.button('\N{BLACK LEFT-POINTING DOUBLE TRIANGLE}')
async def on_rewind(self, ctx, payload):
await self.message.edit(content="b")
@menus.button('\N{BLACK RIGHT-POINTING DOUBLE TRIANGLE}')
async def on_fast_forward(self, ctx, payload):
await self.message.edit(content="c")
@menus.button('\N{BLACK RIGHT-POINTING DOUBLE TRIANGLE WITH VERTICAL BAR}\N{VARIATION SELECTOR-16}')
async def on_track_next(self, ctx, payload):
await self.message.edit(content="d")