private async Task RestartBot(SocketInteraction interaction, ulong botId) { if (interaction.User.Id != Config.ReversesId) { await interaction.PrintError(); return; } else if (!Bots.List.Contains(botId)) { await interaction.PrintError("That can't be restarted"); return; } Bots.RestartBot(botId); var botAccount = _reversesGuild.GetUser(botId); await interaction.RespondAsync(embed : new EmbedBuilder() .WithAuthor(new EmbedAuthorBuilder() .WithName($"Restarted {botAccount.Username}") .WithIconUrl(botAccount.GetAvatarUrl())) .WithColor(Embeds.Green) .Build()); }
// Restart one of my bots if they went offline private async Task OnGuildMemberUpdated(Cacheable <SocketGuildUser, ulong> before, SocketGuildUser after) { // If the SocketGuildUser isn't my bot, then we don't care if (!Bots.List.Contains(before.Id)) { return; } // If one of my bots went offline, restart it if (before.Value.Status == UserStatus.Online && after.Status == UserStatus.Offline) { Bots.RestartBot(before.Id); } }