Add media stuff
This commit is contained in:
12
aquabot.py
12
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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
28
config/media.py
Normal file
28
config/media.py
Normal file
@@ -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 = []
|
||||
@@ -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}")
|
||||
|
||||
Reference in New Issue
Block a user