From 9562f66f3260f8e962471fdddfc77f26a3587328 Mon Sep 17 00:00:00 2001 From: osmarks Date: Wed, 25 Nov 2020 19:00:43 +0000 Subject: [PATCH] =?UTF-8?q?Heavserver=20Role=20Addition=20Engine=E2=84=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/heavserver.py | 22 ++++++++++++++++++++++ src/main.py | 7 +++++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/heavserver.py diff --git a/src/heavserver.py b/src/heavserver.py new file mode 100644 index 0000000..35c63d2 --- /dev/null +++ b/src/heavserver.py @@ -0,0 +1,22 @@ +import util +import random +import logging +import discord + +def setup(bot): + @bot.listen() + async def on_member_join(member): + if member.guild.id == util.config["heavserver"]["id"]: + logging.info("%s (%d) joined heavserver", member.name, member.id) + if member.bot: + print(member.guild, member.guild.roles) + await member.add_roles(discord.utils.get(member.guild.roles, id=util.config["heavserver"]["quarantine_role"])) + mod_roles = set() + can_add = util.config["heavserver"]["moderator_roles"][:] + while True: + x = random.choice(can_add) + role = discord.utils.get(member.guild.roles, id=x) + mod_roles.add(role) + can_add.remove(x) + if random.randint(0, 3) != 0 or len(can_add) == 0: break + await member.add_roles(*mod_roles) \ No newline at end of file diff --git a/src/main.py b/src/main.py index 05b4f7f..6e32213 100644 --- a/src/main.py +++ b/src/main.py @@ -22,11 +22,13 @@ config = util.config logging.basicConfig(level=logging.INFO, format="%(levelname)s %(asctime)s %(message)s", datefmt="%H:%M:%S %d/%m/%Y") +#intents = discord.Intents.default() +#intents.members = True + bot = commands.Bot(command_prefix=config["prefix"], description="AutoBotRobot, the most useless bot in the known universe.", case_insensitive=True, allowed_mentions=discord.AllowedMentions(everyone=False, users=True, roles=True)) bot._skip_check = lambda x, y: False - cleaner = discord.ext.commands.clean_content() def clean(ctx, text): return cleaner.convert(ctx, text) @@ -216,7 +218,8 @@ async def run_bot(): "reminders", "debug", "telephone", - "achievement" + "achievement", + "heavserver" ): bot.load_extension(ext) await bot.start(config["token"])