fixed mentions even though they will be changed in the future... why

This commit is contained in:
Amish Shah
2015-12-19 21:22:06 +00:00
parent 941fd2fe98
commit 90045db92d
7 changed files with 26 additions and 8 deletions

View File

@@ -495,7 +495,10 @@ var InternalClient = (function () {
return this.resolver.resolveChannel(where).then(function (destination) {
//var destination;
var content = _this10.resolver.resolveString(_content);
var mentions = _this10.resolver.resolveMentions(content);
var resolved = _this10.resolver.resolveMentions(content);
var mentions = resolved[0],
content = resolved[1];
return _this10.apiRequest("post", _Constants.Endpoints.CHANNEL_MESSAGES(destination.id), true, {
content: content,

View File

@@ -125,6 +125,7 @@ var Resolver = (function () {
Resolver.prototype.resolveMentions = function resolveMentions(resource) {
// resource is a string
var _mentions = [];
var changed = resource;
for (var _iterator = resource.match(/<@[^>]*>/g) || [], _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
@@ -139,9 +140,12 @@ var Resolver = (function () {
var mention = _ref;
_mentions.push(mention.substring(2, mention.length - 1));
var userID = mention.substring(2, mention.length - 1);
_mentions.push(userID);
changed = changed.replace(new RegExp(mention, "g"), "@" + this.internal.client.users.get("id", userID).username);
}
return _mentions;
console.log(changed);
return [_mentions, changed];
};
Resolver.prototype.resolveString = function resolveString(resource) {

View File

@@ -290,9 +290,10 @@ var VoiceConnection = (function (_EventEmitter) {
var _this3 = this;
var self = this;
console.log("\n\nendpoint:", this.endpoint, "\n\n");
_dns2["default"].lookup(this.endpoint, function (err, address, family) {
_this3.endpoint = address;
var vWS = self.vWS = new _ws2["default"]("wss://" + _this3.endpoint, null, { rejectUnauthorized: false });
_this3.endpoint = address;
var udpClient = self.udp = _dgram2["default"].createSocket("udp4");
var firstPacket = true;

View File

@@ -393,7 +393,9 @@ export default class InternalClient {
.then(destination => {
//var destination;
var content = this.resolver.resolveString(_content);
var mentions = this.resolver.resolveMentions(content);
var resolved = this.resolver.resolveMentions(content);
var mentions = resolved[0], content = resolved[1];
return this.apiRequest("post", Endpoints.CHANNEL_MESSAGES(destination.id), true, {
content: content,

View File

@@ -84,10 +84,13 @@ export default class Resolver {
resolveMentions(resource) {
// resource is a string
var _mentions = [];
var changed = resource;
for (var mention of (resource.match(/<@[^>]*>/g) || [])) {
_mentions.push(mention.substring(2, mention.length - 1));
let userID = mention.substring(2, mention.length - 1);
_mentions.push(userID);
changed = changed.replace(new RegExp(mention, "g"), `@${this.internal.client.users.get("id", userID).username}`);
}
return _mentions;
return [_mentions, changed];
}
resolveString(resource) {

View File

@@ -256,9 +256,10 @@ export default class VoiceConnection extends EventEmitter {
init() {
var self = this;
console.log("\n\nendpoint:", this.endpoint, "\n\n");
dns.lookup(this.endpoint, (err, address, family) => {
this.endpoint = address;
var vWS = self.vWS = new WebSocket("wss://" + this.endpoint, null, { rejectUnauthorized: false });
this.endpoint = address;
var udpClient = self.udp = udp.createSocket("udp4");
var firstPacket = true;

View File

@@ -26,6 +26,10 @@ client.on("message", msg => {
client.destroy();
}
if(msg.content === "replyme"){
msg.reply("hi");
}
if (msg.content === "$perms") {
msg.reply(client.channels.get("id", msg.channel.id));
}