英文:
The bot does not mention messages
问题
我阅读了discord.py
文档,并根据其编写了这段代码,但它没有生效。
@client.command()
async def ping(ctx):
await ctx.send(f'Pong! 🚀\n主机延迟:{round(client.latency * 1000)} 毫秒!'.format(ctx.message.author.mention))
print(f'尝试回应:Pong! 🚀\n主机延迟:{round(client.latency * 1000)} 毫秒!')
英文:
I read the discord.py
documentation and wrote this code according to it, but it didn't work.
@client.command()
async def ping(ctx):
await ctx.send(f'Pong! 🏓\\nHost Latency: {round (client.latency \* 1000)} ms!'.format(ctx.message.author.mention))
print(f'TalkBack atemping: Pong! 🏓\\nHost Latency: {round (client.latency \* 1000)} ms!' )
答案1
得分: 1
why do you format a f string?!
await ctx.send(f'{ctx.author.mention} Pong! 🏓\nHost Latency: {round(client.latency * 1000)} ms!')
and the \ makes no sense you want a new line not a special character  ... so make
in the operation you dont use * only * you dont want the character ...
and the format problem is that there is nothing that can be formated there is no empty {} ...
英文:
hey here the first problem:
why do you format a f string?!
await ctx.send(f'Pong! 🏓\\nHost Latency: {round (client.latency \* 1000)} ms!'.format(ctx.message.author.mention))
should rather be
await ctx.send(f'{ctx.author.mention} Pong! 🏓\nHost Latency: {round(client.latency * 1000)} ms!')
and the \ makes no sense you want a new line not a special character  ... so make
in the operation you dont use * only * you dont want the character ...
and the format problem is that there is nothing that can be formated there is no empty {} ...
答案2
得分: -1
只获取作者的ID并执行
<@ctx.author.id>
英文:
Just get the authors ID and do
<@ctx.author.id>
答案3
得分: -1
I solved the problem myself
@client.command()
async def ping(ctx):
await ctx.send(f'Pong! 🏳️\nHost Latency: {round(client.latency * 1000)} ms! {ctx.author.mention}')
print('TalkBack attempting: Pong! 🏳️\nHost Latency: {round(client.latency * 1000)} ms!')
If anyone has a problem, use this method
英文:
I solved the problem myself
@client.command()
async def ping(ctx):
await ctx.send(f'Pong! 🏓\nHost Latency: {round (client.latency * 1000)} ms! {(ctx.author.mention)}')
print(f'TalkBack atemping: Pong! 🏓\nHost Latency: {round (client.latency * 1000)} ms!')
If anyone has a problem, use this method
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论