【发布时间】:2021-02-19 15:26:33
【问题描述】:
好的,所以我制作了一个 Discord Bot,它从 reddit 获取模因并每 5 分钟将其发送到用户指定的频道,为此我必须创建一个 cog
#imports
import discord
...
...
#Automemer
class Automemer(commands.Cog):
def __init__(self, client):
....
#used to loop the task of posting memes
@tasks.loop(minutes=5.0)
async def automemer(self):
all_subs = []
...
#start of formating embed for task loop
name = random_sub.title
url = random_sub.url
em = discord.Embed(title = name)
em.set_image(url = url)
em.color = 0xff0000
em.set_footer(text=f'Memes from r/AmongUsMemes')
#used to post the memes where the user does the command am.memechannel
@commands.command()
async def memechannel(self, ctx):
channel_id = ctx.channel.id
await ctx.send('Memes will now be sent in this channel')
memeChannel = ctx.guild.get_channel(channel_id)
if memeChannel:
emoji1 = ':arrow_up:'
emoji2 = ':arrow_down:'
msg = await ctx.send(embed=em)
await msg.add_reaction(emoji1)
await msg.add_reaction(emoji2)
await ctx.send(embed=em)
Error = Ignoring exception in command None: discord.ext.commands.errors.CommandNotFound: Command "memechannel" is not found
每当我运行命令 am.memechannel 时都会发生错误。
如果有人告诉我如何解决这个错误,那就太好了。 这是该机器人的最后一个功能,这将是我第一个向公众发布的 Discord Bot! :)
【问题讨论】:
标签: python python-3.x discord bots discord.py