From cc1e3923154b81170af9a1795599f050b856b9c9 Mon Sep 17 00:00:00 2001 From: gx1285 <78240988+gx1285@users.noreply.github.com> Date: Sun, 30 Oct 2022 07:34:12 +0900 Subject: [PATCH 1/7] fix: bool => str --- cogs/role_all.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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) From 034087300929794dc9190d2778f615ff4d68c442 Mon Sep 17 00:00:00 2001 From: gx1285 <78240988+gx1285@users.noreply.github.com> Date: Sun, 30 Oct 2022 08:07:13 +0900 Subject: [PATCH 2/7] bug fix --- cogs/ban_member.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/cogs/ban_member.py b/cogs/ban_member.py index 9952f20..71a1ad9 100644 --- a/cogs/ban_member.py +++ b/cogs/ban_member.py @@ -10,19 +10,18 @@ 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) + if i.channel.permissions_for(i.user) == discord.Permissions.ban_members: + if i.channel.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) + if len(m) == 0: + send_content = "Banされたユーザーはいません。" + await i.response.send_message(send_content) else: - await i.response.send_message("データを取得できませんでした(権限がないなどの原因で)", ephemeral=True) - except: - await i.response.send_message("データを取得できませんでした(権限がないなどの原因で)", ephemeral=True) + await i.response.send_message("データを取得できませんでした(Botの権限がないなどの原因で)", ephemeral=True) + else: + await i.response.send_message("データを取得できませんでした。(権限がないなどの原因)", ephemeral=True) async def setup(bot: commands.Bot) -> None: From d9d7ce2d096e67f11fe350fbce384d7062861ac4 Mon Sep 17 00:00:00 2001 From: gx1285 <78240988+gx1285@users.noreply.github.com> Date: Sun, 30 Oct 2022 08:27:18 +0900 Subject: [PATCH 3/7] fix --- cogs/ban_member.py | 21 +++++++++------------ main.py | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/cogs/ban_member.py b/cogs/ban_member.py index 71a1ad9..ee010b1 100644 --- a/cogs/ban_member.py +++ b/cogs/ban_member.py @@ -10,18 +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 = [] - if i.channel.permissions_for(i.user) == discord.Permissions.ban_members: - if i.channel.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) - if len(m) == 0: - send_content = "Banされたユーザーはいません。" - await i.response.send_message(send_content) - else: - await i.response.send_message("データを取得できませんでした(Botの権限がないなどの原因で)", ephemeral=True) - else: - 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/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="起動準備をしています...", From d3bf3c92a0b31244d8f18bfc6d2936e7ce5a79a5 Mon Sep 17 00:00:00 2001 From: gx1285 <78240988+gx1285@users.noreply.github.com> Date: Sun, 30 Oct 2022 20:59:59 +0900 Subject: [PATCH 4/7] Update main.yml --- .github/workflows/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d2164ab..14a6588 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,9 +26,11 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pipenv + pip install flake8 pipenv + pipenv install pyright pipenv install - - name: Lint with flake8 + - name: Lint with flake8 & Pyright run: | flake8 . --count --ignore=E501,E722,C901 --select=E9,F63,F7,F82 --show-source --statistics flake8 . --count --ignore=E501,E722,C901 --exit-zero --max-complexity=10 --max-line-length=127 --statistics + pipenv run pyright **/*.py From c08b926697bb91496ac59effa3f571ecadd48ecb Mon Sep 17 00:00:00 2001 From: gx1285 <78240988+gx1285@users.noreply.github.com> Date: Sun, 30 Oct 2022 21:02:30 +0900 Subject: [PATCH 5/7] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 14a6588..b1084fb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ jobs: run: | python -m pip install --upgrade pip pip install flake8 pipenv - pipenv install pyright + pipenv install pyright discord.py replit discord.py-pagination requests pipenv install - name: Lint with flake8 & Pyright run: | From 9574a5472df193e96a3c0fa81dfb8322db562207 Mon Sep 17 00:00:00 2001 From: gx1285 <78240988+gx1285@users.noreply.github.com> Date: Sun, 30 Oct 2022 21:09:41 +0900 Subject: [PATCH 6/7] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b1084fb..be17161 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,7 +27,7 @@ jobs: run: | python -m pip install --upgrade pip pip install flake8 pipenv - pipenv install pyright discord.py replit discord.py-pagination requests + pipenv install pyright discord.py replit discord.py-pagination requests async-google-trans-new pipenv install - name: Lint with flake8 & Pyright run: | From ef04822c458ebebbd1add811527d41ea912ebec2 Mon Sep 17 00:00:00 2001 From: gx1285 <78240988+gx1285@users.noreply.github.com> Date: Mon, 31 Oct 2022 18:47:35 +0900 Subject: [PATCH 7/7] Update main.yml --- .github/workflows/main.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index be17161..789452f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,10 +27,7 @@ jobs: run: | python -m pip install --upgrade pip pip install flake8 pipenv - pipenv install pyright discord.py replit discord.py-pagination requests async-google-trans-new - pipenv install - - name: Lint with flake8 & Pyright + - name: Lint with flake8 run: | flake8 . --count --ignore=E501,E722,C901 --select=E9,F63,F7,F82 --show-source --statistics flake8 . --count --ignore=E501,E722,C901 --exit-zero --max-complexity=10 --max-line-length=127 --statistics - pipenv run pyright **/*.py