mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-22 05:54:36 +00:00
Fix override remove not acting on correct data
This commit is contained in:
parent
996540b08e
commit
f8251a3b71
1 changed files with 7 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
||||||
using BirthdayBot.Data;
|
using BirthdayBot.Data;
|
||||||
using Discord.Interactions;
|
using Discord.Interactions;
|
||||||
|
using static BirthdayBot.Common;
|
||||||
|
|
||||||
namespace BirthdayBot.ApplicationCommands;
|
namespace BirthdayBot.ApplicationCommands;
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ public class BirthdayOverrideModule : BotModuleBase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await RespondAsync($":white_check_mark: {Common.FormatName(target, false)}'s birthday has been set to " +
|
await RespondAsync($":white_check_mark: {FormatName(target, false)}'s birthday has been set to " +
|
||||||
$"**{FormatDate(inmonth, inday)}**.").ConfigureAwait(false);
|
$"**{FormatDate(inmonth, inday)}**.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ public class BirthdayOverrideModule : BotModuleBase {
|
||||||
|
|
||||||
var user = target.GetUserEntryOrNew(db);
|
var user = target.GetUserEntryOrNew(db);
|
||||||
if (user.IsNew) {
|
if (user.IsNew) {
|
||||||
await RespondAsync($":x: {Common.FormatName(target, false)} does not have a birthday set.")
|
await RespondAsync($":x: {FormatName(target, false)} does not have a birthday set.")
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -62,21 +63,21 @@ public class BirthdayOverrideModule : BotModuleBase {
|
||||||
}
|
}
|
||||||
user.TimeZone = newzone;
|
user.TimeZone = newzone;
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
await RespondAsync($":white_check_mark: {Common.FormatName(target, false)}'s time zone has been set to " +
|
await RespondAsync($":white_check_mark: {FormatName(target, false)}'s time zone has been set to " +
|
||||||
$"**{newzone}**.").ConfigureAwait(false);
|
$"**{newzone}**.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
[SlashCommand("remove-birthday", HelpPfxModOnly + "Remove a user's birthday information on their behalf.")]
|
[SlashCommand("remove-birthday", HelpPfxModOnly + "Remove a user's birthday information on their behalf.")]
|
||||||
public async Task OvRemove([Summary(description: HelpOptOvTarget)]SocketGuildUser target) {
|
public async Task OvRemove([Summary(description: HelpOptOvTarget)]SocketGuildUser target) {
|
||||||
using var db = new BotDatabaseContext();
|
using var db = new BotDatabaseContext();
|
||||||
var user = ((SocketGuildUser)Context.User).GetUserEntryOrNew(db);
|
var user = target.GetUserEntryOrNew(db);
|
||||||
if (!user.IsNew) {
|
if (!user.IsNew) {
|
||||||
db.UserEntries.Remove(user);
|
db.UserEntries.Remove(user);
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
await RespondAsync($":white_check_mark: {Common.FormatName(target, false)}'s birthday in this server has been removed.")
|
await RespondAsync($":white_check_mark: {FormatName(target, false)}'s birthday in this server has been removed.")
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
} else {
|
} else {
|
||||||
await RespondAsync($":white_check_mark: {Common.FormatName(target, false)}'s birthday is not registered.")
|
await RespondAsync($":white_check_mark: {FormatName(target, false)}'s birthday is not registered.")
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue