Skip to content

Commit

Permalink
Merge pull request #56 from Guilded-Bot-NPM/v1.1.0
Browse files Browse the repository at this point in the history
V1.1.0
  • Loading branch information
MDCYT authored Oct 8, 2022
2 parents f98f157 + 55275b9 commit ccf6f40
Show file tree
Hide file tree
Showing 13 changed files with 1,050 additions and 5,601 deletions.
5,823 changes: 454 additions & 5,369 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name":"guilded-bot",
"version":"1.0.8",
"version":"1.1.0",
"description":"A library for interacting with the Guilded API for your Guilded Bot",
"main":"src/index.js",
"scripts":{
Expand Down Expand Up @@ -35,15 +35,15 @@
"type":"git",
"url":"https://github.com/Guilded-Bot-NPM/Guilded-Bot.git"
},
"engines":{
"node":"^16.0.0"
},
"license":"MIT",
"dependencies":{
"axios":"^0.27.2",
"docdash":"^1.2.0",
"ws":"^8.9.0"
},
"devDependencies":{
"better-docs":"^2.7.2",
"clean-jsdoc-theme":"^4.1.8",
"dotenv":"^16.0.3",
"minami":"^1.2.3",
"nodemon":"^2.0.20"
Expand Down
56 changes: 46 additions & 10 deletions src/classes/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ class Client extends EventEmitter {
* Creates a new bot instance.
* See {@tutorial example-bot} for an example
* @param {String} token Your guilded bot's Auth Token
* @param {Object} [options] Options for the client
* @param {String} [options.maxReconnectTries=Infinity] The maximum number of times to retry a request or reconnect
* @returns {Client}
* @example
* const { Client } = require('guilded.js');
* const client = new Client('token');
*/
constructor (token = String) {
constructor (token = String, options = Object) {
super()

/**
Expand All @@ -33,6 +35,13 @@ class Client extends EventEmitter {
* @readonly
*/
this.ws = null

/**
* The options of the bot
* @type {Object}
* @readonly
*/
this.options = options
}

/**
Expand Down Expand Up @@ -78,7 +87,7 @@ class Client extends EventEmitter {
* console.log('Bot is ready!');
* });
*/
this.ws.on('open', (client) => {
this.ws.on('clientReady', (client) => {
this.emit('ready', client)
})

Expand Down Expand Up @@ -137,10 +146,10 @@ class Client extends EventEmitter {
/**
* Emitted when the bot receives a member leave
* @event Client#memberLeave
* @param {Member} member
* @param {MemberRemoved} member
* @example
* client.on('serverMemberLeft', (member) => {
* console.log(member.nickname);
* console.log(member.username);
* });
*/
this.ws.on('memberRemoved', (member) => {
Expand Down Expand Up @@ -174,18 +183,31 @@ class Client extends EventEmitter {
})

/**
* Emitted when the bot receives a member role update
* @event Client#memberRoleUpdate
* @param {Member} member
* Emitted when the bot receives a member update
* @event Client#memberUpdate
* @param {MemberUpdated} member
* @example
* client.on('serverMemberUpdate', (member) => {
* console.log(member.nickname);
* console.log(member.username);
* });
*/
this.ws.on('memberRolesUpdated', (member) => {
this.ws.on('memberUpdated', (member) => {
this.emit('serverMemberUpdate', member)
})

/**
* Emitted when the bot receives a member role update
* @event Client#memberRoleUpdate
* @param {RolesUpdated} rolesUpdated
* @example
* client.on('serverMemberUpdate', (rolesUpdated) => {
* console.log(rolesUpdated[0]);
* });
*/
this.ws.on('memberRolesUpdated', (rolesUpdated) => {
this.emit('serverMemberUpdate', rolesUpdated)
})

/**
* Emitted when the bot receives a webhook create
* @event Client#webhookCreate
Expand Down Expand Up @@ -259,10 +281,24 @@ class Client extends EventEmitter {
* console.log(error);
* });
*/
this.ws.on('error', (error) => {
this.ws.on('clientError', (error) => {
this.emit('error', error)
})

/**
* Emitted when the bot receives a debug event
* @event Client#debug
* @param {String} message
* @example
* client.on('debug', (message) => {
* console.log(message);
* });
*/
this.ws.on('clientDebug', (message) => {
this.emit('debug', message)
})


/**
* Delete the client
* @event Client#destroy
Expand Down
Loading

0 comments on commit ccf6f40

Please sign in to comment.