Resolve role IDs

This commit is contained in:
abalabahaha
2016-01-29 17:14:40 -08:00
parent ee2172c1d5
commit 8726b23730
4 changed files with 139 additions and 55 deletions

View File

@@ -9,6 +9,7 @@ import TextChannel from "../../Structures/TextChannel";
import VoiceChannel from "../../Structures/VoiceChannel";
import ServerChannel from "../../Structures/ServerChannel";
import PMChannel from "../../Structures/PMChannel";
import Role from "../../Structures/Role";
import Server from "../../Structures/Server";
import Message from "../../Structures/Message";
import Invite from "../../Structures/Invite";
@@ -58,6 +59,21 @@ export default class Resolver {
return null;
}
resolveRole(resource) {
if (resource instanceof Role) {
return resource;
}
if (resource instanceof String || typeof resource === "string") {
var role = null;
for (var server of this.internal.servers) {
if (role = server.roles.find(r => r.id == resource)) {
return role;
}
}
}
return null;
}
resolveFile(resource) {
if (typeof resource === "string" || resource instanceof String) {
return fs.createReadStream(resource);