Skip to content

Commit

Permalink
Update server-specific features
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Sep 18, 2024
1 parent 909b7c0 commit 687d72c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ServerSpecificFeatures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ public static async Task MessageCreateChecks(MessageCreateEventArgs e)
|| e.Message.Content.Equals("**shut**", StringComparison.OrdinalIgnoreCase) || e.Message.Content.Equals("**open**", StringComparison.OrdinalIgnoreCase)))
{
if (e.Message.Author.IsBot)
if (!ShutBotsAllowed || e.Message.Author.Id == Program.Discord.CurrentApplication.Id) return;
if (!ShutBotsAllowed || e.Message.Author.Id == Program.Discord.CurrentApplication.Id || e.Channel.Id != 1285684652543185047) return;

var userId = e.Message.Author.Id;
var userShutCooldownSerialized = await Program.Db.HashGetAsync("shutCooldowns", userId.ToString());
KeyValuePair<DateTime, bool> userShutCooldown;
KeyValuePair<DateTime, bool> userShutCooldown = new();
if (userShutCooldownSerialized.HasValue)
{
try
Expand All @@ -144,7 +144,6 @@ public static async Task MessageCreateChecks(MessageCreateEventArgs e)
catch (Exception ex)
{
Program.Discord.Logger.LogWarning("Failed to read shut cooldown from db for user {user}! {exType}: {exMessage}\n{exStackTrace}", userId, ex.GetType(), ex.Message, ex.StackTrace);
userShutCooldown = new();
}

var userCooldownTime = userShutCooldown.Key;
Expand Down Expand Up @@ -176,10 +175,12 @@ public static async Task MessageCreateChecks(MessageCreateEventArgs e)
|| e.Message.Content.Equals("**open**", StringComparison.OrdinalIgnoreCase))
await e.Message.RespondAsync("shut");

userShutCooldown = new(DateTime.Now.AddSeconds(5), false);
if (e.Message.Author.Id != 1264728368847523850)
userShutCooldown = new(DateTime.Now.AddSeconds(5), false);
}

await Program.Db.HashSetAsync("shutCooldowns", userId.ToString(), JsonConvert.SerializeObject(userShutCooldown));
if (userShutCooldown.Key == DateTime.MinValue && userShutCooldown.Value == false)
await Program.Db.HashSetAsync("shutCooldowns", userId.ToString(), JsonConvert.SerializeObject(userShutCooldown));
}
}
}
Expand Down

0 comments on commit 687d72c

Please sign in to comment.