示例#1
0
        public async Task DbRemovePlayer(CommandContext c, DiscordUser user)
        {
            c.LogDebug($"{c.User.GetFullUsername()} -> {nameof(DbRemovePlayer)}");
            await c.Channel.DeleteMessageAsync(c.Message);

            using (var db = ContentManager.GetDb())
            {
                var players = db.GetPlayerTable();

                if (players.Exists(p => p.DiscordId == user.Id) == false)
                {
                    await c.RespondWithDmAsync("User not found");

                    return;
                }

                players.Delete(p => p.DiscordId == user.Id);

                c.LogWarning($"Player {user.GetFullUsername()}({user.Id}) has been deleted by {c.User.GetFullUsername()}");

                await c.RespondWithDmAsync($"User {user.GetFullUsername()} ({user.Id}) has been deleted");
            }
        }