This repository has been archived by the owner on Dec 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 1.3.0
- Loading branch information
Showing
15 changed files
with
1,397 additions
and
585 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
} |
Oops, something went wrong.