Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get current server. #453

Closed
MTRNord opened this issue Mar 10, 2016 · 2 comments
Closed

How to get current server. #453

MTRNord opened this issue Mar 10, 2016 · 2 comments

Comments

@MTRNord
Copy link

MTRNord commented Mar 10, 2016

Since I am using the code snippet from @jirwin that he gave me in #434 I need to know from which server a meassage is send. Is there a way to get this value?

@jirwin
Copy link
Collaborator

jirwin commented Mar 10, 2016

@MTRNord you could include the client in your listeners, so in your function you always have the appropriate client available.

var client1 = Client(...);
var client2 = Client(...);
var clients = [client1, client2];

function eventHandler(callback) {
  console.log("Now when this function is called, 'this' is equal to the client that received the message");
};

function addListener(event, callback) {
  clients.forEach(function(client) {
    client.addListener(event, eventHandler.bind(client));
  });
}

@MTRNord
Copy link
Author

MTRNord commented Mar 10, 2016

that is not working :/ now the bot is not working anymore :/ i will better leave it as before. (the function is triggered but bot is not responding anymore.

@MTRNord MTRNord closed this as completed Mar 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants