Ejemplo n.º 1
0
        public DiscordUser(TokenResponse resp)
        {
            this.CurrentToken = resp.access_token;
            this.Refresh      = resp.refresh_token;
            this.authType     = resp.token_type;

            SessionToken = GenerateToken();

            getId();

            if (HasPermissions())
            {
                Permission = SessionPermission.Staff;
            }
            else
            {
                var discordUser = Global.GetSwissbotUser(this.ID).Result;
                if (discordUser == null)
                {
                    return;
                }
                if (discordUser.Roles.Any(x => x.Id == 779943693951565824))
                {
                    Permission = SessionPermission.EventManager;
                }
            }
        }
Ejemplo n.º 2
0
    public override void WriteJson(
        JsonWriter writer,
        object value,
        JsonSerializer serializer)
    {
        SessionPermission permission = (SessionPermission)value;

        JObject obj = new JObject();

        obj[permission.Permission] = permission.IsAllowed;

        obj.WriteTo(writer);
    }