From 87bce0be570bd9dd4741ea7c49c1dc8f39195d93 Mon Sep 17 00:00:00 2001 From: Marco Thomas Date: Wed, 3 Mar 2021 17:44:47 +0100 Subject: [PATCH] QOL Updates --- Dockerfile | 6 +++--- aquabot.py | 42 ++++++++++++++---------------------------- cogs/admin.py | 3 +-- cogs/help.py | 3 +-- cogs/jikan.py | 4 ++-- cogs/meme.py | 1 - cogs/music.py | 14 +------------- cogs/reddit.py | 1 - cogs/reminder.py | 17 ----------------- cogs/utility.py | 2 +- cogs/welcome.py | 33 --------------------------------- requirements.txt | 2 +- 12 files changed, 24 insertions(+), 104 deletions(-) delete mode 100644 cogs/reminder.py delete mode 100644 cogs/welcome.py diff --git a/Dockerfile b/Dockerfile index eae1025..904b3b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,9 +3,9 @@ FROM python:3.8-alpine WORKDIR /data COPY . /data -RUN apk add .build-deps gcc libc-dev \ - apk add ffmpeg \ - && python3 -m pip install -r requirements.txt +RUN apk add gcc libc-dev \ + && python3 -m pip install -r requirements.txt \ + && apk del gcc libc-dev ENV PREFIX /data ENV TOKEN /data diff --git a/aquabot.py b/aquabot.py index 4839ecc..b13cd5a 100644 --- a/aquabot.py +++ b/aquabot.py @@ -5,10 +5,9 @@ \__,_|\__, |\__,_|\__,_|_.__/ \___/ \__| |_| -created by Marc. +by MarcMK -This project uses discordpy: -https://discordpy.readthedocs.io/en/latest/intro.html +This project uses discordpy: https://discordpy.readthedocs.io/en/latest/intro.html """ import discord @@ -17,7 +16,7 @@ import logging import platform import os - +# Environment PREFIX = os.environ['PREFIX'] TOKEN = os.environ['TOKEN'] REDDIT_CLIENT_ID = os.environ['REDDIT_CLIENT_ID'] @@ -25,33 +24,26 @@ REDDIT_CLIENT_SECRET = os.environ['REDDIT_CLIENT_SECRET'] REDDIT_CLIENT_USERAGENT = os.environ['REDDIT_CLIENT_USERAGENT'] AVATAR = "https://i.redd.it/0uajctrps9u41.jpg" +# Logger logger = logging.getLogger("discord") logger.setLevel(logging.INFO) -handler = logging.FileHandler( - filename="logs/discord.log", - encoding="utf-8", - mode="w") -handler.setFormatter( - logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s")) +handler = logging.FileHandler(filename="logs/discord.log", encoding="utf-8", mode="w") +handler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s")) logger.addHandler(handler) - -bot = commands.Bot( - command_prefix=PREFIX, - description="Holy Goddess Aqua!") +# Bot declaration +bot = commands.Bot(command_prefix=PREFIX, description="Holy Goddess Aqua!") # Preloaded Cogs -cogs = [ - "cogs.admin", +cogs = ["cogs.admin", "cogs.anime", "cogs.help", "cogs.jikan", "cogs.meme", - "cogs.music", +# "cogs.music", "cogs.reddit", "cogs.utility", - "cogs.welcome" - ] + "cogs.welcome"] for cog in cogs: try: @@ -61,13 +53,9 @@ for cog in cogs: else: print(f"SUCCESS: Loaded {cog}") - -########## Start Bot +# Start Bot @bot.event async def on_ready(): - """ - This prints some information about the bot, while starting up - """ bot.AppInfo = await bot.application_info() startup = f""" @@ -76,17 +64,15 @@ async def on_ready(): Command Prefix: {PREFIX}\n discord.py Version: {discord.__version__}\n python Version: {platform.python_version()}\n - OS: {platform.system()} {platform.release()} {platform.version()}\n """ print(startup) - name = f"with water | {PREFIX}aquabot" - activity = discord.Activity(name=name, type=discord.ActivityType.playing) + activity_name = f"with water | {PREFIX}aquabot" + activity = discord.Activity(activity_name=name, type=discord.ActivityType.playing) await bot.change_presence(activity=activity) print("AquaBot is ready!\n") - bot.run(TOKEN, bot=True, reconnect=True) diff --git a/cogs/admin.py b/cogs/admin.py index 75e5a87..f89b145 100644 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -1,11 +1,10 @@ """ -Admin commands, that can be used from within the discord-client-chat +Admin commands, that can be used within the Discord Client """ import discord from discord.ext import commands - class Admin(commands.Cog): def __init__(self, bot): self.bot = bot diff --git a/cogs/help.py b/cogs/help.py index 23771a7..3a39765 100644 --- a/cogs/help.py +++ b/cogs/help.py @@ -1,5 +1,5 @@ """ -Some help for the users +User help """ import discord @@ -7,7 +7,6 @@ from discord.ext import commands from __main__ import PREFIX - class Help(commands.Cog): def __init__(self, bot): self.bot = bot diff --git a/cogs/jikan.py b/cogs/jikan.py index e6f1c34..259d3ac 100644 --- a/cogs/jikan.py +++ b/cogs/jikan.py @@ -1,5 +1,5 @@ """ -Jikan is an unofficial api to access data from myanimelist +Jikan is an unofficial API to access data from MyAnimeList https://jikanpy.readthedocs.io/en/latest/ """ @@ -7,13 +7,13 @@ import discord from discord.ext import commands from jikanpy import Jikan - jikan = Jikan() class Jikan(commands.Cog): def __init__(self, bot): self.bot = bot + @commands.group(name="anime") async def anime(self, ctx): if ctx.invoked_subcommand is None: diff --git a/cogs/meme.py b/cogs/meme.py index 19d7501..b50820b 100644 --- a/cogs/meme.py +++ b/cogs/meme.py @@ -8,7 +8,6 @@ import random import memes - class Meme(commands.Cog): def __init__(self, bot): self.bot = bot diff --git a/cogs/music.py b/cogs/music.py index 4ac25b6..abcafed 100644 --- a/cogs/music.py +++ b/cogs/music.py @@ -1,7 +1,7 @@ """ Play Music -A COG ORIGINALLY CREATED BY ME, I ALTERED THIS ONE TO FIT MY NEEDS +A COG ORIGINALLY NOT CREATED BY ME, I ALTERED THIS ONE TO FIT MY NEEDS https://gist.github.com/vbe0201/ade9b80f2d3b64643d854938d40a0a2d """ @@ -392,18 +392,6 @@ class Music(commands.Cog): if ctx.voice_client.channel != ctx.author.voice.channel: raise commands.CommandError('Bot is already in a voice channel.') -# @commands.command(name='loop') -# async def loop(self, ctx: commands.Context): -# """ -# Loops the currently playing song. -# """ -# if not ctx.voice_state.is_playing: -# return await ctx.send('Nothing being played at the moment.') -# -# # Swap states -# ctx.voice_state.loop = not ctx.voice_state.loop -# await ctx.message.add_reaction('✅') - @commands.command(name="queue") async def queue(self, ctx: commands.Context): diff --git a/cogs/reddit.py b/cogs/reddit.py index fed706d..ffdb909 100644 --- a/cogs/reddit.py +++ b/cogs/reddit.py @@ -11,7 +11,6 @@ from __main__ import REDDIT_CLIENT_ID from __main__ import REDDIT_CLIENT_SECRET from __main__ import REDDIT_CLIENT_USERAGENT - class Reddit(commands.Cog): def __init__(self, bot): self.bot = bot diff --git a/cogs/reminder.py b/cogs/reminder.py deleted file mode 100644 index 64a466b..0000000 --- a/cogs/reminder.py +++ /dev/null @@ -1,17 +0,0 @@ -""" -A simple reminder option -""" - -import discord -from discord.ext import commands - - -class Reminder(commands.Cog): - def __init__(self, bot): - self.bot = bot - - - - -def setup(bot): - bot.add_cog(Reminder(bot)) diff --git a/cogs/utility.py b/cogs/utility.py index f1d5d00..e436e83 100644 --- a/cogs/utility.py +++ b/cogs/utility.py @@ -1,5 +1,5 @@ """ -Some (more or less) handy utility +Some utility commands """ import discord diff --git a/cogs/welcome.py b/cogs/welcome.py deleted file mode 100644 index b9128b1..0000000 --- a/cogs/welcome.py +++ /dev/null @@ -1,33 +0,0 @@ -""" -Welcoming new users etc. -""" - -import discord -from discord.ext import commands - - -class Welcome(commands.Cog): - def __init__(self, bot): - self.bot = bot - - - @commands.Cog.listener() - async def on_member_join(self, member): - """ - Greets new users joining your server - """ - channel = member.guild.system_channel - text = f"Welcome {member.mention} to our Discord!" - if channel is not None: - await channel.send(text) - - @commands.command(name="hello") - async def hello(self, ctx): - """ - Sends a simple reply to the user - """ - await ctx.send(f"Hello {ctx.author.mention}!") - - -def setup(bot): - bot.add_cog(Welcome(bot)) diff --git a/requirements.txt b/requirements.txt index df7b4c2..112f274 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -discord.py[voice] +discord.py youtube-dl praw argparse