2019-10-04 13:10:27 -04:00
|
|
|
"""
|
2019-10-04 19:45:59 -04:00
|
|
|
Base cog for qrm
|
2019-10-04 13:10:27 -04:00
|
|
|
---
|
2019-10-04 18:05:57 -04:00
|
|
|
|
|
|
|
Copyright (C) 2019 Abigail Gold, 0x5c
|
|
|
|
|
|
|
|
This file is part of discord-qrmbot.
|
|
|
|
|
|
|
|
discord-qrmbot is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2019-10-04 13:10:27 -04:00
|
|
|
"""
|
|
|
|
|
|
|
|
import discord
|
|
|
|
import discord.ext.commands as commands
|
|
|
|
|
2019-10-04 18:26:20 -04:00
|
|
|
import os
|
2019-10-04 13:10:27 -04:00
|
|
|
|
2019-10-04 18:16:47 -04:00
|
|
|
class BaseCog(commands.Cog):
|
2019-10-04 13:10:27 -04:00
|
|
|
def __init__(self, bot):
|
|
|
|
self.bot = bot
|
|
|
|
self.gs = bot.get_cog("GlobalSettings")
|
|
|
|
|
|
|
|
@commands.command(name="info", aliases=["about"])
|
|
|
|
async def _info(self, ctx):
|
|
|
|
"""Shows info about qrm."""
|
|
|
|
embed = discord.Embed(title="About qrm", description=self.gs.info.description, colour=self.gs.colours.neutral)
|
|
|
|
embed = embed.add_field(name="Authors", value=", ".join(self.gs.info.authors))
|
|
|
|
embed = embed.add_field(name="Contributing", value=self.gs.info.contributing)
|
|
|
|
embed = embed.add_field(name="License", value=self.gs.info.license)
|
|
|
|
await ctx.send(embed=embed)
|
|
|
|
|
2019-10-04 13:46:40 -04:00
|
|
|
@commands.command(name="restart")
|
|
|
|
async def _restart_bot(self, ctx):
|
|
|
|
"""Restarts the bot."""
|
|
|
|
if ctx.author.id in self.gs.opt.owners_uids:
|
|
|
|
await ctx.message.add_reaction("✅")
|
|
|
|
await self.bot.logout()
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
await ctx.message.add_reaction("❌")
|
|
|
|
except:
|
|
|
|
return
|
|
|
|
|
2019-10-04 18:26:20 -04:00
|
|
|
@commands.command(name="shutdown")
|
|
|
|
async def _shutdown_bot(self, ctx):
|
|
|
|
"""Shuts down the bot."""
|
|
|
|
if ctx.author.id in self.gs.opt.owners_uids:
|
|
|
|
await ctx.message.add_reaction("✅")
|
|
|
|
os._exit(42)
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
await ctx.message.add_reaction("❌")
|
|
|
|
except:
|
|
|
|
return
|
2019-10-04 13:10:27 -04:00
|
|
|
|
2019-10-04 19:48:58 -04:00
|
|
|
@commands.command(name="ping")
|
2019-10-04 19:45:59 -04:00
|
|
|
async def _ping(self, ctx):
|
|
|
|
await ctx.send(f'**Pong!** Current ping is {self.bot.latency*1000:.1f} ms')
|
|
|
|
|
|
|
|
|
2019-10-04 13:10:27 -04:00
|
|
|
def setup(bot):
|
2019-10-04 18:16:47 -04:00
|
|
|
bot.add_cog(BaseCog(bot))
|