Skip to content

Commit 618c615

Browse files
committed
Merge branch 'v1.4.0' into main
2 parents 527cba5 + e86cc21 commit 618c615

8 files changed

Lines changed: 46 additions & 138 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ 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.4.0] - 2023-07-23
9+
10+
### Added
11+
12+
- Add new ACCEPTED suggestion status.
13+
14+
### Changed
15+
16+
- `/suggestion implement` and `/suggestion reject` combined to `/suggestion setstatus`.
17+
818
## [1.3.2] - 2023-07-22
919

1020
### Added

SuggestionBot/Commands/SuggestionCommand.Reject.cs

Lines changed: 0 additions & 43 deletions
This file was deleted.

SuggestionBot/Commands/SuggestionCommand.Implement.cs renamed to SuggestionBot/Commands/SuggestionCommand.SetStatus.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
using DSharpPlus.Entities;
22
using DSharpPlus.SlashCommands;
3+
using Humanizer;
34
using SuggestionBot.AutocompleteProviders;
45
using SuggestionBot.Data;
56

67
namespace SuggestionBot.Commands;
78

89
internal sealed partial class SuggestionCommand
910
{
10-
[SlashCommand("implement", "Implements a suggestion.", false)]
11-
public async Task ImplementAsync(InteractionContext context,
12-
[Option("suggestion", "The suggestion to implement."), Autocomplete(typeof(SuggestionAutocompleteProvider))]
13-
string query)
11+
[SlashCommand("setstatus", "Sets a new status for a suggestion.", false)]
12+
public async Task SetStatusAsync(InteractionContext context,
13+
[Option("suggestion", "The suggestion whose status to change.")]
14+
[Autocomplete(typeof(SuggestionAutocompleteProvider))]
15+
string query,
16+
[Option("status", "The new status of the suggestion.")]
17+
SuggestionStatus status)
1418
{
1519
var response = new DiscordInteractionResponseBuilder();
1620

@@ -23,17 +27,19 @@ public async Task ImplementAsync(InteractionContext context,
2327
}
2428

2529
var embed = new DiscordEmbedBuilder();
26-
if (_suggestionService.Implement(suggestion, context.Member))
30+
string humanizedStatus = status.Humanize(LetterCasing.AllCaps);
31+
32+
if (_suggestionService.SetStatus(suggestion, status, context.Member))
2733
{
2834
embed.WithColor(DiscordColor.Orange);
29-
embed.WithTitle("Suggestion Implemented");
30-
embed.WithDescription($"The suggestion with the ID {suggestion.Id} has been marked as IMPLEMENTED.");
35+
embed.WithTitle("Suggestion Status Changed");
36+
embed.WithDescription($"The suggestion with the ID {suggestion.Id} has been marked as {humanizedStatus}.");
3137
}
3238
else
3339
{
3440
embed.WithColor(DiscordColor.Orange);
3541
embed.WithTitle("Suggestion Unchanged");
36-
embed.WithDescription($"The suggestion with the ID {suggestion.Id} was already implemented. " +
42+
embed.WithDescription($"The suggestion with the ID {suggestion.Id} was already {humanizedStatus}. " +
3743
"No changes were made.");
3844
}
3945

SuggestionBot/Configuration/GuildConfiguration.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
/// </summary>
66
public sealed class GuildConfiguration
77
{
8+
/// <summary>
9+
/// Gets or sets the embed color for accepted suggestions.
10+
/// </summary>
11+
/// <value>The embed color for accepted suggestions.</value>
12+
public int AcceptedColor { get; set; } = 0x00FF00;
13+
814
/// <summary>
915
/// Gets or sets the cooldown for posting suggestions.
1016
/// </summary>

SuggestionBot/Data/SuggestionStatus.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ public enum SuggestionStatus
77
{
88
Suggested,
99
Rejected,
10-
Implemented
10+
Implemented,
11+
Accepted
1112
}

SuggestionBot/Services/SuggestionService.cs

Lines changed: 7 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public DiscordEmbed CreatePrivateEmbed(Suggestion suggestion)
7474
SuggestionStatus.Suggested => "🗳️",
7575
SuggestionStatus.Rejected => "❌",
7676
SuggestionStatus.Implemented => "✅",
77+
SuggestionStatus.Accepted => "✅",
7778
_ => throw new ArgumentOutOfRangeException(nameof(suggestion), suggestion.Status, null)
7879
};
7980

@@ -89,6 +90,7 @@ public DiscordEmbed CreatePrivateEmbed(Suggestion suggestion)
8990
SuggestionStatus.Suggested => configuration.SuggestedColor,
9091
SuggestionStatus.Rejected => configuration.RejectedColor,
9192
SuggestionStatus.Implemented => configuration.ImplementedColor,
93+
SuggestionStatus.Accepted => configuration.AcceptedColor,
9294
_ => throw new ArgumentOutOfRangeException(nameof(suggestion), suggestion.Status, null)
9395
});
9496

@@ -136,6 +138,7 @@ public DiscordEmbed CreatePublicEmbed(Suggestion suggestion)
136138
SuggestionStatus.Suggested => "🗳️",
137139
SuggestionStatus.Rejected => "❌",
138140
SuggestionStatus.Implemented => "✅",
141+
SuggestionStatus.Accepted => "✅",
139142
_ => throw new ArgumentOutOfRangeException(nameof(suggestion), suggestion.Status, null)
140143
};
141144

@@ -152,6 +155,7 @@ public DiscordEmbed CreatePublicEmbed(Suggestion suggestion)
152155
SuggestionStatus.Suggested => configuration.SuggestedColor,
153156
SuggestionStatus.Rejected => configuration.RejectedColor,
154157
SuggestionStatus.Implemented => configuration.ImplementedColor,
158+
SuggestionStatus.Accepted => configuration.AcceptedColor,
155159
_ => throw new ArgumentOutOfRangeException(nameof(suggestion), suggestion.Status, null)
156160
});
157161

@@ -317,42 +321,6 @@ public Uri GetSuggestionLink(Suggestion suggestion)
317321
return new Uri($"https://discord.com/channels/{guildId}/{configuration?.SuggestionChannel}/{messageId}");
318322
}
319323

320-
/// <summary>
321-
/// Marks a suggestion as implemented, and optionally updates the remarks for the implementation.
322-
/// </summary>
323-
/// <param name="suggestion">The suggestion to update.</param>
324-
/// <param name="staffMember">The staff member who implemented the suggestion.</param>
325-
/// <returns><see langword="true" /> if the status was updated; otherwise, <see langword="false" />.</returns>
326-
/// <exception cref="ArgumentNullException">
327-
/// <para><paramref name="suggestion" /> is <see langword="null" />.</para>
328-
/// -or-
329-
/// <para><paramref name="staffMember" /> is <see langword="null" />.</para>
330-
/// </exception>
331-
public bool Implement(Suggestion suggestion, DiscordMember staffMember)
332-
{
333-
if (suggestion is null)
334-
{
335-
throw new ArgumentNullException(nameof(suggestion));
336-
}
337-
338-
if (staffMember is null)
339-
{
340-
throw new ArgumentNullException(nameof(staffMember));
341-
}
342-
343-
if (!SetStatus(suggestion, SuggestionStatus.Implemented, staffMember))
344-
{
345-
return false;
346-
}
347-
348-
_logger.LogInformation("{StaffMember} marked suggestion {Id} as IMPLEMENTED", staffMember, suggestion.Id);
349-
350-
using SuggestionContext context = _contextFactory.CreateDbContext();
351-
context.Suggestions.Update(suggestion);
352-
context.SaveChanges();
353-
return true;
354-
}
355-
356324
/// <summary>
357325
/// Posts a suggestion to the suggestion channel of the guild in which it was made.
358326
/// </summary>
@@ -396,42 +364,6 @@ public bool Implement(Suggestion suggestion, DiscordMember staffMember)
396364
return message;
397365
}
398366

399-
/// <summary>
400-
/// Marks a suggestion as rejected, and updates the reason for the rejection if one is provided.
401-
/// </summary>
402-
/// <param name="suggestion">The suggestion to update.</param>
403-
/// <param name="staffMember">The staff member who rejected the suggestion.</param>
404-
/// <returns><see langword="true" /> if the status was updated; otherwise, <see langword="false" />.</returns>
405-
/// <exception cref="ArgumentNullException">
406-
/// <para><paramref name="suggestion" /> is <see langword="null" />.</para>
407-
/// -or-
408-
/// <para><paramref name="staffMember" /> is <see langword="null" />.</para>
409-
/// </exception>
410-
public bool Reject(Suggestion suggestion, DiscordMember staffMember)
411-
{
412-
if (suggestion is null)
413-
{
414-
throw new ArgumentNullException(nameof(suggestion));
415-
}
416-
417-
if (staffMember is null)
418-
{
419-
throw new ArgumentNullException(nameof(staffMember));
420-
}
421-
422-
if (!SetStatus(suggestion, SuggestionStatus.Rejected, staffMember))
423-
{
424-
return false;
425-
}
426-
427-
_logger.LogInformation("{StaffMember} marked suggestion {Id} as REJECTED", staffMember, suggestion.Id);
428-
429-
using SuggestionContext context = _contextFactory.CreateDbContext();
430-
context.Suggestions.Update(suggestion);
431-
context.SaveChanges();
432-
return true;
433-
}
434-
435367
/// <summary>
436368
/// Sets the message of a suggestion.
437369
/// </summary>
@@ -503,6 +435,9 @@ public bool SetStatus(Suggestion suggestion, SuggestionStatus status, DiscordMem
503435
context.Suggestions.Update(suggestion);
504436
context.SaveChanges();
505437

438+
_logger.LogInformation("{StaffMember} marked suggestion {Id} as {Status}", staffMember, suggestion.Id,
439+
humanizedStatus);
440+
506441
_ = UpdateSuggestionAsync(suggestion);
507442
return true;
508443
}

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.3.2</VersionPrefix>
9+
<VersionPrefix>1.4.0</VersionPrefix>
1010
</PropertyGroup>
1111

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

USAGE.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,14 @@ Allow a user to send suggestions again.
3838

3939
## Implementing and Rejecting Suggestions
4040

41-
### `/suggestion implement`
41+
### `/suggestion setstatus`
4242

43-
Mark a suggestion as implemented.
43+
Change the status of a suggestion
4444

45-
| Parameter | Required | Type | Description |
46-
|:-----------|:---------|:-------------------------|:-----------------------------|
47-
| suggestion | ✅ Yes | Suggestion or Message ID | The suggestion to implement. |
48-
49-
### `/suggestion reject`
50-
51-
Mark a suggestion as rejected.
52-
53-
| Parameter | Required | Type | Description |
54-
|:-----------|:---------|:-------------------------|:--------------------------|
55-
| suggestion | ✅ Yes | Suggestion or Message ID | The suggestion to reject. |
45+
| Parameter | Required | Type | Description |
46+
|:-----------|:---------|:-------------------------|:---------------------------------------|
47+
| suggestion | ✅ Yes | Suggestion or Message ID | The suggestion whose status to change. |
48+
| status | ✅ Yes | SuggestionStatus | The new status of the suggestion. |
5649

5750
# Ephemeral responses
5851

0 commit comments

Comments
 (0)