def _build_commands(self):
for key in self.owoe.types:
# Avoid duplicate commands by removing them.
if key in self.bot.all_commands.keys():
self.bot.remove_command(key)
helptext = f"{key.capitalize()}!"
async def callback(self, ctx, *tags):
tags = list(tags)
for tag in tags:
if tag not in self.owoe.tags:
tags.remove(tag)
url_image = await self.owoe.random_image(type_=ctx.command.name, tags=tags)
if isinstance(url_image, str):
embed = discord.Embed()
embed.set_image(url=url_image)
embed.set_footer(text="Powered by weeb.sh")
await ctx.send(embed=embed)
return
await ctx.send("No image matching your criteria was found.")
# Ew, gross.
command = commands.command(name=key, help=helptext)(callback)
command = commands.cooldown(6, 12, commands.BucketType.channel)(command)
command.instance = self
setattr(self, key, command)
self.bot.add_command(command)
评论列表
文章目录