Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

Commit

Permalink
Version 1.3.0
Browse files Browse the repository at this point in the history
Version 1.3.0
  • Loading branch information
Psykka authored Nov 13, 2020
2 parents 3f0c80f + 2b8b62e commit 8358962
Show file tree
Hide file tree
Showing 15 changed files with 1,397 additions and 585 deletions.
42 changes: 29 additions & 13 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
Copyright (c) 2020 Gorillas-Team

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
BSD 3-Clause License

Copyright (c) 2020, Gorillas-Team
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,29 @@ const nodes = [
// Instantiating discord.js client
const client = new Client()

client.on('ready', async () => {
// Creating GorilinkManager
client.music = new GorilinkManager(client, nodes)
// Listens events
.on('nodeConnect', node => {
console.log(`${node.tag || node.host} - Lavalink connected with success.`)
})
.on('trackStart', (player, track) => {
player.textChannel.send(`Now playing \`${track.info.title}\``)
})
client.music = new GorilinkManager(client, nodes, {
sendWS: (data) => {
const guild = client.guilds.cache.get(data.d.guild_id)
if (!guild) return

return guild.shard.send(data)
}
})
// Listens events
.on('nodeConnect', node => {
console.log(`${node.tag || node.host} - Lavalink connected with success.`)
})
.on('trackStart', (player, track) => {
player.textChannel.send(`Now playing \`${track.title}\``)
})

client.on('ready', async () => {
// Starting GorilinkManager
client.music.start(client.user.id)
console.log('Online on the client', client.user.username)
})

client.on('raw', packet => client.music.packetUpdate(packet))

client.on('message', async (message) => {
const prefix = '!'
Expand All @@ -97,15 +106,15 @@ client.on('message', async (message) => {
// Adding in queue
player.queue.add(tracks[0])

message.channel.send('Added in queue: ' + tracks[0].info.title)
message.channel.send('Added in queue: ' + tracks[0].title)

// Playing
if (!player.playing) return player.play()
}
})

// Logging the bot
client.login('your-token')
client.login('YOUR_TOKEN_HERE')
```

## Help
Expand Down
10 changes: 0 additions & 10 deletions esm/gorilink.mjs

This file was deleted.

33 changes: 21 additions & 12 deletions examples/index.js → examples/discordjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,29 @@ const nodes = [
// Instantiating discord.js client
const client = new Client()

client.on('ready', async () => {
// Creating GorilinkManager
client.music = new GorilinkManager(client, nodes)
// Listens events
.on('nodeConnect', node => {
console.log(`${node.tag || node.host} - Lavalink connected with success.`)
})
.on('trackStart', (player, track) => {
player.textChannel.send(`Now playing \`${track.info.title}\``)
})
client.music = new GorilinkManager(client, nodes, {
sendWS: (data) => {
const guild = client.guilds.cache.get(data.d.guild_id)
if (!guild) return

return guild.shard.send(data)
}
})
// Listens events
.on('nodeConnect', node => {
console.log(`${node.tag || node.host} - Lavalink connected with success.`)
})
.on('trackStart', (player, track) => {
player.textChannel.send(`Now playing \`${track.title}\``)
})

client.on('ready', async () => {
// Starting GorilinkManager
client.music.start(client.user.id)
console.log('Online on the client', client.user.username)
})

client.on('raw', packet => client.music.packetUpdate(packet))

client.on('message', async (message) => {
const prefix = '!'
Expand All @@ -56,12 +65,12 @@ client.on('message', async (message) => {
// Adding in queue
player.queue.add(tracks[0])

message.channel.send('Added in queue: ' + tracks[0].info.title)
message.channel.send('Added in queue: ' + tracks[0].title)

// Playing
if (!player.playing) return player.play()
}
})

// Logging the bot
client.login('your-token')
client.login('YOUR_TOKEN_HERE')
76 changes: 76 additions & 0 deletions examples/discordjsv11.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Importing Discord.js Client
const { Client } = require('discord.js')
// Importing GorilinkManager
const { GorilinkManager } = require('gorilink')

// Your lavalink node config
const nodes = [
{
tag: 'Node 1', // optional
host: 'localhost',
port: 2333,
password: 'youshallnotpass'
}
]

// Instantiating discord.js client
const client = new Client()

client.music = new GorilinkManager(client, nodes, {
sendWS: (data) => {
const guild = client.guilds.get(data.d.guild_id)
if (!guild) return

return guild.shard.send(data)
}
})
// Listens events
.on('nodeConnect', node => {
console.log(`${node.tag || node.host} - Lavalink connected with success.`)
})
.on('trackStart', (player, track) => {
player.textChannel.send(`Now playing \`${track.title}\``)
})

client.on('ready', async () => {
// Starting GorilinkManager
client.music.start(client.user.id)
console.log('Online on the client', client.user.username)
})

client.on('raw', packet => client.music.packetUpdate(packet))

client.on('message', async (message) => {
const prefix = '!'
const args = message.content.slice(prefix.length).trim().split(/ +/g)
const cmd = args.shift().toLowerCase()

if (cmd === 'play') {
// Tries to get the voice channel
const memberChannel = message.member.voiceChannel.id

// Checks if the member is on a voice channel
if(!memberChannel) return message.channel.send('You are not on a voice channel')

// Spawning lavalink player
const player = await client.music.join({
guild: message.guild.id,
voiceChannel: memberChannel,
textChannel: message.channel
})

// Getting tracks
const { tracks } = await client.music.fetchTracks(args.join(' '))

// Adding in queue
player.queue.add(tracks[0])

message.channel.send('Added in queue: ' + tracks[0].title)

// Playing
if (!player.playing) return player.play()
}
})

// Logging the bot
client.login('YOUR_TOKEN_HERE')
77 changes: 77 additions & 0 deletions examples/eris.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Importing eris Client
const { Client } = require('eris')
// Importing GorilinkManager
const { GorilinkManager } = require('../src')

// Your lavalink node config
const nodes = [
{
tag: 'Node 1', // optional
host: 'localhost',
port: 2333,
password: 'youshallnotpass'
}
]

// Instantiating eris client
const client = new Client('YOUR_TOKEN_HERE')

// Creating GorilinkManager
client.music = new GorilinkManager(client, nodes, {
sendWS: (data) => {
const guild = client.guilds.get(data.d.guild_id)
if (!guild) return

return guild.shard.sendWS(data.op, data.d)
}
})
// Listens events
.on('nodeConnect', node => {
console.log(`${node.tag || node.host} - Lavalink connected with success.`)
})
.on('trackStart', (player, track) => {
player.textChannel.createMessage(`Now playing \`${track.title}\``)
})

client.on('ready', async () => {
// Starting GorilinkManager
client.music.start(client.user.id)
console.log('Online on the client', client.user.username)
})

client.on('rawWS', packet => client.music.packetUpdate(packet))

client.on('messageCreate', async (message) => {
const prefix = '!'
const args = message.content.slice(prefix.length).trim().split(/ +/g)
const cmd = args.shift().toLowerCase()

if (cmd === 'play') {
// Tries to get the voice channel
const memberChannel = message.member.voiceState.channelID

// Checks if the member is on a voice channel
if(!memberChannel) return message.channel.createMessage('You are not on a voice channel')

// Spawning lavalink player
const player = await client.music.join({
guild: message.guildID,
voiceChannel: memberChannel,
textChannel: message.channel
})

// Getting tracks
const { tracks } = await client.music.fetchTracks(args.join(' '))

// Adding in queue
player.queue.add(tracks[0])

message.channel.createMessage('Added in queue: ' + tracks[0].title)

// Playing
if (!player.playing) return player.play()
}
})

// Logging the bot
client.connect()
23 changes: 7 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
{
"name": "gorilink",
"version": "1.2.1",
"version": "1.3.0",
"main": "./src/index.js",
"types": "./typings/index.d.ts",
"exports": {
".": [
{
"require": "./src/index.js",
"import": "./esm/gorilink.mjs"
},
"./src/index.js"
],
"./esm": "./esm/gorilink.mjs"
},
"license": "ISC",
"license": "BSD",
"scripts": {
"test:ts": "tsc",
"lint": "eslint src/ examples/",
Expand All @@ -37,18 +27,19 @@
"@types/node": "^14.0.14",
"@types/ws": "^7.2.6",
"discord.js": "^12.2.0",
"eslint": "^6.8.0",
"eris": "^0.14.0",
"eslint": "^7.13.0",
"jsdoc": "^3.6.4",
"jsdoc-template": "https://github.com/braintree/jsdoc-template",
"jsdoc-template": "^1.2.0",
"nodemon": "^2.0.3",
"typescript": "^3.9.5"
"typescript": "^4.0.5"
},
"dependencies": {
"@discordjs/collection": "^0.1.5",
"node-fetch": "^2.6.0",
"ws": "^7.2.5"
},
"description": "Easy lavalink wrapper for Discord.js. (soon eris)",
"description": "Easy lavalink wrapper for Discord Bots",
"directories": {
"example": "examples"
},
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
GorilinkManager: require('./lib/GorilinkManager'),
GorilinkPlayer: require('./lib/GorilinkPlayer'),
LavalinkNode: require('./lib/LavalinkNode'),
GorilinkNode: require('./lib/GorilinkNode'),

Queue: require('./lib/structures/Queue')
}
Loading

0 comments on commit 8358962

Please sign in to comment.