如何让您的机器人从聊天中说出话?

问题描述 投票:1回答:2

我希望能够解决我的不和谐,但是我不确定如何编写这样的东西;这是我尝试过的。

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)

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

ME:,Msay hello world

我的邮件已删除

Mike-Bot:你好,世界

python python-3.x discord discord.py
2个回答
2
投票
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)

0
投票

我遇到此错误。

SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:877:16)
at Module._compile (internal/modules/cjs/loader.js:928:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:994:10)
at Module.load (internal/modules/cjs/loader.js:813:32)
at Function.Module._load (internal/modules/cjs/loader.js:725:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1046:10)
at internal/main/run_main_module.js:17:11
© www.soinside.com 2019 - 2024. All rights reserved.