我如何制作一个接受信息的命令,更多内容在后

时间:2018-09-10 11:55:40

标签: python python-3.x discord.py discord.py-rewrite

执行此操作的命令,感谢任何帮助我的人

示例:

user: !say Hello

Bot: Hello

2 个答案:

答案 0 :(得分:2)

如何您要接受该信息。您是否只想接受a single word,而忽略多余的单词?

from discord.ext import commands

bot = commands.Bot(command_prefix='!')

@bot.command()
async def say(ctx, word):
    await ctx.send(word)

您想接受any number of inputs,但要分开对待吗?

@bot.command()
async def longest(ctx, *words):
    await ctx.send(max(words, key=len))

或者您想process the rest of the message as a single string(可能包含许多单词)

@bot.command()
async def echo(ctx, *, message):
    await ctx.send(message)

答案 1 :(得分:0)

如果您想让漫游器重复作者的消息并删除原始消息,请尝试使用此命令:

@bot.command(pass_context=True)
async def say(ctx, *args):
    mesg = ''.join(args)
    await bot.delete_message(ctx.message)
    return await bot.say(mesg)