Temporary workaround for https://github.com/DSharpPlus/DSharpPlus/issues/565
This commit is contained in:
parent
c1d17c2944
commit
892601110f
@ -11,6 +11,7 @@ using Autofac;
|
||||
using DSharpPlus;
|
||||
using DSharpPlus.Entities;
|
||||
using DSharpPlus.EventArgs;
|
||||
using DSharpPlus.Exceptions;
|
||||
|
||||
using NodaTime;
|
||||
|
||||
@ -122,6 +123,8 @@ namespace PluralKit.Bot
|
||||
{
|
||||
// Make this beforehand so we can access the event ID for logging
|
||||
var sentryEvent = new SentryEvent(exc);
|
||||
if (exc is BadRequestException bre)
|
||||
sentryEvent.SetExtra("errors", MiscUtils.ExtractError(bre));
|
||||
|
||||
_logger.Error(exc, "Exception in bot event handler (Sentry ID: {SentryEventId})", sentryEvent.EventId);
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace PluralKit.Bot {
|
||||
var eb = new DiscordEmbedBuilder()
|
||||
.WithColor(DiscordUtils.Gray)
|
||||
.WithTitle(system.Name ?? null)
|
||||
.WithThumbnailUrl(system.AvatarUrl ?? null)
|
||||
.WithThumbnailUrl(system.AvatarUrl)
|
||||
.WithFooter($"System ID: {system.Hid} | Created on {DateTimeFormats.ZonedDateTimeFormat.Format(system.Created.InZone(system.Zone))}");
|
||||
|
||||
var latestSwitch = await _data.GetLatestSwitch(system);
|
||||
@ -66,7 +66,8 @@ namespace PluralKit.Bot {
|
||||
// TODO: pronouns in ?-reacted response using this card
|
||||
var timestamp = DiscordUtils.SnowflakeToInstant(messageId);
|
||||
return new DiscordEmbedBuilder()
|
||||
.WithAuthor($"#{channel.Name}: {member.Name}", iconUrl: member.AvatarUrl)
|
||||
.WithAuthor($"#{channel.Name}: {member.Name}", iconUrl: DiscordUtils.WorkaroundForUrlBug(member.AvatarUrl))
|
||||
.WithThumbnailUrl(member.AvatarUrl)
|
||||
.WithDescription(content?.NormalizeLineEndSpacing())
|
||||
.WithFooter($"System ID: {system.Hid} | Member ID: {member.Hid} | Sender: {sender.Username}#{sender.Discriminator} ({sender.Id}) | Message ID: {messageId} | Original Message ID: {originalMsgId}")
|
||||
.WithTimestamp(timestamp.ToDateTimeOffset())
|
||||
@ -101,7 +102,7 @@ namespace PluralKit.Bot {
|
||||
|
||||
var eb = new DiscordEmbedBuilder()
|
||||
// TODO: add URL of website when that's up
|
||||
.WithAuthor(name, avatar)
|
||||
.WithAuthor(name, iconUrl: DiscordUtils.WorkaroundForUrlBug(avatar))
|
||||
.WithColor(member.MemberPrivacy.CanAccess(ctx) ? color : DiscordUtils.Gray)
|
||||
.WithFooter($"System ID: {system.Hid} | Member ID: {member.Hid} | Created on {DateTimeFormats.ZonedDateTimeFormat.Format(member.Created.InZone(system.Zone))}");
|
||||
|
||||
@ -167,7 +168,7 @@ namespace PluralKit.Bot {
|
||||
}
|
||||
|
||||
var eb = new DiscordEmbedBuilder()
|
||||
.WithAuthor(msg.Member.Name, msg.Member.AvatarUrl)
|
||||
.WithAuthor(msg.Member.Name, iconUrl: DiscordUtils.WorkaroundForUrlBug(msg.Member.AvatarUrl))
|
||||
.WithDescription(serverMsg?.Content?.NormalizeLineEndSpacing() ?? "*(message contents deleted or inaccessible)*")
|
||||
.WithImageUrl(serverMsg?.Attachments?.FirstOrDefault()?.Url)
|
||||
.AddField("System",
|
||||
|
@ -84,5 +84,11 @@ namespace PluralKit.Bot
|
||||
await msg.CreateReactionAsync(DiscordEmoji.FromUnicode(reaction));
|
||||
}
|
||||
}
|
||||
|
||||
public static string WorkaroundForUrlBug(string input)
|
||||
{
|
||||
// Workaround for https://github.com/DSharpPlus/DSharpPlus/issues/565
|
||||
return input.Replace("%20", "+");
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,8 @@ using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using DSharpPlus.Exceptions;
|
||||
|
||||
using Npgsql;
|
||||
|
||||
using PluralKit.Core;
|
||||
@ -40,5 +42,10 @@ namespace PluralKit.Bot
|
||||
// This may expanded at some point.
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string ExtractError(BadRequestException e)
|
||||
{
|
||||
return e.WebResponse.Response;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user