Total Complexity | 5 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from typing import Optional |
||
2 | |||
3 | from discord import TextChannel |
||
4 | from discord.ext import commands |
||
5 | |||
6 | from app.bot import Bot |
||
7 | |||
8 | CHANNEL_ID = 900370744263966821 |
||
9 | ROLE_ID = 888527962935296091 |
||
10 | |||
11 | |||
12 | class WorkerRole(commands.Cog): |
||
13 | """A simple commands cog template.""" |
||
14 | |||
15 | def __init__(self, client: Bot): |
||
16 | """Link to bot instance.""" |
||
17 | self.client: Bot = client |
||
18 | self.channel: Optional[TextChannel] = None |
||
19 | |||
20 | @commands.Cog.listener() |
||
21 | async def on_ready(self): |
||
22 | self.channel = self.client.guild.get_channel(CHANNEL_ID) |
||
23 | |||
24 | @commands.Cog.listener() |
||
25 | async def on_member_update(self, before, after): |
||
26 | diff_roles = [ |
||
27 | role.id for role in after.roles if role not in before.roles |
||
28 | ] |
||
29 | |||
30 | if ROLE_ID in diff_roles: |
||
31 | await self.channel.send(f"{after.mention}") |
||
32 | |||
33 | |||
34 | def setup(client: Bot): |
||
35 | client.add_cog(WorkerRole(client)) |
||
36 |