mirror of
https://github.com/RPCS3/discord-bot.git
synced 2025-02-12 05:20:27 +00:00
parent
d729ceddd2
commit
c68678c740
@ -90,7 +90,11 @@ namespace CompatBot.Commands
|
||||
{
|
||||
try
|
||||
{
|
||||
LogParsingHandler.EnqueueLogProcessing(ctx.Client, ctx.Channel, ctx.Message, ctx.Member, true, true);
|
||||
if (ctx.Message.Attachments.Any())
|
||||
LogParsingHandler.EnqueueLogProcessing(ctx.Client, ctx.Channel, ctx.Message, ctx.Member, true, true);
|
||||
else if (ctx.Message.ReferencedMessage is {} refMsg && refMsg.Attachments.Any())
|
||||
LogParsingHandler.EnqueueLogProcessing(ctx.Client, ctx.Channel, refMsg, ctx.Member, true, true);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -101,7 +101,10 @@ namespace CompatBot.EventHandlers
|
||||
{
|
||||
Config.Log.Debug($">>>>>>> {message.Id % 100} Parsing log '{source.FileName}' from {message.Author.Username}#{message.Author.Discriminator} ({message.Author.Id}) using {source.GetType().Name} ({source.SourceFileSize} bytes)...");
|
||||
var analyzingProgressEmbed = GetAnalyzingMsgEmbed(client);
|
||||
botMsg = await channel.SendMessageAsync(embed: analyzingProgressEmbed.AddAuthor(client, message, source)).ConfigureAwait(false);
|
||||
var msgBuilder = new DiscordMessageBuilder()
|
||||
.WithEmbed(analyzingProgressEmbed.AddAuthor(client, message, source))
|
||||
.WithReply(message.Id);
|
||||
botMsg = await channel.SendMessageAsync(msgBuilder).ConfigureAwait(false);
|
||||
parsedLog = true;
|
||||
|
||||
LogParseState? result = null, tmpResult;
|
||||
@ -238,7 +241,7 @@ namespace CompatBot.EventHandlers
|
||||
}
|
||||
|
||||
botMsg = await botMsg.UpdateOrCreateMessageAsync(channel,
|
||||
requester == null ? null : $"Analyzed log from {client.GetMember(channel.Guild, message.Author)?.GetUsernameWithNickname()} by request from {requester.Mention}:",
|
||||
//requester == null ? null : $"Analyzed log from {client.GetMember(channel.Guild, message.Author)?.GetUsernameWithNickname()} by request from {requester.Mention}:",
|
||||
embed: await result.AsEmbedAsync(client, message, source).ConfigureAwait(false)
|
||||
).ConfigureAwait(false);
|
||||
}
|
||||
|
@ -11,15 +11,20 @@ namespace CompatBot.Utils
|
||||
{
|
||||
public static class DiscordMessageExtensions
|
||||
{
|
||||
public static async Task<DiscordMessage> UpdateOrCreateMessageAsync(this DiscordMessage? message, DiscordChannel channel, string? content = null, DiscordEmbed? embed = null)
|
||||
public static async Task<DiscordMessage> UpdateOrCreateMessageAsync(this DiscordMessage? botMsg, DiscordChannel channel, string? content = null, DiscordEmbed? embed = null, DiscordMessage? refMsg = null)
|
||||
{
|
||||
Exception? lastException = null;
|
||||
for (var i = 0; i<3; i++)
|
||||
try
|
||||
{
|
||||
if (message == null)
|
||||
if (botMsg == null)
|
||||
{
|
||||
var newMsg = await channel.SendMessageAsync(content, embed).ConfigureAwait(false);
|
||||
var msgBuilder = new DiscordMessageBuilder()
|
||||
.WithContent(content)
|
||||
.WithEmbed(embed);
|
||||
if (refMsg is not null)
|
||||
msgBuilder.WithReply(refMsg.Id);
|
||||
var newMsg = await channel.SendMessageAsync(msgBuilder).ConfigureAwait(false);
|
||||
#warning Ugly hack, needs proper fix in upstream, but they are not enthused to do so
|
||||
if (newMsg.Channel is null)
|
||||
{
|
||||
@ -30,7 +35,7 @@ namespace CompatBot.Utils
|
||||
}
|
||||
return newMsg;
|
||||
}
|
||||
return await message.ModifyAsync(content, embed).ConfigureAwait(false);
|
||||
return await botMsg.ModifyAsync(content, embed).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user