Skip to content

Commit

Permalink
feat: testing a feature for unique invites
Browse files Browse the repository at this point in the history
  • Loading branch information
en3sis committed Feb 26, 2024
1 parent 62b353c commit 51d7137
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/commands/unique_invite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { SlashCommandBuilder } from '@discordjs/builders'
import { CommandInteraction, TextChannel } from 'discord.js'
import { logger } from '../utils/debugging'

// https://discord.js.org/#/docs/main/stable/class/CommandInteraction?scrollTo=replied
module.exports = {
ephemeral: true,
data: new SlashCommandBuilder()
.setName('unique_invite')
.setDescription('Generates an unique, 24h duration invite to current channel')
.setDefaultMemberPermissions('0'),
async execute(interaction: CommandInteraction) {
try {
const cnl = interaction.channel as TextChannel

cnl
.createInvite({ maxUses: 1, unique: true })
.then((invite) => {
interaction.editReply(`Here's your invite link: ${invite.url}`)
})
.catch((error) => {
console.error('Error creating invite:', error)
interaction.reply('There was an error creating the invite.')
})
} catch (error) {
logger('❌ Command: invite: ', error)
}
},
}

0 comments on commit 51d7137

Please sign in to comment.