예제 #1
0
    public async Task AddAdminAsync(string mentioned, int permLevel)
    {
        if (!PermissionManager.CheckAdmin(Context.Message.Author.Id).Result)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }
        if (PermissionManager.GetPerms(Context.Message.Author.Id) < PermissionConfig.Admin)
        {
            await Context.Channel.SendMessageAsync("Not authorised to run this command."); return;
        }

        string id = mentioned.Replace("<@!", "").Replace(">", "");
        ulong  idParsed;

        ulong.TryParse(id, out idParsed);
        SocketGuildUser u       = Context.Guild.GetUser(idParsed);
        bool            success = await PermissionManager.AddAdmin(idParsed, u.Username, permLevel);

        if (success)
        {
            await Context.Channel.SendMessageAsync($"Admin added with id `{id}`");
        }
        else
        {
            await Context.Channel.SendMessageAsync($"Admin either already exists or is invalid");
        }

        await Utilities.StatusMessage("addadmin", Context);
    }