Files
Gwendolyn/gwendolyn/cogs/misc_cog.py
2021-08-17 18:05:41 +02:00

100 lines
3.2 KiB
Python

"""Contains the MiscCog, which deals with miscellaneous commands."""
from discord.ext import commands # Has the cog class
from discord_slash import cog_ext # Used for slash commands
from gwendolyn.utils import get_params # pylint: disable=import-error
params = get_params()
class MiscCog(commands.Cog):
"""Contains the miscellaneous commands."""
def __init__(self, bot):
"""Initialize the cog."""
self.bot = bot
self.bot.remove_command("help")
self.generators = bot.other.generators
self.plex = bot.other.plex
self.nerd_shit = bot.other.nerd_shit
@cog_ext.cog_slash(**params["ping"])
async def ping(self, ctx):
"""Send the bot's latency."""
await ctx.send(f"Pong!\nLatency is {round(self.bot.latency * 1000)}ms")
@cog_ext.cog_slash(**params["stop"])
async def stop(self, ctx):
"""Stop the bot."""
await self.bot.stop(ctx)
@cog_ext.cog_slash(**params["help"])
async def help_command(self, ctx, command=""):
"""Get help for commands."""
await self.bot.other.helpFunc(ctx, command)
@cog_ext.cog_slash(**params["thank"])
async def thank(self, ctx):
"""Thank the bot."""
await ctx.send("You're welcome :blush:")
@cog_ext.cog_slash(**params["hello"])
async def hello(self, ctx):
"""Greet the bot."""
await self.bot.other.helloFunc(ctx)
@cog_ext.cog_slash(**params["roll"])
async def roll(self, ctx, dice="1d20"):
"""Roll dice."""
await self.bot.other.rollDice(ctx, dice)
@cog_ext.cog_slash(**params["image"])
async def image(self, ctx):
"""Get a random image from Bing."""
await self.bot.other.imageFunc(ctx)
@cog_ext.cog_slash(**params["movie"])
async def movie(self, ctx):
"""Get a random movie from the Plex server."""
await self.bot.other.movieFunc(ctx)
@cog_ext.cog_slash(**params["name"])
async def name(self, ctx):
"""Generate a random name."""
await self.generators.nameGen(ctx)
@cog_ext.cog_slash(**params["tavern"])
async def tavern(self, ctx):
"""Generate a random tavern name."""
await self.generators.tavernGen(ctx)
@cog_ext.cog_slash(**params["wiki"])
async def wiki(self, ctx, wiki_page=""):
"""Get a page on a fandom wiki."""
await self.bot.other.findWikiPage(ctx, wiki_page)
@cog_ext.cog_slash(**params["add_movie"])
async def add_movie(self, ctx, movie):
"""Search for a movie and add it to the Plex server."""
await self.plex.request_movie(ctx, movie)
@cog_ext.cog_slash(**params["add_show"])
async def add_show(self, ctx, show):
"""Search for a show and add it to the Plex server."""
await self.plex.request_show(ctx, show)
@cog_ext.cog_slash(**params["downloading"])
async def downloading(self, ctx, parameters="-d"):
"""Get the current downloading torrents."""
await self.plex.downloading(ctx, parameters)
@cog_ext.cog_slash(**params["wolf"])
async def wolf(self, ctx, query):
"""Perform a search on Wolfram Alpha."""
await self.nerd_shit.wolfSearch(ctx, query)
def setup(bot):
"""Add the cog to the bot."""
bot.add_cog(MiscCog(bot))