diff --git a/DiscordBot/DiscordBot.csproj b/DiscordBot/DiscordBot.csproj
index dc5c4509..8d7e9c26 100644
--- a/DiscordBot/DiscordBot.csproj
+++ b/DiscordBot/DiscordBot.csproj
@@ -6,12 +6,12 @@
enable
-
+
+
-
diff --git a/DiscordBot/Domain/Casino/CasinoUser.cs b/DiscordBot/Domain/Casino/CasinoUser.cs
index d4aa664e..354321d1 100644
--- a/DiscordBot/Domain/Casino/CasinoUser.cs
+++ b/DiscordBot/Domain/Casino/CasinoUser.cs
@@ -6,7 +6,7 @@ public class CasinoUser
{
public int Id { get; set; }
public required string UserID { get; set; }
- public ulong Tokens { get; set; }
+ public long Tokens { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
public DateTime LastDailyReward { get; set; }
@@ -16,8 +16,17 @@ public class TokenTransaction
{
public int Id { get; set; }
public required string UserID { get; set; }
- public long Amount { get; set; } // Can be negative for spending
- public TransactionType Type { get; set; } // Enum for transaction types
+ public string? TargetUserID { get; set; }
+ public long Amount { get; set; }
+ public string TransactionType { get; set; } = "";
+
+ // Computed from TransactionType string β not mapped to DB
+ [JsonIgnore]
+ public TransactionKind Kind
+ {
+ get => Enum.TryParse(TransactionType, true, out var result) ? result : TransactionKind.Admin;
+ set => TransactionType = value.ToString();
+ }
private Dictionary? _details;
@@ -28,17 +37,26 @@ public Dictionary? Details
set => _details = value;
}
- // This property will be mapped to the database JSON column
- public string? DetailsJson
+ // Maps to DB column "description" (text). Stores Details dict as JSON, deserializes with fallback for plain text (from MySQL migration)
+ public string? Description
{
get => Details != null && Details.Any() ? JsonConvert.SerializeObject(Details) : null;
- set => Details = !string.IsNullOrEmpty(value) ? JsonConvert.DeserializeObject>(value) : new Dictionary();
+ set
+ {
+ if (string.IsNullOrEmpty(value))
+ {
+ _details = new Dictionary();
+ return;
+ }
+ try { _details = JsonConvert.DeserializeObject>(value); }
+ catch (JsonException) { _details = new Dictionary { ["text"] = value }; }
+ }
}
public DateTime CreatedAt { get; set; }
}
-public enum TransactionType
+public enum TransactionKind
{
TokenInitialisation,
DailyReward,
@@ -96,8 +114,9 @@ public static class CasinoProps
// TokenTransaction properties
public const string TransactionId = nameof(TokenTransaction.Id);
public const string TransactionUserID = nameof(TokenTransaction.UserID);
+ public const string TargetUserID = nameof(TokenTransaction.TargetUserID);
public const string Amount = nameof(TokenTransaction.Amount);
- public const string TransactionType = nameof(TokenTransaction.Type);
- public const string Details = nameof(TokenTransaction.DetailsJson);
+ public const string TransactionType = nameof(TokenTransaction.TransactionType);
+ public const string Details = nameof(TokenTransaction.Description);
public const string TransactionCreatedAt = nameof(TokenTransaction.CreatedAt);
}
\ No newline at end of file
diff --git a/DiscordBot/Domain/Casino/Game.cs b/DiscordBot/Domain/Casino/Game.cs
index c50fafe0..85478fad 100644
--- a/DiscordBot/Domain/Casino/Game.cs
+++ b/DiscordBot/Domain/Casino/Game.cs
@@ -56,7 +56,7 @@ public interface ICasinoGame
public IReadOnlyList<(GamePlayer player, long payout)> EndGame();
public abstract GamePlayerResult GetPlayerGameResult(GamePlayer player);
- public abstract long CalculatePayout(GamePlayer player, ulong totalPot);
+ public abstract long CalculatePayout(GamePlayer player, long totalPot);
public void Reset();
@@ -149,8 +149,8 @@ public void StartGame(IEnumerable players)
// Default implementation does nothing, override in specific games if needed
protected virtual void FinalizeGame(List players) { }
public abstract GamePlayerResult GetPlayerGameResult(GamePlayer player);
- protected ulong GetTotalPot => (ulong)Players.Sum(p => (long)p.Bet);
- public abstract long CalculatePayout(GamePlayer player, ulong totalPot);
+ protected long GetTotalPot => Players.Sum(p => p.Bet);
+ public abstract long CalculatePayout(GamePlayer player, long totalPot);
///
/// Determines if the game should enter the FINISHED state.
diff --git a/DiscordBot/Domain/Casino/GamePlayer.cs b/DiscordBot/Domain/Casino/GamePlayer.cs
index fab05a10..3ecb33e6 100644
--- a/DiscordBot/Domain/Casino/GamePlayer.cs
+++ b/DiscordBot/Domain/Casino/GamePlayer.cs
@@ -16,7 +16,7 @@ public class GamePlayer
///
/// The bet amount placed by the player
///
- public required ulong Bet { get; set; }
+ public required long Bet { get; set; }
///
/// The final result of the player in the game (won, lost, tie)
///
diff --git a/DiscordBot/Domain/Casino/GameSession.cs b/DiscordBot/Domain/Casino/GameSession.cs
index 3294d156..6fb29dc9 100644
--- a/DiscordBot/Domain/Casino/GameSession.cs
+++ b/DiscordBot/Domain/Casino/GameSession.cs
@@ -10,12 +10,12 @@ public interface IGameSession
public Type ActionType { get; }
public DiscordGamePlayer? GetPlayer(ulong userId);
- public bool AddPlayer(ulong userId, ulong bet);
+ public bool AddPlayer(ulong userId, long bet);
public bool AddPlayerAI();
public void RemovePlayer(ulong userId);
public void RemovePlayerAI();
public void SetPlayerReady(ulong userId, bool isReady);
- public void SetPlayerBet(ulong userId, ulong bet);
+ public void SetPlayerBet(ulong userId, long bet);
public void DoPlayerAction(ulong userId, Enum action);
public bool HasNextDealerAction();
@@ -75,7 +75,7 @@ public GameSession(TGame game, int maxSeats)
///
public bool CanStart => Game.State == GameState.NotStarted && PlayerCount >= Game.MinPlayers && AllPlayersReady;
- public ulong GetTotalPot => (ulong)Players.Sum(p => (long)p.Bet);
+ public long GetTotalPot => Players.Sum(p => p.Bet);
public bool ShouldFinish() => Game.ShouldFinish();
@@ -94,7 +94,7 @@ public void Reset()
public DiscordGamePlayer? GetPlayer(ulong userId) => Players.FirstOrDefault(p => p.UserId == userId);
- public bool AddPlayer(ulong userId, ulong bet)
+ public bool AddPlayer(ulong userId, long bet)
{
if (!CanJoin) return false;
if (Players.Any(p => p.UserId == userId)) return false; // Player already in game
@@ -156,7 +156,7 @@ public void SetPlayerReady(ulong userId, bool ready = true)
if (ready && CanStart) Game.StartGame(Players);
}
- public void SetPlayerBet(ulong userId, ulong bet)
+ public void SetPlayerBet(ulong userId, long bet)
{
if (Game.State != GameState.NotStarted) return; // Cannot change bet after the game has started
var player = GetPlayer(userId);
diff --git a/DiscordBot/Domain/Casino/Games/Cards/Blackjack/Blackjack.cs b/DiscordBot/Domain/Casino/Games/Cards/Blackjack/Blackjack.cs
index 06f4e70a..15d2682b 100644
--- a/DiscordBot/Domain/Casino/Games/Cards/Blackjack/Blackjack.cs
+++ b/DiscordBot/Domain/Casino/Games/Cards/Blackjack/Blackjack.cs
@@ -105,12 +105,12 @@ public override GamePlayerResult GetPlayerGameResult(GamePlayer player)
return GamePlayerResult.NoResult;
}
- public override long CalculatePayout(GamePlayer player, ulong _totalPot)
+ public override long CalculatePayout(GamePlayer player, long _totalPot)
{
return player.Result switch
{
- GamePlayerResult.Won => (long)player.Bet,
- GamePlayerResult.Lost => -(long)player.Bet,
+ GamePlayerResult.Won => player.Bet,
+ GamePlayerResult.Lost => -player.Bet,
GamePlayerResult.Tie => 0,
_ => 0
};
diff --git a/DiscordBot/Domain/Casino/Games/Cards/Poker/Poker.cs b/DiscordBot/Domain/Casino/Games/Cards/Poker/Poker.cs
index 3f28f866..3a4a71e3 100644
--- a/DiscordBot/Domain/Casino/Games/Cards/Poker/Poker.cs
+++ b/DiscordBot/Domain/Casino/Games/Cards/Poker/Poker.cs
@@ -230,11 +230,11 @@ public override GamePlayerResult GetPlayerGameResult(GamePlayer player)
return winners.Any(w => w.player == player) ? GamePlayerResult.Won : GamePlayerResult.Lost;
}
- public override long CalculatePayout(GamePlayer player, ulong totalPot)
+ public override long CalculatePayout(GamePlayer player, long totalPot)
{
var result = GetPlayerGameResult(player);
if (result == GamePlayerResult.Lost)
- return -(long)player.Bet;
+ return -player.Bet;
// Calculate winner's share
var allHands = Players.Where(p => GameData[p].FinalHand != null)
@@ -244,12 +244,11 @@ public override long CalculatePayout(GamePlayer player, ulong totalPot)
if (winner.player != null)
{
- // Winner gets their share of the total pot minus their original bet
- var winnings = (long)(totalPot * (ulong)winner.share);
- return winnings - (long)player.Bet;
+ var winnings = (long)(totalPot * winner.share);
+ return winnings - player.Bet;
}
- return -(long)player.Bet;
+ return -player.Bet;
}
public override bool ShouldFinish() => State == GameState.InProgress && Players.All(p => GameData[p].HasDiscarded);
diff --git a/DiscordBot/Domain/Casino/Games/RockPaperScissors/RockPaperScissors.cs b/DiscordBot/Domain/Casino/Games/RockPaperScissors/RockPaperScissors.cs
index b45dbd34..3dd73647 100644
--- a/DiscordBot/Domain/Casino/Games/RockPaperScissors/RockPaperScissors.cs
+++ b/DiscordBot/Domain/Casino/Games/RockPaperScissors/RockPaperScissors.cs
@@ -74,13 +74,13 @@ public override GamePlayerResult GetPlayerGameResult(GamePlayer player)
return playerWins ? GamePlayerResult.Won : GamePlayerResult.Lost;
}
- public override long CalculatePayout(GamePlayer player, ulong totalPot)
+ public override long CalculatePayout(GamePlayer player, long totalPot)
{
return player.Result switch
{
- GamePlayerResult.Won => (long)totalPot - (long)player.Bet, // Winner gets the total pot minus their bet
- GamePlayerResult.Lost => -(long)player.Bet, // Loser loses their bet
- GamePlayerResult.Tie => 0, // Tie gets bet back (no loss, no gain)
+ GamePlayerResult.Won => totalPot - player.Bet,
+ GamePlayerResult.Lost => -player.Bet,
+ GamePlayerResult.Tie => 0,
_ => 0
};
}
diff --git a/DiscordBot/Domain/ProfileData.cs b/DiscordBot/Domain/ProfileData.cs
index 82ef6162..2942a5fc 100644
--- a/DiscordBot/Domain/ProfileData.cs
+++ b/DiscordBot/Domain/ProfileData.cs
@@ -7,15 +7,15 @@ public class ProfileData
public ulong UserId { get; set; }
public string Nickname { get; set; }
public string Username { get; set; }
- public uint XpTotal { get; set; }
- public uint XpRank { get; set; }
- public uint KarmaRank { get; set; }
- public uint Karma { get; set; }
- public uint Level { get; set; }
+ public long XpTotal { get; set; }
+ public long XpRank { get; set; }
+ public long KarmaRank { get; set; }
+ public int Karma { get; set; }
+ public int Level { get; set; }
public double XpLow { get; set; }
public double XpHigh { get; set; }
- public uint XpShown { get; set; }
- public uint MaxXpShown { get; set; }
+ public int XpShown { get; set; }
+ public int MaxXpShown { get; set; }
public float XpPercentage { get; set; }
public Color MainRoleColor { get; set; }
public MagickImage Picture { get; set; }
diff --git a/DiscordBot/Extensions/CasinoRepository.cs b/DiscordBot/Extensions/CasinoRepository.cs
index e63c145c..6216431e 100644
--- a/DiscordBot/Extensions/CasinoRepository.cs
+++ b/DiscordBot/Extensions/CasinoRepository.cs
@@ -8,8 +8,8 @@ public interface ICasinoRepo
// Casino User Operations
[Sql($@"
INSERT INTO {CasinoProps.CasinoTableName} ({CasinoProps.UserID}, {CasinoProps.Tokens}, {CasinoProps.CreatedAt}, {CasinoProps.UpdatedAt}, {CasinoProps.LastDailyReward})
- VALUES (@{CasinoProps.UserID}, @{CasinoProps.Tokens}, @{CasinoProps.CreatedAt}, @{CasinoProps.UpdatedAt}, @{CasinoProps.LastDailyReward});
- SELECT * FROM {CasinoProps.CasinoTableName} WHERE {CasinoProps.UserID} = @{CasinoProps.UserID}")]
+ VALUES (@{CasinoProps.UserID}, @{CasinoProps.Tokens}, @{CasinoProps.CreatedAt}, @{CasinoProps.UpdatedAt}, @{CasinoProps.LastDailyReward})
+ RETURNING *")]
Task InsertCasinoUser(CasinoUser user);
[Sql($"SELECT * FROM {CasinoProps.CasinoTableName} WHERE {CasinoProps.UserID} = @userId")]
@@ -19,10 +19,10 @@ public interface ICasinoRepo
Task> GetTopTokenHolders(int limit);
[Sql($"UPDATE {CasinoProps.CasinoTableName} SET {CasinoProps.Tokens} = @tokens, {CasinoProps.UpdatedAt} = @updatedAt WHERE {CasinoProps.UserID} = @userId")]
- Task UpdateTokens(string userId, ulong tokens, DateTime updatedAt);
+ Task UpdateTokens(string userId, long tokens, DateTime updatedAt);
[Sql($"UPDATE {CasinoProps.CasinoTableName} SET {CasinoProps.Tokens} = @tokens, {CasinoProps.UpdatedAt} = @updatedAt, {CasinoProps.LastDailyReward} = @lastDailyReward WHERE {CasinoProps.UserID} = @userId")]
- Task UpdateTokensAndDailyReward(string userId, ulong tokens, DateTime updatedAt, DateTime lastDailyReward);
+ Task UpdateTokensAndDailyReward(string userId, long tokens, DateTime updatedAt, DateTime lastDailyReward);
[Sql($"DELETE FROM {CasinoProps.CasinoTableName} WHERE {CasinoProps.UserID} = @userId")]
Task DeleteCasinoUser(string userId);
@@ -32,9 +32,9 @@ public interface ICasinoRepo
// Token Transaction Operations
[Sql($@"
- INSERT INTO {CasinoProps.TransactionTableName} ({CasinoProps.TransactionUserID}, {CasinoProps.Amount}, {CasinoProps.TransactionType}, {CasinoProps.Details}, {CasinoProps.TransactionCreatedAt})
- VALUES (@{CasinoProps.TransactionUserID}, @{CasinoProps.Amount}, @{CasinoProps.TransactionType}, @{CasinoProps.Details}, @{CasinoProps.TransactionCreatedAt});
- SELECT * FROM {CasinoProps.TransactionTableName} WHERE {CasinoProps.TransactionId} = LAST_INSERT_ID()")]
+ INSERT INTO {CasinoProps.TransactionTableName} ({CasinoProps.TransactionUserID}, {CasinoProps.TargetUserID}, {CasinoProps.Amount}, {CasinoProps.TransactionType}, {CasinoProps.Details}, {CasinoProps.TransactionCreatedAt})
+ VALUES (@{CasinoProps.TransactionUserID}, @{CasinoProps.TargetUserID}, @{CasinoProps.Amount}, @{CasinoProps.TransactionType}, @{CasinoProps.Details}, @{CasinoProps.TransactionCreatedAt})
+ RETURNING *")]
Task InsertTransaction(TokenTransaction tokenTransaction);
[Sql($"SELECT * FROM {CasinoProps.TransactionTableName} WHERE {CasinoProps.TransactionUserID} = @userId ORDER BY {CasinoProps.TransactionCreatedAt} DESC LIMIT @limit")]
@@ -47,7 +47,7 @@ public interface ICasinoRepo
Task ClearAllTransactions();
[Sql($"SELECT * FROM {CasinoProps.TransactionTableName} WHERE {CasinoProps.TransactionType} = @transactionType ORDER BY {CasinoProps.TransactionCreatedAt} DESC")]
- Task> GetTransactionsOfType(TransactionType transactionType);
+ Task> GetTransactionsOfType(string transactionType);
// Test connection
[Sql($"SELECT COUNT(*) FROM {CasinoProps.CasinoTableName}")]
diff --git a/DiscordBot/Extensions/DBConnectionExtension.cs b/DiscordBot/Extensions/DBConnectionExtension.cs
index bba946b9..9294ebd0 100644
--- a/DiscordBot/Extensions/DBConnectionExtension.cs
+++ b/DiscordBot/Extensions/DBConnectionExtension.cs
@@ -1,5 +1,6 @@
using System.Data.Common;
using Insight.Database;
+using Npgsql;
namespace DiscordBot.Extensions;
@@ -7,9 +8,8 @@ public static class DBConnectionExtension
{
public static async Task ColumnExists(this DbConnection connection, string tableName, string columnName)
{
- // Execute the query `SHOW COLUMNS FROM `{tableName}` LIKE '{columnName}'` and check if any rows are returned
- var query = $"SHOW COLUMNS FROM `{tableName}` LIKE '{columnName}'";
- var response = await connection.QuerySqlAsync(query);
+ const string query = "SELECT 1 FROM information_schema.columns WHERE LOWER(table_name) = LOWER(@tableName) AND LOWER(column_name) = LOWER(@columnName)";
+ var response = await connection.QuerySqlAsync(query, new { tableName, columnName });
return response.Count > 0;
}
}
\ No newline at end of file
diff --git a/DiscordBot/Extensions/UserDBRepository.cs b/DiscordBot/Extensions/UserDBRepository.cs
index b5c62837..ce932b21 100644
--- a/DiscordBot/Extensions/UserDBRepository.cs
+++ b/DiscordBot/Extensions/UserDBRepository.cs
@@ -6,13 +6,13 @@ public class ServerUser
{
// ReSharper disable once InconsistentNaming
public string UserID { get; set; }
- public uint Karma { get; set; }
- public uint KarmaWeekly { get; set; }
- public uint KarmaMonthly { get; set; }
- public uint KarmaYearly { get; set; }
- public uint KarmaGiven { get; set; }
- public ulong Exp { get; set; }
- public uint Level { get; set; }
+ public int Karma { get; set; }
+ public int KarmaWeekly { get; set; }
+ public int KarmaMonthly { get; set; }
+ public int KarmaYearly { get; set; }
+ public int KarmaGiven { get; set; }
+ public long Exp { get; set; }
+ public int Level { get; set; }
// DefaultCity - Optional Location for Weather, BDay, Temp, Time, etc. (Added - Jan 2024)
public string DefaultCity { get; set; } = string.Empty;
}
@@ -23,7 +23,7 @@ public class ServerUser
public static class UserProps
{
public const string TableName = "users";
-
+
public const string UserID = nameof(ServerUser.UserID);
public const string Karma = nameof(ServerUser.Karma);
public const string KarmaWeekly = nameof(ServerUser.KarmaWeekly);
@@ -38,8 +38,8 @@ public static class UserProps
public interface IServerUserRepo
{
[Sql($@"
- INSERT INTO {UserProps.TableName} ({UserProps.UserID}) VALUES (@{UserProps.UserID});
- SELECT * FROM {UserProps.TableName} WHERE {UserProps.UserID} = @{UserProps.UserID}")]
+ INSERT INTO {UserProps.TableName} ({UserProps.UserID}) VALUES (@{UserProps.UserID})
+ RETURNING *")]
Task InsertUser(ServerUser user);
[Sql($"DELETE FROM {UserProps.TableName} WHERE {UserProps.UserID} = @userId")]
Task RemoveUser(string userId);
@@ -48,54 +48,54 @@ public interface IServerUserRepo
Task GetUser(string userId);
#region Ranks
-
- [Sql($"SELECT {UserProps.UserID}, {UserProps.Karma}, {UserProps.Level}, {UserProps.Exp} FROM {UserProps.TableName} ORDER BY {UserProps.Level} DESC, RAND() LIMIT @n")]
+
+ [Sql($"SELECT {UserProps.UserID}, {UserProps.Karma}, {UserProps.Level}, {UserProps.Exp} FROM {UserProps.TableName} ORDER BY {UserProps.Level} DESC, RANDOM() LIMIT @n")]
Task> GetTopLevel(int n);
- [Sql($"SELECT {UserProps.UserID}, {UserProps.Karma}, {UserProps.KarmaGiven} FROM {UserProps.TableName} ORDER BY {UserProps.Karma} DESC, RAND() LIMIT @n")]
+ [Sql($"SELECT {UserProps.UserID}, {UserProps.Karma}, {UserProps.KarmaGiven} FROM {UserProps.TableName} ORDER BY {UserProps.Karma} DESC, RANDOM() LIMIT @n")]
Task> GetTopKarma(int n);
- [Sql($"SELECT {UserProps.UserID}, {UserProps.KarmaWeekly} FROM {UserProps.TableName} ORDER BY {UserProps.KarmaWeekly} DESC, RAND() LIMIT @n")]
+ [Sql($"SELECT {UserProps.UserID}, {UserProps.KarmaWeekly} FROM {UserProps.TableName} ORDER BY {UserProps.KarmaWeekly} DESC, RANDOM() LIMIT @n")]
Task> GetTopKarmaWeekly(int n);
- [Sql($"SELECT {UserProps.UserID}, {UserProps.KarmaMonthly} FROM {UserProps.TableName} ORDER BY {UserProps.KarmaMonthly} DESC, RAND() LIMIT @n")]
+ [Sql($"SELECT {UserProps.UserID}, {UserProps.KarmaMonthly} FROM {UserProps.TableName} ORDER BY {UserProps.KarmaMonthly} DESC, RANDOM() LIMIT @n")]
Task> GetTopKarmaMonthly(int n);
- [Sql($"SELECT {UserProps.UserID}, {UserProps.KarmaYearly} FROM {UserProps.TableName} ORDER BY {UserProps.KarmaYearly} DESC, RAND() LIMIT @n")]
+ [Sql($"SELECT {UserProps.UserID}, {UserProps.KarmaYearly} FROM {UserProps.TableName} ORDER BY {UserProps.KarmaYearly} DESC, RANDOM() LIMIT @n")]
Task> GetTopKarmaYearly(int n);
[Sql($"SELECT COUNT({UserProps.UserID})+1 FROM {UserProps.TableName} WHERE {UserProps.Level} > @level")]
- Task GetLevelRank(string userId, uint level);
+ Task GetLevelRank(string userId, int level);
[Sql($"SELECT COUNT({UserProps.UserID})+1 FROM {UserProps.TableName} WHERE {UserProps.Karma} > @karma")]
- Task GetKarmaRank(string userId, uint karma);
-
+ Task GetKarmaRank(string userId, int karma);
+
#endregion // Ranks
#region Update Values
-
+
[Sql($"UPDATE {UserProps.TableName} SET {UserProps.Karma} = @karma WHERE {UserProps.UserID} = @userId")]
- Task UpdateKarma(string userId, uint karma);
+ Task UpdateKarma(string userId, int karma);
[Sql($"UPDATE {UserProps.TableName} SET {UserProps.Karma} = {UserProps.Karma} + 1, {UserProps.KarmaWeekly} = {UserProps.KarmaWeekly} + 1, {UserProps.KarmaMonthly} = {UserProps.KarmaMonthly} + 1, {UserProps.KarmaYearly} = {UserProps.KarmaYearly} + 1 WHERE {UserProps.UserID} = @userId")]
Task IncrementKarma(string userId);
[Sql($"UPDATE {UserProps.TableName} SET {UserProps.KarmaGiven} = @karmaGiven WHERE {UserProps.UserID} = @userId")]
- Task UpdateKarmaGiven(string userId, uint karmaGiven);
+ Task UpdateKarmaGiven(string userId, int karmaGiven);
[Sql($"UPDATE {UserProps.TableName} SET {UserProps.Exp} = @xp WHERE {UserProps.UserID} = @userId")]
- Task UpdateXp(string userId, ulong xp);
+ Task UpdateXp(string userId, long xp);
[Sql($"UPDATE {UserProps.TableName} SET {UserProps.Level} = @level WHERE {UserProps.UserID} = @userId")]
- Task UpdateLevel(string userId, uint level);
+ Task UpdateLevel(string userId, int level);
[Sql($"UPDATE {UserProps.TableName} SET {UserProps.DefaultCity} = @city WHERE {UserProps.UserID} = @userId")]
Task UpdateDefaultCity(string userId, string city);
-
+
#endregion // Update Values
#region Get Single Values
-
+
[Sql($"SELECT {UserProps.Karma} FROM {UserProps.TableName} WHERE {UserProps.UserID} = @userId")]
- Task GetKarma(string userId);
+ Task GetKarma(string userId);
[Sql($"SELECT {UserProps.KarmaGiven} FROM {UserProps.TableName} WHERE {UserProps.UserID} = @userId")]
- Task GetKarmaGiven(string userId);
+ Task GetKarmaGiven(string userId);
[Sql($"SELECT {UserProps.Exp} FROM {UserProps.TableName} WHERE {UserProps.UserID} = @userId")]
- Task GetXp(string userId);
+ Task GetXp(string userId);
[Sql($"SELECT {UserProps.Level} FROM {UserProps.TableName} WHERE {UserProps.UserID} = @userId")]
- Task GetLevel(string userId);
+ Task GetLevel(string userId);
[Sql($"SELECT {UserProps.DefaultCity} FROM {UserProps.TableName} WHERE {UserProps.UserID} = @userId")]
Task GetDefaultCity(string userId);
-
+
#endregion // Get Single Values
/// Returns a count of {Props.TableName} in the Table, otherwise it fails.
diff --git a/DiscordBot/Modules/Casino/CasinoSlashModule.Games.cs b/DiscordBot/Modules/Casino/CasinoSlashModule.Games.cs
index 6ccf6784..c0d6926d 100644
--- a/DiscordBot/Modules/Casino/CasinoSlashModule.Games.cs
+++ b/DiscordBot/Modules/Casino/CasinoSlashModule.Games.cs
@@ -300,7 +300,7 @@ public async Task RemoveAIPlayer(string id)
#region Betting Actions
[ComponentInteraction("bet_add:*:*", true)]
- public async Task BetAdd(string id, ulong amount)
+ public async Task BetAdd(string id, long amount)
{
await DeferAsync();
@@ -320,7 +320,7 @@ public async Task BetAdd(string id, ulong amount)
}
[ComponentInteraction("bet_set:*:*", true)]
- public async Task BetSet(string id, ulong amount)
+ public async Task BetSet(string id, long amount)
{
if (!Context.Interaction.HasResponded) await DeferAsync();
diff --git a/DiscordBot/Modules/Casino/CasinoSlashModule.cs b/DiscordBot/Modules/Casino/CasinoSlashModule.cs
index d9ad21db..4d30b28e 100644
--- a/DiscordBot/Modules/Casino/CasinoSlashModule.cs
+++ b/DiscordBot/Modules/Casino/CasinoSlashModule.cs
@@ -79,7 +79,7 @@ public async Task CheckTokens()
[SlashCommand("gift", "Gift tokens to another user")]
public async Task GiftTokens(
[Summary("user", "User to gift tokens to")] SocketGuildUser targetUser,
- [Summary("amount", "Amount of tokens to gift")] uint amount)
+ [Summary("amount", "Amount of tokens to gift")] int amount)
{
if (!await CheckChannelPermissions()) return;
@@ -380,14 +380,14 @@ public async Task NavigateHistory(string userId, string pageStr, string requestT
private (string emoji, string title, string description) FormatTransactionDisplay(TokenTransaction transaction, bool showUserInfo = false)
{
- var (emoji, title, description) = transaction.Type switch
+ var (emoji, title, description) = transaction.Kind switch
{
- TransactionType.TokenInitialisation => ("π―", "Account Created", ""),
- TransactionType.DailyReward => ("π
", "Daily Reward", ""),
- TransactionType.Gift => GetGiftDisplay(transaction),
- TransactionType.Game => GetGameDisplay(transaction),
- TransactionType.Admin => GetAdminDisplay(transaction),
- _ => ("β", transaction.Type.ToString(), "")
+ TransactionKind.TokenInitialisation => ("π―", "Account Created", ""),
+ TransactionKind.DailyReward => ("π
", "Daily Reward", ""),
+ TransactionKind.Gift => GetGiftDisplay(transaction),
+ TransactionKind.Game => GetGameDisplay(transaction),
+ TransactionKind.Admin => GetAdminDisplay(transaction),
+ _ => ("β", transaction.TransactionType, "")
};
// If showing user info (for all-users view), prepend user name to title
@@ -462,7 +462,7 @@ private string CapitalizeFirst(string input)
[RequireUserPermission(GuildPermission.Administrator)]
public async Task SetTokens(
[Summary("user", "User to set tokens for")] SocketGuildUser targetUser,
- [Summary("amount", "New token amount")] uint amount)
+ [Summary("amount", "New token amount")] int amount)
{
if (!await CheckChannelPermissions()) return;
@@ -484,13 +484,13 @@ public async Task SetTokens(
[RequireUserPermission(GuildPermission.Administrator)]
public async Task AddTokens(
[Summary("user", "User to add tokens to")] SocketGuildUser targetUser,
- [Summary("amount", "Amount of tokens to add")] uint amount)
+ [Summary("amount", "Amount of tokens to add")] int amount)
{
if (!await CheckChannelPermissions()) return;
await Context.Interaction.DeferAsync(ephemeral: true);
- await CasinoService.UpdateUserTokens(targetUser.Id.ToString(), (long)amount, TransactionType.Admin, new Dictionary
+ await CasinoService.UpdateUserTokens(targetUser.Id.ToString(), amount, TransactionKind.Admin, new Dictionary
{
["admin"] = Context.User.Id.ToString(),
["action"] = "add"
diff --git a/DiscordBot/Modules/ModerationModule.cs b/DiscordBot/Modules/ModerationModule.cs
index 48de2952..69c17141 100644
--- a/DiscordBot/Modules/ModerationModule.cs
+++ b/DiscordBot/Modules/ModerationModule.cs
@@ -7,7 +7,6 @@
using Pathoschild.NaturalTimeParser.Parser;
using DiscordBot.Attributes;
using DiscordBot.Utils;
-using Org.BouncyCastle.Asn1.Cms;
namespace DiscordBot.Modules;
@@ -22,13 +21,13 @@ public class ModerationModule : ModuleBase
public BotSettings Settings { get; set; }
public UserService UserService { get; set; }
public ModerationService ModerationService { get; set; }
-
+
#endregion
-
+
private async Task IsModerationEnabled()
{
if (Settings.ModeratorCommandsEnabled) return true;
- if (await Context.Guild.GetChannelAsync(Settings.BotAnnouncementChannel.Id)is IMessageChannel botAnnouncementChannel)
+ if (await Context.Guild.GetChannelAsync(Settings.BotAnnouncementChannel.Id) is IMessageChannel botAnnouncementChannel)
{
var sentMessage = await botAnnouncementChannel.SendMessageAsync($"{Context.User.Mention} some moderation commands are disabled, try using Wick.");
await Context.Message.DeleteAsync();
@@ -114,7 +113,7 @@ await LoggingService.LogChannelAndFile(
$"You have been muted from UDC for **{Utils.Utils.FormatTime(seconds)}** for the following reason : **{message}**. " +
"This is not appealable and any tentative to avoid it will result in your permanent ban."))
{
- if (await Context.Guild.GetChannelAsync(Settings.BotCommandsChannel.Id)is ISocketMessageChannel botCommandChannel)
+ if (await Context.Guild.GetChannelAsync(Settings.BotCommandsChannel.Id) is ISocketMessageChannel botCommandChannel)
await botCommandChannel.SendMessageAsync(
$"I could not DM you {user.Mention}!\nYou have been muted from UDC for **{Utils.Utils.FormatTime(seconds)}** for the following reason : **{message}**. " +
"This is not appealable and any tentative to avoid it will result in your permanent ban.");
@@ -442,7 +441,7 @@ public async Task FullSync()
}
#region General Utility Commands
-
+
[Command("WelcomeMessageCount")]
[Summary("Returns a count of pending welcome messages.")]
[RequireModerator, HideFromHelp]
@@ -462,7 +461,7 @@ public async Task WelcomeMessageCount()
}
await Context.Message.DeleteAsync();
}
-
+
// Command to show the tags available for a specific channel, so the command needs to be run in a channel with tags or specific a channel id to check
[Command("ChannelTags")]
[Summary("Returns a list of tags for the current channel.")]
@@ -499,7 +498,7 @@ public async Task ChannelTags(ulong channelId)
}
#endregion
-
+
#region CommandList
[RequireModerator]
[Summary("Does what you see now.")]
diff --git a/DiscordBot/Modules/UserModule.cs b/DiscordBot/Modules/UserModule.cs
index ced5b0c4..d8bc3b65 100644
--- a/DiscordBot/Modules/UserModule.cs
+++ b/DiscordBot/Modules/UserModule.cs
@@ -251,7 +251,7 @@ public async Task UserCompleted(string message)
return;
}
- const uint xpGain = 5000;
+ const int xpGain = 5000;
var userXp = await DatabaseService.Query.GetXp(userId.ToString());
await DatabaseService.Query.UpdateXp(userId.ToString(), userXp + xpGain);
await Context.Message.DeleteAsync();
@@ -468,7 +468,7 @@ public async Task TopKarmaYearly()
await ReplyAsync(embed: embed).DeleteAfterTime(minutes: 1);
}
- private async Task