Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.

Commit

Permalink
feat(help): new help command using embeds
Browse files Browse the repository at this point in the history
new help command using embeds as well as a slight overhaul of the array system for aliases
  • Loading branch information
animafps committed Jan 7, 2021
1 parent b6c14d4 commit b73afed
Show file tree
Hide file tree
Showing 12 changed files with 389 additions and 78 deletions.
57 changes: 29 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,46 @@ Note: When building or runing from source you have to input your own discord tok

## Usage

<required|alternitive option>
[optional]
\<required\|alternitive option\> \[optional\] **exact argument**

### Main Commands

| Command | Arguments | Description | Example |
| -------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ------------------------- |
| /cm | &lt;sens&gt; &lt;game&#124;yaw&gt; &lt;cpi&gt; | Converts Senstivity to cm/360 | `/cm 6 ow 1600` |
| /deg | &lt;sens&gt; &lt;game&#124;yaw&gt; &lt;cpi&gt; | Converts Senstivity to deg/mm | `/deg 1.9 0.022 800` |
| /convert | &lt;sens&gt; &lt;initial game&#124;yaw&gt; &lt;output game&#124;yaw&gt; | Converts Different Sensitivities from one game to another | `/convert 3 ow 0.022` |
| /fov | &lt;input fov&gt; &lt;input aspect ratio&#124;game&gt; &lt;output aspect ratio&#124;game&gt; | Converts fovs from one type to another or finds the equivilent for a differnet resolution aspect ratio | `/fov 90 16:9 quake` |
| /focal | &lt;sens&gt; &lt;old fov&gt; &lt;new fov&gt; | Focal Length Scales a desired sens between 2 fov values of the same type | `/focal 3 90 100` |
| /sens | &lt;cm/360&gt; &lt;game&#124;yaw&gt; &lt;cpi/dpi&gt; &#91;-cm&#124;-deg&#124;-inch&#93; | Converts cm/360&#124;deg/mm&#124;inch/360 to a game sensitivity | `/sens 28 quake 1600 -cm` |
| Command | Arguments | Description | Example |
| -------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------- |
| /cm | \<sens\> \<game\|yaw\> \<cpi\> | Converts Senstivity to cm/360 | `/cm 6 ow 1600` |
| /deg | \<sens\> \<game\|yaw\> \<cpi\> | Converts Senstivity to deg/mm | `/deg 1.9 0.022 800` |
| /convert | \<sens\> \<initial game\|yaw\> \<output game\|yaw\> | Converts Different Sensitivities from one game to another | `/convert 3 ow 0.022` |
| /fov | \<input fov\> \<input aspect ratio\|game\> \<output aspect ratio\|game\> | Converts fovs from one type to another or finds the equivilent for a differnet resolution aspect ratio | `/fov 90 16:9 quake` |
| /focal | \<sens\> \<old fov\> \<new fov\> | Focal Length Scales a desired sens between 2 fov values of the same type | `/focal 3 90 100` |
| /sens | \<cm/360\> \<game\|yaw\> \<cpi/dpi\> \[**-cm**\|**-deg**\|**-inch**\] | Converts cm/360\|deg/mm\|inch/360 to a game sensitivity | `/sens 28 quake 1600 -cm` |

### Utility Commands

| Command | Arguments | Description | Example |
| ---------- | -------------------------------------------- | --------------------------------------------------------------------------------------- | ------------------- |
| /prefix | &lt;prefix&#124;none&#124;default&gt; | Shows or sets the command prefix. | `/prefix !` |
| /help | none | Displays a list of available commands, or detailed information for a specified command. | `/help` |
| /games | none | Displays the supported games for this bot | `/games` |
| /getobject | &lt;game&gt; &lt;yaw&#124;name&#124;fovt&gt; | Displays the object from the array assoiated for a game | `/getobject ow yaw` |
| Command | Arguments | Description | Example |
| ---------- | ---------------------------------------- | --------------------------------------------------------------------------------------- | ------------------- |
| /prefix | \<prefix\|**none**\|**default**\> | Shows or sets the command prefix. | `/prefix !` |
| /help | none | Displays a list of available commands, or detailed information for a specified command. | `/help` |
| /games | none | Displays the supported games for this bot | `/games` |
| /getobject | \<game\> \<**yaw**\|**name**\|**fovt**\> | Displays the object from the array assoiated for a game | `/getobject ow yaw` |

## Supported Games

### Games

- Apex Legends (`apex`)
- Aimgods (`aimgods`)
- Call of Duty (`cod`)
- Counter Strike(`cs` or `csgo`)
- Fortnite Config (`fortnite` or `fortnite-config`)
- Overwatch (`overwatch` or `ow`)
- Quake (`quake`)
- Rainbow Six Siege (`r6`)
- Source Engine games (`source`)
- Valorant (`valorant` or `val`)
- Battlefield (`battlefield`)
- Destiny 2 (`destiny`)
- Aimgods: (`aimgods`)
- Apex Legends: (`apex-legends`, `apex`)
- Battlefield: (`battlefield`, `bf`)
- Call of Duty: (`cod`, `callofduty`, `call-of-duty`, `warzone`, `wz`)
- Counter Strike: (`cs`, `cs:go`, `csgo`)
- Destiny: (`destiny`, `d2`, `destiny2`)
- Diabotical: (`diabotical`, `dbt`)
- Fortnite: (`fornite`, `fn`)
- Fortnite config: (`fn-config`, `fornite-config`)
- Overwatch: (`overwatch`, `ow`)
- Quake: (`quake`)
- Rainbow Six: Siege: (`r6`, `rainbow6`, `r6s`)
- Source: (`source`)
- Valorant: (`valorant`, `val`)

## Built With

Expand Down
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ client
${guild ? `in guild ${guild.name} (${guild.id})` : 'globally'}.
`);
});

client.setProvider(new commando.SyncSQLiteProvider(db));

client.registry
.registerGroup('math', 'Math')
.registerDefaultGroups()
.registerDefaultTypes()
.registerDefaultCommands({ unknownCommand: false })
.registerDefaultCommands({
unknownCommand: false,
help: false,
})
.registerTypesIn(path.join(__dirname, '/src/types'))
.registerCommandsIn(path.join(__dirname, '/src/commands'));

Expand Down
103 changes: 73 additions & 30 deletions src/array.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,88 @@
const array = [
{ name: 'aimgods', yaw: 0.0023331 },
{ name: 'source', yaw: 0.022, fovt: 0.75 },
{ name: 'csgo', yaw: 0.022, fovt: 0.75 },
{ name: 'cs', yaw: 0.022, fovt: 0.75 },
{ name: 'quake', yaw: 0.022, fovt: 0.75 },
{ name: 'apex', yaw: 0.022, fovt: 0.75 },
{ name: 'val', yaw: 0.07, fovt: 0.5625 },
{ name: 'valorant', yaw: 0.07, fovt: 0.5625 },
{ name: 'ow', yaw: 0.0066, fovt: 0.5625 },
{ name: 'overwatch', yaw: 0.0066, fovt: 0.5625 },
{ name: 'fn', yaw: 0.005555, fovt: 1 },
{ name: 'fortnite', yaw: 0.005555, fovt: 1 },
{ name: 'fn-config', yaw: 2.222, fovt: 1 },
{ name: 'fortnite-config', yaw: 2.222, fovt: 1 },
{ name: 'dbt', yaw: 0.022000000000000002, fovt: 1 },
{ name: 'r6', yaw: 0.005729577951308232, fovt: 1 },
{ name: 'cod', yaw: 0.0066, fovt: 0.5625 },
{ name: 'battlefield', yaw: 2.291831180523293, fovt: 1 },
{ name: 'destiny', yaw: 0.0066, fovt: 0.5625 },
{ name: 'Aimgods', yaw: 0.0023331, aliases: ['aimgods'] },
{ name: 'Source', yaw: 0.022, fovt: 0.75, aliases: ['source'] },
{
name: 'Counter Strike',
yaw: 0.022,
fovt: 0.75,
aliases: ['cs', 'cs:go', 'csgo', 'counter-strike'],
},
{ name: 'Quake', yaw: 0.022, fovt: 0.75, aliases: ['quake'] },
{
name: 'Apex Legends',
yaw: 0.022,
fovt: 0.75,
aliases: ['apex-legends', 'apex'],
},
{ name: 'Valorant', yaw: 0.07, fovt: 0.5625, aliases: ['valorant', 'val'] },
{
name: 'Overwatch',
yaw: 0.0066,
fovt: 0.5625,
aliases: ['overwatch', 'ow'],
},
{ name: 'Fortnite', yaw: 0.005555, fovt: 1, aliases: ['fornite', 'fn'] },
{
name: 'Fortnite config',
yaw: 2.222,
fovt: 1,
aliases: ['fn-config', 'fornite-config'],
},
{
name: 'Diabotical',
yaw: 0.022000000000000002,
fovt: 1,
aliases: ['diabotical', 'dbt'],
},
{
name: 'Rainbow Six: Siege',
yaw: 0.005729577951308232,
fovt: 1,
aliases: ['r6', 'rainbow6', 'r6s'],
},
{
name: 'Call of Duty',
yaw: 0.0066,
fovt: 0.5625,
aliases: ['cod', 'callofduty', 'call-of-duty', 'warzone', 'wz'],
},
{
name: 'Battlefield',
yaw: 2.291831180523293,
fovt: 1,
aliases: ['battlefield', 'bf'],
},
{
name: 'Destiny',
yaw: 0.0066,
fovt: 0.5625,
aliases: ['destiny', 'd2', 'destiny2'],
},
];

array.sort();

function getObject(args, object) {
const isYaw = array.some(elem => elem.name === args);
const isYaw = array.some(elem =>
elem.aliases.some(currentValue => currentValue === args)
);
if (!isYaw) {
return args;
} else {
for (let i = 0; i < array.length; i++) {
if (args == array[i].name) {
return array[i][object];
array.forEach(item => {
if (item.aliases.some(currentValue => currentValue === args)) {
return item[object];
}
}
});
}
}

function gameNames() {
let gamenames = '';
for (let x = 0; x < array.length - 1; x++) {
gamenames += array[x].name + ', ';
}
gamenames += array[array.length - 1].name;
return gamenames;
let result = '';
array.forEach(item => {
result += `${item.name}: (${item.aliases.join(', ')})\n`;
});
return result;
}

module.exports = {
Expand Down
5 changes: 3 additions & 2 deletions src/commands/math/cm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { games, getObject } = require('../../array');
const { getObject } = require('../../array');
const commando = require('discord.js-commando');
module.exports = class cmCommand extends commando.Command {
constructor(client) {
Expand All @@ -8,7 +8,8 @@ module.exports = class cmCommand extends commando.Command {
group: 'math',
memberName: 'cm',
description: 'Converts Senstivity to cm/360',
details: `Converts Senstivity to cm/360 \n (Supported Games: ${games()})`,
details:
'Converts Senstivity to cm/360 \nTo see the Supported games do /games)',
examples: ['`/cm 0.95 ow 1600`'],
format: '<sens> <game|yaw> <cpi>',

Expand Down
5 changes: 3 additions & 2 deletions src/commands/math/convert.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { games, getObject } = require('../../array');
const { getObject } = require('../../array');
const commando = require('discord.js-commando');

module.exports = class convertCommand extends commando.Command {
Expand All @@ -8,7 +8,8 @@ module.exports = class convertCommand extends commando.Command {
group: 'math',
memberName: 'convert',
description: 'Converts Different Sensitivities from one game to another',
details: `Converts Different Sensitivities from one game to another \n (Supported Games: ${games()})`,
details:
'Converts Different Sensitivities from one game to another \nTo see the Supported games do /games)',
examples: ['`/convert 0.95 ow 0.022`'],
format: '<sens> <input game|yaw> <output game|yaw>',

Expand Down
5 changes: 3 additions & 2 deletions src/commands/math/deg.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { games, getObject } = require('../../array');
const { getObject } = require('../../array');
const commando = require('discord.js-commando');
module.exports = class degCommand extends commando.Command {
constructor(client) {
Expand All @@ -8,7 +8,8 @@ module.exports = class degCommand extends commando.Command {
group: 'math',
memberName: 'deg',
description: 'Converts Senstivity to deg/mm',
details: `Converts Senstivity to deg/mm \n (Supported Games: ${games()})`,
details:
'Converts Senstivity to deg/mm \nTo see the Supported games do /games)',
examples: ['`/deg 0.95 ow 1600`'],
format: '<sens> <game|yaw> <cpi>',

Expand Down
5 changes: 3 additions & 2 deletions src/commands/math/fov.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { atan, tan } = require('mathjs');
const PI = 3.14159;
const { games, getObject } = require('../../array');
const { getObject } = require('../../array');
const commando = require('discord.js-commando');
module.exports = class fovCommand extends commando.Command {
constructor(client) {
Expand All @@ -11,7 +11,8 @@ module.exports = class fovCommand extends commando.Command {
memberName: 'fov',
description:
'Converts fovs from one type to another or finds the true fov for a resolution aspect ratio',
details: `Converts fovs from one type to another or finds the true fov for a resolution aspect ratio(if the game scales to maintain vFOV) \n(Supported Games: ${games()})`,
details:
'Converts fovs from one type to another or finds the true fov for a resolution aspect ratio(if the game scales to maintain vFOV) \nTo see the Supported games do /games)',
examples: ['`/fov 90 quake 16:9`'],
format: '<fov> <input game|aspect ratio> <output game|aspect ratio>',

Expand Down
45 changes: 45 additions & 0 deletions src/commands/math/inch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const { getObject } = require('../../array');
const commando = require('discord.js-commando');
module.exports = class inchCommand extends commando.Command {
constructor(client) {
super(client, {
name: 'inch',
aliases: ['inch/360', 'inch/rev'],
group: 'math',
memberName: 'inch',
description: 'Converts Senstivity to inch/360',
details:
'Converts Senstivity to inch/360 \nTo see the Supported games do /games',
examples: ['`/inch 0.95 ow 1600`'],
format: '<sens> <game|yaw> <cpi>',

args: [
{
key: 'sens',
prompt: 'What Sensitivity do you want to convert from',
type: 'float',
},
{
key: 'yawv',
label: 'Game or yaw value',
prompt: 'What game or yaw value do you want to use',
type: 'gamename|float',
},
{
key: 'cpi',
label: 'cpi/dpi',
prompt: 'What CPI/DPI do you want to use',
type: 'float',
},
],
});
}

async run(message, args) {
const output = (
360 /
(args.cpi * getObject(args.yawv, 'yaw') * args.sens)
).toFixed(2);
return message.say(output + ' inch/360');
}
};
17 changes: 10 additions & 7 deletions src/commands/math/sens.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { games, getObject } = require('../../array');
const { getObject } = require('../../array');
const commando = require('discord.js-commando');
module.exports = class sensCommand extends commando.Command {
constructor(client) {
Expand All @@ -7,15 +7,18 @@ module.exports = class sensCommand extends commando.Command {
aliases: ['sens-cm', 'sens-deg', 'sens-inch'],
group: 'math',
memberName: 'sens',
description: 'Converts cm/360|deg/mm|inch/360 to a game sensitivity',
details: `Converts cm/360|deg/mm|inch/360 to a game sensitivity \n(Supported Games: ${games()})`,
description:
'Converts cm/360(default), deg/mm or inch/360 to a game sensitivity',
details:
'Converts cm/360(default), deg/mm or inch/360 to a game sensitivity \nTo see the Supported games do /games',
examples: [
'`/sens 28.5 quake 1600`',
'`/sens 28.5 ow 1600 -cm`',
'`/sens 1.21 cs 1600 -deg`',
'`/sens 11.22 fortnite 1600 -inch`',
],
format: '<cm/360|deg/mm|inch/360> <game|yaw> <cpi> [-cm|-deg|-inch]',
format:
'<cm/360|deg/mm|inch/360> <game|yaw> <cpi> ["-cm"|"-deg"|"-inch"]',

args: [
{
Expand Down Expand Up @@ -51,7 +54,7 @@ module.exports = class sensCommand extends commando.Command {
case '-deg': {
const output = (
(24.5 * args.cm) /
(args.cpi * getObject(args.yawv, 'yaw'))
(args.cpi * getObject(args.yawv.toLowerCase(), 'yaw'))
).toFixed(2);
console.log(output);
message.say(output);
Expand All @@ -61,7 +64,7 @@ module.exports = class sensCommand extends commando.Command {
case '-inch': {
const output = (
360 /
(args.cpi * getObject(args.yawv, 'yaw') * args.cm)
(args.cpi * getObject(args.yawv.toLowerCase(), 'yaw') * args.cm)
).toFixed(2);
message.say(output);
break;
Expand All @@ -70,7 +73,7 @@ module.exports = class sensCommand extends commando.Command {
case '-cm': {
const output = (
(2.54 * 360) /
(args.cpi * getObject(args.yawv, 'yaw') * args.cm)
(args.cpi * getObject(args.yawv.toLowerCase(), 'yaw') * args.cm)
).toFixed(2);
message.say(output);
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/util/games.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const { games } = require('../../array');
const commando = require('discord.js-commando');
const discord = require('discord.js');

module.exports = class gamesCommand extends commando.Command {
constructor(client) {
super(client, {
Expand All @@ -12,6 +14,9 @@ module.exports = class gamesCommand extends commando.Command {
}

async run(message) {
return message.say(`Suported Games: ${games()}`);
const Embed = new discord.MessageEmbed()
.setColor('#0099ff')
.addField('Supported Games:', `\`\`\`${games()}\`\`\``);
return message.say(Embed);
}
};
Loading

0 comments on commit b73afed

Please sign in to comment.