Remove all string identifiers, changed to long
This commit is contained in:
parent
17170962b1
commit
81c32f1137
@ -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"];
|
||||
}
|
||||
}
|
||||
|
||||
@ -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"];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -16,7 +16,7 @@ namespace ChaosBot.Database.Repository
|
||||
return pointsList.ToArray();
|
||||
}
|
||||
|
||||
public static Points[] All(string guildId)
|
||||
public static Points[] All(long guildId)
|
||||
{
|
||||
List<Points> 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();
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ namespace ChaosBot.Database.Repository
|
||||
/// </summary>
|
||||
/// <param name="guildId"></param>
|
||||
/// <returns>List of raffles</returns>
|
||||
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
|
||||
/// </summary>
|
||||
/// <param name="guildId"></param>
|
||||
/// <returns>Amount of raffles</returns>
|
||||
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
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="guildId"></param>
|
||||
/// <returns>Amount of raffles</returns>
|
||||
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
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns>List of raffles</returns>
|
||||
public static Raffle[] SelectUser(string userId)
|
||||
public static Raffle[] SelectUser(long userId)
|
||||
{
|
||||
List<Raffle> raffles = Raffle.Query().Where("userId", userId).Get();
|
||||
|
||||
@ -82,7 +82,7 @@ namespace ChaosBot.Database.Repository
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="guildId"></param>
|
||||
/// <returns>List of raffles</returns>
|
||||
public static Raffle[] SelectUser(string userId, string guildId)
|
||||
public static Raffle[] SelectUser(long userId, long guildId)
|
||||
{
|
||||
List<Raffle> raffles = Raffle.Query().Where("userId", userId).Where("guildId", guildId).Get();
|
||||
|
||||
@ -115,7 +115,7 @@ namespace ChaosBot.Database.Repository
|
||||
/// </summary>
|
||||
/// <param name="guildId"></param>
|
||||
/// <returns>Random raffle</returns>
|
||||
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 <c>Raffle</c>s for a given guild
|
||||
/// </summary>
|
||||
/// <param name="guildId"></param>
|
||||
public static void ClearRaffle(string guildId)
|
||||
public static void ClearRaffle(long guildId)
|
||||
{
|
||||
Raffle.Query().Where("guildId", guildId).Delete();
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -140,32 +140,32 @@ namespace ChaosBot.Discord.Modules
|
||||
List<Raffle> raffles = new List<Raffle>();
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user