Update Discord.Net
This commit is contained in:
parent
1f3283b853
commit
75a807a330
7 changed files with 25 additions and 23 deletions
|
@ -1,4 +1,5 @@
|
|||
using Discord.WebSocket;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Noikoio.RegexBot.ConfigItem;
|
||||
using Npgsql;
|
||||
|
@ -81,7 +82,7 @@ namespace Noikoio.RegexBot.EntityCache
|
|||
}
|
||||
|
||||
// Guild member information has changed
|
||||
private async Task Client_GuildMemberUpdated(SocketGuildUser arg1, SocketGuildUser arg2)
|
||||
private async Task Client_GuildMemberUpdated(Cacheable<SocketGuildUser, ulong> arg1, SocketGuildUser arg2)
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
|
@ -113,13 +114,13 @@ namespace Noikoio.RegexBot.EntityCache
|
|||
}
|
||||
|
||||
// User left the guild. No new data, but gives an excuse to update the cache date.
|
||||
private async Task Client_UserLeft(SocketGuildUser arg)
|
||||
private async Task Client_UserLeft(SocketGuild guild, SocketUser user)
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await SqlHelper.UpdateGuildMemberAsync(arg);
|
||||
await SqlHelper.UpdateGuildMemberAsync((SocketGuildUser)user);
|
||||
}
|
||||
catch (NpgsqlException ex)
|
||||
{
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace Noikoio.RegexBot.Module.AutoMod
|
|||
if (targetName == "_")
|
||||
{
|
||||
if (et == EntityType.Channel) return m.Channel;
|
||||
else return await m.Author.GetOrCreateDMChannelAsync();
|
||||
else return await m.Author.CreateDMChannelAsync();
|
||||
}
|
||||
|
||||
EntityName ei = new EntityName(targetName, et);
|
||||
|
@ -141,7 +141,7 @@ namespace Noikoio.RegexBot.Module.AutoMod
|
|||
if (ei.Id.HasValue)
|
||||
{
|
||||
// The easy way
|
||||
return await Client.GetUser(ei.Id.Value).GetOrCreateDMChannelAsync();
|
||||
return await Client.GetUser(ei.Id.Value).CreateDMChannelAsync();
|
||||
}
|
||||
|
||||
// The hard way
|
||||
|
@ -150,7 +150,7 @@ namespace Noikoio.RegexBot.Module.AutoMod
|
|||
if (string.Equals(ei.Name, u.Username, StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(ei.Name, u.Nickname, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return await u.GetOrCreateDMChannelAsync();
|
||||
return await u.CreateDMChannelAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,10 +70,10 @@ namespace Noikoio.RegexBot.Module.EntryAutoRole
|
|||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private Task Client_UserLeft(SocketGuildUser arg)
|
||||
private Task Client_UserLeft(SocketGuild guild, SocketUser user)
|
||||
{
|
||||
if (GetState<object>(arg.Guild.Id) == null) return Task.CompletedTask;
|
||||
lock (_roleWaitLock) _roleWaitlist.RemoveAll(m => m.GuildId == arg.Guild.Id && m.UserId == arg.Id);
|
||||
if (GetState<object>(guild.Id) == null) return Task.CompletedTask;
|
||||
lock (_roleWaitLock) _roleWaitlist.RemoveAll(m => m.GuildId == guild.Id && m.UserId == user.Id);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ namespace Noikoio.RegexBot.Module.ModCommands.Commands
|
|||
if (_notifyMsg == null) return true;
|
||||
if (target == null) return false;
|
||||
|
||||
var ch = await target.GetOrCreateDMChannelAsync();
|
||||
var ch = await target.CreateDMChannelAsync();
|
||||
string outresult = _notifyMsg;
|
||||
outresult = outresult.Replace("$s", target.Guild.Name);
|
||||
outresult = outresult.Replace("$r", reason ?? NotifyReasonNone);
|
||||
|
|
|
@ -64,17 +64,17 @@ namespace Noikoio.RegexBot.Module.ModLogs
|
|||
await AddOrUpdateCacheItemAsync(after);
|
||||
}
|
||||
|
||||
private async Task Client_MessageDeleted(Cacheable<Discord.IMessage, ulong> msg, ISocketMessageChannel channel)
|
||||
private async Task Client_MessageDeleted(Cacheable<IMessage, ulong> msg, Cacheable<IMessageChannel, ulong> channel)
|
||||
{
|
||||
if (channel is IDMChannel) return; // No DMs
|
||||
await ProcessReportMessage(true, msg.Id, channel, null);
|
||||
if (channel.Value is IDMChannel) return; // No DMs
|
||||
await ProcessReportMessage(true, msg.Id, channel.Value, null);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Reporting
|
||||
// Reports an edited or deleted message as if it were a log entry (even though it's not).
|
||||
private async Task ProcessReportMessage(
|
||||
bool isDelete, ulong messageId, ISocketMessageChannel ch, string editMsg)
|
||||
bool isDelete, ulong messageId, IMessageChannel ch, string editMsg)
|
||||
{
|
||||
ulong guildId;
|
||||
if (ch is SocketTextChannel sch)
|
||||
|
@ -146,7 +146,7 @@ namespace Noikoio.RegexBot.Module.ModLogs
|
|||
const string ReportCutoffNotify = "**Message length too long; showing first {0} characters.**\n\n";
|
||||
private EmbedBuilder CreateReportEmbed(
|
||||
bool isDelete,
|
||||
EntityCache.CacheUser ucd, ulong messageId, ISocketMessageChannel chInfo,
|
||||
EntityCache.CacheUser ucd, ulong messageId, IMessageChannel chInfo,
|
||||
(string, string) content, // Item1 = cached content. Item2 = post-edit message (null if isDelete)
|
||||
DateTimeOffset msgCreated, DateTimeOffset? msgEdited)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Discord.WebSocket;
|
||||
using Discord;
|
||||
using Discord.WebSocket;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Noikoio.RegexBot.ConfigItem;
|
||||
using System.Linq;
|
||||
|
@ -34,12 +35,12 @@ namespace Noikoio.RegexBot.Module.PendingAutoRole {
|
|||
}
|
||||
}
|
||||
|
||||
private async Task Client_GuildMemberUpdated(SocketGuildUser previous, SocketGuildUser current) {
|
||||
private async Task Client_GuildMemberUpdated(Cacheable<SocketGuildUser, ulong> previous, SocketGuildUser current) {
|
||||
var conf = GetState<ModuleConfig>(current.Guild.Id);
|
||||
if (conf == null) return;
|
||||
|
||||
if (!(previous.IsPending.HasValue && current.IsPending.HasValue)) return;
|
||||
if (previous.IsPending == true && current.IsPending == false) {
|
||||
if (!(previous.Value.IsPending.HasValue && current.IsPending.HasValue)) return;
|
||||
if (previous.Value.IsPending == true && current.IsPending == false) {
|
||||
var r = GetRole(current.Guild);
|
||||
if (r == null) {
|
||||
await Log($"Failed to update {current} - was the role renamed or deleted?");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<Description>Highly configurable Discord moderation bot</Description>
|
||||
<Authors>Noikoio</Authors>
|
||||
<Company />
|
||||
<Version>2.6.7</Version>
|
||||
<Version>2.6.8</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
|
@ -15,9 +15,9 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Discord.Net" Version="2.4.0" />
|
||||
<PackageReference Include="Discord.Net" Version="3.4.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Npgsql" Version="5.0.10" />
|
||||
<PackageReference Include="Npgsql" Version="5.0.12" />
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
Loading…
Reference in a new issue