Skip to content

Commit

Permalink
Updated dependencies and added poll suppression
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianusIV committed Apr 22, 2024
1 parent e12ffd5 commit 0c5a843
Show file tree
Hide file tree
Showing 39 changed files with 326 additions and 4,113 deletions.
2 changes: 0 additions & 2 deletions LathBotBack/Config/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ public struct Configuration
public string Token { get; internal set; }
public string ConnectionString { get; internal set; }
public string NasaApiKey { get; set; }

public string LavaLinkPass { get; set; }
public string RijndaelInputKey { get; set; }
public string UptimeKumaUrl { get; set; }
}
Expand Down
1 change: 0 additions & 1 deletion LathBotBack/Config/ReadConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public static void Read()
Token = Environment.GetEnvironmentVariable("Token"),
ConnectionString = Environment.GetEnvironmentVariable("ConnectionString"),
NasaApiKey = Environment.GetEnvironmentVariable("NASAApiKey"),
LavaLinkPass = Environment.GetEnvironmentVariable("LavaLinkPass"),
RijndaelInputKey = Environment.GetEnvironmentVariable("RijndaelInputKey"),
UptimeKumaUrl = Environment.GetEnvironmentVariable("UptimeKumaUrl")
};
Expand Down
11 changes: 5 additions & 6 deletions LathBotBack/LathBotBack.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DSharpPlus" Version="5.0.0-nightly-01735" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="5.0.0-nightly-01735" />
<PackageReference Include="DSharpPlus.Interactivity" Version="5.0.0-nightly-01735" />
<PackageReference Include="DSharpPlus.Lavalink" Version="5.0.0-nightly-01735" />
<PackageReference Include="DSharpPlus.SlashCommands" Version="5.0.0-nightly-01735" />
<PackageReference Include="DSharpPlus" Version="5.0.0-nightly-02211" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="5.0.0-nightly-02211" />
<PackageReference Include="DSharpPlus.Interactivity" Version="5.0.0-nightly-02211" />
<PackageReference Include="DSharpPlus.SlashCommands" Version="5.0.0-nightly-02211" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
</ItemGroup>

Expand Down
7 changes: 2 additions & 5 deletions LathBotBack/Logging/LoggingEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

namespace LathBotBack.Logging
{
public class LoggingEventArgs : EventArgs
public class LoggingEventArgs(string message) : EventArgs
{
public LoggingEventArgs(string message)
=> Message = message;

public string Message { get; set; }
public string Message { get; set; } = message;
}
}
21 changes: 6 additions & 15 deletions LathBotBack/Models/Rule.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
namespace LathBotBack.Models
{
public class Rule
public class Rule(int ruleNum, string ruleText, int minPoints, int maxPoints, string shortDesc)
{
public int RuleNum { get; set; }
public string RuleText { get; set; }
public int MinPoints { get; set; }
public int MaxPoints { get; set; }
public string ShortDesc { get; set; }

public Rule(int ruleNum, string ruleText, int minPoints, int maxPoints, string shortDesc)
{
RuleNum = ruleNum;
RuleText = ruleText;
MinPoints = minPoints;
MaxPoints = maxPoints;
ShortDesc = shortDesc;
}
public int RuleNum { get; set; } = ruleNum;
public string RuleText { get; set; } = ruleText;
public int MinPoints { get; set; } = minPoints;
public int MaxPoints { get; set; } = maxPoints;
public string ShortDesc { get; set; } = shortDesc;
}
}
4 changes: 1 addition & 3 deletions LathBotBack/Repos/AuditRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

namespace LathBotBack.Repos
{
public class AuditRepository : RepositoryBase
public class AuditRepository(string connectionString) : RepositoryBase(connectionString)
{
public AuditRepository(string connectionString) : base(connectionString) { }

public bool Create(Audit entity)
{
bool result = false;
Expand Down
6 changes: 2 additions & 4 deletions LathBotBack/Repos/ModRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@

namespace LathBotBack.Repos
{
public class ModRepository : RepositoryBase
public class ModRepository(string connectionString) : RepositoryBase(connectionString)
{
public ModRepository(string connectionString) : base(connectionString) { }

public bool GetAll(out List<Mod> list)
{
bool result = false;
Expand All @@ -22,7 +20,7 @@ public bool GetAll(out List<Mod> list)
DbCommand.Parameters.Clear();
DbConnection.Open();
using SqlDataReader reader = DbCommand.ExecuteReader();
list = new List<Mod>();
list = [];
while (reader.Read())
{
var mod = new Mod
Expand Down
6 changes: 2 additions & 4 deletions LathBotBack/Repos/MuteRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@

namespace LathBotBack.Repos
{
public class MuteRepository : RepositoryBase
public class MuteRepository(string connectionString) : RepositoryBase(connectionString)
{
public MuteRepository(string connectionString) : base(connectionString) { }

public bool GetAll(out List<Mute> list)
{
bool result = false;
list = new List<Mute>();
list = [];

try
{
Expand Down
6 changes: 2 additions & 4 deletions LathBotBack/Repos/UserRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@

namespace LathBotBack.Repos
{
public class UserRepository : RepositoryBase
public class UserRepository(string connectionString) : RepositoryBase(connectionString)
{
public UserRepository(string connectionString) : base(connectionString) { }

public bool GetAll(out List<User> list)
{
bool result = false;
list = new List<User>();
list = [];

try
{
Expand Down
4 changes: 1 addition & 3 deletions LathBotBack/Repos/VariableRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

namespace LathBotBack.Repos
{
public class VariableRepository : RepositoryBase
public class VariableRepository(string connectionString) : RepositoryBase(connectionString)
{
public VariableRepository(string connectionString) : base(connectionString) { }

public bool Create(ref Variable entity)
{
bool result = false;
Expand Down
8 changes: 3 additions & 5 deletions LathBotBack/Repos/WarnRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@

namespace LathBotBack.Repos
{
public class WarnRepository : RepositoryBase
public class WarnRepository(string connectionString) : RepositoryBase(connectionString)
{
public WarnRepository(string connectionString) : base(connectionString) { }

public bool GetAll(out List<Warn> list)
{
bool result = false;
list = new List<Warn>();
list = [];

try
{
Expand Down Expand Up @@ -58,7 +56,7 @@ public bool GetAll(out List<Warn> list)
public bool GetAllByUser(int UserDbId, out List<Warn> list)
{
bool result = false;
list = new List<Warn>();
list = [];

try
{
Expand Down
13 changes: 6 additions & 7 deletions LathBotBack/Services/DiscordObjectService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ public class DiscordObjectService : BaseService
{
#region Singleton
private static DiscordObjectService instance;
private static readonly object padlock = new object();
private static readonly object padlock = new();
public static DiscordObjectService Instance
{
get
{
lock (padlock)
{
if (instance == null)
instance = new DiscordObjectService();
instance ??= new DiscordObjectService();
return instance;
}
}
Expand All @@ -41,7 +40,7 @@ public static DiscordObjectService Instance
public Dictionary<ulong, DiscordMessage> LastDeletes { get; set; }
public Dictionary<ulong, DiscordMessage> LastEdits { get; set; }

public readonly DiscordEmbedBuilder LathQuestionsEmbed = new DiscordEmbedBuilder
public readonly DiscordEmbedBuilder LathQuestionsEmbed = new()
{
Title = "To make sure Lathrix does not get the same question multiple times please look at the pins.",
Description = "This channel is not to be used to request things from Lathrix.\n" +
Expand All @@ -50,7 +49,7 @@ public static DiscordObjectService Instance
"Failure to follow these rules may result in a punishment.",
Color = new DiscordColor(101, 24, 201)
};
public readonly DiscordEmbedBuilder StaffQuestionsEmbed = new DiscordEmbedBuilder
public readonly DiscordEmbedBuilder StaffQuestionsEmbed = new()
{
Title = "This channel is for asking questions, that the staff will answer.",
Description = "To make sure they do not get the same question multiple times please look at the pins.\n" +
Expand Down Expand Up @@ -102,8 +101,8 @@ public override void Init(DiscordClient client)
else
LathQuestions = QuestionsChannel.SendMessageAsync(LathQuestionsEmbed).GetAwaiter().GetResult();

LastEdits = new Dictionary<ulong, DiscordMessage>();
LastDeletes = new Dictionary<ulong, DiscordMessage>();
LastEdits = [];
LastDeletes = [];
}
}
}
33 changes: 0 additions & 33 deletions LathBotBack/Services/LavalinkService.cs

This file was deleted.

6 changes: 3 additions & 3 deletions LathBotBack/Services/RuleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public static RuleService Instance

public override void Init(DiscordClient client)
{
Rules = new Rule[14]
{
Rules =
[
new Rule(1, "Follow the discord [ToS](https://discord.com/terms) and [community guidelines](https://discord.com/guidelines).", 1, 15, "TOS"),
new Rule(2, "Do not ping Lathrix", 1, 3, "PING"),
new Rule(3, "Use appropriate channels and follow the channel rules (description/pins).", 1, 5, "CHANNELS"),
Expand All @@ -43,7 +43,7 @@ public override void Init(DiscordClient client)
new Rule(12, "Don't share personal information about others", 1, 15, "DOXXING"),
new Rule(13, "Holding bias as a staff member is prohibited, or if you are a member who is trying to make staff biased. This will be known as corruption and should be reported to a member of the Senate immediately.", 1, 10, "BIAS"),
new Rule(0, "This rule is for anything that goes against basic human decency, and for cases not covered by the rules, that should be warned.", 1, 15, "OTHER")
};
];
}
}
}
2 changes: 1 addition & 1 deletion LathBotBack/Services/StartupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public DateTime StartTime
get => Process.GetCurrentProcess().StartTime;
}

public override void Init(DiscordClient client)
public override void Init(DiscordClient client)
=> StartUpCompleted = true;
}
}
1 change: 0 additions & 1 deletion LathBotBack/Services/SystemService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using DSharpPlus;
using LathBotBack.Base;
using LathBotBack.Logging;
using System;
using System.Timers;

namespace LathBotBack.Services
Expand Down
6 changes: 3 additions & 3 deletions LathBotFront/2FA/AesEncryption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ public static string DecryptStringToBytes(byte[] cipherText, string salt)
/// <returns></returns>
private static Aes NewAes(string salt)
{
if (salt == null)
throw new ArgumentNullException(nameof(salt));
ArgumentNullException.ThrowIfNull(salt, nameof(salt));
var saltBytes = Encoding.ASCII.GetBytes(salt);
#pragma warning disable SYSLIB0041
var key = new Rfc2898DeriveBytes(ReadConfig.Config.RijndaelInputKey, saltBytes);

#pragma warning restore SYSLIB0041
var aesAlg = Aes.Create();
aesAlg.Key = key.GetBytes(aesAlg.KeySize / 8);
aesAlg.IV = key.GetBytes(aesAlg.BlockSize / 8);
Expand Down
Loading

0 comments on commit 0c5a843

Please sign in to comment.