Create structure

This commit creates the first, inital structure for the project.
This commit is contained in:
CramMK
2020-01-17 15:09:53 +00:00
parent 13bcf884d9
commit 7e805ff13a
11 changed files with 277 additions and 12 deletions

0
cogs/__init__.py Normal file
View File

62
cogs/admin.py Normal file
View File

@@ -0,0 +1,62 @@
#
# A Cog that add admin command, usable within the Discord Client
#
# https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
#
# "load", "unload", "reload"
# https://gist.github.com/EvieePy/d78c061a4798ae81be9825468fe146be
#
# IMPORTS
import discord
from discord.ext import commands
# COG INIT
class AdminCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
# COG BODY
# used as "load cogs.COGNAME"
@commands.command(name="load", hidden=True)
@commands.is_owner()
async def cog_load(self, ctx, *, cog: str):
try:
self.bot.load_extension(cog)
except Exception as e:
await ctx.send(f'**`ERROR:`** {type(e).__name__} - {e}')
else:
await ctx.send('**`SUCCESS`**')
# used as "unload cogs.COGNAME"
@commands.command(name="unload", hidden=True)
@commands.is_owner()
async def cog_unload(self, ctx, *, cog: str):
try:
self.bot.unload_extension(cog)
except Exception as e:
await ctx.send(f'**`ERROR:`** {type(e).__name__} - {e}')
else:
await ctx.send('**`SUCCESS`**')
# used as "reload cogs.COGNAME"
@commands.command(name="reload", hidden=True)
@commands.is_owner()
async def cog_reload(self, ctx, *, cog: str):
try:
self.bot.unload_extension(cog)
self.bot.load_extension(cog)
except Exception as e:
await ctx.send(f'**`ERROR:`** {type(e).__name__} - {e}')
else:
await ctx.send('**`SUCCESS`**')
# COG ENDING
def setup(bot):
bot.add_cog(AdminCog(bot))

20
cogs/cog_framework.py Normal file
View File

@@ -0,0 +1,20 @@
#
# foo
#
# https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
#
# IMPORTS
import discord
from discord.ext import commands
# COG INIT
class FooCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
# COG BODY
# COG ENDING
def setup(bot):
bot.add_cog(FooCog(bot))

49
cogs/general.py Normal file
View File

@@ -0,0 +1,49 @@
#
# A Cog that add some general commands
#
# https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
#
# IMPORTS
import discord
from discord.ext import commands
# COG INIT
class GeneralCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
# COG BODY
@commands.command(
name="invitelink",
description="Sends the invite link",
aliases=["invite"]
)
async def invite_link(self, ctx):
# TODO fetch this from config so more servers are supported
link = "Here is our invite link: https://discordapp.com/invite/HbYfyJT"
await ctx.send(link)
@commands.command(
name="pat",
description="Pats the selected user"
)
@commands.guild_only()
async def pat(self, ctx, target: str):
author = ctx.message.author
if target is None:
response = "No one to pat..."
else if target.capitalize == "Noel":
response = "NNN-GYAAAA!"
else:
response = f"{target.mention} got pat by {author.mention}"
await ctx.send(response)
# COG ENDING
def setup(bot):
bot.add_cog(GeneralCog(bot))

31
cogs/help.py Normal file
View File

@@ -0,0 +1,31 @@
#
# Cog for a custom Help Command
#
# https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
#
# IMPORTS
import discord
from discord.ext import commands
# COG INIT
class HelpCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
# COG BODY
@commands.command(
name="aquabot"
description="Prints a short help for new users"
)
async def aquabot(self, ctx):
await ctx.send("""
I'm the usele... divine AquaBot!\n
If you need help, try using the `help` command!\n
""")
# COG ENDING
def setup(bot):
bot.add_cog(HelpCog(bot))

36
cogs/welcome.py Normal file
View File

@@ -0,0 +1,36 @@
#
# A Cog thats deals with welcoming new users etc.
#
# https://discordpy.readthedocs.io/en/latest/ext/commands/cogs.html
#
# IMPORTS
import discord
from discord.ext import commands
# COG INIT
class WelcomeCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
# COG BODY
@commands.Cog.listener()
async def on_member_join(self, member):
channel = member.guild.system_channel
text = f"Welcome {member.mention} to our useless Discord!"
if channel is Not None:
await channel.send(text)
@commands.command(
name="hello",
description="Hello!"
)
async def hello(self, ctx):
await ctx.send(f"Hello {ctx.author}!")
# COG ENDING
def setup(bot):
bot.add_cog(WelcomeCog(bot))