<commit_before>var Dota2 = require("../index"),
    util = require("util");


// Methods

Dota2.Dota2Client.prototype.requestGuildData = function() {
  /* Asks the GC for info on the users current guilds.  Expect k_EMsgGCGuildOpenPartyRefresh from GC for guild ids. */
  if (!this._gcReady) {
    if (this.debug) util.log("GC not ready, please listen for the 'ready' event.");
    return null;
  }

  if (this.debug) util.log("Requesting current user guild data. ");
  var payload = Dota2.schema.CMsgDOTARequestGuildData({
    // Doesn't take anything.
  });
  this.protoBufHeader.msg = Dota2.EDOTAGCMsg.k_EMsgGCRequestGuildData;
  this._gc.send(this.protoBufHeader,
                payload.toBuffer()
  );
};

Dota2.Dota2Client.prototype.inviteToGuild = function(guildId, targetAccountId, callback) {
  callback = callback || null;

  /* Attempts to invite targetAccountId to a guild.  Expect k_EMsgGCGuildInviteAccountResponse from GC. */
  if (!this._gcReady) {
    if (this.debug) util.log("GC not ready, please listen for the 'ready' event.");
    return null;
  }

  if (this.debug) util.log("Inviting person to guild. " + [guildId, targetAccountId].join(", "));
  var payload = Dota2.schema.CMsgDOTAGuildInviteAccountRequest({
    "guildId": guildId,
    "targetAccountId": targetAccountId
  });
  this.protoBufHeader.msg = Dota2.EDOTAGCMsg.k_EMsgGCGuildInviteAccountRequest;
  this._gc.send(this.protoBufHeader,
                payload.toBuffer(),
                callback
  );
};

Dota2.Dota2Client.prototype.cancelInviteToGuild = function(guildId, targetAccountId, callback) {
  callback = callback || null;

  /* Attempts to cancel targetAccountId's invitation to a guild.  Expect k_EMsgGCGuildCancelInviteAccountResponse from GC. */
  if (!this._gcReady) {
    if (this.debug) util.log("GC not ready, please listen for the 'ready' event.");
    return null;
  }

  if (this.debug) util.log("Cancelling invite to guild. " + [guildId, targetAccountId].join(", "));
  var payload = Dota2.schema.CMsgDOTAGuildCancelInviteRequest({
    "guildId": guildId,
    "targetAccountId": targetAccountId
  });
  this.protoBufHeader.msg = Dota2.EDOTAGCMsg.k_EMsgGCGuildCancelInviteRequest;
  this._gc.send(this.protoBufHeader,
                payload.toBuffer(),
                callback
  );
};

Dota2.Dota2Client.prototype.setGuildAccountRole = function(guildId, targetAccountId, targetRole, callback) {
  callback = callback || null;

  /* Attempts to change an account's role in a guild. This can be accepting an invitation or promoting/demoting other guild members. Expect k_EMsgGCGuildSetAccountRoleResponse from GC.
     Roles:
     - 0: Kick member from guild.
     - 1: Leader
     - 2: Officer
     - 3: Member
  */
  if (!this._gcReady) {
    if (this.debug) util.log("GC not ready, please listen for the 'ready' event.");
    return null;
  }

  if (this.debug) util.log("Setting guild account role. " + [guildId, targetAccountId, targetRole].join(", "));
  var payload = Dota2.schema.CMsgDOTAGuildSetAccountRoleRequest({
    "guildId": guildId,
    "targetAccountId": targetAccountId,
    "targetRole": targetRole
  });
  this.protoBufHeader.msg = Dota2.EDOTAGCMsg.k_EMsgGCGuildSetAccountRoleRequest;
  this._gc.send(this.protoBufHeader,
                payload.toBuffer(),
                callback
  );
};


// Handlers

var handlers = Dota2.Dota2Client.prototype._handlers;

handlers[Dota2.EDOTAGCMsg.k_EMsgGCGuildOpenPartyRefresh] = function onGuildOpenPartyRefresh(message) {
  /* Response from requestGuildData containing data on open parties, but most notably - it can tell the library what guilds the user is in. */
  var response = Dota2.schema.CMsgDOTAGuildOpenPartyRefresh.decode(message);
  if (this.debug) util.log("Got guild open party data");
  this.emit("guildOpenPartyData", response.guildId, response.openParties, response);
};<commit_msg>Payload was missing new initialization. Guild functions seem to work now<commit_after>var Dota2 = require("../index"),
    util = require("util");


// Methods

Dota2.Dota2Client.prototype.requestGuildData = function() {
  /* Asks the GC for info on the users current guilds.  Expect k_EMsgGCGuildOpenPartyRefresh from GC for guild ids. */
  if (!this._gcReady) {
    if (this.debug) util.log("GC not ready, please listen for the 'ready' event.");
    return null;
  }

  if (this.debug) util.log("Requesting current user guild data. ");
  var payload = new Dota2.schema.CMsgDOTARequestGuildData();
  this.protoBufHeader.msg = Dota2.EDOTAGCMsg.k_EMsgGCRequestGuildData;
  this._gc.send(this.protoBufHeader,
                payload.toBuffer()
  );
};

Dota2.Dota2Client.prototype.inviteToGuild = function(guildId, targetAccountId, callback) {
  callback = callback || null;

  /* Attempts to invite targetAccountId to a guild.  Expect k_EMsgGCGuildInviteAccountResponse from GC. */
  if (!this._gcReady) {
    if (this.debug) util.log("GC not ready, please listen for the 'ready' event.");
    return null;
  }

  if (this.debug) util.log("Inviting person to guild. " + [guildId, targetAccountId].join(", "));
  var payload = new Dota2.schema.CMsgDOTAGuildInviteAccountRequest({
    "guildId": guildId,
    "targetAccountId": targetAccountId
  });
  this.protoBufHeader.msg = Dota2.EDOTAGCMsg.k_EMsgGCGuildInviteAccountRequest;
  this._gc.send(this.protoBufHeader,
                payload.toBuffer(),
                callback
  );
};

Dota2.Dota2Client.prototype.cancelInviteToGuild = function(guildId, targetAccountId, callback) {
  callback = callback || null;

  /* Attempts to cancel targetAccountId's invitation to a guild.  Expect k_EMsgGCGuildCancelInviteAccountResponse from GC. */
  if (!this._gcReady) {
    if (this.debug) util.log("GC not ready, please listen for the 'ready' event.");
    return null;
  }

  if (this.debug) util.log("Cancelling invite to guild. " + [guildId, targetAccountId].join(", "));
  var payload = new Dota2.schema.CMsgDOTAGuildCancelInviteRequest({
    "guildId": guildId,
    "targetAccountId": targetAccountId
  });
  this.protoBufHeader.msg = Dota2.EDOTAGCMsg.k_EMsgGCGuildCancelInviteRequest;
  this._gc.send(this.protoBufHeader,
                payload.toBuffer(),
                callback
  );
};

Dota2.Dota2Client.prototype.setGuildAccountRole = function(guildId, targetAccountId, targetRole, callback) {
  callback = callback || null;

  /* Attempts to change an account's role in a guild. This can be accepting an invitation or promoting/demoting other guild members. Expect k_EMsgGCGuildSetAccountRoleResponse from GC.
     Roles:
     - 0: Kick member from guild.
     - 1: Leader
     - 2: Officer
     - 3: Member
  */
  if (!this._gcReady) {
    if (this.debug) util.log("GC not ready, please listen for the 'ready' event.");
    return null;
  }

  if (this.debug) util.log("Setting guild account role. " + [guildId, targetAccountId, targetRole].join(", "));
  var payload = new Dota2.schema.CMsgDOTAGuildSetAccountRoleRequest({
    "guildId": guildId,
    "targetAccountId": targetAccountId,
    "targetRole": targetRole
  });
  this.protoBufHeader.msg = Dota2.EDOTAGCMsg.k_EMsgGCGuildSetAccountRoleRequest;
  this._gc.send(this.protoBufHeader,
                payload.toBuffer(),
                callback
  );
};


// Handlers

var handlers = Dota2.Dota2Client.prototype._handlers;

handlers[Dota2.EDOTAGCMsg.k_EMsgGCGuildOpenPartyRefresh] = function onGuildOpenPartyRefresh(message) {
  /* Response from requestGuildData containing data on open parties, but most notably - it can tell the library what guilds the user is in. */
  var response = Dota2.schema.CMsgDOTAGuildOpenPartyRefresh.decode(message);
  if (this.debug) util.log("Got guild open party data");
  this.emit("guildOpenPartyData", response.guildId, response.openParties, response);
};
{'fraction_non_alphanumeric': 0.1133556356150283, 'fraction_numerical': 0.006433350488934638, 'mean_word_length': 3.7863300492610836, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3779777', 'n_tokens_mistral': 2562, 'n_tokens_neox': 2478, 'n_words': 589}