mirror of
https://github.com/RPCS3/discord-bot.git
synced 2026-01-31 01:25:22 +01:00
update the default warning message
This commit is contained in:
@@ -69,10 +69,7 @@ internal static class WarningsContextMenus
|
||||
|
||||
if (!suppress)
|
||||
{
|
||||
var userMsgContent = $"""
|
||||
User warning saved, {user.Mention} has {recent} recent warning{StringUtils.GetSuffix(recent)} ({total} total)
|
||||
Warned for: {reason} by {ctx.User.Mention}
|
||||
""";
|
||||
var userMsgContent = await Warnings.GetDefaultWarningMessageAsync(ctx.Client, user, reason, recent, total, ctx.User).ConfigureAwait(false);
|
||||
var userMsg = new DiscordMessageBuilder()
|
||||
.WithContent(userMsgContent)
|
||||
.AddMention(new UserMention(user.Id));
|
||||
|
||||
@@ -29,10 +29,7 @@ internal static partial class Warnings
|
||||
|
||||
if (!suppress)
|
||||
{
|
||||
var userMsgContent = $"""
|
||||
User warning saved, {user.Mention} has {recent} recent warning{StringUtils.GetSuffix(recent)} ({total} total)
|
||||
Warned for: {reason} by {ctx.User.Mention}
|
||||
""";
|
||||
var userMsgContent = await GetDefaultWarningMessageAsync(ctx.Client, user, reason, recent, total, ctx.User).ConfigureAwait(false);
|
||||
var userMsg = new DiscordMessageBuilder()
|
||||
.WithContent(userMsgContent)
|
||||
.AddMention(new UserMention(user));
|
||||
@@ -175,6 +172,27 @@ internal static partial class Warnings
|
||||
await ctx.RespondAsync($"{Config.Reactions.Failure} Warning is not retracted", ephemeral: true).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
internal static async ValueTask<string> GetDefaultWarningMessageAsync(
|
||||
DiscordClient client,
|
||||
DiscordUser userToWarn,
|
||||
string reason,
|
||||
int recentWarnCount,
|
||||
int totalWarnCount,
|
||||
DiscordUser moderator)
|
||||
{
|
||||
var rulesCh = await client.GetChannelAsync(Config.BotRulesChannelId).ConfigureAwait(false);
|
||||
return $"""
|
||||
## ⚠️ {userToWarn.Mention} you have been warned ⚠️
|
||||
**Reason:** {reason}
|
||||
|
||||
**Read the {rulesCh.Mention} before continuing to chat**
|
||||
Refusing to read/follow the server rules *will* result in a server ban
|
||||
|
||||
-# You have {recentWarnCount} recent warning{StringUtils.GetSuffix(recentWarnCount)} ({totalWarnCount} total)
|
||||
-# Warning added by {moderator.Mention}
|
||||
""";
|
||||
}
|
||||
|
||||
internal static async ValueTask<(bool saved, bool suppress, int recentCount, int totalCount)>
|
||||
AddAsync(ulong userId, DiscordUser issuer, string reason, string? fullReason = null)
|
||||
{
|
||||
|
||||
@@ -233,20 +233,17 @@ internal static class ContentFilter
|
||||
).ConfigureAwait(false);
|
||||
if (saved && !suppress && message.Channel is not null)
|
||||
{
|
||||
var msgContent = await Warnings.GetDefaultWarningMessageAsync(client, message.Author, warningReason, recent, total, client.CurrentUser).ConfigureAwait(false);
|
||||
var msg = new DiscordMessageBuilder()
|
||||
.WithContent(
|
||||
$"""
|
||||
User warning saved, {message.Author.Mention} has {recent} recent warning{StringUtils.GetSuffix(recent)} ({total} total)
|
||||
Warned for: {warningReason} by {client.CurrentUser.Mention}
|
||||
"""
|
||||
).AddMention(new UserMention(message.Author));
|
||||
.WithContent(msgContent)
|
||||
.AddMention(new UserMention(message.Author));
|
||||
await message.Channel.SendMessageAsync(msg).ConfigureAwait(false);
|
||||
}
|
||||
completedActions.Add(FilterAction.IssueWarning);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Config.Log.Warn(e, $"Couldn't issue warning in #{message.Channel.Name}");
|
||||
Config.Log.Warn(e, $"Couldn't issue warning in #{message.Channel?.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Net.Http.Headers;
|
||||
using System.Text.RegularExpressions;
|
||||
using CompatApiClient.Compression;
|
||||
using CompatBot.Commands;
|
||||
using CompatBot.Database;
|
||||
using CompatBot.Database.Providers;
|
||||
using CompatBot.Utils.Extensions;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
@@ -130,13 +131,10 @@ internal static partial class DiscordInviteFilter
|
||||
).ConfigureAwait(false);
|
||||
if (saved && !suppress)
|
||||
{
|
||||
var content = await Warnings.GetDefaultWarningMessageAsync(client, message.Author, reason, recent, total, client.CurrentUser).ConfigureAwait(false);
|
||||
var msg = new DiscordMessageBuilder()
|
||||
.WithContent(
|
||||
$"""
|
||||
User warning saved, {message.Author.Mention} has {recent} recent warning{StringUtils.GetSuffix(recent)} ({total} total)
|
||||
Warned for: {reason} by {client.CurrentUser.Mention}
|
||||
"""
|
||||
).AddMention(new UserMention(message.Author));
|
||||
.WithContent(content)
|
||||
.AddMention(new UserMention(message.Author));
|
||||
await message.Channel.SendMessageAsync(msg).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,13 +235,10 @@ public static class LogParsingHandler
|
||||
);
|
||||
if (saved && !suppress)
|
||||
{
|
||||
var content = await Warnings.GetDefaultWarningMessageAsync(client, message.Author, reason, recent, total, client.CurrentUser).ConfigureAwait(false);
|
||||
var msg = new DiscordMessageBuilder()
|
||||
.WithContent(
|
||||
$"""
|
||||
User warning saved, {message.Author.Mention} has {recent} recent warning{StringUtils.GetSuffix(recent)} ({total} total)
|
||||
Warned for: {reason} by {client.CurrentUser.Mention}
|
||||
"""
|
||||
).AddMention(new UserMention(message.Author));
|
||||
.WithContent(content)
|
||||
.AddMention(new UserMention(message.Author));
|
||||
await message.Channel!.SendMessageAsync(msg).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user