Skip to content

Commit

Permalink
feat: add PUBLISH_COMMANDS environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
eartharoid committed Feb 23, 2023
1 parent ff626d2 commit adab383
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docker-compose.yml
Expand Up @@ -39,11 +39,12 @@ services:
HTTP_HOST: 0.0.0.0
HTTP_PORT: 80
HTTP_TRUST_PROXY: false # set to true if you're using a reverse proxy
PUBLIC_BOT: false
OVERRIDE_ARCHIVE: null
PUBLIC_BOT: false
PUBLISH_COMMANDS: false
SETTINGS_PORT: 8169
SETTINGS_HOST: 127.0.0.1
SUPER: !!str 319467558166069248 # optionally add `,youruseridhere`
SUPER: 319467558166069248 # optionally add `,youruseridhere`

networks:
discord-tickets:
Expand Down
1 change: 1 addition & 0 deletions scripts/preinstall.js
Expand Up @@ -24,6 +24,7 @@ const env = {
HTTP_TRUST_PROXY: false,
OVERRIDE_ARCHIVE: '',
PUBLIC_BOT: false,
PUBLISH_COMMANDS: false,
SETTINGS_HOST: '127.0.0.1',
SETTINGS_PORT: 8169,
SUPER: '319467558166069248',
Expand Down
1 change: 1 addition & 0 deletions src/env.js
Expand Up @@ -35,6 +35,7 @@ const env = {
HTTP_TRUST_PROXY: () => true, // optional
OVERRIDE_ARCHIVE: () => true, // optional
PUBLIC_BOT: () => true, // optional
PUBLISH_COMMANDS: () => true, // optional
SETTINGS_HOST: v =>
(!!v && !v.startsWith('http')) ||
new Error('is required and must be an address, not a URL'),
Expand Down
8 changes: 8 additions & 0 deletions src/listeners/client/ready.js
Expand Up @@ -23,8 +23,16 @@ module.exports = class extends Listener {
process.title = 'tickets';
client.log.success('Connected to Discord as "%s"', client.user.tag);

// fill cache
await sync(client);

if (process.env.PUBLISH_COMMANDS === 'true') {
client.log.info('Automatically publishing commands...');
client.commands.publish()
.then(commands => client.log.success('Published %d commands', commands?.size))
.catch(client.log.error);
}

// presence/activity
let next = 0;
const setPresence = async () => {
Expand Down

0 comments on commit adab383

Please sign in to comment.