mirror of https://github.com/miaowware/qrm2.git
*COGS COGS COGS COG COGS COGS*
- Added GlobalSettings cog to allow extensions to access "global" settings - Moved _info() to a separate cog - added default on_ready() stuff
This commit is contained in:
parent
c8c2e80099
commit
0d7dc3853c
|
@ -0,0 +1,26 @@
|
||||||
|
"""
|
||||||
|
Info cog for qrm
|
||||||
|
---
|
||||||
|
"""
|
||||||
|
|
||||||
|
import discord
|
||||||
|
import discord.ext.commands as commands
|
||||||
|
|
||||||
|
|
||||||
|
class InfoCog(commands.Cog):
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
def setup(bot):
|
||||||
|
bot.add_cog(InfoCog(bot))
|
33
main.py
33
main.py
|
@ -22,7 +22,16 @@ import keys
|
||||||
debug_mode = opt.debug # Separate assignement in-case we define an override (ternary operator goes here)
|
debug_mode = opt.debug # Separate assignement in-case we define an override (ternary operator goes here)
|
||||||
|
|
||||||
|
|
||||||
bot_colours = SimpleNamespace(good=0x2dc614, neutral=0x2044f7, bad=0xc91628)
|
class GlobalSettings(commands.Cog):
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
self.opt = opt
|
||||||
|
self.keys = keys
|
||||||
|
self.info = info
|
||||||
|
|
||||||
|
self.colours = SimpleNamespace(good=0x2dc614, neutral=0x2044f7, bad=0xc91628)
|
||||||
|
self.debug = debug_mode
|
||||||
|
|
||||||
|
|
||||||
# --- Bot setup ---
|
# --- Bot setup ---
|
||||||
|
@ -32,14 +41,20 @@ bot = commands.Bot(command_prefix=opt.prefix, description=info.description, help
|
||||||
|
|
||||||
# --- Commands ---
|
# --- Commands ---
|
||||||
|
|
||||||
@bot.command(name="info", aliases=["about"])
|
|
||||||
async def _info(ctx):
|
# --- Events ---
|
||||||
"""Shows info about qrm."""
|
|
||||||
embed = discord.Embed(title="About qrm", description=info.description, colour=bot_colours.neutral)
|
@bot.event
|
||||||
embed = embed.add_field(name="Authors", value=", ".join(info.authors))
|
async def on_ready():
|
||||||
embed = embed.add_field(name="Contributing", value=info.contributing)
|
print(f"Logged in as: {bot.user} - {bot.user.id}")
|
||||||
embed = embed.add_field(name="License", value=info.license)
|
print("------")
|
||||||
await ctx.send(embed=embed)
|
await bot.change_presence(activity=discord.Game(name="with lids on 7.200"))
|
||||||
|
|
||||||
|
|
||||||
|
# --- Run ---
|
||||||
|
|
||||||
|
bot.add_cog(GlobalSettings(bot))
|
||||||
|
bot.load_extension("cogs.infocog")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
bot.run(keys.discord_token)
|
bot.run(keys.discord_token)
|
||||||
|
|
Loading…
Reference in New Issue