|
| 1 | +import os |
| 2 | + |
1 | 3 | import discord
|
2 | 4 | from discord.ext import commands
|
3 |
| -from enum import Enum, unique |
4 | 5 |
|
5 | 6 | from bot import VERSION
|
6 | 7 |
|
7 |
| -client = commands.Bot(command_prefix=commands.when_mentioned_or('$'), |
8 |
| - help_command=None, |
9 |
| - intents=discord.Intents.all(), |
10 |
| - case_insensitive=True) |
11 |
| - |
12 |
| - |
13 |
| -@unique |
14 |
| -class Cinturoes(Enum): |
15 |
| - Branco = 1 |
16 |
| - Amarelo = 2 |
17 |
| - Azul = 3 |
18 |
| - Verde = 4 |
19 |
| - Laranja = 5 |
20 |
| - Vermelho = 6 |
21 |
| - Roxo = 7 |
22 |
| - Preto = 8 |
23 |
| - |
24 |
| - |
25 |
| -class Ninja_data(): |
26 |
| - def __init__(self, guild, member): |
27 |
| - self.guild = guild |
28 |
| - self.member = member |
29 |
| - |
30 |
| - def current_belt(self): |
31 |
| - for belt in self.member.roles: |
32 |
| - for cinturao in Cinturoes: |
33 |
| - if cinturao.name == belt.name: |
34 |
| - return belt |
35 |
| - |
36 |
| - def next_belt(self): |
37 |
| - for belt in self.member.roles: |
38 |
| - for cinturao in Cinturoes: |
39 |
| - if cinturao.name == belt.name: |
40 |
| - next_cinturao_value = cinturao.value + 1 |
41 |
| - return get_role_from_name( |
42 |
| - self.guild, |
43 |
| - Cinturoes(next_cinturao_value).name) |
44 |
| - |
45 |
| - |
46 |
| -def get_role_from_name(guild, belt_name): |
47 |
| - for role in guild.roles: |
48 |
| - if role.name == belt_name: |
49 |
| - return role |
50 |
| - |
| 8 | +client = commands.Bot( |
| 9 | + command_prefix = commands.when_mentioned_or('$'), |
| 10 | + help_command = None, |
| 11 | + intents = discord.Intents.all(), |
| 12 | + case_insensitive = True |
| 13 | +) |
51 | 14 |
|
52 | 15 | @client.event
|
53 | 16 | async def on_ready():
|
54 | 17 | print(f'We have logged in as {client.user}')
|
55 | 18 |
|
56 |
| - |
57 | 19 | @client.command()
|
58 |
| -@commands.has_any_role("🛡️ Admin", "🏆 Champion", "🧑🏫 Mentores") |
59 |
| -async def promove(ctx, user, belt): |
60 |
| - await ctx.send(f"<@{ctx.message.author.id}> quer promover {user} a {belt}") |
61 |
| - |
62 |
| - mentions = ctx.message.raw_mentions #List of id mentions in the command |
63 |
| - guild = ctx.guild #Guild of the command |
64 |
| - member = guild.get_member( |
65 |
| - mentions[0]) #gets the member of the mentioned id |
66 |
| - |
67 |
| - ninja = Ninja_data(guild, member) |
68 |
| - |
69 |
| - if belt == "Branco": |
70 |
| - |
71 |
| - cinturao = get_role_from_name(guild, "Branco").id |
72 |
| - await member.add_roles(guild.get_role(cinturao), |
73 |
| - reason=None, |
74 |
| - atomic=True) |
75 |
| - |
76 |
| - await ctx.send(f'{user} agora és cinturão {belt}') |
| 20 | +async def load(ctx, extension): |
| 21 | + client.load_extension(f'bot.cogs.{extension}') |
| 22 | + |
| 23 | + await ctx.send( |
| 24 | + f'O cog {extension} foi ativado.' |
| 25 | + ) |
77 | 26 |
|
78 |
| - elif belt == ninja.current_belt().name: |
79 |
| - |
80 |
| - await ctx.send( |
81 |
| - f'<@{ctx.message.author.id}> esse já é o cinturão atual do ninja {user}' |
82 |
| - ) |
83 |
| - |
84 |
| - elif ninja.next_belt().name == belt: |
85 |
| - |
86 |
| - await member.add_roles(guild.get_role(ninja.next_belt().id), |
87 |
| - reason=None, |
88 |
| - atomic=True) |
89 |
| - await member.remove_roles(guild.get_role(ninja.current_belt().id), |
90 |
| - reason=None, |
91 |
| - atomic=True) |
| 27 | +@client.command() |
| 28 | +async def unload(ctx, extension): |
| 29 | + client.unload_extension(f'bot.cogs.{extension}') |
| 30 | + |
| 31 | + await ctx.send( |
| 32 | + f'O cog {extension} foi desativado.' |
| 33 | + ) |
92 | 34 |
|
93 |
| - await ctx.send(f'{user} agora és cinturão {belt}') |
| 35 | +for filename in os.listdir('bot/cogs'): |
| 36 | + if filename.endswith('.py'): |
| 37 | + client.load_extension(f'bot.cogs.{filename[:-3]}') |
94 | 38 |
|
95 |
| - else: |
96 |
| - await ctx.send( |
97 |
| - f'<@{ctx.message.author.id}> esse cinturão não é valido de se ser atribuido' |
98 |
| - ) |
0 commit comments