【问题标题】:How to make your bot say things from chat?如何让你的机器人在聊天中说话?
【发布时间】:2017-09-14 23:16:22
【问题描述】:

我希望能够通过我的不和谐进行交谈,但我不确定如何编写这样的代码;这是我尝试过的。

from discord.ext.commands import Bot

Mike = Bot(command_prefix=",")

@Mike.command()
    async def Msay(*args, message):
        Mike.delete_message(message)
        return await Mike.say(args)

Mike.run(secrets.BOT_TOKEN)

我希望能够输入我的不和谐聊天

我:,Msay hello world

我的消息已删除

Mike-Bot:你好世界

【问题讨论】:

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


    【解决方案1】:
    import asyncio
    import discord
    from discord.ext.commands import Bot
    
    Mike = Bot(',')
    
    @Mike.command(pass_context = True)
    async def Msay(ctx, *args):
        mesg = ' '.join(args)
        await Mike.delete_message(ctx.message)
        return await Mike.say(mesg)
    
    Mike.run(Token)
    

    【讨论】:

    猜你喜欢
    • 2018-12-13
    • 1970-01-01
    • 1970-01-01
    • 2017-05-09
    • 1970-01-01
    • 1970-01-01
    • 2019-08-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多