feat: add PUBLISH_COMMANDS environment variable

This commit is contained in:
Isaac 2023-02-23 22:40:14 +00:00
parent ff626d2871
commit adab3831fa
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33
4 changed files with 13 additions and 2 deletions

View File

@ -39,11 +39,12 @@ services:
HTTP_HOST: 0.0.0.0 HTTP_HOST: 0.0.0.0
HTTP_PORT: 80 HTTP_PORT: 80
HTTP_TRUST_PROXY: false # set to true if you're using a reverse proxy HTTP_TRUST_PROXY: false # set to true if you're using a reverse proxy
PUBLIC_BOT: false
OVERRIDE_ARCHIVE: null OVERRIDE_ARCHIVE: null
PUBLIC_BOT: false
PUBLISH_COMMANDS: false
SETTINGS_PORT: 8169 SETTINGS_PORT: 8169
SETTINGS_HOST: 127.0.0.1 SETTINGS_HOST: 127.0.0.1
SUPER: !!str 319467558166069248 # optionally add `,youruseridhere` SUPER: 319467558166069248 # optionally add `,youruseridhere`
networks: networks:
discord-tickets: discord-tickets:

View File

@ -24,6 +24,7 @@ const env = {
HTTP_TRUST_PROXY: false, HTTP_TRUST_PROXY: false,
OVERRIDE_ARCHIVE: '', OVERRIDE_ARCHIVE: '',
PUBLIC_BOT: false, PUBLIC_BOT: false,
PUBLISH_COMMANDS: false,
SETTINGS_HOST: '127.0.0.1', SETTINGS_HOST: '127.0.0.1',
SETTINGS_PORT: 8169, SETTINGS_PORT: 8169,
SUPER: '319467558166069248', SUPER: '319467558166069248',

View File

@ -35,6 +35,7 @@ const env = {
HTTP_TRUST_PROXY: () => true, // optional HTTP_TRUST_PROXY: () => true, // optional
OVERRIDE_ARCHIVE: () => true, // optional OVERRIDE_ARCHIVE: () => true, // optional
PUBLIC_BOT: () => true, // optional PUBLIC_BOT: () => true, // optional
PUBLISH_COMMANDS: () => true, // optional
SETTINGS_HOST: v => SETTINGS_HOST: v =>
(!!v && !v.startsWith('http')) || (!!v && !v.startsWith('http')) ||
new Error('is required and must be an address, not a URL'), new Error('is required and must be an address, not a URL'),

View File

@ -23,8 +23,16 @@ module.exports = class extends Listener {
process.title = 'tickets'; process.title = 'tickets';
client.log.success('Connected to Discord as "%s"', client.user.tag); client.log.success('Connected to Discord as "%s"', client.user.tag);
// fill cache
await sync(client); 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 // presence/activity
let next = 0; let next = 0;
const setPresence = async () => { const setPresence = async () => {