-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandoBot.py
71 lines (54 loc) · 2.01 KB
/
RandoBot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import asyncio
import os
import nextcord
from nextcord.ext import commands
from cogwatch import watch
from cogs.utils import cogs, config
__author__ = "QuentiumYT"
__version__ = "2.2.1"
class RandoBot(commands.Bot):
def __init__(self):
intents = nextcord.Intents.all()
intents.message_content = True
intents.presences = False
super().__init__(
description="Rando Bot",
owner_id=246943045105221633,
help_command=None,
case_insensitive=True,
max_messages=999999,
intents=intents,
)
@watch(path="cogs")
async def on_ready(self):
print(f"Logged in as {self.user.name}#{self.user.discriminator}")
await self.change_presence(
status=nextcord.Status.online,
activity=nextcord.Activity(
name="Prépare une rando...",
type=nextcord.ActivityType.playing,
)
)
async def on_raw_reaction_add(self, ctx):
if not ctx.member.bot and any(ctx.emoji.name == x for x in ["Check", "Average"]):
role = nextcord.utils.get(ctx.member.guild.roles, id=config.get(ctx.guild_id, "role_next_rando"))
try:
await ctx.member.add_roles(role)
except nextcord.errors.Forbidden:
pass
async def on_raw_reaction_remove(self, ctx):
guild = nextcord.utils.get(self.guilds, id=ctx.guild_id)
user = nextcord.utils.get(guild.members, id=ctx.user_id)
if not user.bot and any(ctx.emoji.name == x for x in ["Check", "Average", "Cross"]):
role = nextcord.utils.get(guild.roles, id=config.get(ctx.guild_id, "role_next_rando"))
try:
await user.remove_roles(role)
except nextcord.errors.Forbidden:
pass
async def main():
bot = RandoBot()
for cog in cogs:
bot.load_extension(f"cogs.{cog}")
await bot.start(os.environ.get("TOKEN"))
if __name__ == "__main__":
asyncio.run(main())