diff --git a/ChaosBot/Database/Entity/Points.cs b/ChaosBot/Database/Entity/Points.cs index c074d88..b6803df 100644 --- a/ChaosBot/Database/Entity/Points.cs +++ b/ChaosBot/Database/Entity/Points.cs @@ -12,12 +12,12 @@ namespace ChaosBot.Database.Entity [DBUnique] public int id { get; private set; } public int points { get; private set; } - public string userId { get; private set; } - public string guildId { get; private set; } + public long userId { get; private set; } + public long guildId { get; private set; } public Points() {} - public Points(int id, string userId, string guildId, int points) + public Points(int id, long userId, long guildId, int points) { this.id = id; this.userId = userId; @@ -25,7 +25,7 @@ namespace ChaosBot.Database.Entity this.points = points; } - public Points(string userId, string guildId, int points) + public Points(long userId, long guildId, int points) { this.points = points; this.userId = userId; @@ -40,8 +40,8 @@ namespace ChaosBot.Database.Entity public override void SetFromRow(DataRow row) { id = (int)row["id"]; - userId = (string)row["userId"]; - guildId = (string)row["guildId"]; + userId = (long)row["userId"]; + guildId = (long)row["guildId"]; points = (int)row["points"]; } } diff --git a/ChaosBot/Database/Entity/Raffle.cs b/ChaosBot/Database/Entity/Raffle.cs index 4be0ade..d3da395 100644 --- a/ChaosBot/Database/Entity/Raffle.cs +++ b/ChaosBot/Database/Entity/Raffle.cs @@ -11,19 +11,19 @@ namespace ChaosBot.Database.Entity [DBNotNull] [DBUnique] public int id { get; private set; } - public string userId { get; private set; } - public string guildId { get; private set; } + public long userId { get; private set; } + public long guildId { get; private set; } public Raffle() {} - public Raffle(int id, string userId, string guildId) + public Raffle(int id, long userId, long guildId) { this.id = id; this.userId = userId; this.guildId = guildId; } - public Raffle(string userId, string guildId) + public Raffle(long userId, long guildId) { this.userId = userId; this.guildId = guildId; @@ -37,8 +37,8 @@ namespace ChaosBot.Database.Entity public override void SetFromRow(DataRow row) { id = (int)row["id"]; - userId = (string)row["userid"]; - guildId = (string) row["guildid"]; + userId = (long)row["userid"]; + guildId = (long) row["guildid"]; } } } \ No newline at end of file diff --git a/ChaosBot/Database/Repository/PointsRepository.cs b/ChaosBot/Database/Repository/PointsRepository.cs index 3d7a068..5bae385 100644 --- a/ChaosBot/Database/Repository/PointsRepository.cs +++ b/ChaosBot/Database/Repository/PointsRepository.cs @@ -16,7 +16,7 @@ namespace ChaosBot.Database.Repository return pointsList.ToArray(); } - public static Points[] All(string guildId) + public static Points[] All(long guildId) { List pointsList = Points.Query().Where("guildId", guildId).All(); @@ -24,7 +24,7 @@ namespace ChaosBot.Database.Repository } - public static int Total(string userId, string guildId) + public static int Total(long userId, long guildId) { Points userPoints = Points.Query().Where("userId", userId).Where("guildId", guildId).First(); @@ -37,13 +37,13 @@ namespace ChaosBot.Database.Repository } - public static int Count(string userId, string guildId) + public static int Count(long userId, long guildId) { return Points.Query().Where("userId", userId).Where("guildId", guildId).Count(); } - public static int Add(string userId, int points, string guildId) + public static int Add(long userId, int points, long guildId) { Points userPoints = Points.Query().Where("userId", userId).Where("guildId", guildId).First(); if (userPoints != null) @@ -59,7 +59,7 @@ namespace ChaosBot.Database.Repository return points; } - public static int Remove(string userId, int points, string guildId) + public static int Remove(long userId, int points, long guildId) { Points userPoints = Points.Query().Where("userId", userId).Where("guildId", guildId).First(); diff --git a/ChaosBot/Database/Repository/RaffleRepository.cs b/ChaosBot/Database/Repository/RaffleRepository.cs index bae7c01..728f242 100644 --- a/ChaosBot/Database/Repository/RaffleRepository.cs +++ b/ChaosBot/Database/Repository/RaffleRepository.cs @@ -27,7 +27,7 @@ namespace ChaosBot.Database.Repository /// /// /// List of raffles - public static Raffle[] All(string guildId) + public static Raffle[] All(long guildId) { var raffles = Raffle.Query().Where("guildId", guildId).All(); @@ -48,7 +48,7 @@ namespace ChaosBot.Database.Repository /// /// /// Amount of raffles - public static int Count(string guildId) + public static int Count(long guildId) { return Raffle.Query().Where("guildId", guildId).Count(); } @@ -59,7 +59,7 @@ namespace ChaosBot.Database.Repository /// /// /// Amount of raffles - public static int Count(string userId, string guildId) + public static int Count(long userId, long guildId) { return Raffle.Query().Where("userId", userId).Where("guildId", guildId).Count(); } @@ -69,7 +69,7 @@ namespace ChaosBot.Database.Repository /// /// /// List of raffles - public static Raffle[] SelectUser(string userId) + public static Raffle[] SelectUser(long userId) { List raffles = Raffle.Query().Where("userId", userId).Get(); @@ -82,7 +82,7 @@ namespace ChaosBot.Database.Repository /// /// /// List of raffles - public static Raffle[] SelectUser(string userId, string guildId) + public static Raffle[] SelectUser(long userId, long guildId) { List raffles = Raffle.Query().Where("userId", userId).Where("guildId", guildId).Get(); @@ -115,7 +115,7 @@ namespace ChaosBot.Database.Repository /// /// /// Random raffle - public static Raffle PickRandom(string guildId) + public static Raffle PickRandom(long guildId) { return Raffle.Query().Where("guildId", guildId).OrderBy("RANDOM()").First(); } @@ -124,7 +124,7 @@ namespace ChaosBot.Database.Repository /// Clear all Raffles for a given guild /// /// - public static void ClearRaffle(string guildId) + public static void ClearRaffle(long guildId) { Raffle.Query().Where("guildId", guildId).Delete(); } diff --git a/ChaosBot/Discord/Modules/PointsCommands.cs b/ChaosBot/Discord/Modules/PointsCommands.cs index b67c733..d5e7365 100644 --- a/ChaosBot/Discord/Modules/PointsCommands.cs +++ b/ChaosBot/Discord/Modules/PointsCommands.cs @@ -58,7 +58,7 @@ namespace ChaosBot.Discord.Modules [Alias("points info")] public async Task PointsCommandTotal() { - int cur = PointsRepository.Total(Context.User.Id.ToString(), Context.Guild.Id.ToString()); + int cur = PointsRepository.Total(Convert.ToInt64(Context.User.Id), Convert.ToInt64(Context.Guild.Id)); await ReplyAsync($"You have {cur} points.", false); } @@ -72,7 +72,7 @@ namespace ChaosBot.Discord.Modules { ulong userId = Convert.ToUInt64(user.Substring(3, user.Length - 4)); - await ReplyAsync($"{Context.User.Mention} has given <@{userId}> {amount} points for a total of {PointsRepository.Add(userId.ToString(), amount, Context.Guild.Id.ToString())} points.", false); + await ReplyAsync($"{Context.User.Mention} has given <@{userId}> {amount} points for a total of {PointsRepository.Add(Convert.ToInt64(userId), amount, Convert.ToInt64(Context.Guild.Id))} points.", false); } else await ReplyAsync($"NO ACCESS"); @@ -85,9 +85,9 @@ namespace ChaosBot.Discord.Modules public async Task RaffleCommandRemove(string user, int amount = 1) { ulong userId = Convert.ToUInt64(user.Substring(3, user.Length - 4)); - int cur = PointsRepository.Total(Context.User.Id.ToString(), Context.Guild.Id.ToString()); + int cur = PointsRepository.Total(Convert.ToInt64(Context.User.Id), Convert.ToInt64(Context.Guild.Id)); if (cur > amount) - await ReplyAsync($"{Context.User.Mention} has removed {amount} points from <@{userId}> for a total of {PointsRepository.Remove(userId.ToString(), amount, Context.Guild.Id.ToString())} points.", false); + await ReplyAsync($"{Context.User.Mention} has removed {amount} points from <@{userId}> for a total of {PointsRepository.Remove(Convert.ToInt64(userId), amount, Convert.ToInt64(Context.Guild.Id))} points.", false); else await ReplyAsync($"{Context.User.Mention} has tried to remove {amount} points from <@{userId}> they only had {cur} points. None were taken...", false); } @@ -98,7 +98,7 @@ namespace ChaosBot.Discord.Modules { ulong userId = Convert.ToUInt64(userMention.Substring(3, userMention.Length - 4)); - int matches = PointsRepository.Count(userId.ToString(), Context.Guild.Id.ToString()); + int matches = PointsRepository.Count(Convert.ToInt64(userId), Convert.ToInt64(Context.Guild.Id)); if (matches > 0) { Points.Query().Where("userId", userId).Where("guildId", Context.Guild.Id).Delete(); diff --git a/ChaosBot/Discord/Modules/RaffleSystem.cs b/ChaosBot/Discord/Modules/RaffleSystem.cs index e589429..703688f 100644 --- a/ChaosBot/Discord/Modules/RaffleSystem.cs +++ b/ChaosBot/Discord/Modules/RaffleSystem.cs @@ -140,32 +140,32 @@ namespace ChaosBot.Discord.Modules List raffles = new List(); for (int i = 0; i < amount; i++) - raffles.Add(new Raffle(userId.ToString(), Context.Guild.Id.ToString())); + raffles.Add(new Raffle(Convert.ToInt64(userId), Convert.ToInt64(Context.Guild.Id))); RaffleRepository.MassInsert(raffles); } else { - RaffleRepository.Insert(new Raffle(userId.ToString(), Context.Guild.Id.ToString())); + RaffleRepository.Insert(new Raffle(Convert.ToInt64(userId), Convert.ToInt64(Context.Guild.Id))); } sb.AppendLine($"{Context.User.Mention} has added {amount} rafflepoints to <@{userId}>."); sb.AppendLine(); - sb.AppendLine($"<@{userId}> now has {RaffleRepository.Count(userId.ToString(), Context.Guild.Id.ToString())} rafflepoints!"); + sb.AppendLine($"<@{userId}> now has {RaffleRepository.Count(Convert.ToInt64(userId), Convert.ToInt64(Context.Guild.Id))} rafflepoints!"); } private void PickRaffle(StringBuilder sb) { - Raffle winner = RaffleRepository.PickRandom(Context.Guild.Id.ToString()); + Raffle winner = RaffleRepository.PickRandom(Convert.ToInt64(Context.Guild.Id)); RaffleRepository.Delete(winner.id); sb.Append($"<@{winner.userId}> has won the raffle!"); } private void ClearRaffle(StringBuilder sb, bool noOutput = false) { - int removed = RaffleRepository.Count(Context.Guild.Id.ToString()); + int removed = RaffleRepository.Count(Convert.ToInt64(Context.Guild.Id)); - RaffleRepository.ClearRaffle(Context.Guild.Id.ToString()); + RaffleRepository.ClearRaffle(Convert.ToInt64(Context.Guild.Id)); sb.AppendLine($"{Context.User.Mention} has cleared all {removed} rafflepoints"); } @@ -174,8 +174,8 @@ namespace ChaosBot.Discord.Modules { ulong userId = Convert.ToUInt64(user.Substring(3, user.Length-4)); - sb.AppendLine($"<@{userId}>, you have {RaffleRepository.Count(userId.ToString(), Context.Guild.Id.ToString())} rafflepoints."); - sb.AppendLine($"There is a total of {RaffleRepository.Count(Context.Guild.Id.ToString())} rafflepoints."); + sb.AppendLine($"<@{userId}>, you have {RaffleRepository.Count(Convert.ToInt64(userId), Convert.ToInt64(Context.Guild.Id))} rafflepoints."); + sb.AppendLine($"There is a total of {RaffleRepository.Count(Convert.ToInt64(Context.Guild.Id))} rafflepoints."); } } } \ No newline at end of file