Compare commits

..

5 commits

Author SHA1 Message Date
71d006165e
fix(send): pylint fixes
Some checks failed
Pylint / Pylint (push) Failing after 1m5s
2023-09-24 17:17:30 -04:00
d2df32ddaf
fix(issues): pylint fixes 2023-09-24 17:16:32 -04:00
b1874b0161
fix(info): pylint fixes 2023-09-24 17:11:54 -04:00
e27182f47f
fix(pylint): added too-many-statements to the ignore list 2023-09-24 17:06:06 -04:00
00c8130cbe
fix(forums): pylint fixes 2023-09-24 17:01:50 -04:00
6 changed files with 49 additions and 49 deletions

View file

@ -9,4 +9,5 @@
superfluous-parens,
invalid-name,
too-many-locals,
too-many-public-methods
too-many-public-methods,
too-many-statements

View file

@ -1,6 +1,6 @@
import discord
from discord import ui
from redbot.core import Config, checks, commands
from redbot.core import Config, commands
class Forums(commands.Cog):
@ -55,7 +55,7 @@ class Forums(commands.Cog):
self.config = Config.get_conf(None, cog_name='Forums', identifier=2352711325)
@ui.button(label="Yes", style=discord.ButtonStyle.success, emoji="")
async def resolved_button_yes(self, interaction: discord.Interaction, button: ui.Button): # pylint: disable=unused-variable
async def resolved_button_yes(self, interaction: discord.Interaction, button: ui.Button): # pylint: disable=unused-argument
request_role_ids = await self.config.guild(interaction.guild).request_roles()
request_roles = [interaction.guild.get_role(role_id) for role_id in request_role_ids]
match = any(role in interaction.user.roles for role in request_roles)
@ -78,7 +78,7 @@ class Forums(commands.Cog):
await interaction.response.send_message(content="You cannot close this thread!", ephemeral=True)
@ui.button(label="No", style=discord.ButtonStyle.danger, emoji="✖️")
async def resolved_button_no(self, interaction: discord.Interaction, button: ui.Button): # pylint: disable=unused-variable
async def resolved_button_no(self, interaction: discord.Interaction, button: ui.Button): # pylint: disable=unused-argument
request_role_ids = await self.config.guild(interaction.guild).request_roles()
request_roles = [interaction.guild.get_role(role_id) for role_id in request_role_ids]
match = any(role in interaction.user.roles for role in request_roles)

View file

@ -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)

View file

@ -39,11 +39,11 @@ class Issues(commands.Cog):
channel = self.bot.get_channel(await self.config.request_channel())
if channel is None:
await original_interaction.edit_original_response(content="Command cancelled.", view=None)
await interaction.response.send_message(content=f"The cog is misconfigured, please report this error.", ephemeral=True)
await interaction.response.send_message(content="The cog is misconfigured, please report this error.", ephemeral=True)
try:
message = await channel.send(content=".")
await message.edit(content="", embed=embed, view=self.IssueResponseButtons(channel, message.id, interaction.user))
await original_interaction.edit_original_response(content=f"Issue request sent!", embed=embed, view=None)
await original_interaction.edit_original_response(content="Issue request sent!", embed=embed, view=None)
await interaction.response.defer()
except (discord.HTTPException, discord.Forbidden) as error:
await original_interaction.edit_original_response(content="Command cancelled.", view=None)
@ -57,19 +57,19 @@ class Issues(commands.Cog):
self.original_interaction = original_interaction
@discord.ui.button(label="Bot Bug", style=discord.ButtonStyle.danger)
async def issue_button_bot_bug(self, interaction: discord.Interaction, button: discord.ui.Button):
async def issue_button_bot_bug(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument
await interaction.response.send_modal(modals.BotBugModal(self.color, self.cog_instance, self.original_interaction))
@discord.ui.button(label="Cog Bug", style=discord.ButtonStyle.danger)
async def issue_button_cog_bug(self, interaction: discord.Interaction, button: discord.ui.Button):
async def issue_button_cog_bug(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument
await interaction.response.send_modal(modals.CogBugModal(self.color, self.cog_instance, self.original_interaction))
@discord.ui.button(label="Bot Suggestion", style=discord.ButtonStyle.blurple)
async def issue_button_bot_suggestion(self, interaction: discord.Interaction, button: discord.ui.Button):
async def issue_button_bot_suggestion(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument
await interaction.response.send_modal(modals.BotSuggestionModal(self.color, self.cog_instance, self.original_interaction))
@discord.ui.button(label="Cog Suggestion", style=discord.ButtonStyle.blurple)
async def issue_button_cog_suggestion(self, interaction: discord.Interaction, button: discord.ui.Button):
async def issue_button_cog_suggestion(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument
await interaction.response.send_modal(modals.CogSuggestionModal(self.color, self.cog_instance, self.original_interaction))
class IssueConfigurationButton(discord.ui.View):
@ -79,7 +79,7 @@ class Issues(commands.Cog):
self.ctx = ctx
@discord.ui.button(label="Change Configuration", style=discord.ButtonStyle.blurple, row=0)
async def issue_configuration_button(self, interaction: discord.Interaction, button: discord.ui.Button):
async def issue_configuration_button(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument
await interaction.response.send_modal(modals.IssuesConfigurationModal(self.config, self.ctx))
class IssueResponseButtons(discord.ui.View):
@ -90,9 +90,9 @@ class Issues(commands.Cog):
self.user = user
@discord.ui.button(label="Approve", style=discord.ButtonStyle.green)
async def issue_response_button_approve(self, interaction: discord.Interaction, button: discord.ui.Button):
async def issue_response_button_approve(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument
await interaction.response.send_modal(modals.IssueResponseModal(self.channel, self.message_id, self.user, True))
@discord.ui.button(label="Deny", style=discord.ButtonStyle.danger)
async def issue_response_button_deny(self, interaction: discord.Interaction, button: discord.ui.Button):
async def issue_response_button_deny(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument
await interaction.response.send_modal(modals.IssueResponseModal(self.channel, self.message_id, self.user, False))

View file

@ -2,6 +2,8 @@ import aiohttp
import discord
from redbot.core import Config
# pylint: disable=arguments-differ
#
# Misc. functions
#
@ -297,16 +299,16 @@ class IssueResponseModal(discord.ui.Modal, title="Sending response message..."):
[f"{name}\n{value}" for name, value in zip(field_names, field_values)]
)
async def fetch_labels():
async with aiohttp.ClientSession(headers=headers) as session:
async with session.post(url=f"{await self.config.gitea_root_url()}/api/v1/repos/{await self.config.gitea_repository_owner()}/{await self.config.gitea_repository()}/labels") as response:
label_list = []
for label in response.json():
if label["name"] in desired_labels:
label_list.append(label["id"])
if label_list is None:
print("Error! Labels are not properly configured on the target repository.")
return await label_list
# async def fetch_labels():
# async with aiohttp.ClientSession(headers=headers) as session:
# async with session.post(url=f"{await self.config.gitea_root_url()}/api/v1/repos/{await self.config.gitea_repository_owner()}/{await self.config.gitea_repository()}/labels") as response:
# label_list = []
# for label in response.json():
# if label["name"] in desired_labels:
# label_list.append(label["id"])
# if label_list is None:
# print("Error! Labels are not properly configured on the target repository.")
# return await label_list
issue_labels = None

View file

@ -1,6 +1,8 @@
from typing import Union
import discord
from redbot.core import commands, checks, app_commands
from redbot.core import commands, app_commands
# pylint: disable=arguments-differ
class Send(commands.Cog):
"""Allows you to send messages as the bot account."""
@ -20,7 +22,7 @@ class Send(commands.Cog):
await interaction.response.send_message(content=f"Message sent to {target.mention}!\nMessage contents:\n```{message}```\n```{secondary_message}```", ephemeral=True)
else:
await interaction.response.send_message(content=f"Message sent to {target.mention}!\nMessage contents:\n```{message}```", ephemeral=True)
except (discord.HTTPException, discord.Forbidden) as error:
except (discord.HTTPException, discord.Forbidden):
if target_type == "member":
await interaction.response.send_message(content="That user has their direct messages closed!", ephemeral=True)
elif target_type == "textchannel":