Skip to content

Commit 8232b42

Browse files
committed
Tidy up app.ts
We should probably label things in settings. As well as add some info to the readme/contributing file about how to get the bot running without PM2.
1 parent 2a5615a commit 8232b42

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export const guildLog = '455088142475591691'
66
export const owner = '191380396586303489'
77
export const devId = '436326730089889812'
88
export const prodId = '423530119836073986'
9+
export const guildId = '423525617598988288'

src/app.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,12 @@ const client = new Client({ intents: [Intents.FLAGS.GUILDS] })
3535
const commands = new Collection<string, Command>()
3636

3737
const commandFiles = fs.readdirSync(path.join(__dirname, 'commands')).filter(file => file.endsWith('.ts'))
38-
const dataArr = []
3938

4039
const clientId = process.env.NODE_ENV === 'production' ? settings.prodId : settings.devId
41-
const guildId = '423525617598988288'
4240

4341
for (const file of commandFiles) {
4442
const command: Command = require(`./commands/${file}`)
4543
commands.set(command.data.name, command)
46-
dataArr.push(command.data)
4744
}
4845

4946
const rest = new REST({ version: '9' }).setToken(process.env.TOKEN);
@@ -54,9 +51,9 @@ const rest = new REST({ version: '9' }).setToken(process.env.TOKEN);
5451

5552
await rest.put(
5653
process.env.NODE_ENV === 'development'
57-
? Routes.applicationGuildCommands(clientId, guildId) // register commands as guild commands in development (instantly updates)
54+
? Routes.applicationGuildCommands(clientId, settings.guildId) // register commands as guild commands in development (instantly updates)
5855
: Routes.applicationCommands(clientId), // otherwise, register commands globally (updates slower, up to an hour)
59-
{ body: dataArr }
56+
{ body: commands.map(command => command.data) }
6057
)
6158

6259
console.log('Successfully reloaded application (/) commands.')
@@ -66,15 +63,12 @@ const rest = new REST({ version: '9' }).setToken(process.env.TOKEN);
6663
})()
6764

6865
// Client events
69-
client.once('ready', () => {
70-
console.log('Ready!')
71-
})
66+
client.once('ready', () => { console.log('Ready!') })
7267

7368
client.on('interactionCreate', async interaction => {
7469
if (!interaction.isCommand()) return
7570

7671
const command = commands.get(interaction.commandName)
77-
7872
if (!command) return
7973

8074
try {

0 commit comments

Comments
 (0)