1
|
|
|
"""Rank features cog for CCC Bot""" |
2
|
|
|
import discord.utils |
3
|
|
|
from discord.ext import commands |
4
|
|
|
from bot.utils import make_embed, error_message |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
class RankCog(commands.Cog, name="Rank"): |
8
|
|
|
"""Rank Cog |
9
|
|
|
Cog that deals with rank commands |
10
|
|
|
|
11
|
|
|
**Commands:** |
12
|
|
|
- `add-rank`: Command that add either student, alumni, or professor role. |
13
|
|
|
""" |
14
|
|
|
|
15
|
|
|
def __init__(self, bot): |
16
|
|
|
self.bot = bot |
17
|
|
|
|
18
|
|
|
@commands.command(name="add-rank", help="Assigns student, alumni or professor role.") |
19
|
|
|
@commands.has_role("verified") |
20
|
|
|
async def add_rank(self, ctx: commands.Context, *, rank: str) -> None: |
21
|
|
|
"""Add Rank |
22
|
|
|
|
23
|
|
|
Allows users to set student, alumni or professor role. |
24
|
|
|
|
25
|
|
|
:param ctx: Command context |
26
|
|
|
:type ctx: discord.ext.commands.Context |
27
|
|
|
:param rank: Name of rank to add |
28
|
|
|
:type rank: str |
29
|
|
|
:return: None |
30
|
|
|
""" |
31
|
|
|
user = ctx.message.author |
32
|
|
|
ranks = ["student", "professor", "alumni"] |
33
|
|
|
checked = [i for i in user.roles if i.name.lower() in ranks] |
34
|
|
|
if len(checked) > 0: |
35
|
|
|
await error_message(ctx, "You already have a rank.") |
36
|
|
|
else: |
37
|
|
|
await user.add_roles(discord.utils.get(ctx.guild.roles, name=rank)) |
38
|
|
|
await make_embed( |
39
|
|
|
ctx, |
40
|
|
|
color="28b463", |
41
|
|
|
title="Success", |
42
|
|
|
description="Rank assigned successfully", |
43
|
|
|
) |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
def setup(bot): |
47
|
|
|
"""Needed for extension loading""" |
48
|
|
|
bot.add_cog(RankCog(bot)) |
49
|
|
|
|