mirror of
https://github.com/discordjs/discord.js.git
synced 2026-06-01 16:40:07 +00:00
39 lines
683 B
JavaScript
39 lines
683 B
JavaScript
'use strict';
|
|
|
|
const Action = require('./Action');
|
|
const Constants = require('../../util/Constants');
|
|
const Role = require('../../structures/Role');
|
|
|
|
class GuildRoleCreate extends Action {
|
|
|
|
constructor(client) {
|
|
super(client);
|
|
}
|
|
|
|
handle(data) {
|
|
|
|
let client = this.client;
|
|
let guild = client.store.get('guilds', data.guild_id);
|
|
|
|
if (guild) {
|
|
let already = guild.store.get('roles', data.role.id);
|
|
let role = new Role(guild, data.role);
|
|
guild.store.add('roles', role);
|
|
|
|
if (!already) {
|
|
client.emit(Constants.Events.GUILD_ROLE_CREATE, guild, role);
|
|
}
|
|
|
|
return {
|
|
role,
|
|
};
|
|
}
|
|
|
|
return {
|
|
role: null,
|
|
};
|
|
}
|
|
};
|
|
|
|
module.exports = GuildRoleCreate;
|