Skip to content
This repository was archived by the owner on Sep 29, 2023. It is now read-only.

Commit 4052fd8

Browse files
committed
Updated to Discord.net 3.4 for api V9. Also had to update the interactive addon to another fork. Should really switch interactive plugins fully.
1 parent af6a743 commit 4052fd8

25 files changed

+821
-5
lines changed

BotHATTwaffle2.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotHATTwaffle2", "BotHATTwa
77
EndProject
88
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreRCON", "CoreRCON\CoreRCON.csproj", "{4ADEAD8F-818B-4061-A906-A3F5F7B2FDA5}"
99
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Discord.Addons.Interactive", "Discord.Addons.Interactive\Discord.Addons.Interactive.csproj", "{6BC829F6-D65A-4D30-B9A1-7E0A6BBC292E}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
2123
{4ADEAD8F-818B-4061-A906-A3F5F7B2FDA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
2224
{4ADEAD8F-818B-4061-A906-A3F5F7B2FDA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
2325
{4ADEAD8F-818B-4061-A906-A3F5F7B2FDA5}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{6BC829F6-D65A-4D30-B9A1-7E0A6BBC292E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{6BC829F6-D65A-4D30-B9A1-7E0A6BBC292E}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{6BC829F6-D65A-4D30-B9A1-7E0A6BBC292E}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{6BC829F6-D65A-4D30-B9A1-7E0A6BBC292E}.Release|Any CPU.Build.0 = Release|Any CPU
2430
EndGlobalSection
2531
GlobalSection(SolutionProperties) = preSolution
2632
HideSolutionNode = FALSE

BotHATTwaffle2/BotHATTwaffle2.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Discord.Extensions.Interactive" Version="2.3.0" />
16-
<PackageReference Include="Discord.Net" Version="2.3.1" />
15+
<PackageReference Include="Discord.Net" Version="3.4.1" />
1716
<PackageReference Include="FaceitLib" Version="1.0.7" />
1817
<PackageReference Include="FluentFTP" Version="25.0.3" />
1918
<PackageReference Include="FluentScheduler" Version="5.3.0" />
@@ -24,7 +23,7 @@
2423
<PackageReference Include="Imgur.API" Version="4.0.1" />
2524
<PackageReference Include="LiteDB" Version="4.1.4" />
2625
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
27-
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
26+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
2827
<PackageReference Include="Pfim" Version="0.8.0" />
2928
<PackageReference Include="Renci.SshNet.Async" Version="1.4.0" />
3029
<PackageReference Include="SharpZipLib" Version="1.2.0" />
@@ -36,6 +35,7 @@
3635

3736
<ItemGroup>
3837
<ProjectReference Include="..\CoreRCON\CoreRCON.csproj" />
38+
<ProjectReference Include="..\Discord.Addons.Interactive\Discord.Addons.Interactive.csproj" />
3939
</ItemGroup>
4040

4141
<ItemGroup>

BotHATTwaffle2/src/Handlers/UserJoinHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ await _log.LogMessage($"USER JOINED {user}" +
5151
//DatabaseUtil.AddJoinedUser(user.Id);
5252
}
5353

54-
// private async Task UserLeftEventHandler(SocketGuildUser user)
54+
// private async Task UserLeftEventHandler(SocketUser user)
5555
// {
5656
//
5757
// }

BotHATTwaffle2/src/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public static async Task Main(string[] args)
3030
//Always download users to make sure we can always get them
3131
var config = new DiscordSocketConfig
3232
{
33-
AlwaysDownloadUsers = true
33+
AlwaysDownloadUsers = true,
34+
GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.GuildMembers
3435
};
3536

3637
var interactiveConfig = new InteractiveServiceConfig
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using Discord.Commands;
4+
using Discord.WebSocket;
5+
6+
namespace Discord.Addons.Interactive
7+
{
8+
public interface IReactionCallback
9+
{
10+
RunMode RunMode { get; }
11+
ICriterion<SocketReaction> Criterion { get; }
12+
TimeSpan? Timeout { get; }
13+
SocketCommandContext Context { get; }
14+
15+
Task<bool> HandleCallbackAsync(SocketReaction reaction);
16+
}
17+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Collections.Generic;
2+
using System.Threading.Tasks;
3+
using Discord.Commands;
4+
5+
namespace Discord.Addons.Interactive
6+
{
7+
public class Criteria<T> : ICriterion<T>
8+
{
9+
private List<ICriterion<T>> _critiera = new List<ICriterion<T>>();
10+
11+
public Criteria<T> AddCriterion(ICriterion<T> criterion)
12+
{
13+
_critiera.Add(criterion);
14+
return this;
15+
}
16+
17+
public async Task<bool> JudgeAsync(SocketCommandContext sourceContext, T parameter)
18+
{
19+
foreach (var criterion in _critiera)
20+
{
21+
var result = await criterion.JudgeAsync(sourceContext, parameter).ConfigureAwait(false);
22+
if (!result) return false;
23+
}
24+
return true;
25+
}
26+
}
27+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using System.Threading.Tasks;
5+
using Discord.Commands;
6+
using Discord.WebSocket;
7+
8+
namespace Discord.Addons.Interactive
9+
{
10+
public class EmptyCriterion<T> : ICriterion<T>
11+
{
12+
public Task<bool> JudgeAsync(SocketCommandContext sourceContext, T parameter)
13+
=> Task.FromResult(true);
14+
}
15+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Threading.Tasks;
2+
using Discord.Commands;
3+
4+
namespace Discord.Addons.Interactive
5+
{
6+
public class EnsureFromChannelCriterion : ICriterion<IMessage>
7+
{
8+
private readonly ulong _channelId;
9+
10+
public EnsureFromChannelCriterion(IMessageChannel channel)
11+
=> _channelId = channel.Id;
12+
13+
public Task<bool> JudgeAsync(SocketCommandContext sourceContext, IMessage parameter)
14+
{
15+
bool ok = _channelId == parameter.Channel.Id;
16+
return Task.FromResult(ok);
17+
}
18+
}
19+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.ComponentModel;
2+
using System.Threading.Tasks;
3+
using Discord.Commands;
4+
5+
namespace Discord.Addons.Interactive
6+
{
7+
public class EnsureFromUserCriterion : ICriterion<IMessage>
8+
{
9+
private readonly ulong _id;
10+
11+
public EnsureFromUserCriterion(IUser user)
12+
=> _id = user.Id;
13+
14+
[EditorBrowsable(EditorBrowsableState.Never)]
15+
public EnsureFromUserCriterion(ulong id)
16+
=> _id = id;
17+
18+
public Task<bool> JudgeAsync(SocketCommandContext sourceContext, IMessage parameter)
19+
{
20+
bool ok = _id == parameter.Author.Id;
21+
return Task.FromResult(ok);
22+
}
23+
}
24+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Threading.Tasks;
2+
using Discord.Commands;
3+
4+
namespace Discord.Addons.Interactive
5+
{
6+
public class EnsureSourceChannelCriterion : ICriterion<IMessage>
7+
{
8+
public Task<bool> JudgeAsync(SocketCommandContext sourceContext, IMessage parameter)
9+
{
10+
var ok = sourceContext.Channel.Id == parameter.Channel.Id;
11+
return Task.FromResult(ok);
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)