-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed handler command
- Loading branch information
Showing
6 changed files
with
168 additions
and
91 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,4 +1,4 @@ | ||
node_modules/ | ||
.idea/ | ||
.vscode/ | ||
settings-development.json | ||
settings-development.json |
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,17 +1,20 @@ | ||
import Axios from "axios"; | ||
import Settings from "../../src/settings" | ||
const { prefix } = require('../../src/utils.js'); | ||
|
||
module.exports = { | ||
name: 'create', | ||
aliases: ['c'], | ||
description: 'Creates the handler from the provided information. Example: "-create GameName"', | ||
async execute(receivedMessage, DiscordBot) { | ||
console.log('settings: ',Settings.private.DEVELOPMENT_CHANNELS) | ||
console.log('received: ',receivedMessage.guild.id); | ||
if(Settings.private.DEVELOPMENT_CHANNELS.includes(receivedMessage.guild.id)){ | ||
console.log("access granted") | ||
receivedMessage.channel.send('-create access granted'); | ||
} | ||
// | ||
} | ||
exports.config = { | ||
name: `create`, | ||
aliases: [`c`, `make`], | ||
description: `Creates the handler from the provided information. Example: "-create GameName"`, | ||
usage: `${prefix}create [game name]`, | ||
example: `${prefix}create Grand Theft Auto V` | ||
} | ||
|
||
exports.execute = async (DiscordBot, receivedMessage, args) => { | ||
console.log('settings: ', Settings.private.DEVELOPMENT_CHANNELS) | ||
console.log('received: ', receivedMessage.guild.id); | ||
if (Settings.private.DEVELOPMENT_CHANNELS.includes(receivedMessage.guild.id)) { | ||
console.log("access granted") | ||
receivedMessage.channel.send(`${prefix}create access granted`); | ||
} | ||
}; |
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,81 +1,84 @@ | ||
import Axios from "axios"; | ||
const { prefix } = require('../../src/utils.js'); | ||
|
||
const publicSSMApiPath = "https://hub.splitscreen.me/api/v1/"; | ||
exports.config = { | ||
name: `handler`, | ||
aliases: [`h`, `script`], | ||
description: `Return handler for the specified game.`, | ||
usage: `${prefix}handler [game name]`, | ||
example: `${prefix}handler Grand Theft Auto V` | ||
} | ||
|
||
module.exports = { | ||
name: 'handler', | ||
aliases: ['h', 'script'], | ||
description: 'Return handler for the specified game. Example: "-handler Game name"', | ||
async execute(receivedMessage, DiscordBot) { | ||
let fullCommand = receivedMessage.content.substr(1); // Remove the leading exclamation mark | ||
let splitCommand = fullCommand.split(' '); // Split the message up in to pieces for each space | ||
let argume = splitCommand.slice(1); | ||
// console.log(argume); | ||
if (argume.length === 0) { | ||
receivedMessage.channel.send('Please, provide a game name.'); | ||
return; | ||
} | ||
exports.execute = async (DiscordBot, receivedMessage, args) => { | ||
let fullCommand = receivedMessage.content.substr(1); // Remove the leading exclamation mark | ||
let splitCommand = fullCommand.split(' '); // Split the message up in to pieces for each space | ||
let argume = splitCommand.slice(1); | ||
// console.log(argume); | ||
if (argume.length === 0) { | ||
receivedMessage.channel.send('Please, provide a game name.'); | ||
return; | ||
} | ||
|
||
let totalGame = ''; | ||
argume.forEach(value => { | ||
totalGame = totalGame + ' ' + value; | ||
}); | ||
totalGame = totalGame.substr(1); | ||
const allHandlers = await Axios.get(publicSSMApiPath + 'handlers/' + totalGame.replace(/[^a-z0-9 -]/g, "")); | ||
if (!allHandlers.data.Handlers) { | ||
receivedMessage.channel.send('Sorry, no handler found matching your query!'); | ||
return; | ||
} | ||
const foundHandlers = allHandlers.data.Handlers.length > 3 ? allHandlers.data.Handlers.slice(0, 3) : allHandlers.data.Handlers; | ||
var downloadLink = " "; | ||
foundHandlers.forEach(handler => { | ||
downloadLink = `https://hub.splitscreen.me/cdn/storage/packages/${handler.currentPackage}/original/handler-${handler._id}-v${handler.currentVersion}.nc?download=true` | ||
receivedMessage.channel.send({ | ||
embed: { | ||
color: 3447003, | ||
author: { | ||
name: DiscordBot.user.username, | ||
icon_url: DiscordBot.user.avatarURL, | ||
let totalGame = ''; | ||
argume.forEach(value => { | ||
totalGame = totalGame + ' ' + value; | ||
}); | ||
totalGame = totalGame.substr(1); | ||
const allHandlers = await Axios.get(publicSSMApiPath + 'handlers/' + totalGame.replace(/[^a-z0-9 -]/g, "")); | ||
if (!allHandlers.data.Handlers) { | ||
receivedMessage.channel.send('Sorry, no handler found matching your query!'); | ||
return; | ||
} | ||
const foundHandlers = allHandlers.data.Handlers.length > 3 ? allHandlers.data.Handlers.slice(0, 3) : allHandlers.data.Handlers; | ||
var downloadLink = " "; | ||
foundHandlers.forEach(handler => { | ||
downloadLink = `https://hub.splitscreen.me/cdn/storage/packages/${handler.currentPackage}/original/handler-${handler._id}-v${handler.currentVersion}.nc?download=true` | ||
receivedMessage.channel.send({ | ||
embed: { | ||
color: 3447003, | ||
author: { | ||
name: DiscordBot.user.username, | ||
icon_url: DiscordBot.user.avatarURL, | ||
}, | ||
title: handler.gameName, | ||
url: `https://hub.splitscreen.me/handler/${handler._id}`, | ||
thumbnail: { | ||
url: `https://images.igdb.com/igdb/image/upload/t_cover_big/${handler.gameCover}.jpg`, | ||
}, | ||
fields: [ | ||
{ | ||
name: 'Author', | ||
inline: true, | ||
value: `[${handler.ownerName}](https://hub.splitscreen.me/user/${handler.owner})` | ||
}, | ||
{ | ||
name: 'Hotness', | ||
inline: true, | ||
value: handler.stars, | ||
}, | ||
title: handler.gameName, | ||
url: `https://hub.splitscreen.me/handler/${handler._id}`, | ||
thumbnail: { | ||
url: `https://images.igdb.com/igdb/image/upload/t_cover_big/${handler.gameCover}.jpg`, | ||
{ | ||
name: 'Total downloads', | ||
inline: true, | ||
value: handler.downloadCount, | ||
}, | ||
fields: [ | ||
{ | ||
name: 'Author', | ||
inline: true, | ||
value: `[${handler.ownerName}](https://hub.splitscreen.me/user/${handler.owner})` | ||
}, | ||
{ | ||
name: 'Hotness', | ||
inline: true, | ||
value: handler.stars, | ||
}, | ||
{ | ||
name: 'Total downloads', | ||
inline: true, | ||
value: handler.downloadCount, | ||
}, | ||
{ | ||
name: 'Status', | ||
inline: true, | ||
value: handler.verified ? 'Verified' : 'Unverified', | ||
}, | ||
{ | ||
name: `Download`, | ||
inline: false, | ||
value: `[Download Handler (v${handler.currentVersion})](${downloadLink})`, | ||
}, | ||
], | ||
timestamp: new Date(), | ||
footer: { | ||
icon_url: DiscordBot.user.avatarURL, | ||
text: '© SplitScreen.Me', | ||
{ | ||
name: 'Status', | ||
inline: true, | ||
value: handler.verified ? 'Verified' : 'Unverified', | ||
}, | ||
{ | ||
name: `Download`, | ||
inline: false, | ||
value: `[Download Handler (v${handler.currentVersion})](${downloadLink})`, | ||
}, | ||
], | ||
timestamp: new Date(), | ||
footer: { | ||
icon_url: DiscordBot.user.avatarURL, | ||
text: '© SplitScreen.Me', | ||
}, | ||
}); | ||
}, | ||
}); | ||
} | ||
}); | ||
}; |
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,69 @@ | ||
import Axios from "axios"; | ||
import Settings from "../settings"; | ||
const { prefix } = require('../../src/utils.js'); | ||
|
||
const publicSSMApiPath = "https://hub.splitscreen.me/api/v1/"; | ||
|
||
exports.config = { | ||
name: `help`, | ||
aliases: [`commands`, `commandlist`], | ||
description: `Shows a list of all available bot commands`, | ||
usage: `${prefix}help [command_name]`, | ||
example: `${prefix}help handler` | ||
} | ||
exports.execute = async (DiscordBot, receivedMessage, args) => { | ||
const data = []; | ||
const {commands} = receivedMessage.client; | ||
console.log("args" + args) | ||
if (!args.length) { | ||
console.log("we got this far"); | ||
data.push("Here is a list of all my commands"); | ||
data.push( prefix + commands.map(c => ` ${c.config.name} \`${c.config.aliases.join(` , `)}\``).join(`\n-`)); | ||
data.push(`\n use ${prefix}help [command name] to get info about a specific command`); | ||
receivedMessage.channel.send(data); | ||
return; | ||
} | ||
|
||
const name = args[0]; | ||
const cmd = commands.get(name) || commands.find(c => c.config.aliases && c.config.aliases.includes(name)); | ||
|
||
if (!cmd) { | ||
receivedMessage.reply(`${name} is not a valid command`) | ||
return; | ||
} | ||
|
||
|
||
if (cmd.config.name) data.push(`**Name**: ${cmd.config.name}`); | ||
if (cmd.config.description) data.push(`**Description:** ${cmd.config.description}`); | ||
if (cmd.config.aliases) data.push(`**Aliases:** ${cmd.config.aliases.join(` , `)}`); | ||
if (cmd.config.usage) data.push(`**Usage:** ${cmd.config.usage}`); | ||
if (cmd.config.example) data.push(`**Example:** ${cmd.config.example}`); | ||
|
||
receivedMessage.channel.send(data); | ||
|
||
/*receivedMessage.channel.send({ | ||
embed: { | ||
color: 3447003, | ||
author: { | ||
name: DiscordBot.user.username, | ||
icon_url: DiscordBot.user.avatarURL, | ||
}, | ||
title: "Commandlist", | ||
thumbnail: { | ||
url: `https://images.igdb.com/igdb/image/upload/t_cover_big/.jpg`, | ||
}, | ||
fields: [{ | ||
name: DiscordBot.commands.name, | ||
inline: true, | ||
value: `[](https://hub.splitscreen.me/user/)` | ||
}, | ||
], | ||
timestamp: new Date(), | ||
footer: { | ||
icon_url: DiscordBot.user.avatarURL, | ||
text: '© SplitScreen.Me', | ||
}, | ||
}, | ||
});*/ | ||
}; |
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 @@ | ||
exports.prefix = "-" |