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