package yliasdiscordbothx.model; import yliasdiscordbothx.utils.YliasDiscordUtils; import discordhx.channel.Channel; import yliasdiscordbothx.model.entity.Permission; import discordbothx.core.CommunicationContext; import discordbothx.core.IPermissionSystem; import js.Promise; class PermissionSystem implements IPermissionSystem { public function new() {} public function check(context: CommunicationContext, command: String): Promise { return new Promise(function (resolve: Bool->Void, reject: Dynamic->Void): Void { var channel: Channel = cast context.message.channel; var serverId: String = YliasDiscordUtils.getServerIdFromMessage(context.message); Permission.check(context.message.author.id, channel.id, serverId, command, function (error: Dynamic, granted: Bool): Void { if (error == null) { resolve(granted); } else { reject(error); } }); }); } public function getDeniedCommandList(context: CommunicationContext): Promise> { return new Promise>(function (resolve: Array->Void, reject: Dynamic->Void): Void { var channel: Channel = cast context.message.channel; var serverId: String = YliasDiscordUtils.getServerIdFromMessage(context.message); Permission.getDeniedCommandList(context.message.author.id, channel.id, serverId, function (error: Dynamic, deniedCommandList: Array): Void { if (error == null) { resolve(deniedCommandList); } else { reject(error); } }); }); } }