Skip to content

Commit

Permalink
2 new commands, and some fixes for existing ones
Browse files Browse the repository at this point in the history
fixes #15, fixes #16
  • Loading branch information
Snailedlt committed Aug 15, 2021
1 parent 9255e89 commit a1923de
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { prefix } = require('../../src/utils.js');
exports.config = {
name: `create`,
aliases: [`c`, `make`],
description: `Creates the handler from the provided information. Example: "-create GameName"`,
description: `Creates the handler from the provided information.`,
usage: `${prefix}create [game name]`,
example: `${prefix}create Grand Theft Auto V`
}
Expand All @@ -14,7 +14,7 @@ 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")
console.log("create access granted")
receivedMessage.channel.send(`${prefix}create access granted`);
}
};
10 changes: 4 additions & 6 deletions src/commands/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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`],
Expand All @@ -11,17 +12,14 @@ exports.config = {
}

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) {
// console.log([...args]);
if (args.length === 0) {
receivedMessage.channel.send('Please, provide a game name.');
return;
}

let totalGame = '';
argume.forEach(value => {
args.forEach(value => {
totalGame = totalGame + ' ' + value;
});
totalGame = totalGame.substr(1);
Expand Down
5 changes: 2 additions & 3 deletions src/commands/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ exports.config = {
name: `help`,
aliases: [`commands`, `commandlist`],
description: `Shows a list of all available bot commands`,
usage: `${prefix}help [command_name]`,
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( prefix + commands.map(c => ` ${c.config.name} ${c.config.aliases.length ? `, ` + 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;
Expand Down
24 changes: 24 additions & 0 deletions src/commands/hubstats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Axios from "axios";
import Settings from "../../src/settings"
const { prefix } = require('../../src/utils.js');

const publicSSMApiPath = "https://hub.splitscreen.me/api/v1/";

exports.config = {
name: `hubstats`,
aliases: [],
description: `Return stats from the hub`,
usage: `${prefix}hubstats`,
example: `${prefix}hubstats`
}

exports.execute = async (DiscordBot, receivedMessage, args) => {

const totalDownloadCountEver = await Axios.get(publicSSMApiPath + 'totalDownloadCountEver');
console.log('settings: ', Settings.private.DEVELOPMENT_CHANNELS)
console.log('received: ', receivedMessage.guild.id);
if (Settings.private.DEVELOPMENT_CHANNELS.includes(receivedMessage.guild.id)) {
console.log("hubstats access granted")
receivedMessage.channel.send(`${totalDownloadCountEver.data}`);
}
};
21 changes: 21 additions & 0 deletions src/commands/invite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Axios from "axios";
import Settings from "../../src/settings"
const { prefix } = require('../../src/utils.js');

const publicSSMApiPath = "https://hub.splitscreen.me/api/v1/";

exports.config = {
name: `invite`,
aliases: ["inv", "invite-link", "inv-link"],
description: `Return invite link to the Nucleus Coop Discord`,
usage: `${prefix}invite`,
example: `${prefix}invite`
}

exports.execute = async (DiscordBot, receivedMessage, args) => {
console.log('settings: ', Settings.private.DEVELOPMENT_CHANNELS)
console.log('received: ', receivedMessage.guild.id);
console.log("hubstats access granted")
console.log("guild.name: " + receivedMessage.guild.name)
receivedMessage.reply("\nhttps://discord.gg/a9ssM5pxTW")
};

0 comments on commit a1923de

Please sign in to comment.