Fix Entity data types to longs
This commit is contained in:
parent
707e0b1bc1
commit
7046b97bee
@ -11,14 +11,14 @@ namespace ChaosBot.Database.Entity
|
||||
[DBAutoIncrement]
|
||||
[DBNotNull]
|
||||
[DBUnique]
|
||||
public Nullable<int> id { get; private set; }
|
||||
public int points { get; private set; }
|
||||
public Nullable<long> id { get; private set; }
|
||||
public long points { get; private set; }
|
||||
public long userId { get; private set; }
|
||||
public long guildId { get; private set; }
|
||||
|
||||
public Points() {}
|
||||
|
||||
public Points(int id, long userId, long guildId, int points)
|
||||
public Points(long id, long userId, long guildId, int points)
|
||||
{
|
||||
this.id = id;
|
||||
this.userId = userId;
|
||||
@ -26,7 +26,7 @@ namespace ChaosBot.Database.Entity
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
public Points(long userId, long guildId, int points)
|
||||
public Points(long userId, long guildId, long points)
|
||||
{
|
||||
this.points = points;
|
||||
this.userId = userId;
|
||||
@ -40,10 +40,10 @@ namespace ChaosBot.Database.Entity
|
||||
|
||||
public override void SetFromRow(DataRow row)
|
||||
{
|
||||
id = (int)row["id"];
|
||||
id = (long)row["id"];
|
||||
userId = (long)row["userId"];
|
||||
guildId = (long)row["guildId"];
|
||||
points = (int)row["points"];
|
||||
points = (long)row["points"];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -24,7 +24,7 @@ namespace ChaosBot.Database.Repository
|
||||
}
|
||||
|
||||
|
||||
public static int Total(long userId, long guildId)
|
||||
public static long Total(long userId, long guildId)
|
||||
{
|
||||
Points userPoints = Points.Query().Where("userId", userId).Where("guildId", guildId).First();
|
||||
|
||||
@ -43,14 +43,13 @@ namespace ChaosBot.Database.Repository
|
||||
}
|
||||
|
||||
|
||||
public static int Add(long userId, int points, long guildId)
|
||||
public static long Add(long userId, long points, long guildId)
|
||||
{
|
||||
Points userPoints = Points.Query().Where("userId", userId).Where("guildId", guildId).First();
|
||||
if (userPoints != null)
|
||||
{
|
||||
Points.Query().Where("userId", userId).Where("guildId", guildId).Set("points", userPoints.points + points).Update();
|
||||
return userPoints.points + points;
|
||||
|
||||
}
|
||||
|
||||
Points newUserPoints = new Points(userId, guildId, points);
|
||||
@ -59,7 +58,7 @@ namespace ChaosBot.Database.Repository
|
||||
return points;
|
||||
}
|
||||
|
||||
public static int Remove(long userId, int points, long guildId)
|
||||
public static long Remove(long userId, long points, long guildId)
|
||||
{
|
||||
Points userPoints = Points.Query().Where("userId", userId).Where("guildId", guildId).First();
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ namespace ChaosBot.Discord.Modules
|
||||
[Alias("points info")]
|
||||
public async Task PointsCommandTotal()
|
||||
{
|
||||
int cur = PointsRepository.Total(Convert.ToInt64(Context.User.Id), Convert.ToInt64(Context.Guild.Id));
|
||||
long cur = PointsRepository.Total(Convert.ToInt64(Context.User.Id), Convert.ToInt64(Context.Guild.Id));
|
||||
await ReplyAsync($"You have {cur} points.", false);
|
||||
|
||||
}
|
||||
@ -82,10 +82,10 @@ namespace ChaosBot.Discord.Modules
|
||||
|
||||
[Command("points remove")]
|
||||
[RequireUserPermission(ChannelPermission.ManageMessages)]
|
||||
public async Task RaffleCommandRemove(string user, int amount = 1)
|
||||
public async Task RaffleCommandRemove(string user, long amount = 1)
|
||||
{
|
||||
ulong userId = Convert.ToUInt64(user.Substring(3, user.Length - 4));
|
||||
int cur = PointsRepository.Total(Convert.ToInt64(Context.User.Id), Convert.ToInt64(Context.Guild.Id));
|
||||
long 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(Convert.ToInt64(userId), amount, Convert.ToInt64(Context.Guild.Id))} points.", false);
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user