Switch to discord.net 3.0.0

This commit is contained in:
Kwoth
2021-12-23 08:02:23 +07:00
parent f78e4d457c
commit 93b8bca018
34 changed files with 159 additions and 384 deletions

View File

@@ -38,23 +38,6 @@ public static class Extensions
}),
_ => throw new ArgumentOutOfRangeException(nameof(text))
};
public static Task<IUserMessage> SendAsync(this IMessageChannel channel, string plainText, Embed embed, bool sanitizeAll = false)
{
plainText = sanitizeAll
? plainText?.SanitizeAllMentions() ?? ""
: plainText?.SanitizeMentions() ?? "";
return channel.SendMessageAsync(plainText, embed: embed);
}
public static Task<IUserMessage> SendAsync(this IMessageChannel channel, SmartText text, bool sanitizeAll = false)
=> text switch
{
SmartEmbedText set => channel.SendAsync(set.PlainText, set.GetEmbed().Build(), sanitizeAll),
SmartPlainText st => channel.SendAsync(st.Text, null, sanitizeAll),
_ => throw new ArgumentOutOfRangeException(nameof(text))
};
public static List<ulong> GetGuildIds(this DiscordSocketClient client)
=> client.Guilds.Select(x => x.Id).ToList();
@@ -334,10 +317,9 @@ public static class Extensions
public static async Task<IMessage> SendMessageToOwnerAsync(this IGuild guild, string message)
{
var ownerPrivate = await (await guild.GetOwnerAsync().ConfigureAwait(false)).GetOrCreateDMChannelAsync()
.ConfigureAwait(false);
var owner = await guild.GetOwnerAsync();
return await ownerPrivate.SendMessageAsync(message).ConfigureAwait(false);
return await owner.SendMessageAsync(message);
}
public static bool IsImage(this HttpResponseMessage msg) => IsImage(msg, out _);