diff --git a/DimBot.py b/DimBot.py index 2038c16..6e12edf 100644 --- a/DimBot.py +++ b/DimBot.py @@ -485,6 +485,15 @@ async def decode(ctx: commands.Context, content: str): await ctx.send('Malformed base64 string.') +@missile.guild_only() +@missile.bot_has_perm(mention_everyone=True) +@bot.command(brief='If the user is in the role, pings the role') +async def roleping(ctx: commands.Context, role: discord.Role): + """roleping """ + if not role.is_default() and not role.is_premium_subscriber() and role in ctx.author.roles: + await ctx.reply(role.mention) + + async def ready_tasks(): bot.add_cog(Ricciardo(bot)) # bot.add_cog(Verstapen(bot)) diff --git a/missile.py b/missile.py index 7c15341..5c8bdbd 100644 --- a/missile.py +++ b/missile.py @@ -134,6 +134,7 @@ async def check(ctx): def bot_has_perm(**kwargs): + """Checks whether DimBot has perms in that guild channel""" async def check(ctx): remote = ctx.guild.me.permissions_in(ctx.channel) has = remote.is_superset(discord.Permissions(**kwargs)) diff --git a/sql/cfg.sql b/sql/cfg.sql index e844df3..7558091 100644 --- a/sql/cfg.sql +++ b/sql/cfg.sql @@ -41,6 +41,32 @@ UPDATE GuildCfg SET antiInvisible = :invisible WHERE guildID = :guild; +--name: get-joinable-role^ +SELECT requiredRoleID, checkHighestRole +FROM RoleJoinable +WHERE roleID = :role; + +--name: add-joinable-role! +INSERT INTO RoleJoinable +VALUES (:role, :required, :checkHighest); + +--name: update-joinable-role! +UPDATE RoleJoinable +SET requiredRoleID = :required, checkHighestRole = :checkHighest +WHERE roleID = :role; + +--name: remove-joinable-role! +DELETE FROM RoleJoinable +WHERE roleID = :role; + +--name: add-role-ping! +INSERT INTO RolePing +VALUES (:role); + +--name: remove-role-ping! +DELETE FROM RolePing +WHERE roleID = :role; + /* * User cfg */ diff --git a/sql/mod.sql b/sql/mod.sql index 17c42fd..e77b834 100644 --- a/sql/mod.sql +++ b/sql/mod.sql @@ -39,22 +39,4 @@ WHERE guildID = :guild; --name: add-lockdown! INSERT INTO GuildLockdown -VALUES (:guild, :role, :perm); - ---name: get-joinable-role^ -SELECT requiredRoleID, checkHighestRole -FROM RoleJoinable -WHERE roleID = :role; - ---name: add-joinable-role! -INSERT INTO RoleJoinable -VALUES (:role, :required, :checkHighest); - ---name: update-joinable-role! -UPDATE RoleJoinable -SET requiredRoleID = :required, checkHighestRole = :checkHighest -WHERE roleID = :role; - ---name: remove-joinable-role! -DELETE FROM RoleJoinable -WHERE roleID = :role; \ No newline at end of file +VALUES (:guild, :role, :perm); \ No newline at end of file diff --git a/tribe.py b/tribe.py index 896aad4..e52ed8d 100644 --- a/tribe.py +++ b/tribe.py @@ -1,4 +1,5 @@ import asyncio +from sqlite3 import IntegrityError from typing import Optional import discord @@ -200,6 +201,19 @@ async def deljr(self, ctx: Context, role: discord.Role): await self.bot.sql.remove_joinable_role(self.bot.db, role=role.id) await ctx.reply('Deleted') + @guild.command() + async def roleping(self, ctx: Context, role: discord.Role): + if role.is_default() or role.is_premium_subscriber(): + await ctx.reply('The role cannot be the default role or Nitro role') + else: + resp = 'The role is no longer pingable by its members' + try: + await self.bot.sql.add_role_ping(self.bot.db, role=role.id) + resp = 'The role is now pingable by its members' + except IntegrityError: + await self.bot.sql.remove_role_ping(self.bot.db, role=role.id) + await ctx.reply(resp) + @group(brief='Settings for a user') async def user(self, ctx: Context): await self.send_grp_cmd_help(ctx)