QOL Updates

This commit is contained in:
Marco Thomas
2021-03-03 17:44:47 +01:00
parent e14a1ef2a3
commit 87bce0be57
12 changed files with 24 additions and 104 deletions

View File

@@ -3,9 +3,9 @@ FROM python:3.8-alpine
WORKDIR /data WORKDIR /data
COPY . /data COPY . /data
RUN apk add .build-deps gcc libc-dev \ RUN apk add gcc libc-dev \
apk add ffmpeg \ && python3 -m pip install -r requirements.txt \
&& python3 -m pip install -r requirements.txt && apk del gcc libc-dev
ENV PREFIX /data ENV PREFIX /data
ENV TOKEN /data ENV TOKEN /data

View File

@@ -5,10 +5,9 @@
\__,_|\__, |\__,_|\__,_|_.__/ \___/ \__| \__,_|\__, |\__,_|\__,_|_.__/ \___/ \__|
|_| |_|
created by Marc. by MarcMK
This project uses discordpy: This project uses discordpy: https://discordpy.readthedocs.io/en/latest/intro.html
https://discordpy.readthedocs.io/en/latest/intro.html
""" """
import discord import discord
@@ -17,7 +16,7 @@ import logging
import platform import platform
import os import os
# Environment
PREFIX = os.environ['PREFIX'] PREFIX = os.environ['PREFIX']
TOKEN = os.environ['TOKEN'] TOKEN = os.environ['TOKEN']
REDDIT_CLIENT_ID = os.environ['REDDIT_CLIENT_ID'] 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'] REDDIT_CLIENT_USERAGENT = os.environ['REDDIT_CLIENT_USERAGENT']
AVATAR = "https://i.redd.it/0uajctrps9u41.jpg" AVATAR = "https://i.redd.it/0uajctrps9u41.jpg"
# Logger
logger = logging.getLogger("discord") logger = logging.getLogger("discord")
logger.setLevel(logging.INFO) logger.setLevel(logging.INFO)
handler = logging.FileHandler( handler = logging.FileHandler(filename="logs/discord.log", encoding="utf-8", mode="w")
filename="logs/discord.log", handler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s"))
encoding="utf-8",
mode="w")
handler.setFormatter(
logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s"))
logger.addHandler(handler) logger.addHandler(handler)
# Bot declaration
bot = commands.Bot( bot = commands.Bot(command_prefix=PREFIX, description="Holy Goddess Aqua!")
command_prefix=PREFIX,
description="Holy Goddess Aqua!")
# Preloaded Cogs # Preloaded Cogs
cogs = [ cogs = ["cogs.admin",
"cogs.admin",
"cogs.anime", "cogs.anime",
"cogs.help", "cogs.help",
"cogs.jikan", "cogs.jikan",
"cogs.meme", "cogs.meme",
"cogs.music", # "cogs.music",
"cogs.reddit", "cogs.reddit",
"cogs.utility", "cogs.utility",
"cogs.welcome" "cogs.welcome"]
]
for cog in cogs: for cog in cogs:
try: try:
@@ -61,13 +53,9 @@ for cog in cogs:
else: else:
print(f"SUCCESS: Loaded {cog}") print(f"SUCCESS: Loaded {cog}")
# Start Bot
########## Start Bot
@bot.event @bot.event
async def on_ready(): async def on_ready():
"""
This prints some information about the bot, while starting up
"""
bot.AppInfo = await bot.application_info() bot.AppInfo = await bot.application_info()
startup = f""" startup = f"""
@@ -76,17 +64,15 @@ async def on_ready():
Command Prefix: {PREFIX}\n Command Prefix: {PREFIX}\n
discord.py Version: {discord.__version__}\n discord.py Version: {discord.__version__}\n
python Version: {platform.python_version()}\n python Version: {platform.python_version()}\n
OS: {platform.system()} {platform.release()} {platform.version()}\n
""" """
print(startup) print(startup)
name = f"with water | {PREFIX}aquabot" activity_name = f"with water | {PREFIX}aquabot"
activity = discord.Activity(name=name, type=discord.ActivityType.playing) activity = discord.Activity(activity_name=name, type=discord.ActivityType.playing)
await bot.change_presence(activity=activity) await bot.change_presence(activity=activity)
print("AquaBot is ready!\n") print("AquaBot is ready!\n")
bot.run(TOKEN, bot.run(TOKEN,
bot=True, bot=True,
reconnect=True) reconnect=True)

View File

@@ -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 import discord
from discord.ext import commands from discord.ext import commands
class Admin(commands.Cog): class Admin(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot

View File

@@ -1,5 +1,5 @@
""" """
Some help for the users User help
""" """
import discord import discord
@@ -7,7 +7,6 @@ from discord.ext import commands
from __main__ import PREFIX from __main__ import PREFIX
class Help(commands.Cog): class Help(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot

View File

@@ -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/ https://jikanpy.readthedocs.io/en/latest/
""" """
@@ -7,13 +7,13 @@ import discord
from discord.ext import commands from discord.ext import commands
from jikanpy import Jikan from jikanpy import Jikan
jikan = Jikan() jikan = Jikan()
class Jikan(commands.Cog): class Jikan(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot
@commands.group(name="anime") @commands.group(name="anime")
async def anime(self, ctx): async def anime(self, ctx):
if ctx.invoked_subcommand is None: if ctx.invoked_subcommand is None:

View File

@@ -8,7 +8,6 @@ import random
import memes import memes
class Meme(commands.Cog): class Meme(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot

View File

@@ -1,7 +1,7 @@
""" """
Play Music 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 https://gist.github.com/vbe0201/ade9b80f2d3b64643d854938d40a0a2d
""" """
@@ -392,18 +392,6 @@ class Music(commands.Cog):
if ctx.voice_client.channel != ctx.author.voice.channel: if ctx.voice_client.channel != ctx.author.voice.channel:
raise commands.CommandError('Bot is already in a 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") @commands.command(name="queue")
async def queue(self, ctx: commands.Context): async def queue(self, ctx: commands.Context):

View File

@@ -11,7 +11,6 @@ from __main__ import REDDIT_CLIENT_ID
from __main__ import REDDIT_CLIENT_SECRET from __main__ import REDDIT_CLIENT_SECRET
from __main__ import REDDIT_CLIENT_USERAGENT from __main__ import REDDIT_CLIENT_USERAGENT
class Reddit(commands.Cog): class Reddit(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot = bot self.bot = bot

View File

@@ -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))

View File

@@ -1,5 +1,5 @@
""" """
Some (more or less) handy utility Some utility commands
""" """
import discord import discord

View File

@@ -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))

View File

@@ -1,4 +1,4 @@
discord.py[voice] discord.py
youtube-dl youtube-dl
praw praw
argparse argparse