mirror of
https://github.com/RPCS3/discord-bot.git
synced 2026-01-31 01:25:22 +01:00
update dependencies
This commit is contained in:
@@ -16,8 +16,8 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.3.6" />
|
||||
<PackageReference Include="NLog" Version="4.7.6" />
|
||||
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.4.0" />
|
||||
<PackageReference Include="NLog" Version="4.7.7" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Crc32.NET" Version="1.2.0" />
|
||||
<PackageReference Include="DiscUtils.OpticalDisk" Version="0.16.0-alpha0038" />
|
||||
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.3.6" />
|
||||
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.3.6" />
|
||||
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.CommandsNext.Attributes;
|
||||
using DSharpPlus.Entities;
|
||||
|
||||
namespace CompatBot.Commands.Attributes
|
||||
{
|
||||
@@ -23,7 +24,7 @@ namespace CompatBot.Commands.Attributes
|
||||
return true;
|
||||
|
||||
await using var stream = new MemoryStream(Poster.Value);
|
||||
await ctx.RespondWithFileAsync("senpai_plz.jpg", stream).ConfigureAwait(false);
|
||||
await ctx.RespondAsync(new DiscordMessageBuilder().WithFile("senpai_plz.jpg", stream)).ConfigureAwait(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,12 +346,12 @@ namespace CompatBot.Commands
|
||||
if (!string.IsNullOrEmpty(item.Text))
|
||||
{
|
||||
await using var stream = new MemoryStream(Encoding.UTF8.GetBytes(item.Text));
|
||||
await ctx.Channel.SendFileAsync($"{termOrLink}.txt", stream).ConfigureAwait(false);
|
||||
await ctx.Channel.SendMessageAsync(new DiscordMessageBuilder().WithFile($"{termOrLink}.txt", stream)).ConfigureAwait(false);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(item.AttachmentFilename) && item.Attachment?.Length > 0)
|
||||
{
|
||||
await using var stream = new MemoryStream(item.Attachment);
|
||||
await ctx.Channel.SendFileAsync(item.AttachmentFilename, stream).ConfigureAwait(false);
|
||||
await ctx.Channel.SendMessageAsync(new DiscordMessageBuilder().WithFile(item.AttachmentFilename, stream)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -423,7 +423,7 @@ namespace CompatBot.Commands
|
||||
else
|
||||
{
|
||||
await using var stream = new MemoryStream(Encoding.UTF8.GetBytes(explanation));
|
||||
await ctx.Channel.SendFileAsync("explanation.txt", stream).ConfigureAwait(false);
|
||||
await ctx.Channel.SendMessageAsync(new DiscordMessageBuilder().WithFile("explanation.txt", stream)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace CompatBot.Commands
|
||||
var msgLen = (4 * width * height - 4) + (height - 1) + mineCount * MaxBombLength + (width * height - mineCount) * "0️⃣".Length + header.Length;
|
||||
if (width * height > 198 || msgLen > 2000) // for some reason discord would cut everything beyond 198 cells even if the content length is well within the limits
|
||||
{
|
||||
await ctx.RespondAsync("Requested field size is too large for one message", true).ConfigureAwait(false);
|
||||
await ctx.RespondAsync("Requested field size is too large for one message").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace CompatBot.Commands
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
if (memoryStream.Length <= Config.AttachmentSizeLimit)
|
||||
{
|
||||
await ctx.RespondWithFileAsync("names.txt", memoryStream).ConfigureAwait(false);
|
||||
await ctx.RespondAsync(new DiscordMessageBuilder().WithFile("names.txt", memoryStream)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace CompatBot.Commands
|
||||
await gzip.FlushAsync().ConfigureAwait(false);
|
||||
compressedResult.Seek(0, SeekOrigin.Begin);
|
||||
if (compressedResult.Length <= Config.AttachmentSizeLimit)
|
||||
await ctx.RespondWithFileAsync("names.txt.gz", compressedResult).ConfigureAwait(false);
|
||||
await ctx.RespondAsync(new DiscordMessageBuilder().WithFile("names.txt.gz", compressedResult)).ConfigureAwait(false);
|
||||
else
|
||||
await ctx.RespondAsync($"Dump is too large: {compressedResult.Length} bytes").ConfigureAwait(false);
|
||||
}
|
||||
@@ -216,7 +216,7 @@ namespace CompatBot.Commands
|
||||
|
||||
if (uncompressedStream.Length <= Config.AttachmentSizeLimit)
|
||||
{
|
||||
await ctx.RespondWithFileAsync("spoofing_check_results.txt", uncompressedStream).ConfigureAwait(false);
|
||||
await ctx.RespondAsync(new DiscordMessageBuilder().WithFile("spoofing_check_results.txt", uncompressedStream)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace CompatBot.Commands
|
||||
}
|
||||
compressedStream.Seek(0, SeekOrigin.Begin);
|
||||
if (compressedStream.Length <= Config.AttachmentSizeLimit)
|
||||
await ctx.RespondWithFileAsync("spoofing_check_results.txt.gz", compressedStream).ConfigureAwait(false);
|
||||
await ctx.RespondAsync(new DiscordMessageBuilder().WithFile("spoofing_check_results.txt.gz", compressedStream)).ConfigureAwait(false);
|
||||
else
|
||||
await ctx.RespondAsync($"Dump is too large: {compressedStream.Length} bytes").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace CompatBot.Commands
|
||||
if (result.Length <= attachmentSizeLimit)
|
||||
{
|
||||
result.Seek(0, SeekOrigin.Begin);
|
||||
await ctx.RespondWithFileAsync(Path.GetFileName(logPath) + ".gz", result).ConfigureAwait(false);
|
||||
await ctx.RespondAsync(new DiscordMessageBuilder().WithFile(Path.GetFileName(logPath) + ".gz", result)).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
await ctx.ReactWithAsync(Config.Reactions.Failure, "Compressed log size is too large, ask 13xforever for help :(", true).ConfigureAwait(false);
|
||||
@@ -162,7 +162,7 @@ namespace CompatBot.Commands
|
||||
if (result.Length <= attachmentSizeLimit)
|
||||
{
|
||||
result.Seek(0, SeekOrigin.Begin);
|
||||
await ctx.RespondWithFileAsync(Path.GetFileName(dbName) + ".zip", result).ConfigureAwait(false);
|
||||
await ctx.RespondAsync(new DiscordMessageBuilder().WithFile(Path.GetFileName(dbName) + ".zip", result)).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
await ctx.ReactWithAsync(Config.Reactions.Failure, "Compressed Thumbs.db size is too large, ask 13xforever for help :(", true).ConfigureAwait(false);
|
||||
|
||||
@@ -10,6 +10,7 @@ using CompatBot.EventHandlers;
|
||||
using CompatBot.Utils;
|
||||
using DSharpPlus.CommandsNext;
|
||||
using DSharpPlus.CommandsNext.Attributes;
|
||||
using DSharpPlus.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace CompatBot.Commands
|
||||
@@ -77,7 +78,7 @@ namespace CompatBot.Commands
|
||||
await streamWriter.WriteAsync(fullList).ConfigureAwait(false);
|
||||
await streamWriter.FlushAsync().ConfigureAwait(false);
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
await ctx.RespondWithFileAsync($"{search}.txt", memoryStream, $"See attached file for full list of {groupedList.Count} entries").ConfigureAwait(false);
|
||||
await ctx.RespondAsync(new DiscordMessageBuilder().WithFile($"{search}.txt", memoryStream).WithContent($"See attached file for full list of {groupedList.Count} entries")).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -167,7 +168,7 @@ namespace CompatBot.Commands
|
||||
await streamWriter.WriteAsync(result).ConfigureAwait(false);
|
||||
await streamWriter.FlushAsync().ConfigureAwait(false);
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
await ctx.RespondWithFileAsync($"{productId} syscalls.txt", memoryStream, $"List of syscalls used by `{title}`").ConfigureAwait(false);
|
||||
await ctx.RespondAsync(new DiscordMessageBuilder().WithFile($"{productId} syscalls.txt", memoryStream).WithContent($"List of syscalls used by `{title}`")).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
await ctx.RespondAsync($"No information available for `{title}`").ConfigureAwait(false);
|
||||
|
||||
@@ -304,7 +304,10 @@ namespace CompatBot.Commands
|
||||
resultStream.Seek(0, SeekOrigin.Begin);
|
||||
quality--;
|
||||
} while (resultStream.Length > Config.AttachmentSizeLimit);
|
||||
var respondMsg = await ctx.RespondWithFileAsync(Path.GetFileNameWithoutExtension(imageUrl) + "_tagged.jpg", resultStream, description).ConfigureAwait(false);
|
||||
var messageBuilder = new DiscordMessageBuilder()
|
||||
.WithContent(description)
|
||||
.WithFile(Path.GetFileNameWithoutExtension(imageUrl) + "_tagged.jpg", resultStream);
|
||||
var respondMsg = await ctx.RespondAsync(messageBuilder).ConfigureAwait(false);
|
||||
await ReactToTagsAsync(respondMsg, result.Objects.Select(o => o.ObjectProperty).Concat(result.Description.Tags)).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -31,10 +31,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DSharpPlus" Version="4.0.0-rc1" />
|
||||
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.0.0-rc1" />
|
||||
<PackageReference Include="DSharpPlus.Interactivity" Version="4.0.0-rc1" />
|
||||
<PackageReference Include="Google.Apis.Drive.v3" Version="1.49.0.2194" />
|
||||
<PackageReference Include="DSharpPlus" Version="4.0.0-nightly-00783" />
|
||||
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.0.0-nightly-00783" />
|
||||
<PackageReference Include="DSharpPlus.Interactivity" Version="4.0.0-nightly-00783" />
|
||||
<PackageReference Include="Google.Apis.Drive.v3" Version="1.49.0.2201" />
|
||||
<PackageReference Include="ksemenenko.ColorThief" Version="1.1.1.4" />
|
||||
<PackageReference Include="MathParser.org-mXparser" Version="4.4.2" />
|
||||
<PackageReference Include="MegaApiClient" Version="1.8.2" />
|
||||
@@ -54,15 +54,15 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.3.6" />
|
||||
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.4.0" />
|
||||
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="16.170.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Services.Client" Version="16.170.0" />
|
||||
<PackageReference Include="Nerdbank.Streams" Version="2.6.81" />
|
||||
<PackageReference Include="NLog" Version="4.7.6" />
|
||||
<PackageReference Include="NLog" Version="4.7.7" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.0" />
|
||||
<PackageReference Include="NReco.Text.AhoCorasickDoubleArrayTrie" Version="1.0.2" />
|
||||
<PackageReference Include="SharpCompress" Version="0.27.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.27.1" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.2" />
|
||||
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta11" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="5.0.0" />
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace CompatBot.Database.Providers
|
||||
|
||||
memStream.Seek(0, SeekOrigin.Begin);
|
||||
var spam = await client.GetChannelAsync(Config.ThumbnailSpamId).ConfigureAwait(false);
|
||||
var message = await spam.SendFileAsync(contentId + ".jpg", memStream, contentId).ConfigureAwait(false);
|
||||
var message = await spam.SendMessageAsync(new DiscordMessageBuilder().WithFile(contentId + ".jpg", memStream).WithContent(contentId)).ConfigureAwait(false);
|
||||
url = message.Attachments[0].Url;
|
||||
return (url, memStream.ToArray());
|
||||
}
|
||||
|
||||
@@ -59,11 +59,11 @@ namespace CompatBot.EventHandlers
|
||||
await PostLock.WaitAsync().ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await logChannel.SendMessageAsync(embed: embed, mentions: Config.AllowedMentions.Nothing).ConfigureAwait(false);
|
||||
await logChannel.SendMessageAsync(new DiscordMessageBuilder().WithEmbed(embed.Build()).WithAllowedMentions(Config.AllowedMentions.Nothing)).ConfigureAwait(false);
|
||||
if (attachmentContent?.Count > 0)
|
||||
await logChannel.SendMultipleFilesAsync(attachmentContent, msg.Content, mentions: Config.AllowedMentions.Nothing).ConfigureAwait(false);
|
||||
await logChannel.SendMessageAsync(new DiscordMessageBuilder().WithFiles(attachmentContent).WithContent(msg.Content).WithAllowedMentions(Config.AllowedMentions.Nothing)).ConfigureAwait(false);
|
||||
else if (!string.IsNullOrEmpty(msg.Content))
|
||||
await logChannel.SendMessageAsync(msg.Content, mentions: Config.AllowedMentions.Nothing).ConfigureAwait(false);
|
||||
await logChannel.SendMessageAsync(new DiscordMessageBuilder().WithContent(msg.Content).WithAllowedMentions(Config.AllowedMentions.Nothing)).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace CompatBot.EventHandlers
|
||||
{
|
||||
Throttling.Set(args.Channel.Id, similarList, ThrottleDuration);
|
||||
var msgContent = GetAvgContent(similarList.Select(m => m.Content).ToList());
|
||||
var botMsg = await args.Channel.SendMessageAsync(msgContent, mentions: Config.AllowedMentions.UsersOnly).ConfigureAwait(false);
|
||||
var botMsg = await args.Channel.SendMessageAsync(new DiscordMessageBuilder().WithContent(msgContent).WithAllowedMentions(Config.AllowedMentions.UsersOnly)).ConfigureAwait(false);
|
||||
similarList.Add(botMsg);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -122,9 +122,9 @@ namespace CompatBot.Utils
|
||||
try
|
||||
{
|
||||
if (conents?.Count > 0)
|
||||
return await logChannel.SendMultipleFilesAsync(conents, embed: embedBuilder.Build(), mentions: Config.AllowedMentions.Nothing).ConfigureAwait(false);
|
||||
return await logChannel.SendMessageAsync(new DiscordMessageBuilder().WithEmbed(embedBuilder.Build()).WithFiles(conents).WithAllowedMentions(Config.AllowedMentions.Nothing)).ConfigureAwait(false);
|
||||
else
|
||||
return await logChannel.SendMessageAsync(embed: embedBuilder.Build(), mentions: Config.AllowedMentions.Nothing).ConfigureAwait(false);
|
||||
return await logChannel.SendMessageAsync(new DiscordMessageBuilder().WithEmbed(embedBuilder.Build()).WithAllowedMentions(Config.AllowedMentions.Nothing)).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -143,7 +143,7 @@ namespace CompatBot.Utils
|
||||
var mentions = reporters.Where(m => m is not null).Select(GetMentionWithNickname!);
|
||||
embedBuilder.AddField("Reporters", string.Join(Environment.NewLine, mentions));
|
||||
var logChannel = await getLogChannelTask.ConfigureAwait(false);
|
||||
return await logChannel.SendMessageAsync(embed: embedBuilder.Build(), mentions: Config.AllowedMentions.Nothing).ConfigureAwait(false);
|
||||
return await logChannel.SendMessageAsync(new DiscordMessageBuilder().WithEmbed(embedBuilder.Build()).WithAllowedMentions(Config.AllowedMentions.Nothing)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public static async Task<DiscordMessage> ReportAsync(this DiscordClient client, string infraction, string description, ICollection<DiscordMember>? potentialVictims, ReportSeverity severity)
|
||||
@@ -157,7 +157,7 @@ namespace CompatBot.Utils
|
||||
if (potentialVictims?.Count > 0)
|
||||
result.AddField("Potential Targets", string.Join(Environment.NewLine, potentialVictims.Select(GetMentionWithNickname)).Trim(EmbedPager.MaxFieldLength));
|
||||
var logChannel = await client.GetChannelAsync(Config.BotLogId).ConfigureAwait(false);
|
||||
return await logChannel.SendMessageAsync(embed: result.Build(), mentions: Config.AllowedMentions.Nothing).ConfigureAwait(false);
|
||||
return await logChannel.SendMessageAsync(new DiscordMessageBuilder().WithEmbed(result.Build()).WithAllowedMentions(Config.AllowedMentions.Nothing)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public static string GetMentionWithNickname(this DiscordMember member)
|
||||
@@ -202,7 +202,7 @@ namespace CompatBot.Utils
|
||||
public static Task SendMessageAsync(this DiscordChannel channel, string message, byte[]? attachment, string? filename)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(filename) && attachment?.Length > 0)
|
||||
return channel.SendFileAsync(filename, new MemoryStream(attachment), message);
|
||||
return channel.SendMessageAsync(new DiscordMessageBuilder().WithFile(filename, new MemoryStream(attachment)).WithContent(message));
|
||||
return channel.SendMessageAsync(message);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ namespace CompatBot.Utils
|
||||
{
|
||||
public static class DiscordMessageExtensions
|
||||
{
|
||||
public static Task<DiscordMessage> UpdateOrCreateMessageAsync(this DiscordMessage? message, DiscordChannel channel, string? content = null, bool tts = false, DiscordEmbed? embed = null)
|
||||
public static Task<DiscordMessage> UpdateOrCreateMessageAsync(this DiscordMessage? message, DiscordChannel channel, string? content = null, DiscordEmbed? embed = null)
|
||||
{
|
||||
Exception? lastException = null;
|
||||
for (var i = 0; i<3; i++)
|
||||
try
|
||||
{
|
||||
if (message == null)
|
||||
return channel.SendMessageAsync(content, tts, embed);
|
||||
return channel.SendMessageAsync(content, embed);
|
||||
return message.ModifyAsync(content, embed);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
Reference in New Issue
Block a user