fix(antipolls): fixed typeerror in the configuration commands
This commit is contained in:
parent
d9c123d441
commit
73b0e73ff0
1 changed files with 14 additions and 10 deletions
|
@ -93,7 +93,7 @@ class AntiPolls(commands.Cog):
|
||||||
"""Add roles to the whitelist."""
|
"""Add roles to the whitelist."""
|
||||||
async with self.config.guild(ctx.guild).role_whitelist() as role_whitelist:
|
async with self.config.guild(ctx.guild).role_whitelist() as role_whitelist:
|
||||||
role_whitelist: list
|
role_whitelist: list
|
||||||
failed: list[discord.Role.mention] = []
|
failed: list[discord.Role] = []
|
||||||
for role in roles:
|
for role in roles:
|
||||||
if role.id in role_whitelist:
|
if role.id in role_whitelist:
|
||||||
failed.append(role.mention)
|
failed.append(role.mention)
|
||||||
|
@ -101,22 +101,24 @@ class AntiPolls(commands.Cog):
|
||||||
role_whitelist.append(role.id)
|
role_whitelist.append(role.id)
|
||||||
await ctx.tick()
|
await ctx.tick()
|
||||||
if failed:
|
if failed:
|
||||||
await ctx.send(f"The following roles were already in the whitelist: {humanize_list(mention for mention in failed)}", delete_after=10, allowed_mentions=discord.AllowedMentions.none)
|
mention_list = (role.mention for role in failed)
|
||||||
|
await ctx.send(f"The following roles were already in the whitelist: {humanize_list(mention_list)}", delete_after=10, allowed_mentions=discord.AllowedMentions.none)
|
||||||
|
|
||||||
@antipolls_roles.command(name="remove")
|
@antipolls_roles.command(name="remove")
|
||||||
async def antipolls_roles_remove(self, ctx: commands.Context, *roles: discord.Role) -> None:
|
async def antipolls_roles_remove(self, ctx: commands.Context, *roles: discord.Role) -> None:
|
||||||
"""Remove roles from the whitelist."""
|
"""Remove roles from the whitelist."""
|
||||||
async with self.config.guild(ctx.guild).role_whitelist() as role_whitelist:
|
async with self.config.guild(ctx.guild).role_whitelist() as role_whitelist:
|
||||||
role_whitelist: list
|
role_whitelist: list
|
||||||
failed: list[discord.Role.mention] = []
|
failed: list[discord.Role] = []
|
||||||
for role in roles:
|
for role in roles:
|
||||||
if role.id not in role_whitelist:
|
if role.id not in role_whitelist:
|
||||||
failed.append(role.mention)
|
failed.append(role)
|
||||||
continue
|
continue
|
||||||
role_whitelist.remove(role.id)
|
role_whitelist.remove(role.id)
|
||||||
await ctx.tick()
|
await ctx.tick()
|
||||||
if failed:
|
if failed:
|
||||||
await ctx.send(f"The following roles were not in the whitelist: {humanize_list(mention for mention in failed)}", delete_after=10, allowed_mentions=discord.AllowedMentions.none)
|
mention_list = (role.mention for role in failed)
|
||||||
|
await ctx.send(f"The following roles were not in the whitelist: {humanize_list(mention_list)}", delete_after=10, allowed_mentions=discord.AllowedMentions.none)
|
||||||
|
|
||||||
@antipolls_roles.command(name="list")
|
@antipolls_roles.command(name="list")
|
||||||
async def antipolls_roles_list(self, ctx: commands.Context) -> None:
|
async def antipolls_roles_list(self, ctx: commands.Context) -> None:
|
||||||
|
@ -136,7 +138,7 @@ class AntiPolls(commands.Cog):
|
||||||
"""Add channels to the whitelist."""
|
"""Add channels to the whitelist."""
|
||||||
async with self.config.guild(ctx.guild).channel_whitelist() as channel_whitelist:
|
async with self.config.guild(ctx.guild).channel_whitelist() as channel_whitelist:
|
||||||
channel_whitelist: list
|
channel_whitelist: list
|
||||||
failed: list[discord.TextChannel.mention] = []
|
failed: list[discord.TextChannel] = []
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
if channel.id in channel_whitelist:
|
if channel.id in channel_whitelist:
|
||||||
failed.append(channel)
|
failed.append(channel)
|
||||||
|
@ -144,22 +146,24 @@ class AntiPolls(commands.Cog):
|
||||||
channel_whitelist.append(channel.id)
|
channel_whitelist.append(channel.id)
|
||||||
await ctx.tick()
|
await ctx.tick()
|
||||||
if failed:
|
if failed:
|
||||||
await ctx.send(f"The following channels were already in the whitelist: {humanize_list(mention for mention in failed)}", delete_after=10, allowed_mentions=discord.AllowedMentions.none)
|
mention_list = (role.mention for role in failed)
|
||||||
|
await ctx.send(f"The following channels were already in the whitelist: {humanize_list(mention_list)}", delete_after=10, allowed_mentions=discord.AllowedMentions.none)
|
||||||
|
|
||||||
@antipolls_channels.command(name="remove")
|
@antipolls_channels.command(name="remove")
|
||||||
async def antipolls_channels_remove(self, ctx: commands.Context, *channels: discord.TextChannel) -> None:
|
async def antipolls_channels_remove(self, ctx: commands.Context, *channels: discord.TextChannel) -> None:
|
||||||
"""Remove channels from the whitelist."""
|
"""Remove channels from the whitelist."""
|
||||||
async with self.config.guild(ctx.guild).channel_whitelist() as channel_whitelist:
|
async with self.config.guild(ctx.guild).channel_whitelist() as channel_whitelist:
|
||||||
channel_whitelist: list
|
channel_whitelist: list
|
||||||
failed: list[discord.TextChannel.mention] = []
|
failed: list[discord.TextChannel] = []
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
if channel.id not in channel_whitelist:
|
if channel.id not in channel_whitelist:
|
||||||
failed.append(channel.mention)
|
failed.append(channel)
|
||||||
continue
|
continue
|
||||||
channel_whitelist.remove(channel.id)
|
channel_whitelist.remove(channel.id)
|
||||||
await ctx.tick()
|
await ctx.tick()
|
||||||
if failed:
|
if failed:
|
||||||
await ctx.send(f"The following channels were not in the whitelist: {humanize_list(mention for mention in failed)}", delete_after=10, allowed_mentions=discord.AllowedMentions.none)
|
mention_list = (role.mention for role in failed)
|
||||||
|
await ctx.send(f"The following channels were not in the whitelist: {humanize_list(mention_list)}", delete_after=10, allowed_mentions=discord.AllowedMentions.none)
|
||||||
|
|
||||||
@antipolls_channels.command(name="list")
|
@antipolls_channels.command(name="list")
|
||||||
async def antipolls_channels_list(self, ctx: commands.Context) -> None:
|
async def antipolls_channels_list(self, ctx: commands.Context) -> None:
|
||||||
|
|
Loading…
Reference in a new issue