kbotify
Version:
kaiheila bot framework
45 lines • 1.68 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GuildUser = void 0;
const guild_1 = require("../guild");
const user_base_1 = require("./user.base");
class GuildUser extends user_base_1.BaseUser {
constructor(userObject, guildId, bot) {
super(userObject, bot);
this.full = async () => {
if (!this.guild.id) {
throw new Error('no guild id provided for guild user');
}
const guildCache = this.client.cache.guild(this.guild.id);
return guildCache.getUser(this.id, this.username);
};
this.grantRole = async (roleId, guildId) => {
if (!guildId) {
guildId = this.guild.id;
}
return this.client.API.guildRole.grant(guildId, this.id, roleId);
};
this.revokeRole = async (roleId, guildId) => {
if (!guildId) {
guildId = this.guild.id;
}
return this.client.API.guildRole.revoke(guildId, this.id, roleId);
};
this.changeNickname = async (nickname, guildId) => {
if (!guildId) {
guildId = this.guild.id;
}
return this.client.API.guild.nickname(guildId, nickname, this.id);
};
this.guild = new guild_1.Guild(guildId, bot);
this.nickname = userObject.nickname;
if ('roles' in userObject && userObject.roles) {
this.roles = userObject.roles;
this.client.cache
.guild(this.guild.id)
.setUser(this);
}
}
}
exports.GuildUser = GuildUser;
//# sourceMappingURL=user.guild.js.map