Skip to content

Commit

Permalink
feat: Add restart functionality
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Drla <[email protected]>
  • Loading branch information
mimotej committed Jun 25, 2022
1 parent 66aae25 commit 1843a3f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * as whoami from './whoami';
export * as whois from './whois';
export * as uznanipredmetu from './uznanipredmetu';
export * as prune from './prune';
export * as restart from './restart';
19 changes: 19 additions & 0 deletions src/commands/restart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { SlashCommandBuilder } from '@discordjs/builders';
import { PermissionFlagsBits } from 'discord-api-types/v9';
import { CommandInteraction } from 'discord.js';

/**
* Replies friendly hello to user.
*/
export const data = new SlashCommandBuilder()
.setName('restart')
.setDescription('Will restart bot')
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator);

export async function execute(interaction: CommandInteraction) {
return interaction
.reply('Restarting bot...')
.then(() => interaction.client.destroy())
.then(() => interaction.client.login(process.env.DISCORD_TOKEN))
.then(() => interaction.channel?.send('Bot successfully restarted!'));
}

0 comments on commit 1843a3f

Please sign in to comment.