forked from TeamInklings/Octobot
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() {
|
||||
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("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)),
|
||||
|
@ -67,14 +68,12 @@ public static class Boyfriend {
|
|||
|
||||
EventHandler.InitEvents();
|
||||
|
||||
while (true) {
|
||||
while (ActivityList.Count > 0)
|
||||
foreach (var activity in ActivityList) {
|
||||
await Client.SetActivityAsync(activity.Item1);
|
||||
await Task.Delay(activity.Item2);
|
||||
}
|
||||
}
|
||||
// ReSharper disable once FunctionNeverReturns
|
||||
}
|
||||
|
||||
public static Task Log(LogMessage msg) {
|
||||
switch (msg.Severity) {
|
||||
|
@ -153,3 +152,4 @@ public static class Boyfriend {
|
|||
return removedRoles;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>default</LangVersion>
|
||||
<Title>Boyfriend</Title>
|
||||
<Authors>l1ttle</Authors>
|
||||
<Authors>Octol1ttle, mctaylors</Authors>
|
||||
<PackageProjectUrl>https://github.com/l1ttleO/Boyfriend-CSharp</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/l1ttleO/Boyfriend-CSharp</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
|
@ -17,16 +17,20 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DefineConstants />
|
||||
<DefineConstants/>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Discord.Net" Version="3.8.1" />
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="Humanizer.Core.ru" Version="2.14.1" />
|
||||
<PackageReference Include="Discord.Net" Version="3.8.1"/>
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1"/>
|
||||
<PackageReference Include="Humanizer.Core.ru" Version="2.14.1"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -62,7 +62,7 @@ public static class EventHandler {
|
|||
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;
|
||||
|
||||
_ = message.CleanContent.ToLower() switch {
|
||||
|
@ -76,7 +76,7 @@ public static class EventHandler {
|
|||
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) {
|
||||
var msg = messageCached.Value;
|
||||
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))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ using Humanizer.Localisation;
|
|||
|
||||
namespace Boyfriend;
|
||||
|
||||
public static class Utils {
|
||||
public static partial class Utils {
|
||||
private static readonly Dictionary<string, string> ReflectionMessageCache = new();
|
||||
|
||||
public static readonly Dictionary<string, CultureInfo> CultureInfoCache = new() {
|
||||
|
@ -48,7 +48,7 @@ public static class Utils {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -70,7 +70,7 @@ public static class Utils {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -189,4 +189,7 @@ public static class Utils {
|
|||
public static SocketTextChannel? GetEventNotificationChannel(SocketGuild guild) {
|
||||
return guild.GetTextChannel(ParseMention(Boyfriend.GetGuildConfig(guild.Id)["EventNotificationChannel"]));
|
||||
}
|
||||
|
||||
[GeneratedRegex("[^0-9]")]
|
||||
private static partial Regex NumbersOnlyRegex();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"sdk": {
|
||||
"version": "6.0.0",
|
||||
"rollForward": "latestFeature",
|
||||
"version": "7.0.0",
|
||||
"rollForward": "latestMajor",
|
||||
"allowPrerelease": false
|
||||
}
|
||||
}
|
Reference in a new issue