Skip to content

Commit

Permalink
feat(config): option to toggle automated defering (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
barthofu committed Jan 26, 2023
1 parent b01597d commit 3bfaf28
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/config/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ export const generalConfig: GeneralConfigType = {
name: 'tscord', // the name of your bot
description: '', // the description of your bot
defaultLocale: 'en', // default language of the bot, must be a valid locale
simpleCommandsPrefix: '!', // default prefix for simple command messages (old way to do commands on discord)
ownerId: process.env['BOT_OWNER_ID'] || '',
timezone: 'Europe/Paris', // default TimeZone to well format and localize dates (logs, stats, etc)

simpleCommandsPrefix: '!', // default prefix for simple command messages (old way to do commands on discord)
automaticDefering: true, // enable or not the automatic defering of the replies of the bot on the command interactions

// useful links
links: {
invite: 'https://www.change_invite_link_here.com',
Expand Down
6 changes: 5 additions & 1 deletion src/events/interactionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Guild, User } from "@entities"
import { Maintenance } from "@guards"
import { Database, Logger, Stats } from "@services"
import { syncUser } from "@utils/functions"
import { generalConfig } from "@config"

@Discord()
@injectable()
Expand All @@ -28,7 +29,10 @@ export default class InteractionCreateEvent {
) {

// defer the reply
if (interaction instanceof CommandInteraction) await interaction.deferReply()
if (
generalConfig.automaticDefering &&
interaction instanceof CommandInteraction
) await interaction.deferReply()

// insert user in db if not exists
await syncUser(interaction.user)
Expand Down
4 changes: 3 additions & 1 deletion src/utils/types/configs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ type GeneralConfigType = {
name: string
description: string
defaultLocale: import('@i18n').Locales
simpleCommandsPrefix: string
ownerId: string
timezone: string
automaticUploadImagesToImgur: boolean

simpleCommandsPrefix: string
automaticDefering: boolean

links: {
invite: string
Expand Down

0 comments on commit 3bfaf28

Please sign in to comment.