Skip to content

Commit

Permalink
Add Pingable roles
Browse files Browse the repository at this point in the history
  • Loading branch information
Pythonic-Rainbow committed Oct 7, 2023
1 parent d19f155 commit 2fc90a8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 19 deletions.
9 changes: 9 additions & 0 deletions DimBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <role>"""
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))
Expand Down
1 change: 1 addition & 0 deletions missile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
26 changes: 26 additions & 0 deletions sql/cfg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
20 changes: 1 addition & 19 deletions sql/mod.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
VALUES (:guild, :role, :perm);
14 changes: 14 additions & 0 deletions tribe.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
from sqlite3 import IntegrityError
from typing import Optional

import discord
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2fc90a8

Please sign in to comment.