Some small improvements
This commit is contained in:
10
README.md
10
README.md
@@ -7,8 +7,14 @@ AquaBot
|
||||
|
||||
This Bot was created with the intention to be used on my own server.
|
||||
|
||||
## docker-compose
|
||||
TODO
|
||||
## docker
|
||||
|
||||
Create a docker image with tag 'latest'
|
||||
`docker build . -t aquabot`
|
||||
|
||||
In the correct path, create a docker-compose.yml and start the bot
|
||||
The required env vars are found in 'aquabot.py'
|
||||
`docker-compose up -d`
|
||||
|
||||
## Commands
|
||||
|
||||
|
||||
21
aquabot.py
21
aquabot.py
@@ -13,18 +13,13 @@ This project uses discordpy:
|
||||
https://discordpy.readthedocs.io/en/latest/intro.html
|
||||
"""
|
||||
|
||||
# IMPORTS - external
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import logging
|
||||
from datetime import datetime
|
||||
import platform
|
||||
import random
|
||||
import asyncio
|
||||
import sys
|
||||
import os
|
||||
|
||||
# SET VARS
|
||||
|
||||
PREFIX = os.environ['PREFIX']
|
||||
TOKEN = os.environ['TOKEN']
|
||||
REDDIT_CLIENT_ID = os.environ['REDDIT_CLIENT_ID']
|
||||
@@ -33,9 +28,7 @@ REDDIT_CLIENT_USERAGENT = os.environ['REDDIT_CLIENT_USERAGENT']
|
||||
|
||||
AVATAR = "https://i.redd.it/0uajctrps9u41.jpg"
|
||||
|
||||
# LOGGING
|
||||
logger = logging.getLogger("discord")
|
||||
|
||||
logger.setLevel(logging.INFO)
|
||||
handler = logging.FileHandler(
|
||||
filename="logs/discord.log",
|
||||
@@ -45,12 +38,13 @@ handler.setFormatter(
|
||||
logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s"))
|
||||
logger.addHandler(handler)
|
||||
|
||||
# INIT
|
||||
|
||||
bot = commands.Bot(
|
||||
command_prefix=PREFIX,
|
||||
description="Holy Goddess Aqua!")
|
||||
|
||||
# LOAD COGS
|
||||
|
||||
########## Load Cogs
|
||||
cogs = [
|
||||
"cogs.admin",
|
||||
"cogs.anime",
|
||||
@@ -70,7 +64,8 @@ for cog in cogs:
|
||||
else:
|
||||
print(f"SUCCESS: Loaded {cog}")
|
||||
|
||||
# BOT STARTING EVENT
|
||||
|
||||
########## Start Bot
|
||||
@bot.event
|
||||
async def on_ready():
|
||||
"""
|
||||
@@ -92,9 +87,9 @@ async def on_ready():
|
||||
activity = discord.Activity(name=name, type=discord.ActivityType.playing)
|
||||
await bot.change_presence(activity=activity)
|
||||
|
||||
print(f"AquaBot is ready!\n")
|
||||
print("AquaBot is ready!\n")
|
||||
|
||||
|
||||
# START BOT
|
||||
bot.run(
|
||||
TOKEN,
|
||||
bot=True,
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
"""
|
||||
This framework can be used to create new Cogs, remember to add them in the config
|
||||
"""
|
||||
|
||||
# IMPORTS
|
||||
import discord
|
||||
|
||||
from discord.ext import commands
|
||||
|
||||
# COG INIT
|
||||
|
||||
class Foo(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
# COG BODY
|
||||
|
||||
# COG ENDING
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Foo(bot))
|
||||
|
||||
@@ -2,16 +2,14 @@
|
||||
Admin commands, that can be used from within the discord-client-chat
|
||||
"""
|
||||
|
||||
# IMPORTS
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
# COG INIT
|
||||
|
||||
class Admin(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
# COG BODY
|
||||
|
||||
@commands.command(name="load", hidden=True)
|
||||
@commands.is_owner()
|
||||
async def load(self, ctx, *, cog: str):
|
||||
@@ -55,6 +53,5 @@ class Admin(commands.Cog):
|
||||
await ctx.send('**`SUCCESS`**')
|
||||
|
||||
|
||||
# COG ENDING
|
||||
def setup(bot):
|
||||
bot.add_cog(Admin(bot))
|
||||
|
||||
@@ -2,20 +2,17 @@
|
||||
Some anime-related commands
|
||||
"""
|
||||
|
||||
# IMPORTS - external
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import random
|
||||
|
||||
# IMPORTS - internal
|
||||
import loaddata
|
||||
|
||||
# COG INIT
|
||||
|
||||
class Anime(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
# COG BODY
|
||||
|
||||
@commands.command(name="animepic")
|
||||
async def animemedia(self, ctx):
|
||||
"""
|
||||
@@ -26,6 +23,7 @@ class Anime(commands.Cog):
|
||||
media = random.choice(media_type)
|
||||
await ctx.send(media)
|
||||
|
||||
|
||||
@commands.command(name="waifupic")
|
||||
async def waifumedia(self, ctx, name: str):
|
||||
"""
|
||||
@@ -54,6 +52,5 @@ class Anime(commands.Cog):
|
||||
await ctx.send(text)
|
||||
|
||||
|
||||
# COG ENDING
|
||||
def setup(bot):
|
||||
bot.add_cog(Anime(bot))
|
||||
|
||||
@@ -2,19 +2,16 @@
|
||||
Some help for the users
|
||||
"""
|
||||
|
||||
# IMPORTS - external
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
# IMPORTS - internal
|
||||
from __main__ import PREFIX
|
||||
|
||||
# COG INIT
|
||||
|
||||
class Help(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
# COG BODY
|
||||
|
||||
@commands.command(name="aquabot")
|
||||
async def aquabot(self, ctx):
|
||||
"""
|
||||
@@ -33,6 +30,5 @@ class Help(commands.Cog):
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
|
||||
# COG ENDING
|
||||
def setup(bot):
|
||||
bot.add_cog(Help(bot))
|
||||
|
||||
@@ -2,20 +2,17 @@
|
||||
Send spicy memes to chat
|
||||
"""
|
||||
|
||||
# IMPORTS - external
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import random
|
||||
|
||||
# IMPORTS - internal
|
||||
import memes
|
||||
|
||||
# COG INIT
|
||||
|
||||
class Meme(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
# COG BODY
|
||||
|
||||
@commands.command(name="meme")
|
||||
async def meme(self, ctx, meme: str):
|
||||
"""
|
||||
@@ -40,7 +37,5 @@ class Meme(commands.Cog):
|
||||
await ctx.send("Meme not found in database")
|
||||
|
||||
|
||||
|
||||
# COG ENDING
|
||||
def setup(bot):
|
||||
bot.add_cog(Meme(bot))
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
"""
|
||||
Play Music
|
||||
|
||||
A COG NOT WRITTEN BY ME! ALTERED FROM THIS ONE:
|
||||
A COG ORIGINALLY CREATED BY ME, I ALTERED THIS ONE TO FIT MY NEEDS
|
||||
https://gist.github.com/vbe0201/ade9b80f2d3b64643d854938d40a0a2d
|
||||
"""
|
||||
|
||||
# IMPORTS - external
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import youtube_dl
|
||||
import functools
|
||||
@@ -16,7 +14,6 @@ import math
|
||||
import random
|
||||
from async_timeout import timeout
|
||||
|
||||
# COG BODY
|
||||
|
||||
class VoiceError(Exception):
|
||||
pass
|
||||
@@ -300,6 +297,7 @@ class Music(commands.Cog):
|
||||
ctx.voice_state.voice = await destination.connect()
|
||||
await ctx.message.add_reaction('🤙')
|
||||
|
||||
|
||||
@commands.command(name="leave", aliases=["dc"])
|
||||
async def leave(self, ctx: commands.Context):
|
||||
"""
|
||||
@@ -312,6 +310,7 @@ class Music(commands.Cog):
|
||||
del self.voice_states[ctx.guild.id]
|
||||
await ctx.message.add_reaction('👋')
|
||||
|
||||
|
||||
@commands.command(name="now", aliases=["np"])
|
||||
async def now(self, ctx: commands.Context):
|
||||
"""
|
||||
@@ -319,6 +318,7 @@ class Music(commands.Cog):
|
||||
"""
|
||||
await ctx.send(embed=ctx.voice_state.current.create_embed())
|
||||
|
||||
|
||||
@commands.command(name='pause')
|
||||
async def pause(self, ctx: commands.Context):
|
||||
"""
|
||||
@@ -328,6 +328,7 @@ class Music(commands.Cog):
|
||||
ctx.voice_state.voice.pause()
|
||||
await ctx.message.add_reaction('⏯')
|
||||
|
||||
|
||||
@commands.command(name='resume')
|
||||
async def resume(self, ctx: commands.Context):
|
||||
"""
|
||||
@@ -337,6 +338,7 @@ class Music(commands.Cog):
|
||||
ctx.voice_state.voice.resume()
|
||||
await ctx.message.add_reaction('⏯')
|
||||
|
||||
|
||||
@commands.command(name="skip")
|
||||
async def skip(self, ctx: commands.Context):
|
||||
"""
|
||||
@@ -348,6 +350,7 @@ class Music(commands.Cog):
|
||||
await ctx.message.add_reaction('⏭')
|
||||
ctx.voice_state.skip()
|
||||
|
||||
|
||||
@commands.command(name="clear")
|
||||
async def clear(self, ctx: commands.Context):
|
||||
"""
|
||||
@@ -356,6 +359,7 @@ class Music(commands.Cog):
|
||||
ctx.voice_state.songs.clear()
|
||||
await ctx.message.add_reaction('⏹')
|
||||
|
||||
|
||||
@commands.command(name='play')
|
||||
async def play(self, ctx: commands.Context, *, search: str):
|
||||
"""
|
||||
@@ -376,6 +380,7 @@ class Music(commands.Cog):
|
||||
await ctx.voice_state.songs.put(song)
|
||||
await ctx.send('Enqueued {}'.format(str(source)))
|
||||
|
||||
|
||||
@join.before_invoke
|
||||
@play.before_invoke
|
||||
async def ensure_voice_state(self, ctx: commands.Context):
|
||||
@@ -423,6 +428,6 @@ class Music(commands.Cog):
|
||||
.set_footer(text='Viewing page {}/{}'.format(page, pages)))
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
# COG ENDING
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Music(bot))
|
||||
|
||||
@@ -2,23 +2,20 @@
|
||||
Fetch pictures from subreddits
|
||||
"""
|
||||
|
||||
# IMPORTS - external
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import random
|
||||
import praw
|
||||
|
||||
# IMPORTS - internal
|
||||
from __main__ import REDDIT_CLIENT_ID
|
||||
from __main__ import REDDIT_CLIENT_SECRET
|
||||
from __main__ import REDDIT_CLIENT_USERAGENT
|
||||
|
||||
# COG INIT
|
||||
|
||||
class Reddit(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
# COG BODY
|
||||
|
||||
@commands.command(name="reddit")
|
||||
async def reddit(self, ctx, sub: str):
|
||||
"""
|
||||
@@ -37,6 +34,6 @@ class Reddit(commands.Cog):
|
||||
await ctx.send(f"> '{post.title}' by {post.author.name}")
|
||||
await ctx.send(post.url)
|
||||
|
||||
# COG ENDING
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Reddit(bot))
|
||||
|
||||
@@ -2,18 +2,15 @@
|
||||
A simple reminder option
|
||||
"""
|
||||
|
||||
# IMPORTS
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
# COG INIT
|
||||
|
||||
class Reminder(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
# COG BODY
|
||||
|
||||
|
||||
# COG ENDING
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Reminder(bot))
|
||||
|
||||
@@ -2,17 +2,15 @@
|
||||
Some (more or less) handy utility
|
||||
"""
|
||||
|
||||
# IMPORTS - external
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import random
|
||||
|
||||
# COG INIT
|
||||
|
||||
class Utility(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
# COG BODY
|
||||
|
||||
@commands.command(name="invitelink", aliases=["invite"])
|
||||
async def invite_link(self, ctx, age=60*10, uses=100):
|
||||
"""
|
||||
@@ -57,6 +55,5 @@ class Utility(commands.Cog):
|
||||
await ctx.send(response)
|
||||
|
||||
|
||||
# COG ENDING
|
||||
def setup(bot):
|
||||
bot.add_cog(Utility(bot))
|
||||
|
||||
@@ -2,16 +2,14 @@
|
||||
Welcoming new users etc.
|
||||
"""
|
||||
|
||||
# IMPORTS
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
||||
# COG INIT
|
||||
|
||||
class Welcome(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
# COG BODY
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_member_join(self, member):
|
||||
"""
|
||||
@@ -30,6 +28,5 @@ class Welcome(commands.Cog):
|
||||
await ctx.send(f"Hello {ctx.author.mention}!")
|
||||
|
||||
|
||||
# COG ENDING
|
||||
def setup(bot):
|
||||
bot.add_cog(Welcome(bot))
|
||||
|
||||
Reference in New Issue
Block a user