-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- We are using an experimental feature of ES6, import assertions. This allows us to import JSON files without causing issues, while sticking to the standardized ES6 module structure. - IA will most likely become stable in the future, if not we would most likely convert JSON's to JS exportable objects, or start storing that information in other ways.
- Loading branch information
Showing
53 changed files
with
329 additions
and
731 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
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,3 +1,4 @@ | ||
module.exports = (client) => { | ||
const consoleLog = (client) => { | ||
console.log(`${client.user.tag} is online.`); | ||
}; | ||
}; | ||
export default consoleLog; |
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,55 +1,57 @@ | ||
module.exports = (existingCommand, localCommand) => { | ||
const areChoicesDifferent = (existingChoices, localChoices) => { | ||
for (const localChoice of localChoices) { | ||
const existingChoice = existingChoices?.find( | ||
(choice) => choice.name === localChoice.name | ||
); | ||
|
||
if (!existingChoice) { | ||
return true; | ||
} | ||
|
||
if (localChoice.value !== existingChoice.value) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
const areOptionsDifferent = (existingOptions, localOptions) => { | ||
for (const localOption of localOptions) { | ||
const existingOption = existingOptions?.find( | ||
(option) => option.name === localOption.name | ||
); | ||
|
||
if (!existingOption) { | ||
return true; | ||
} | ||
|
||
if ( | ||
localOption.description !== existingOption.description || | ||
localOption.type !== existingOption.type || | ||
(localOption.required || false) !== existingOption.required || | ||
(localOption.choices?.length || 0) !== | ||
(existingOption.choices?.length || 0) || | ||
areChoicesDifferent( | ||
localOption.choices || [], | ||
existingOption.choices || [] | ||
) | ||
) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
const areChoicesDifferent = (existingChoices, localChoices) => { | ||
for (const localChoice of localChoices) { | ||
const existingChoice = existingChoices?.find( | ||
(choice) => choice.name === localChoice.name | ||
); | ||
|
||
if (!existingChoice) { | ||
return true; | ||
} | ||
|
||
if (localChoice.value !== existingChoice.value) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
const areOptionsDifferent = (existingOptions, localOptions) => { | ||
for (const localOption of localOptions) { | ||
const existingOption = existingOptions?.find( | ||
(option) => option.name === localOption.name | ||
); | ||
|
||
if (!existingOption) { | ||
return true; | ||
} | ||
|
||
if ( | ||
existingCommand.description !== localCommand.description || | ||
existingCommand.options?.length !== (localCommand.options?.length || 0) || | ||
areOptionsDifferent(existingCommand.options, localCommand.options || []) | ||
localOption.description !== existingOption.description || | ||
localOption.type !== existingOption.type || | ||
(localOption.required || false) !== existingOption.required || | ||
(localOption.choices?.length || 0) !== | ||
(existingOption.choices?.length || 0) || | ||
areChoicesDifferent( | ||
localOption.choices || [], | ||
existingOption.choices || [] | ||
) | ||
) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}; | ||
} | ||
return false; | ||
}; | ||
|
||
const areCommandsDifferent = (existingCommand, localCommand) => { | ||
if ( | ||
existingCommand.description !== localCommand.description || | ||
existingCommand.options?.length !== (localCommand.options?.length || 0) || | ||
areOptionsDifferent(existingCommand.options, localCommand.options || []) | ||
) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
export default areCommandsDifferent; |
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,13 +1,15 @@ | ||
module.exports = async (client, guildId) => { | ||
let applicationCommands; | ||
if (guildId) { | ||
const fetchApplicationCommands = async (client, guildId) => { | ||
let applicationCommands; | ||
|
||
if (guildId) { | ||
const guild = await client.guilds.fetch(guildId); | ||
applicationCommands = guild.commands; | ||
} else { | ||
} else { | ||
applicationCommands = await client.application.commands; | ||
} | ||
|
||
await applicationCommands.fetch(); | ||
return applicationCommands; | ||
}; | ||
} | ||
|
||
await applicationCommands.fetch(); | ||
return applicationCommands; | ||
}; | ||
|
||
export default fetchApplicationCommands; |
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,27 +1,30 @@ | ||
const path = require('path'); | ||
const getAllFiles = require('./getAllFiles'); | ||
import path from 'path'; | ||
import getAllFiles from '../commandUtils/getAllFiles.js'; | ||
import { fileURLToPath, pathToFileURL } from 'url'; | ||
|
||
module.exports = (exceptions = []) => { | ||
let localCommands = []; | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
const commandCategories = getAllFiles( | ||
path.join(__dirname, '..', 'commands'), | ||
true | ||
); | ||
|
||
for (const commandCategory of commandCategories) { | ||
const commandFiles = getAllFiles(commandCategory); | ||
const getLocalCommands = async (exceptions = []) => { | ||
let localCommands = []; | ||
|
||
for (const commandFile of commandFiles) { | ||
const commandObject = require(commandFile); | ||
|
||
if (exceptions.includes(commandObject.name)) { | ||
continue; | ||
} | ||
const commandCategories = getAllFiles(path.join(__dirname, '..', 'commands'), true); | ||
|
||
for (const commandCategory of commandCategories) { | ||
const commandFiles = getAllFiles(commandCategory); | ||
|
||
for (const commandFile of commandFiles) { | ||
const commandFileURL = pathToFileURL(commandFile).href; | ||
const commandObject = await import(commandFileURL).then(module => module.default); | ||
|
||
if (exceptions.includes(commandObject.name)) { | ||
continue; | ||
} | ||
|
||
localCommands.push(commandObject); | ||
localCommands.push(commandObject); | ||
} | ||
} | ||
} | ||
|
||
return localCommands; | ||
}; | ||
return localCommands; | ||
}; | ||
|
||
export default getLocalCommands; |
5 changes: 3 additions & 2 deletions
5
src/commands/test/getForumTags.js → src/commands/dev/getForumTags.js
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
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 @@ | ||
module.exports = { | ||
export default { | ||
name: 'ping', | ||
description: 'Replies with the bot ping!', | ||
|
||
|
Oops, something went wrong.
8f6cf68
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More IA info:
nodejs/node#46830