mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 09:09:00 +03:00
Update to .NET 7
This commit is contained in:
parent
2596b48bde
commit
fc00558dce
5 changed files with 26 additions and 18 deletions
|
@ -21,7 +21,8 @@ public static class Boyfriend {
|
||||||
};
|
};
|
||||||
|
|
||||||
private static readonly List<Tuple<Game, TimeSpan>> ActivityList = new() {
|
private static readonly List<Tuple<Game, TimeSpan>> ActivityList = new() {
|
||||||
Tuple.Create(new Game("UNDEAD CORPORATION - Everything will freeze", ActivityType.Listening), new TimeSpan(0, 3, 18)),
|
Tuple.Create(new Game("UNDEAD CORPORATION - Everything will freeze", ActivityType.Listening),
|
||||||
|
new TimeSpan(0, 3, 18)),
|
||||||
Tuple.Create(new Game("Xi - Blue Zenith", ActivityType.Listening), new TimeSpan(0, 4, 16)),
|
Tuple.Create(new Game("Xi - Blue Zenith", ActivityType.Listening), new TimeSpan(0, 4, 16)),
|
||||||
Tuple.Create(new Game("Kurokotei - Scattered Faith", ActivityType.Listening), new TimeSpan(0, 8, 21)),
|
Tuple.Create(new Game("Kurokotei - Scattered Faith", ActivityType.Listening), new TimeSpan(0, 8, 21)),
|
||||||
Tuple.Create(new Game("Splatoon 3 - Candy-Coated Rocks", ActivityType.Listening), new TimeSpan(0, 2, 39)),
|
Tuple.Create(new Game("Splatoon 3 - Candy-Coated Rocks", ActivityType.Listening), new TimeSpan(0, 2, 39)),
|
||||||
|
@ -67,14 +68,12 @@ public static class Boyfriend {
|
||||||
|
|
||||||
EventHandler.InitEvents();
|
EventHandler.InitEvents();
|
||||||
|
|
||||||
while (true) {
|
while (ActivityList.Count > 0)
|
||||||
foreach (var activity in ActivityList) {
|
foreach (var activity in ActivityList) {
|
||||||
await Client.SetActivityAsync(activity.Item1);
|
await Client.SetActivityAsync(activity.Item1);
|
||||||
await Task.Delay(activity.Item2);
|
await Task.Delay(activity.Item2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ReSharper disable once FunctionNeverReturns
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Task Log(LogMessage msg) {
|
public static Task Log(LogMessage msg) {
|
||||||
switch (msg.Severity) {
|
switch (msg.Severity) {
|
||||||
|
@ -153,3 +152,4 @@ public static class Boyfriend {
|
||||||
return removedRoles;
|
return removedRoles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>default</LangVersion>
|
<LangVersion>default</LangVersion>
|
||||||
<Title>Boyfriend</Title>
|
<Title>Boyfriend</Title>
|
||||||
<Authors>l1ttle</Authors>
|
<Authors>Octol1ttle, mctaylors</Authors>
|
||||||
<PackageProjectUrl>https://github.com/l1ttleO/Boyfriend-CSharp</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/l1ttleO/Boyfriend-CSharp</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/l1ttleO/Boyfriend-CSharp</RepositoryUrl>
|
<RepositoryUrl>https://github.com/l1ttleO/Boyfriend-CSharp</RepositoryUrl>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
|
@ -23,6 +23,10 @@
|
||||||
<DebugType>none</DebugType>
|
<DebugType>none</DebugType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Discord.Net" Version="3.8.1"/>
|
<PackageReference Include="Discord.Net" Version="3.8.1"/>
|
||||||
<PackageReference Include="Humanizer.Core" Version="2.14.1"/>
|
<PackageReference Include="Humanizer.Core" Version="2.14.1"/>
|
||||||
|
|
|
@ -62,7 +62,7 @@ public static class EventHandler {
|
||||||
Utils.Wrap(msg.CleanContent)), guild.Id, mention);
|
Utils.Wrap(msg.CleanContent)), guild.Id, mention);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Task MessageReceivedEvent(SocketMessage messageParam) {
|
private static Task MessageReceivedEvent(IDeletable messageParam) {
|
||||||
if (messageParam is not SocketUserMessage message) return Task.CompletedTask;
|
if (messageParam is not SocketUserMessage message) return Task.CompletedTask;
|
||||||
|
|
||||||
_ = message.CleanContent.ToLower() switch {
|
_ = message.CleanContent.ToLower() switch {
|
||||||
|
@ -76,7 +76,7 @@ public static class EventHandler {
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task MessageUpdatedEvent(Cacheable<IMessage, ulong> messageCached, SocketMessage messageSocket,
|
private static async Task MessageUpdatedEvent(Cacheable<IMessage, ulong> messageCached, IMessage messageSocket,
|
||||||
ISocketMessageChannel channel) {
|
ISocketMessageChannel channel) {
|
||||||
var msg = messageCached.Value;
|
var msg = messageCached.Value;
|
||||||
if (channel is not SocketGuildChannel gChannel || msg is null or ISystemMessage ||
|
if (channel is not SocketGuildChannel gChannel || msg is null or ISystemMessage ||
|
||||||
|
@ -176,3 +176,4 @@ public static class EventHandler {
|
||||||
Utils.GetHumanizedTimeOffset(DateTimeOffset.Now.Subtract(scheduledEvent.StartTime))));
|
Utils.GetHumanizedTimeOffset(DateTimeOffset.Now.Subtract(scheduledEvent.StartTime))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ using Humanizer.Localisation;
|
||||||
|
|
||||||
namespace Boyfriend;
|
namespace Boyfriend;
|
||||||
|
|
||||||
public static class Utils {
|
public static partial class Utils {
|
||||||
private static readonly Dictionary<string, string> ReflectionMessageCache = new();
|
private static readonly Dictionary<string, string> ReflectionMessageCache = new();
|
||||||
|
|
||||||
public static readonly Dictionary<string, CultureInfo> CultureInfoCache = new() {
|
public static readonly Dictionary<string, CultureInfo> CultureInfoCache = new() {
|
||||||
|
@ -48,7 +48,7 @@ public static class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ulong ParseMention(string mention) {
|
public static ulong ParseMention(string mention) {
|
||||||
return ulong.TryParse(Regex.Replace(mention, "[^0-9]", ""), out var id) ? id : 0;
|
return ulong.TryParse(NumbersOnlyRegex().Replace(mention, ""), out var id) ? id : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task SendDirectMessage(SocketUser user, string toSend) {
|
public static async Task SendDirectMessage(SocketUser user, string toSend) {
|
||||||
|
@ -70,7 +70,7 @@ public static class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RemoveMuteRoleFromCache(ulong id) {
|
public static void RemoveMuteRoleFromCache(ulong id) {
|
||||||
if (MuteRoleCache.ContainsKey(id)) MuteRoleCache.Remove(id);
|
MuteRoleCache.Remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task SilentSendAsync(SocketTextChannel? channel, string text, bool allowRoles = false) {
|
public static async Task SilentSendAsync(SocketTextChannel? channel, string text, bool allowRoles = false) {
|
||||||
|
@ -189,4 +189,7 @@ public static class Utils {
|
||||||
public static SocketTextChannel? GetEventNotificationChannel(SocketGuild guild) {
|
public static SocketTextChannel? GetEventNotificationChannel(SocketGuild guild) {
|
||||||
return guild.GetTextChannel(ParseMention(Boyfriend.GetGuildConfig(guild.Id)["EventNotificationChannel"]));
|
return guild.GetTextChannel(ParseMention(Boyfriend.GetGuildConfig(guild.Id)["EventNotificationChannel"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[GeneratedRegex("[^0-9]")]
|
||||||
|
private static partial Regex NumbersOnlyRegex();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"sdk": {
|
"sdk": {
|
||||||
"version": "6.0.0",
|
"version": "7.0.0",
|
||||||
"rollForward": "latestFeature",
|
"rollForward": "latestMajor",
|
||||||
"allowPrerelease": false
|
"allowPrerelease": false
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue