ziyadm / test-bot-repo

0 stars 0 forks source link

fix command permissioning when syncing command tree #131

Closed github-actions[bot] closed 1 year ago

github-actions[bot] commented 1 year ago

https://github.com/ziyadm/test-bot-repo/blob/46c3bc460127cc16d6ff161ff2d2d90d99f48860/event_handler.py#L16


        self.__state = state

    async def on_ready(self):
        guild = discord.Object(id=self.__state.discord_client.guild_id)

        commands = await self.__state.discord_client.command_tree.fetch_commands(guild=guild)

        # TODO: fix command permissioning when syncing command tree
        for command in commands:
            slash_command_to_permission = SlashCommand.of_string(command.name)
            if slash_command_to_permission is not None and slash_command_to_permission.admin_only():
                _ = await command.edit(
                    default_member_permissions=discord.Permissions(administrator=True)
                )

        all_reviews_channel = await self.__state.discord_client.all_reviews_channel()
        _ = await all_reviews_channel.send("Running bot")

        await self.__state.discord_client.command_tree.sync(guild=guild)

        print("Running bot")

    async def on_member_join(self, member: discord.Member):
github-actions[bot] commented 1 year ago

Closed in 8d1675c10675fef5865794240605c7a433e1c1d7