fixed voting reward, message, logging
This commit is contained in:
parent
d414ecda2d
commit
aaf8522987
1 changed files with 6 additions and 1 deletions
|
@ -8,6 +8,7 @@ namespace EllieBot.Modules.Gambling.Services;
|
||||||
public class VoteRewardService(
|
public class VoteRewardService(
|
||||||
ShardData shardData,
|
ShardData shardData,
|
||||||
GamblingConfigService gcs,
|
GamblingConfigService gcs,
|
||||||
|
GamblingService gs,
|
||||||
CurrencyService cs,
|
CurrencyService cs,
|
||||||
IBotCache cache,
|
IBotCache cache,
|
||||||
DiscordSocketClient client,
|
DiscordSocketClient client,
|
||||||
|
@ -64,8 +65,12 @@ public class VoteRewardService(
|
||||||
|
|
||||||
var key = VoteKey(userId);
|
var key = VoteKey(userId);
|
||||||
if (!await cache.AddAsync(key, DateTime.UtcNow, expiry: TimeSpan.FromHours(6)))
|
if (!await cache.AddAsync(key, DateTime.UtcNow, expiry: TimeSpan.FromHours(6)))
|
||||||
|
{
|
||||||
|
Log.Information("User {UserId} has already voted in the last 6 hours", userId);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
(reward, var msg) = await gs.GetAmountAndMessage(userId, reward);
|
||||||
await cs.AddAsync(userId, reward, new("vote", requestType.ToString()));
|
await cs.AddAsync(userId, reward, new("vote", requestType.ToString()));
|
||||||
|
|
||||||
_ = Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
|
@ -75,7 +80,7 @@ public class VoteRewardService(
|
||||||
var user = await client.GetUserAsync(userId);
|
var user = await client.GetUserAsync(userId);
|
||||||
|
|
||||||
await sender.Response(user)
|
await sender.Response(user)
|
||||||
.Confirm(strs.vote_reward(N(reward)))
|
.Confirm(strs.vote_reward(N(reward)) + "\n\n" + msg)
|
||||||
.SendAsync();
|
.SendAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
Loading…
Add table
Reference in a new issue