Compare commits

..

No commits in common. "71d006165e9ff49c023a795483988ea5e3787602" and "e0ad1fc3373b17be4d49859f79ca26310f2d3ae6" have entirely different histories.

6 changed files with 49 additions and 49 deletions

View file

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

View file

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

View file

@ -1,13 +1,18 @@
import re
from datetime import datetime from datetime import datetime
import discord import discord
from redbot.core import Config, app_commands, commands from redbot.core import commands, checks, Config, app_commands
from redbot.core.bot import Red from redbot.core.bot import Red
from redbot.core.i18n import Translator, cog_i18n from redbot.core.i18n import Translator, cog_i18n
from redbot.core.utils.chat_formatting import (bold, humanize_number, import re
humanize_timedelta) from redbot.core.utils.chat_formatting import (
bold,
humanize_number,
humanize_timedelta,
)
from redbot.core.utils.common_filters import ( from redbot.core.utils.common_filters import (
escape_spoilers_and_mass_mentions, filter_invites) filter_invites,
escape_spoilers_and_mass_mentions
)
_ = T_ = Translator("General", __file__) _ = T_ = Translator("General", __file__)
@ -28,14 +33,14 @@ class Info(commands.Cog):
self.config.register_user(**self.default_user_settings) self.config.register_user(**self.default_user_settings)
self.cache: dict = {} self.cache: dict = {}
async def red_delete_data_for_user(self): async def red_delete_data_for_user(self, **kwargs):
"""Nothing to delete.""" """Nothing to delete."""
return return
@commands.command() @commands.command()
@commands.guild_only() @commands.guild_only()
@commands.bot_has_permissions(embed_links=True) @commands.bot_has_permissions(embed_links=True)
async def serverinfo(self, ctx: commands.Context, details: bool = False): async def serverinfo(self, ctx, details: bool = False):
""" """
Show server information. Show server information.
@ -82,16 +87,16 @@ class Info(commands.Cog):
def _size(num: int): def _size(num: int):
for unit in ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB"]: for unit in ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB"]:
if abs(num) < 1024.0: if abs(num) < 1024.0:
return f"{num:.1f}{unit}" return "{0:.1f}{1}".format(num, unit)
num /= 1024.0 num /= 1024.0
return f"{num:.1f}YB" return "{0:.1f}{1}".format(num, "YB")
def _bitsize(num: int): def _bitsize(num: int):
for unit in ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB"]: for unit in ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB"]:
if abs(num) < 1000.0: if abs(num) < 1000.0:
return f"{num:.1f}{unit}" return "{0:.1f}{1}".format(num, unit)
num /= 1000.0 num /= 1000.0
return f"{num:.1f}YB" return "{0:.1f}{1}".format(num, "YB")
shard_info = ( shard_info = (
_("\nShard ID: **{shard_id}/{shard_count}**").format( _("\nShard ID: **{shard_id}/{shard_count}**").format(
@ -123,7 +128,7 @@ class Info(commands.Cog):
for emoji, value in online_stats.items(): for emoji, value in online_stats.items():
try: try:
num = len([m for m in guild.members if value(m)]) num = len([m for m in guild.members if value(m)])
except Exception as error: # pylint: disable=broad-exception-caught except Exception as error:
print(error) print(error)
continue continue
else: else:
@ -267,7 +272,7 @@ class Info(commands.Cog):
c_status = None c_status = None
if not a.name and not a.emoji: if not a.name and not a.emoji:
return None, discord.ActivityType.custom return None, discord.ActivityType.custom
if a.name and a.emoji: elif a.name and a.emoji:
c_status = _("Custom: {emoji} {name}").format(emoji=a.emoji, name=a.name) c_status = _("Custom: {emoji} {name}").format(emoji=a.emoji, name=a.name)
elif a.emoji: elif a.emoji:
c_status = _("Custom: {emoji}").format(emoji=a.emoji) c_status = _("Custom: {emoji}").format(emoji=a.emoji)
@ -341,7 +346,7 @@ class Info(commands.Cog):
self.handle_watching(user), self.handle_watching(user),
self.handle_competing(user), self.handle_competing(user),
]: ]:
status_string = a status_string, status_type = a
if status_string is None: if status_string is None:
continue continue
string += f"{status_string}\n" string += f"{status_string}\n"
@ -359,7 +364,7 @@ class Info(commands.Cog):
@commands.command() @commands.command()
@commands.guild_only() @commands.guild_only()
@commands.bot_has_permissions(embed_links=True) @commands.bot_has_permissions(embed_links=True)
async def userinfo(self, ctx: commands.Context, *, member: discord.Member = None): async def userinfo(self, ctx, *, member: discord.Member = None):
"""Show information about a member. """Show information about a member.
This includes fields for status, discord join date, server This includes fields for status, discord join date, server
join date, voice state and previous names/nicknames. join date, voice state and previous names/nicknames.
@ -471,10 +476,10 @@ class Info(commands.Cog):
if voice_state and voice_state.channel: if voice_state and voice_state.channel:
data.add_field( data.add_field(
name=_("Current voice channel"), name=_("Current voice channel"),
value=f"{voice_state.channel.mention} ID: {voice_state.channel.id}", value="{0.mention} ID: {0.id}".format(voice_state.channel),
inline=False, inline=False,
) )
data.set_footer(text=_(f"Member #{member_number} | User ID: {member.id}")) data.set_footer(text=_("Member #{} | User ID: {}").format(member_number, member.id))
if member.discriminator == "0": if member.discriminator == "0":
name = str(member.name) name = str(member.name)
@ -517,7 +522,7 @@ class Info(commands.Cog):
icon_url = await self.fetch_twemoji(unicode_emoji=icon) icon_url = await self.fetch_twemoji(unicode_emoji=icon)
else: else:
icon_url = None icon_url = None
except: # pylint: disable=bare-except except:
icon_url = None icon_url = None
permissions = role.permissions permissions = role.permissions
if role.color.value == 0: if role.color.value == 0:
@ -544,6 +549,6 @@ class Info(commands.Cog):
embed = discord.Embed(title=f"{role.name}", color=colorint, description=description) embed = discord.Embed(title=f"{role.name}", color=colorint, description=description)
if icon_url: if icon_url:
embed.set_thumbnail(url=icon_url) embed.set_thumbnail(url=icon_url)
if permissions.administrator is False and list_permissions is True: if permissions.administrator == False and list_permissions == 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}") 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) 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()) channel = self.bot.get_channel(await self.config.request_channel())
if channel is None: if channel is None:
await original_interaction.edit_original_response(content="Command cancelled.", view=None) await original_interaction.edit_original_response(content="Command cancelled.", view=None)
await interaction.response.send_message(content="The cog is misconfigured, please report this error.", ephemeral=True) await interaction.response.send_message(content=f"The cog is misconfigured, please report this error.", ephemeral=True)
try: try:
message = await channel.send(content=".") message = await channel.send(content=".")
await message.edit(content="", embed=embed, view=self.IssueResponseButtons(channel, message.id, interaction.user)) await message.edit(content="", embed=embed, view=self.IssueResponseButtons(channel, message.id, interaction.user))
await original_interaction.edit_original_response(content="Issue request sent!", embed=embed, view=None) await original_interaction.edit_original_response(content=f"Issue request sent!", embed=embed, view=None)
await interaction.response.defer() await interaction.response.defer()
except (discord.HTTPException, discord.Forbidden) as error: except (discord.HTTPException, discord.Forbidden) as error:
await original_interaction.edit_original_response(content="Command cancelled.", view=None) await original_interaction.edit_original_response(content="Command cancelled.", view=None)
@ -57,19 +57,19 @@ class Issues(commands.Cog):
self.original_interaction = original_interaction self.original_interaction = original_interaction
@discord.ui.button(label="Bot Bug", style=discord.ButtonStyle.danger) @discord.ui.button(label="Bot Bug", style=discord.ButtonStyle.danger)
async def issue_button_bot_bug(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument async def issue_button_bot_bug(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_modal(modals.BotBugModal(self.color, self.cog_instance, self.original_interaction)) 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) @discord.ui.button(label="Cog Bug", style=discord.ButtonStyle.danger)
async def issue_button_cog_bug(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument async def issue_button_cog_bug(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_modal(modals.CogBugModal(self.color, self.cog_instance, self.original_interaction)) 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) @discord.ui.button(label="Bot Suggestion", style=discord.ButtonStyle.blurple)
async def issue_button_bot_suggestion(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument async def issue_button_bot_suggestion(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_modal(modals.BotSuggestionModal(self.color, self.cog_instance, self.original_interaction)) 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) @discord.ui.button(label="Cog Suggestion", style=discord.ButtonStyle.blurple)
async def issue_button_cog_suggestion(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument async def issue_button_cog_suggestion(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_modal(modals.CogSuggestionModal(self.color, self.cog_instance, self.original_interaction)) await interaction.response.send_modal(modals.CogSuggestionModal(self.color, self.cog_instance, self.original_interaction))
class IssueConfigurationButton(discord.ui.View): class IssueConfigurationButton(discord.ui.View):
@ -79,7 +79,7 @@ class Issues(commands.Cog):
self.ctx = ctx self.ctx = ctx
@discord.ui.button(label="Change Configuration", style=discord.ButtonStyle.blurple, row=0) @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): # pylint: disable=unused-argument async def issue_configuration_button(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_modal(modals.IssuesConfigurationModal(self.config, self.ctx)) await interaction.response.send_modal(modals.IssuesConfigurationModal(self.config, self.ctx))
class IssueResponseButtons(discord.ui.View): class IssueResponseButtons(discord.ui.View):
@ -90,9 +90,9 @@ class Issues(commands.Cog):
self.user = user self.user = user
@discord.ui.button(label="Approve", style=discord.ButtonStyle.green) @discord.ui.button(label="Approve", style=discord.ButtonStyle.green)
async def issue_response_button_approve(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument async def issue_response_button_approve(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_modal(modals.IssueResponseModal(self.channel, self.message_id, self.user, True)) await interaction.response.send_modal(modals.IssueResponseModal(self.channel, self.message_id, self.user, True))
@discord.ui.button(label="Deny", style=discord.ButtonStyle.danger) @discord.ui.button(label="Deny", style=discord.ButtonStyle.danger)
async def issue_response_button_deny(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument async def issue_response_button_deny(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_modal(modals.IssueResponseModal(self.channel, self.message_id, self.user, False)) await interaction.response.send_modal(modals.IssueResponseModal(self.channel, self.message_id, self.user, False))

View file

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

View file

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