diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a5cf83..7598096 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - The ability to select an element of a pool in `?hamstudy`. - The ability to answer ❓ to a HamStudy question to get the answer. - The list of available prefixes to `?help` when there is more than one. +- `?donate` command to show ways to support qrm's development. +- `?invite` command to invite qrm to your server. ### Changed - New colour theme for `?greyline`. - Moved great circle distance and bearing calculation from `?ungrid` to `?griddistance`. diff --git a/exts/base.py b/exts/base.py index ebf6627..9d14cf2 100644 --- a/exts/base.py +++ b/exts/base.py @@ -18,6 +18,7 @@ import discord.ext.commands as commands import info import common as cmn +from data import options as opt class QrmHelpCommand(commands.HelpCommand): @@ -120,6 +121,20 @@ class BaseCog(commands.Cog): self.commit = bf.readline().strip()[:7] else: self.commit = "" + self.donation_links = { + "Ko-Fi": "https://ko-fi.com/miaowware", + "LiberaPay": "https://liberapay.com/miaowware", + } + self.bot_invite = None + if self.bot.user: + self.bot_invite = (f"https://discordapp.com/oauth2/authorize?client_id={self.bot.user.id}" + f"&scope=bot&permissions={opt.invite_perms}") + + @commands.Cog.listener() + async def on_ready(self): + if not self.bot_invite: + self.bot_invite = (f"https://discordapp.com/oauth2/authorize?client_id={self.bot.user.id}" + f"&scope=bot&permissions={opt.invite_perms}") @commands.command(name="info", aliases=["about"]) async def _info(self, ctx: commands.Context): @@ -132,6 +147,10 @@ class BaseCog(commands.Cog): embed.add_field(name="Version", value=f"v{info.release} {'(`' + self.commit + '`)' if self.commit else ''}") embed.add_field(name="Contributing", value=info.contributing, inline=False) embed.add_field(name="Official Server", value=info.bot_server, inline=False) + embed.add_field(name="Donate", value="\n".join(f"{k}: {v}" for k, v in self.donation_links.items()), + inline=False) + if opt.enable_invite_cmd: + embed.add_field(name="Invite qrm to Your Server", value=self.bot_invite, inline=False) embed.set_thumbnail(url=str(self.bot.user.avatar_url)) await ctx.send(embed=embed) @@ -196,6 +215,25 @@ class BaseCog(commands.Cog): [miaowware/qrm-resources](https://github.com/miaowware/qrm-resources/issues).""" await ctx.send(embed=embed) + @commands.command(name="donate") + async def _donate(self, ctx: commands.Context): + """Shows ways to help support development of the bot via donations.""" + embed = cmn.embed_factory(ctx) + embed.title = "Help Support qrm's Development!" + embed.description = ("Donations are always appreciated, and help with server and infrastructure costs." + "\nThank you for your support!") + for title, url in self.donation_links.items(): + embed.add_field(name=title, value=url, inline=False) + await ctx.send(embed=embed) + + @commands.command(name="invite", enabled=opt.enable_invite_cmd) + async def _invite(self, ctx: commands.Context): + """Generates a link to invite the bot to a server.""" + embed = cmn.embed_factory(ctx) + embed.title = "Invite qrm to Your Server!" + embed.description = self.bot_invite + await ctx.send(embed=embed) + @commands.command(name="echo", aliases=["e"], category=cmn.cat.admin) @commands.check(cmn.check_if_owner) async def _echo(self, ctx: commands.Context, diff --git a/templates/data/options.py b/templates/data/options.py index e4d66f7..1a19563 100644 --- a/templates/data/options.py +++ b/templates/data/options.py @@ -46,6 +46,13 @@ exts = [ "propagation", ] +# enable a command that provides a link to add the bot to a server +enable_invite_cmd = True + +# the default permissions for the bot, to be included in the invite link for ?invite +# this probably does not need to be changed +invite_perms = 67488832 + # Either "time", "random", or "fixed" (first item in statuses) status_mode = "fixed"