Skip to content

Instantly share code, notes, and snippets.

@rpsirois
Created September 10, 2021 19:25
Show Gist options
  • Save rpsirois/c1aae3df42f07f334ab16cd981e032aa to your computer and use it in GitHub Desktop.
Save rpsirois/c1aae3df42f07f334ab16cd981e032aa to your computer and use it in GitHub Desktop.
require( 'dotenv' ).config()
const fs = require( 'fs' )
const got = require( 'got' )
// authorization details
const headers = {
'Authorization': `Bot ${ process.env.TESTBOT_TOKEN }`
}
// route details
const apiVersion = 9
const api = `https://discord.com/api/v${ apiVersion }`
const endpoint = `/applications/${ process.env.TESTBOT_ID }/guilds/${ process.env.GUILD_ID }/commands`
// payload
const commands = []
const commandFiles = fs.readdirSync( './commands' ).filter( file => file.endsWith( '.js' ) )
for ( const file of commandFiles ) {
const command = require( `./commands/${ file }` )
commands.push( command.data.toJSON() )
}
// send it
( async () => {
const response = await got.put( `${ api }${ endpoint }`, {
headers
, json: commands
}).json()
console.log( response )
})()
const { SlashCommandBuilder } = require( '@discordjs/builders' )
module.exports = {
data: new SlashCommandBuilder()
.setName( 'ships' )
.setDescription( 'List and update ships.' )
.addSubcommand( sc =>
sc
.setName( 'list' )
.setDescription( 'List will give you a listing of all the ships and their revisions.' )
)
.addSubcommand( sc =>
sc
.setName( 'get' )
.setDescription( 'Get will load a ship, where optional revision may be specified.' )
.addStringOption( option =>
option
.setName( 'shipname' )
.setDescription( 'Name of the ship to get.' )
.setRequired( true )
)
)
.addSubcommand( sc =>
sc
.setName( 'setcapacity' )
.setDescription( 'Set will set the ship capacity.' )
.addStringOption( option =>
option
.setName( 'shipname' )
.setDescription( 'Name of the ship to set capacity on.' )
.setRequired( true )
)
.addNumberOption( option =>
option
.setName( 'capacity' )
.setDescription( 'Value of capacity.' )
.setRequired( true )
)
)
.addSubcommand( sc =>
sc
.setName( 'setweight' )
.setDescription( 'Set will set the ship weight.' )
.addStringOption( option =>
option
.setName( 'shipname' )
.setDescription( 'Name of the ship to set weight on.' )
.setRequired( true )
)
.addNumberOption( option =>
option
.setName( 'weight' )
.setDescription( 'Value of weight.' )
.setRequired( true )
)
)
.addSubcommand( sc =>
sc
.setName( 'note' )
.setDescription( 'Note will add a note for the ship.' )
.addStringOption( option =>
option
.setName( 'shipname' )
.setDescription( 'Name of the ship to add a note to.' )
.setRequired( true )
)
.addStringOption( option =>
option
.setName( 'note' )
.setDescription( 'Note contents.' )
.setRequired( true )
)
)
.addSubcommand( sc =>
sc
.setName( 'increment' )
.setDescription( 'Increment will increment the kill or disable by one.' )
.addStringOption( option =>
option
.setName( 'shipname' )
.setDescription( 'Name of the ship to add a note to.' )
.setRequired( true )
)
.addStringOption( option =>
option
.setName( 'statistic' )
.setDescription( 'Statistic to increment.' )
.addChoice( 'Kills', 'kills' )
.addChoice( 'Disables', 'disables' )
.setRequired( true )
)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment