fix(info): pylint fixes
This commit is contained in:
parent
e27182f47f
commit
b1874b0161
1 changed files with 19 additions and 24 deletions
43
info/info.py
43
info/info.py
|
@ -1,18 +1,13 @@
|
|||
import re
|
||||
from datetime import datetime
|
||||
import discord
|
||||
from redbot.core import commands, checks, Config, app_commands
|
||||
from redbot.core import Config, app_commands, commands
|
||||
from redbot.core.bot import Red
|
||||
from redbot.core.i18n import Translator, cog_i18n
|
||||
import re
|
||||
from redbot.core.utils.chat_formatting import (
|
||||
bold,
|
||||
humanize_number,
|
||||
humanize_timedelta,
|
||||
)
|
||||
from redbot.core.utils.chat_formatting import (bold, humanize_number,
|
||||
humanize_timedelta)
|
||||
from redbot.core.utils.common_filters import (
|
||||
filter_invites,
|
||||
escape_spoilers_and_mass_mentions
|
||||
)
|
||||
escape_spoilers_and_mass_mentions, filter_invites)
|
||||
|
||||
_ = T_ = Translator("General", __file__)
|
||||
|
||||
|
@ -33,14 +28,14 @@ class Info(commands.Cog):
|
|||
self.config.register_user(**self.default_user_settings)
|
||||
self.cache: dict = {}
|
||||
|
||||
async def red_delete_data_for_user(self, **kwargs):
|
||||
async def red_delete_data_for_user(self):
|
||||
"""Nothing to delete."""
|
||||
return
|
||||
|
||||
@commands.command()
|
||||
@commands.guild_only()
|
||||
@commands.bot_has_permissions(embed_links=True)
|
||||
async def serverinfo(self, ctx, details: bool = False):
|
||||
async def serverinfo(self, ctx: commands.Context, details: bool = False):
|
||||
"""
|
||||
Show server information.
|
||||
|
||||
|
@ -87,16 +82,16 @@ class Info(commands.Cog):
|
|||
def _size(num: int):
|
||||
for unit in ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB"]:
|
||||
if abs(num) < 1024.0:
|
||||
return "{0:.1f}{1}".format(num, unit)
|
||||
return f"{num:.1f}{unit}"
|
||||
num /= 1024.0
|
||||
return "{0:.1f}{1}".format(num, "YB")
|
||||
return f"{num:.1f}YB"
|
||||
|
||||
def _bitsize(num: int):
|
||||
for unit in ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB"]:
|
||||
if abs(num) < 1000.0:
|
||||
return "{0:.1f}{1}".format(num, unit)
|
||||
return f"{num:.1f}{unit}"
|
||||
num /= 1000.0
|
||||
return "{0:.1f}{1}".format(num, "YB")
|
||||
return f"{num:.1f}YB"
|
||||
|
||||
shard_info = (
|
||||
_("\nShard ID: **{shard_id}/{shard_count}**").format(
|
||||
|
@ -128,7 +123,7 @@ class Info(commands.Cog):
|
|||
for emoji, value in online_stats.items():
|
||||
try:
|
||||
num = len([m for m in guild.members if value(m)])
|
||||
except Exception as error:
|
||||
except Exception as error: # pylint: disable=broad-exception-caught
|
||||
print(error)
|
||||
continue
|
||||
else:
|
||||
|
@ -272,7 +267,7 @@ class Info(commands.Cog):
|
|||
c_status = None
|
||||
if not a.name and not a.emoji:
|
||||
return None, discord.ActivityType.custom
|
||||
elif a.name and a.emoji:
|
||||
if a.name and a.emoji:
|
||||
c_status = _("Custom: {emoji} {name}").format(emoji=a.emoji, name=a.name)
|
||||
elif a.emoji:
|
||||
c_status = _("Custom: {emoji}").format(emoji=a.emoji)
|
||||
|
@ -346,7 +341,7 @@ class Info(commands.Cog):
|
|||
self.handle_watching(user),
|
||||
self.handle_competing(user),
|
||||
]:
|
||||
status_string, status_type = a
|
||||
status_string = a
|
||||
if status_string is None:
|
||||
continue
|
||||
string += f"{status_string}\n"
|
||||
|
@ -364,7 +359,7 @@ class Info(commands.Cog):
|
|||
@commands.command()
|
||||
@commands.guild_only()
|
||||
@commands.bot_has_permissions(embed_links=True)
|
||||
async def userinfo(self, ctx, *, member: discord.Member = None):
|
||||
async def userinfo(self, ctx: commands.Context, *, member: discord.Member = None):
|
||||
"""Show information about a member.
|
||||
This includes fields for status, discord join date, server
|
||||
join date, voice state and previous names/nicknames.
|
||||
|
@ -476,10 +471,10 @@ class Info(commands.Cog):
|
|||
if voice_state and voice_state.channel:
|
||||
data.add_field(
|
||||
name=_("Current voice channel"),
|
||||
value="{0.mention} ID: {0.id}".format(voice_state.channel),
|
||||
value=f"{voice_state.channel.mention} ID: {voice_state.channel.id}",
|
||||
inline=False,
|
||||
)
|
||||
data.set_footer(text=_("Member #{} | User ID: {}").format(member_number, member.id))
|
||||
data.set_footer(text=_(f"Member #{member_number} | User ID: {member.id}"))
|
||||
|
||||
if member.discriminator == "0":
|
||||
name = str(member.name)
|
||||
|
@ -522,7 +517,7 @@ class Info(commands.Cog):
|
|||
icon_url = await self.fetch_twemoji(unicode_emoji=icon)
|
||||
else:
|
||||
icon_url = None
|
||||
except:
|
||||
except: # pylint: disable=bare-except
|
||||
icon_url = None
|
||||
permissions = role.permissions
|
||||
if role.color.value == 0:
|
||||
|
@ -549,6 +544,6 @@ class Info(commands.Cog):
|
|||
embed = discord.Embed(title=f"{role.name}", color=colorint, description=description)
|
||||
if icon_url:
|
||||
embed.set_thumbnail(url=icon_url)
|
||||
if permissions.administrator == False and list_permissions == True:
|
||||
if permissions.administrator is False and list_permissions is True:
|
||||
embed.add_field(name="Permissions", value=f"**Manage Server:** {permissions.manage_guild}\n**Manage Webhooks:** {permissions.manage_webhooks}\n**Manage Channels:** {permissions.manage_channels}\n**Manage Roles:** {permissions.manage_roles}\n**Create Expressions:** {permissions.create_expressions}\n**Manage Events:** {permissions.manage_events}\n**Manage Messages:** {permissions.manage_messages}\n**Manage Nicknames:** {permissions.manage_nicknames}\n**Mention @everyone**: {permissions.mention_everyone}\n**Ban Members:** {permissions.ban_members}\n**Kick Members:** {permissions.kick_members}\n**Timeout Members:** {permissions.moderate_members}\n**View Audit Log:** {permissions.view_audit_log}")
|
||||
await interaction.response.send_message(embed=embed, ephemeral=True)
|
||||
|
|
Loading…
Reference in a new issue