Discord.py 机器人无法识别来自 cogs 的命令
Discord.py bot doesn't recognize commands from cogs
我一直在努力弄清楚 cog 如何与 discord.py 重写一起工作,我设法让一个机器人只使用一个 cog。问题是,机器人可以识别来自一个齿轮的命令,但不能识别另一个齿轮。
导入 bot.py
中的齿轮
cogs = [
'cogs.basic',
'cogs.mod']
@bot.event
async def on_ready():
print("Arthur Morgan")
print("version: "+version)
game = discord.Game("rebuilding.....")
await bot.change_presence(status=discord.Status.idle, activity=game)
for extension in cogs:
bot.load_extension(extension)
return
inside basic.py
这里的命令似乎有效
import discord
from discord.ext import commands
class Basic(commands.Cog):
def __init__(self,bot):
self.bot = bot
@commands.command(name='ping', aliases=['p'])
async def ping(self, ctx):
await ctx.send("Pong! :ping_pong:")
def setup(bot):
bot.add_cog(Basic(bot))
mod.py
输出中的命令 this
import discord
from discord.ext import commands
class Mod(commands.Cog):
def __init__(self,bot):
self.bot = bot
@commands.command()
async def pong(self, ctx):
await ctx.send("Ping!")
def setup(bot):
bot.add_cog(Mod(bot))
有人知道如何解决这个问题吗?
for extension in cogs:
bot.load_extension(extension)
return
协程在仅加载一个 cog 后到达 return
时停止。
我一直在努力弄清楚 cog 如何与 discord.py 重写一起工作,我设法让一个机器人只使用一个 cog。问题是,机器人可以识别来自一个齿轮的命令,但不能识别另一个齿轮。
导入 bot.py
cogs = [
'cogs.basic',
'cogs.mod']
@bot.event
async def on_ready():
print("Arthur Morgan")
print("version: "+version)
game = discord.Game("rebuilding.....")
await bot.change_presence(status=discord.Status.idle, activity=game)
for extension in cogs:
bot.load_extension(extension)
return
inside basic.py
这里的命令似乎有效
import discord
from discord.ext import commands
class Basic(commands.Cog):
def __init__(self,bot):
self.bot = bot
@commands.command(name='ping', aliases=['p'])
async def ping(self, ctx):
await ctx.send("Pong! :ping_pong:")
def setup(bot):
bot.add_cog(Basic(bot))
mod.py
输出中的命令 this
import discord
from discord.ext import commands
class Mod(commands.Cog):
def __init__(self,bot):
self.bot = bot
@commands.command()
async def pong(self, ctx):
await ctx.send("Ping!")
def setup(bot):
bot.add_cog(Mod(bot))
有人知道如何解决这个问题吗?
for extension in cogs:
bot.load_extension(extension)
return
协程在仅加载一个 cog 后到达 return
时停止。