Skip to content

Commit 535210f

Browse files
committed
Merge branch 'v1.6.1' into main
2 parents 102a4b4 + 65c40cc commit 535210f

8 files changed

Lines changed: 137 additions & 65 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.6.1] - 2023-07-24
9+
10+
### Added
11+
12+
- Added additional suggestion states.
13+
814
## [1.6.0] - 2023-07-24
915

1016
### Added
@@ -104,6 +110,7 @@ implemented, accepted, or rejected.
104110

105111
- Initial release.
106112

113+
[1.6.1]: https://github.com/BrackeysBot/SuggestionBot/releases/tag/v1.6.1
107114
[1.6.0]: https://github.com/BrackeysBot/SuggestionBot/releases/tag/v1.6.0
108115
[1.5.1]: https://github.com/BrackeysBot/SuggestionBot/releases/tag/v1.5.1
109116
[1.5.0]: https://github.com/BrackeysBot/SuggestionBot/releases/tag/v1.5.0

SuggestionBot/Configuration/GuildConfiguration.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ public sealed class GuildConfiguration
2929
/// <value><see langword="true" /> if a thread should be created; otherwise, <see langword="false" />.</value>
3030
public bool CreateThreadForSuggestion { get; set; } = true;
3131

32+
/// <summary>
33+
/// Gets or sets the embed color for implemented suggestions.
34+
/// </summary>
35+
/// <value>The embed color for implemented suggestions.</value>
36+
public int DuplicateColor { get; set; } = 0xA0A0A0;
37+
3238
/// <summary>
3339
/// Gets or sets the embed color for implemented suggestions.
3440
/// </summary>
@@ -41,6 +47,12 @@ public sealed class GuildConfiguration
4147
/// <value>The log channel ID.</value>
4248
public ulong LogChannel { get; set; }
4349

50+
/// <summary>
51+
/// Gets or sets the embed color for rejected suggestions.
52+
/// </summary>
53+
/// <value>The embed color for rejected suggestions.</value>
54+
public int PlannedColor { get; set; } = 0x6495ED;
55+
4456
/// <summary>
4557
/// Gets or sets the embed color for rejected suggestions.
4658
/// </summary>

SuggestionBot/Data/SuggestionStatus.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ public enum SuggestionStatus
99
Rejected,
1010
Implemented,
1111
Accepted,
12-
Removed
12+
Removed,
13+
Duplicate,
14+
AlreadyImplemented,
15+
AlreadyPlanned
1316
}

SuggestionBot/Resources/PrivateMessages.Designer.cs

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SuggestionBot/Resources/PrivateMessages.resx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@
2424
</value>
2525
</resheader>
2626

27+
<data name="PlannedDescription" xml:space="preserve">
28+
<value>{user.Mention}, your suggestion in **{guild.Name}** has been closed by staff because the changes you suggested have already been planned for the server.
29+
30+
If you have any further questions, please reach us by sending a DM to ModMail.</value>
31+
</data>
32+
33+
<data name="AlreadyImplementedDescription" xml:space="preserve">
34+
<value>{user.Mention}, your suggestion in **{guild.Name}** has been closed by staff because the changes you suggested are already present in the server.
35+
36+
If you have any further questions, please reach us by sending a DM to ModMail.</value>
37+
</data>
38+
39+
<data name="DuplicateDescription" xml:space="preserve">
40+
<value>{user.Mention}, your suggestion in **{guild.Name}** has been closed by staff because it was determined to be a duplicate of an existing suggestion which supersedes it or was previously closed.
41+
42+
If you have any further questions, please reach us by sending a DM to ModMail.</value>
43+
</data>
44+
2745
<data name="RemovedDescription" xml:space="preserve">
2846
<value>{user.Mention}, your suggestion in **{guild.Name}** has been removed by staff because it was inappropriate or violated our server rules.
2947
Repeated abuse will result in you losing access to the channel.

SuggestionBot/Services/MailmanService.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,24 @@ private bool TryBuildEmbed(Suggestion suggestion, DiscordEmbedBuilder embed, Dis
115115
embed.WithDescription(PrivateMessages.ImplementedDescription.FormatSmart(new { user = author, guild }));
116116
break;
117117

118+
case SuggestionStatus.Duplicate:
119+
embed.WithColor(configuration.DuplicateColor);
120+
embed.WithTitle("Suggestion Closed (Duplicate)");
121+
embed.WithDescription(PrivateMessages.DuplicateDescription.FormatSmart(new { user = author, guild }));
122+
break;
123+
124+
case SuggestionStatus.AlreadyImplemented:
125+
embed.WithColor(configuration.ImplementedColor);
126+
embed.WithTitle("Suggestion Closed (Already Implemented)");
127+
embed.WithDescription(PrivateMessages.DuplicateDescription.FormatSmart(new { user = author, guild }));
128+
break;
129+
130+
case SuggestionStatus.AlreadyPlanned:
131+
embed.WithColor(configuration.PlannedColor);
132+
embed.WithTitle("Suggestion Closed (Already Planned)");
133+
embed.WithDescription(PrivateMessages.PlannedDescription.FormatSmart(new { user = author, guild }));
134+
break;
135+
118136
default:
119137
return false;
120138
}

SuggestionBot/Services/SuggestionService.cs

Lines changed: 44 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -64,37 +64,8 @@ public DiscordEmbed CreatePrivateEmbed(Suggestion suggestion)
6464
return new DiscordEmbedBuilder();
6565
}
6666

67-
if (!_configurationService.TryGetGuildConfiguration(guild, out GuildConfiguration? configuration))
68-
{
69-
configuration = new GuildConfiguration();
70-
}
71-
72-
string emoji = suggestion.Status switch
73-
{
74-
SuggestionStatus.Suggested => "🗳️",
75-
SuggestionStatus.Rejected => "❌",
76-
SuggestionStatus.Implemented => "✅",
77-
SuggestionStatus.Accepted => "✅",
78-
_ => throw new ArgumentOutOfRangeException(nameof(suggestion), suggestion.Status, null)
79-
};
80-
8167
DiscordUser author = GetAuthor(suggestion);
82-
var embed = new DiscordEmbedBuilder();
83-
string authorName = author.GetUsernameWithDiscriminator();
84-
embed.WithAuthor($"Suggestion from {authorName}", iconUrl: author.GetAvatarUrl(ImageFormat.Png));
85-
embed.WithThumbnail(guild.GetIconUrl(ImageFormat.Png));
86-
embed.WithDescription(suggestion.Content);
87-
embed.WithFooter($"Suggestion {suggestion.Id}");
88-
embed.WithColor(suggestion.Status switch
89-
{
90-
SuggestionStatus.Suggested => configuration.SuggestedColor,
91-
SuggestionStatus.Rejected => configuration.RejectedColor,
92-
SuggestionStatus.Implemented => configuration.ImplementedColor,
93-
SuggestionStatus.Accepted => configuration.AcceptedColor,
94-
_ => throw new ArgumentOutOfRangeException(nameof(suggestion), suggestion.Status, null)
95-
});
96-
97-
embed.AddField("Status", $"{emoji} **{suggestion.Status.Humanize(LetterCasing.AllCaps)}**", true);
68+
DiscordEmbedBuilder embed = CreateDefaultEmbed(suggestion, guild);
9869
embed.AddField("Author", author.Mention, true);
9970
embed.AddField("Submitted", Formatter.Timestamp(suggestion.Timestamp), true);
10071
embed.AddField("View Suggestion", GetSuggestionLink(suggestion), true);
@@ -138,39 +109,7 @@ public DiscordEmbed CreatePublicEmbed(Suggestion suggestion)
138109
return new DiscordEmbedBuilder();
139110
}
140111

141-
if (!_configurationService.TryGetGuildConfiguration(guild, out GuildConfiguration? configuration))
142-
{
143-
configuration = new GuildConfiguration();
144-
}
145-
146-
string emoji = suggestion.Status switch
147-
{
148-
SuggestionStatus.Suggested => "🗳️",
149-
SuggestionStatus.Rejected => "❌",
150-
SuggestionStatus.Implemented => "✅",
151-
SuggestionStatus.Accepted => "✅",
152-
_ => throw new ArgumentOutOfRangeException(nameof(suggestion), suggestion.Status, null)
153-
};
154-
155-
DiscordUser author = GetAuthor(suggestion);
156-
var embed = new DiscordEmbedBuilder();
157-
string authorName = author.GetUsernameWithDiscriminator();
158-
embed.WithAuthor($"Suggestion from {authorName}", iconUrl: author.GetAvatarUrl(ImageFormat.Png));
159-
embed.WithThumbnail(guild.GetIconUrl(ImageFormat.Png));
160-
embed.WithDescription(suggestion.Content);
161-
embed.WithFooter($"Suggestion {suggestion.Id}");
162-
embed.WithTimestamp(suggestion.Timestamp);
163-
embed.WithColor(suggestion.Status switch
164-
{
165-
SuggestionStatus.Suggested => configuration.SuggestedColor,
166-
SuggestionStatus.Rejected => configuration.RejectedColor,
167-
SuggestionStatus.Implemented => configuration.ImplementedColor,
168-
SuggestionStatus.Accepted => configuration.AcceptedColor,
169-
_ => throw new ArgumentOutOfRangeException(nameof(suggestion), suggestion.Status, null)
170-
});
171-
172-
embed.AddField("Status", $"{emoji} **{suggestion.Status.Humanize(LetterCasing.AllCaps)}**", true);
173-
112+
DiscordEmbedBuilder embed = CreateDefaultEmbed(suggestion, guild);
174113
if (!string.IsNullOrWhiteSpace(suggestion.Remarks))
175114
{
176115
embed.AddField("Staff Remarks", suggestion.Remarks);
@@ -695,6 +634,48 @@ protected override Task ExecuteAsync(CancellationToken stoppingToken)
695634
return Task.CompletedTask;
696635
}
697636

637+
private DiscordEmbedBuilder CreateDefaultEmbed(Suggestion suggestion, DiscordGuild guild)
638+
{
639+
if (!_configurationService.TryGetGuildConfiguration(guild, out GuildConfiguration? configuration))
640+
{
641+
configuration = new GuildConfiguration();
642+
}
643+
644+
string emoji = suggestion.Status switch
645+
{
646+
SuggestionStatus.Suggested => "🗳️",
647+
SuggestionStatus.Rejected => "❌",
648+
SuggestionStatus.Implemented => "✅",
649+
SuggestionStatus.Accepted => "✅",
650+
SuggestionStatus.Duplicate => "🔁",
651+
SuggestionStatus.AlreadyImplemented => "✅",
652+
SuggestionStatus.AlreadyPlanned => "📅",
653+
_ => throw new ArgumentOutOfRangeException(nameof(suggestion), suggestion.Status, null)
654+
};
655+
656+
DiscordUser author = GetAuthor(suggestion);
657+
var embed = new DiscordEmbedBuilder();
658+
string authorName = author.GetUsernameWithDiscriminator();
659+
embed.WithAuthor($"Suggestion from {authorName}", iconUrl: author.GetAvatarUrl(ImageFormat.Png));
660+
embed.WithThumbnail(guild.GetIconUrl(ImageFormat.Png));
661+
embed.WithDescription(suggestion.Content);
662+
embed.WithFooter($"Suggestion {suggestion.Id}");
663+
embed.WithTimestamp(suggestion.Timestamp);
664+
embed.WithColor(suggestion.Status switch
665+
{
666+
SuggestionStatus.Suggested => configuration.SuggestedColor,
667+
SuggestionStatus.Rejected => configuration.RejectedColor,
668+
SuggestionStatus.Implemented or SuggestionStatus.AlreadyImplemented => configuration.ImplementedColor,
669+
SuggestionStatus.Accepted => configuration.AcceptedColor,
670+
SuggestionStatus.Duplicate => configuration.DuplicateColor,
671+
SuggestionStatus.AlreadyPlanned => configuration.PlannedColor,
672+
_ => throw new ArgumentOutOfRangeException(nameof(suggestion), suggestion.Status, null)
673+
});
674+
675+
embed.AddField("Status", $"{emoji} **{suggestion.Status.Humanize(LetterCasing.AllCaps)}**", true);
676+
return embed;
677+
}
678+
698679
private Task OnGuildAvailable(DiscordClient sender, GuildCreateEventArgs args)
699680
{
700681
DiscordGuild guild = args.Guild;

SuggestionBot/SuggestionBot.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
9-
<VersionPrefix>1.6.0</VersionPrefix>
9+
<VersionPrefix>1.6.1</VersionPrefix>
1010
</PropertyGroup>
1111

1212
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">

0 commit comments

Comments
 (0)