【发布时间】:2021-01-20 13:10:05
【问题描述】:
我一直在尝试在 python 中开发一个不和谐的机器人,我想制作一堆在帮助中不显示的“隐藏”命令。我想这样做,以便每当有人激活隐藏命令时,机器人都会向他们发送 pm。我试图制作一个功能来做到这一点,但到目前为止它不起作用。这是cog文件中的代码:
import discord
from discord.ext import commands
class Hidden(commands.Cog):
def __init__(self, client):
self.client = client
def hidden_message(ctx):
ctx.author.send('You have found one of several hidden commands! :shushing_face:\nCan you find them all? :thinking:')
@commands.command()
async def example(self, ctx):
await ctx.send('yes')
hidden_message(ctx)
def setup(client):
client.add_cog(Hidden(client))
运行示例命令时,机器人正常响应,但未调用该函数。控制台中没有错误消息。我对 python 还是很陌生,所以有人可以告诉我我做错了什么吗?
【问题讨论】:
标签: python discord.py