Skip to content

Commit abde431

Browse files
Develop (#14)
* Refactoring * Add EntityFramework * Add Command handling * Add Command handling * Fix command handling * Improve status check * Add json property names to models * Add Dockerfile * Add webhook * Update webhook system * Refactoring * Fix webhook message * Remove unused file * Add Discord logger * Update status check service to order the results * Refactoring * Fix error handling in DiscordService * Added authentication * Update Discord logging * Fix Discord logging * Fix logging * Update README.md * Delete dotnet-build.yml * Fix and improve status check (#8) * Fix and improve status check * Re-enabled Discord logging * Update MacroBotApp.csproj * Fix/fix member screening (#10) * Update docker-deploy-production.yml * Develop (#9) * Refactoring * Add EntityFramework * Add Command handling * Add Command handling * Fix command handling * Improve status check * Add json property names to models * Add Dockerfile * Add webhook * Update webhook system * Refactoring * Fix webhook message * Remove unused file * Add Discord logger * Update status check service to order the results * Refactoring * Fix error handling in DiscordService * Added authentication * Update Discord logging * Fix Discord logging * Fix logging * Update README.md * Delete dotnet-build.yml * Fix and improve status check (#8) * Fix and improve status check * Re-enabled Discord logging * Update MacroBotApp.csproj * Update docker-deploy-production.yml * Fix Member-screening * Minor improvements * Merge main into develop (#13) * Update docker-deploy-develop.yml * Update docker-deploy-production.yml * Develop (#11) * Refactoring * Add EntityFramework * Add Command handling * Add Command handling * Fix command handling * Improve status check * Add json property names to models * Add Dockerfile * Add webhook * Update webhook system * Refactoring * Fix webhook message * Remove unused file * Add Discord logger * Update status check service to order the results * Refactoring * Fix error handling in DiscordService * Added authentication * Update Discord logging * Fix Discord logging * Fix logging * Update README.md * Delete dotnet-build.yml * Fix and improve status check (#8) * Fix and improve status check * Re-enabled Discord logging * Update MacroBotApp.csproj * Fix/fix member screening (#10) * Update docker-deploy-production.yml * Develop (#9) * Refactoring * Add EntityFramework * Add Command handling * Add Command handling * Fix command handling * Improve status check * Add json property names to models * Add Dockerfile * Add webhook * Update webhook system * Refactoring * Fix webhook message * Remove unused file * Add Discord logger * Update status check service to order the results * Refactoring * Fix error handling in DiscordService * Added authentication * Update Discord logging * Fix Discord logging * Fix logging * Update README.md * Delete dotnet-build.yml * Fix and improve status check (#8) * Fix and improve status check * Re-enabled Discord logging * Update MacroBotApp.csproj * Update docker-deploy-production.yml * Fix Member-screening * Minor improvements * Update MacroBotApp.csproj * Update build.yml * Update docker-deploy-production.yml * Update build.yml * Update docker-deploy-develop.yml * Minor changes * Remove glitched character * Delete test.yml
1 parent f681b20 commit abde431

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

MacroBotApp/Discord/DiscordStatusCheckMessageBuilder.cs

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ public static Embed Build(StatusCheckResult[] statusCheckResults)
3636
description += $"⚠️ {nowOnlineWithWarnings.Select(x => $"**{x.Name}**").Join(", ", " and ")} may not work as expected\r\n";
3737
}
3838

39-
description += "᲼᲼\r\n"; // Add empty line
40-
4139
embed.WithDescription(description);
4240

4341
embed.WithColor(statusCheckResults.All(x => x is { Online: true, OnlineWithWarnings: false })

MacroBotApp/Models/Webhook/WebhookRequestEmbed.cs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace MacroBot.Models.Webhook;
33
public class WebhookRequestEmbed
44
{
55
public WebhookRequestEmbedColor? Color { get; set; }
6+
public string? Title { get; set; }
67
public string? Description { get; set; }
78
public List<WebhookRequestEmbedField>? Fields { get; set; }
89
public string? ThumbnailUrl { get; set; }

MacroBotApp/Services/DiscordService.cs

+17-15
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,11 @@ public class DiscordService : IDiscordService, IHostedService
2727
private readonly InteractionService _interactionService;
2828
private readonly IHttpClientFactory _httpClientFactory;
2929

30-
private ulong _updateMessageId = 1;
31-
private int _currentUpdateEmbedHash = 0;
32-
3330
public bool DiscordReady { get; private set; }
3431

35-
private string prevthread = "";
36-
private ulong? prevplauserid = 0;
37-
private string prevplugin = "";
32+
private string _prevThread = "";
33+
private ulong? _prevPlaUserId = 0;
34+
private string _prevPlugin = "";
3835

3936
public DiscordService(BotConfig botConfig,
4037
DiscordSocketClient discordSocketClient,
@@ -105,7 +102,7 @@ private async Task ThreadCreated(SocketThreadChannel thread) {
105102
}
106103

107104
foreach (var extension in extensions) {
108-
if (prevthread == thread.Name)
105+
if (_prevThread == thread.Name)
109106
{
110107
return;
111108
}
@@ -122,9 +119,9 @@ private async Task ThreadCreated(SocketThreadChannel thread) {
122119

123120
embed.AddField("Name", $"{extension.Name} ({extension.PackageId})", true);
124121
embed.AddField("Author", extension.DSupportUserId is not null? $"<@{extension.DSupportUserId}>" : extension.Author, true);
125-
prevthread = thread.Name;
126-
prevplauserid = extension.DSupportUserId is not null ? ulong.Parse(extension.DSupportUserId) : null;
127-
prevplugin = extension.PackageId!;
122+
_prevThread = thread.Name;
123+
_prevPlaUserId = extension.DSupportUserId is not null ? ulong.Parse(extension.DSupportUserId) : null;
124+
_prevPlugin = extension.PackageId!;
128125

129126
var components = new ComponentBuilder()
130127
.WithButton("Yes", "plugin-problem-yes", ButtonStyle.Success)
@@ -143,8 +140,8 @@ private async Task DiscordSocketClientOnButtonExecuted(SocketMessageComponent co
143140
{
144141
case "plugin-problem-yes":
145142
await component.Message.DeleteAsync();
146-
await component.Channel.SendMessageAsync($"<@{prevplauserid}>, {component.User.Mention} has a problem on your plugin.");
147-
await (component.Channel as SocketThreadChannel)!.ModifyAsync(msg => msg.Name = @$"{component.Channel.Name} (Plugin Problem - {prevplugin})");
143+
await component.Channel.SendMessageAsync($"<@{_prevPlaUserId}>, {component.User.Mention} has a problem on your plugin.");
144+
await (component.Channel as SocketThreadChannel)!.ModifyAsync(msg => msg.Name = @$"{component.Channel.Name} (Plugin Problem - {_prevPlugin})");
148145
await (component.Channel as SocketThreadChannel)!.LeaveAsync();
149146
break;
150147
case "plugin-problem-no":
@@ -270,7 +267,7 @@ private async Task MemberMovement(IGuildUser member, bool joined)
270267
{
271268
return;
272269
}
273-
_logger.Information("{User}#{Discriminator} {Action} the server",
270+
_logger.Verbose("{User}#{Discriminator} {Action} the server",
274271
member.Username,
275272
member.Discriminator,
276273
joined
@@ -330,7 +327,7 @@ public async Task BroadcastWebhookAsync(WebhookItem webhook, WebhookRequest webh
330327
{
331328
return;
332329
}
333-
_logger.Information("Executing Webhook {WebhookId}", webhook.Id);
330+
_logger.Verbose("Executing Webhook {WebhookId}", webhook.Id);
334331
if (_discordSocketClient.GetGuild(_botConfig.GuildId)
335332
.GetChannel(webhook.ChannelId) is not ITextChannel channel)
336333
{
@@ -340,7 +337,7 @@ public async Task BroadcastWebhookAsync(WebhookItem webhook, WebhookRequest webh
340337

341338
var text = (webhookRequest.ToEveryone.HasValue && webhookRequest.ToEveryone.Value
342339
? "@everyone"
343-
: ".")
340+
: "")
344341
+ "\r\n"
345342
+ (!string.IsNullOrWhiteSpace(webhookRequest.Title) ? $"**{webhookRequest.Title}**\r\n" : "")
346343
+ webhookRequest.Text;
@@ -357,6 +354,11 @@ public async Task BroadcastWebhookAsync(WebhookItem webhook, WebhookRequest webh
357354
var color = webhookRequestEmbed.Color;
358355
embed.WithColor(new Color(color.R, color.G, color.B));
359356
}
357+
358+
if (!string.IsNullOrWhiteSpace(webhookRequestEmbed.Title))
359+
{
360+
embed.Title = webhookRequestEmbed.Title;
361+
}
360362

361363
if (!string.IsNullOrWhiteSpace(webhookRequestEmbed.Description))
362364
{

0 commit comments

Comments
 (0)