diff --git a/aquabot.py b/aquabot.py index 6e2b70c..a99c788 100644 --- a/aquabot.py +++ b/aquabot.py @@ -23,18 +23,15 @@ logger.setLevel(logging.INFO) handler = logging.FileHandler( filename="logs/discord-{%Y-%m-%d_%H-%M}.log".format(datetime.now()), encoding="utf-8", - mode="w" - ) + mode="w") handler.setFormatter( - logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s") - ) + logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s")) logger.addHandler(handler) # INIT THE BOT bot = commands.Bot( command_prefix=loadconfig.__prefix__, - description="Holy Goddess Aqua!" - ) + description="Holy Goddess Aqua!") # LOAD COGS SPECIFIED IN 'config/cogs.py' for cog in loadconfig.__cogs__: @@ -83,5 +80,4 @@ async def on_ready(): bot.run( loadconfig.__token__, bot=True, - reconnect=True - ) + reconnect=True) diff --git a/cogs/anime.py b/cogs/anime.py index 15a268f..0eb0323 100644 --- a/cogs/anime.py +++ b/cogs/anime.py @@ -5,9 +5,13 @@ Some anime-related commands: https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html """ -# IMPORTS +# IMPORTS - external import discord from discord.ext import commands +import random + +# IMPORTS - internal +import loadconfig # COG INIT class Anime(commands.Cog): @@ -15,6 +19,32 @@ class Anime(commands.Cog): self.bot = bot # COG BODY + @commands.command(name="animemedia") + async def animemedia(self, ctx): + """ + Sends a random anime gif or pic + """ + # Choose either a gif or a pic -> config/media.py + media_type = random.choice(loadconfig.__anime_media__) + media = random.choice(media) + await ctx.send(media) + + @commands.command(name="waifumedia") + async def waifumedia(self, ctx, waifu: str): + """ + Sends a random pic of a waifu (list in config/media.py) + """ + # Dictionary + waifus = loadconfig.__waifu_media__ + try: + media = random.choice(waifus.get(waifu)) + await ctx.send(media) + except KeyError as error: + text = ( + f"Waifu `{waifu}` not found in database!\n" + "It probably sucks...") + await ctx.send(text) + # COG ENDING def setup(bot): diff --git a/cogs/general.py b/cogs/general.py index b1b3a66..c6c9b20 100644 --- a/cogs/general.py +++ b/cogs/general.py @@ -36,8 +36,7 @@ class General(commands.Cog): footer_text = ( "This Bot is an OpenSource project by Marc and can be found " - "on github.com/CramMK/aquabot" - ) + "on github.com/CramMK/aquabot") embed.set_footer(text=footer_text, icon_url=loadconfig.__avatar__) await ctx.send(embed=embed) diff --git a/config/media.py b/config/media.py new file mode 100644 index 0000000..e8eeef5 --- /dev/null +++ b/config/media.py @@ -0,0 +1,28 @@ +""" +Media, which can be accessed from the bot. +""" + +# Exports +__anime_media__ = [anime_gifs, anime_pics] + +__waifu_media__ = { + "aqua": waifu_aqua, + "meugmin": waifu_megumin, + "akeno": waifu_akeno, + "rem": waifu_rem + } + +# Internal lists +anime_gifs = [] + +anime_pics = [ + "https://i.imgur.com/4xnJN9x.png", + ] + +waifu_aqua = [] + +waifu_megumin = [] + +waifu_akeno = [] + +waifu_rem = [] diff --git a/loadconfig.py b/loadconfig.py index 73794d8..2791ea2 100644 --- a/loadconfig.py +++ b/loadconfig.py @@ -6,11 +6,11 @@ loadconfig.py then gets called in aquabot.py __avatar__ = "https://i.imgur.com/mskM9dH.png" -from config.cogs import __cogs__ - -from config.status import __activity__ - try: + # TODO Maybe use yaml for token and prefix! from config.config import __token__, __prefix__ -except ImportError as e: - print(f"Error while importing: {e}") + from config.cogs import __cogs__ + from config.status import __activity__ + from config.media import __anime_media__, __waifu_media__ +except ImportError as error: + print(f"Error while importing: {error}")