diff --git a/bot.py b/bot.py index a1ea94e..546cb30 100644 --- a/bot.py +++ b/bot.py @@ -19,9 +19,15 @@ def right(s, amount): def mid(s, offset, amount): return s[offset:offset+amount] +intents = discord.Intents( + guilds=True, + members=True, + messages=True, +) + token = os.environ['TOKEN'] prefix = os.environ['PREFIX'] -bot = commands.Bot(command_prefix=prefix) +bot = commands.Bot(intents=intents, command_prefix=prefix) client = discord.Client() admin_role=261603488331595776 @@ -230,23 +236,18 @@ async def say(ctx, *, arg): @bot.command(help="Starte ne Runde PnP", usage="@Rolle") @is_gm() -async def start(ctx, role_id): +async def start(ctx, role_mention): await ctx.message.delete() - role_id = right(left(role_id, len(role_id)-1), len(role_id) - 4) - for r in ctx.author.roles: - if str(r.id) == role_id: - role = r + await pnp_info = ctx.guild.fetch_channel(435501602485305345) + await pnp_voice = ctx.guild.fetch_channel(435869507123281920) + role = ctx.message.role_mentions[0] em = discord.Embed(description='gespieltes PnP: %s\nTeilnehmer (zum Start):' % role.mention, colour=0x00770d) - move_member = [] - for c in ctx.guild.channels: - if str(c.type) == "voice": - for m in c.members: - if role in m.roles: - move_member.append(m) - for m in move_member: - await m.move_to(bot.get_channel(435869507123281920)) - em.add_field(name=":white_check_mark: " + m.display_name, value = m.mention + "ist am Start! Juhu!", inline=False) - start_msg = await bot.get_channel(435501602485305345).send(content=":game_die: **INFO: PnP Sitzung gestartet!**",embed=em) + for c in ctx.guild.voice_channels: + for m in c.members: + if role in m.roles: + await m.move_to(pnp_voice) + em.add_field(name=":white_check_mark: " + m.display_name, value = m.mention + " ist am Start! Juhu!", inline=False) + start_msg = await pnp_info.send(content=":game_die: **INFO: PnP Sitzung gestartet!**",embed=em) text_file = open("start_id.txt", "w") text_file.write(str(start_msg.id)) text_file.close() @@ -255,15 +256,18 @@ async def start(ctx, role_id): @is_gm() async def stop(ctx): await ctx.message.delete() + await pnp_info = ctx.guild.fetch_channel(435501602485305345) + await pnp_voice = ctx.guild.fetch_channel(435869507123281920) + await move_to_talk = ctx.guild.fetch_channel(801869864745697280) text_file = open("start_id.txt", "r") start_id = text_file.read() text_file.close() - start_msg = await bot.get_channel(435501602485305345).fetch_message(start_id) + start_msg = await pnp_info.fetch_message(start_id) now_time = datetime.datetime.utcnow().replace(microsecond=0, tzinfo=datetime.timezone.utc) then_time = start_msg.created_at.replace(microsecond=0, tzinfo=datetime.timezone.utc) dauer = str(now_time - then_time) - for m in bot.get_channel(435869507123281920).members: - await m.move_to(bot.get_channel(801869864745697280)) + for m in pnp_voice.members: + await m.move_to(move_to_talk) await start_msg.edit(content=":game_die: **INFO: PnP Sitzung beendet!** Dauer: %s" % dauer) @bot.command(help="bringt dich ins Labor :)", usage="")