Skip to content

Commit

Permalink
Beta release 4.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LewisHobden committed Jun 21, 2021
1 parent 67215cc commit aa212c6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 30 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 0 additions & 6 deletions cogs/booster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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",
Expand All @@ -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)
Expand All @@ -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)
Expand Down
54 changes: 30 additions & 24 deletions cogs/starboard.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit aa212c6

Please sign in to comment.