Async command handling

This commit is contained in:
Octol1ttle 2022-08-29 21:24:38 +05:00
parent 51c24c1e23
commit 53f13d88a5
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
7 changed files with 54 additions and 40 deletions

View file

@ -65,12 +65,10 @@ public class BanCommand : Command {
await Utils.SendFeedback(feedback, guild.Id, author.Mention, true);
if (duration.TotalSeconds > 0) {
async void DelayUnban() {
var _ = async () => {
await Task.Delay(duration);
await UnbanCommand.UnbanUser(guild, guild.CurrentUser, toBan, Messages.PunishmentExpired);
}
new Task(DelayUnban).Start();
};
}
}
}
}

View file

@ -91,12 +91,11 @@ public class MuteCommand : Command {
CommandHandler.ConfigWriteScheduled = true;
if (hasDuration) {
async void DelayUnmute() {
await Task.Delay(duration);
var copy = duration;
var _ = async () => {
await Task.Delay(copy);
await UnmuteCommand.UnmuteMember(guild, guild.CurrentUser, toMute, Messages.PunishmentExpired);
}
new Task(DelayUnmute).Start();
};
}
}