示例#1
0
        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());
        }
示例#2
0
        // 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);
            }
        }