feat: beta bot patches
This commit is contained in:
parent
997458c9dc
commit
99a9ec7928
@ -24,6 +24,9 @@ public class BotConfig
|
||||
|
||||
public bool DisableErrorReporting { get; set; } = false;
|
||||
|
||||
public bool IsBetaBot { get; set; } = false!;
|
||||
public string BetaBotAPIUrl { get; set; }
|
||||
|
||||
public record ClusterSettings
|
||||
{
|
||||
public string NodeName { get; set; }
|
||||
|
@ -14,11 +14,13 @@ public class Api
|
||||
private static readonly Regex _webhookRegex =
|
||||
new("https://(?:\\w+.)?discord(?:app)?.com/api(?:/v.*)?/webhooks/(.*)");
|
||||
|
||||
private readonly BotConfig _botConfig;
|
||||
private readonly DispatchService _dispatch;
|
||||
private readonly ModelRepository _repo;
|
||||
|
||||
public Api(ModelRepository repo, DispatchService dispatch)
|
||||
public Api(BotConfig botConfig, ModelRepository repo, DispatchService dispatch)
|
||||
{
|
||||
_botConfig = botConfig;
|
||||
_repo = repo;
|
||||
_dispatch = dispatch;
|
||||
}
|
||||
@ -42,6 +44,13 @@ public class Api
|
||||
});
|
||||
await ctx.Rest.CreateMessage(dm.Id, new MessageRequest { Content = token });
|
||||
|
||||
if (_botConfig.IsBetaBot)
|
||||
await ctx.Rest.CreateMessage(dm.Id, new MessageRequest
|
||||
{
|
||||
Content = $"{Emojis.Note} The beta bot's API base URL is currently <{_botConfig.BetaBotAPIUrl}>."
|
||||
+ " You need to use this URL instead of the base URL listed on the documentation website."
|
||||
});
|
||||
|
||||
// If we're not already in a DM, reply with a reminder to check
|
||||
if (ctx.Channel.Type != Channel.ChannelType.Dm)
|
||||
await ctx.Reply($"{Emojis.Success} Check your DMs!");
|
||||
@ -87,6 +96,13 @@ public class Api
|
||||
var token = await MakeAndSetNewToken(ctx.System);
|
||||
await ctx.Rest.CreateMessage(dm.Id, new MessageRequest { Content = token });
|
||||
|
||||
if (_botConfig.IsBetaBot)
|
||||
await ctx.Rest.CreateMessage(dm.Id, new MessageRequest
|
||||
{
|
||||
Content = $"{Emojis.Note} The beta bot's API base URL is currently <{_botConfig.BetaBotAPIUrl}>."
|
||||
+ " You need to use this URL instead of the base URL listed on the documentation website."
|
||||
});
|
||||
|
||||
// If we're not already in a DM, reply with a reminder to check
|
||||
if (ctx.Channel.Type != Channel.ChannelType.Dm)
|
||||
await ctx.Reply($"{Emojis.Success} Check your DMs!");
|
||||
|
@ -50,7 +50,9 @@ public class Misc
|
||||
|
||||
var invite =
|
||||
$"https://discord.com/oauth2/authorize?client_id={clientId}&scope=bot%20applications.commands&permissions={(ulong)permissions}";
|
||||
await ctx.Reply($"{Emojis.Success} Use this link to add PluralKit to your server:\n<{invite}>");
|
||||
|
||||
var botName = _botConfig.IsBetaBot ? "PluralKit Beta" : "PluralKit";
|
||||
await ctx.Reply($"{Emojis.Success} Use this link to add {botName} to your server:\n<{invite}>");
|
||||
}
|
||||
|
||||
public async Task Stats(Context ctx)
|
||||
|
@ -20,11 +20,13 @@ public class ErrorMessageService
|
||||
private static readonly Duration IntervalFromStartup = Duration.FromMinutes(5);
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly BotConfig _botConfig;
|
||||
private readonly IMetrics _metrics;
|
||||
private readonly DiscordApiClient _rest;
|
||||
|
||||
public ErrorMessageService(IMetrics metrics, ILogger logger, DiscordApiClient rest)
|
||||
public ErrorMessageService(BotConfig botConfig, IMetrics metrics, ILogger logger, DiscordApiClient rest)
|
||||
{
|
||||
_botConfig = botConfig;
|
||||
_metrics = metrics;
|
||||
_logger = logger;
|
||||
_rest = rest;
|
||||
@ -46,11 +48,14 @@ public class ErrorMessageService
|
||||
return;
|
||||
}
|
||||
|
||||
var channelInfo = _botConfig.IsBetaBot
|
||||
? "**#hi-please-break-the-beta-bot** on **[the support server *(click to join)*](https://discord.gg/THvbH59btW)**"
|
||||
: "**#bug-reports-and-errors** on **[the support server *(click to join)*](https://discord.gg/PczBt78)**";
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
.Color(0xE74C3C)
|
||||
.Title("Internal error occurred")
|
||||
.Description(
|
||||
"For support, please send the error code above in **#bug-reports-and-errors** on **[the support server *(click to join)*](https://discord.gg/PczBt78)** with a description of what you were doing at the time.")
|
||||
.Description($"For support, please send the error code above in {channelInfo} with a description of what you were doing at the time.")
|
||||
.Footer(new Embed.EmbedFooter(errorId))
|
||||
.Timestamp(now.ToDateTimeOffset().ToString("O"));
|
||||
|
||||
@ -77,7 +82,7 @@ public class ErrorMessageService
|
||||
var startupTime = Instant.FromDateTimeUtc(Process.GetCurrentProcess().StartTime.ToUniversalTime());
|
||||
// don't send errors during startup
|
||||
// mostly because Npgsql throws a bunch of errors when opening connections sometimes???
|
||||
if (now - startupTime < IntervalFromStartup)
|
||||
if (now - startupTime < IntervalFromStartup && !_botConfig.IsBetaBot)
|
||||
return false;
|
||||
|
||||
var interval = now - lastErrorTime;
|
||||
|
Loading…
Reference in New Issue
Block a user