-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from Code4GovTech/main
Bring development alongside main
- Loading branch information
Showing
6 changed files
with
264 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from discord.ext import commands | ||
import discord | ||
from utils.db import SupabaseInterface | ||
|
||
class Listeners(commands.Cog): | ||
def __init__(self, bot) -> None: | ||
super().__init__() | ||
self.bot = bot | ||
|
||
async def grantVerifiedRole(self, member: discord.Member): | ||
verifiedContributorRoleID = 1123967402175119482 | ||
try: | ||
verifiedContributorRole = member.guild.get_role(verifiedContributorRoleID) | ||
if verifiedContributorRole: | ||
if verifiedContributorRole not in member.roles: | ||
await member.add_roles(verifiedContributorRole, reason="Completed Auth and Introduction") | ||
else: | ||
print("Verified Contributor Role not found") | ||
except Exception as e: | ||
print("Exception while granting Role:", e) | ||
|
||
async def isAuthenticated(self, memberID: int) -> bool: | ||
if SupabaseInterface("contributors").read("discord_id", memberID): | ||
return True | ||
else: | ||
return False | ||
|
||
|
||
@commands.Cog.listener("on_message") | ||
async def listenForIntroduction(self, message: discord.Message): | ||
if message.channel.id == 1107343423167541328: #intro channel | ||
if await self.isAuthenticated(message.author.id): | ||
await self.grantVerifiedRole(message.author) | ||
else: | ||
return | ||
|
||
|
||
async def setup(bot: commands.Bot): | ||
await bot.add_cog(Listeners(bot)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters