diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d2164ab..789452f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,8 +26,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pipenv - pipenv install + pip install flake8 pipenv - name: Lint with flake8 run: | flake8 . --count --ignore=E501,E722,C901 --select=E9,F63,F7,F82 --show-source --statistics diff --git a/cogs/ban_member.py b/cogs/ban_member.py index 9952f20..ee010b1 100644 --- a/cogs/ban_member.py +++ b/cogs/ban_member.py @@ -10,19 +10,15 @@ def __init__(self, bot: commands.Bot) -> None: @app_commands.command(name="ban_member", description="Banされたユーザー一覧を表示します。") async def ban_members(self, i: discord.Interaction): m = [] - try: - if i.guild.channels.permissions_for(i.user) == discord.Permissions.ban_members: - if i.guild.channels.permissions_for(i.guild.get_member(self.bot.user.id)) == discord.Permissions.ban_members: - async for entry in i.guild.bans(limit=150): - m.append(f"{entry.user.name}, ") - send_content = "".join(m) - await i.response.send_message(send_content) - else: - await i.response.send_message("データを取得できませんでした(Botの権限がないなどの原因で)", ephemeral=True) - else: - await i.response.send_message("データを取得できませんでした(権限がないなどの原因で)", ephemeral=True) - except: - await i.response.send_message("データを取得できませんでした(権限がないなどの原因で)", ephemeral=True) + async for entry in i.guild.bans(limit=999999): + m.append(f"{entry.user.name}, ") + if not len(m) == 0: + end = len(m) - 1 + m[end] = m[end].split(', ')[0] + send_content = "".join(m) + elif len(m) == 0: + send_content = "Banされたユーザーはいません。" + await i.response.send_message(send_content) async def setup(bot: commands.Bot) -> None: diff --git a/cogs/role_all.py b/cogs/role_all.py index f215fd1..be0a550 100644 --- a/cogs/role_all.py +++ b/cogs/role_all.py @@ -15,30 +15,30 @@ def __init__(self, bot: commands.Bot) -> None: @app_commands.describe(bot='Botにもロールを付与する?') @app_commands.choices(bot=[ - app_commands.Choice(name='はい', value=True), - app_commands.Choice(name='いいえ', value=False), + app_commands.Choice(name='はい', value="y"), + app_commands.Choice(name='いいえ', value="f"), ]) @app_commands.command(name="role_all_add", description="全メンバーにロールを付与します。") - async def roleall_add(self, i: discord.Interaction, role: discord.Role, bot: bool): - if bot: + async def roleall_add(self, i: discord.Interaction, role: discord.Role, bot: str): + if bot == 'y': for member in i.guild.members: await member.add_roles(role) - elif not bot: + elif bot == 'f': for member in i.guild.members: if not member.bot: await member.add_roles(role) @app_commands.describe(bot='Botのロールも除去する?') @app_commands.choices(bot=[ - app_commands.Choice(name='はい', value=True), - app_commands.Choice(name='いいえ', value=False), + app_commands.Choice(name='はい', value='y'), + app_commands.Choice(name='いいえ', value='f'), ]) @app_commands.command(name="role_all_remove", description="全員からロールを除去します。") - async def roleall_remove(self, i: discord.Interaction, role: discord.Role, bot: bool): - if bot: + async def roleall_remove(self, i: discord.Interaction, role: discord.Role, bot: str): + if bot == 'y': for member in i.guild.members: await member.remove_roles(role) - elif not bot: + elif bot == 'f': for member in i.guild.members: if not member.bot: await member.remove_roles(role) diff --git a/main.py b/main.py index 25dae65..2a14ad9 100644 --- a/main.py +++ b/main.py @@ -29,7 +29,7 @@ async def setup_hook(self): bot = EightBot( command_prefix="eg!", - intents=Intents(auto_moderation=False, typing=False), + intents=Intents.all(), activity=Activity( type=ActivityType.watching, name="起動準備をしています...",