diff --git a/CHANGELOG.md b/CHANGELOG.md index a34216f..8e60db3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + +## [4.10.0] - 2021-06-21 ### Booster Features - You can now configure messages to be posted when a person newly boosts a server. - You can now enable booster roles for your server - allowing users who boost the server to assign themselves roles. diff --git a/cogs/booster.py b/cogs/booster.py index 76b4687..61320dd 100644 --- a/cogs/booster.py +++ b/cogs/booster.py @@ -151,7 +151,6 @@ async def _booster_role(self, ctx, instruction: str = None, field: str = None, * @cog_ext.cog_subcommand(base="booster", subcommand_group="role", name="setup", description="Sets up booster roles for your guild!", - guild_ids=[197972184466063381], options=[dict(name="anchor_role", description="The role that booster roles will be placed directly below " "when created.", @@ -167,7 +166,6 @@ async def _setup_booster_roles(self, ctx: SlashContext, anchor_role: Role = None @cog_ext.cog_subcommand(base="booster", subcommand_group="role", name="import", description="Import your current booster roles into this system.", - guild_ids=[197972184466063381], options=[dict(name="user", description="Optionally choose a single user's roles to import.", type=SlashCommandOptionType.USER, required=False)]) @commands.has_permissions(manage_guild=True) @@ -204,7 +202,6 @@ async def _import_booster_roles(self, ctx: SlashContext, user: Member = None): @cog_ext.cog_subcommand(base="booster", subcommand_group="role", name="enable", description="Enable or disable booster roles for your server.", - guild_ids=[197972184466063381], options=[dict(name="enabled", description="Are booster roles enabled in this server?", type=SlashCommandOptionType.BOOLEAN, required=True)]) @commands.has_permissions(manage_guild=True) @@ -224,7 +221,6 @@ def __init__(self, client: commands.Bot): @cog_ext.cog_subcommand(base="booster", subcommand_group="notification", name="add", description="Sets up a new message for when somebody boosts the guild.", - guild_ids=[197972184466063381], options=[{"name": "channel", "description": "The channel to post the message in.", "type": SlashCommandOptionType.CHANNEL, "required": True}, {"name": "message", @@ -241,7 +237,6 @@ async def _add_message(self, ctx: SlashContext, channel: TextChannel, message: s @cog_ext.cog_subcommand(base="booster", subcommand_group="notification", name="delete", description="Deletes a booster notification from the guild.", - guild_ids=[197972184466063381], options=[{"name": "reference", "description": "The reference of the message to delete.", "type": SlashCommandOptionType.STRING, "required": True}]) @commands.has_permissions(manage_guild=True) @@ -257,7 +252,6 @@ async def _delete_message(self, ctx: SlashContext, reference: str): @cog_ext.cog_subcommand(base="booster", subcommand_group="notification", name="list", description="Lists all booster notifications in your guild.", - guild_ids=[197972184466063381], options=[{"name": "channel", "description": "The channel specifically to search.", "type": SlashCommandOptionType.CHANNEL, "required": False}]) @commands.has_permissions(manage_guild=True) diff --git a/cogs/starboard.py b/cogs/starboard.py index a550b30..b47065e 100644 --- a/cogs/starboard.py +++ b/cogs/starboard.py @@ -1,7 +1,6 @@ import logging from datetime import * -import discord from discord import RawReactionActionEvent from discord.ext import commands, tasks from discord.ext.commands import PartialEmojiConversionFailure @@ -45,30 +44,37 @@ async def cleaner(self): # For each message, it updates the embed. for message_to_check in messages_to_check: - original_message_channel = self.client.get_channel(message_to_check.message_channel_id) - starboard_channel = self.client.get_channel(message_to_check.starboard.channel_id) - starboard_message = None - - # The bot may have been removed from the server, in which case skip it for now. - if original_message_channel is None: - continue - try: - original_message = await original_message_channel.fetch_message(message_to_check.message_id) - new_embed = await self._get_starred_embed(message_to_check, original_message) - except discord.NotFound: - new_embed = None - - if message_to_check.embed_message_id: - starboard_message = await starboard_channel.fetch_message(message_to_check.embed_message_id) - - star_threshold = message_to_check.starboard.star_threshold - number_of_stars = len(message_to_check.starrers) - - if message_to_check.starboard.star_threshold != 1 and number_of_stars < star_threshold: - await _delete_starred_message(message_to_check, starboard_message) - else: - await self._update_starred_message(message_to_check, new_embed) + original_message_channel = self.client.get_channel(message_to_check.message_channel_id) + starboard_channel = self.client.get_channel(message_to_check.starboard.channel_id) + starboard_message = None + + # The bot may have been removed from the server, in which case skip it for now. + if original_message_channel is None: + continue + + try: + original_message = await original_message_channel.fetch_message(message_to_check.message_id) + new_embed = await self._get_starred_embed(message_to_check, original_message) + except discord.NotFound: + new_embed = None + + if message_to_check.embed_message_id: + try: + starboard_message = await starboard_channel.fetch_message(message_to_check.embed_message_id) + except discord.NotFound: + continue + + star_threshold = message_to_check.starboard.star_threshold + number_of_stars = len(message_to_check.starrers) + + if message_to_check.starboard.star_threshold != 1 and number_of_stars < star_threshold: + await _delete_starred_message(message_to_check, starboard_message) + else: + await self._update_starred_message(message_to_check, new_embed) + except Exception as e: + # For debug purposes, temporarily widening error handling to find Webhook errors. + logger.error("There was an error running the starboard: {}".format(e), message_id=message_to_check.message_id) @cleaner.before_loop async def before_cleaner(self):