3.1.1 • Published 2 years ago

@akki256/discord-interaction v3.1.1

Weekly downloads
-
License
MIT License
Repository
github
Last release
2 years ago

@akki256/discord-interaction

Module for easier handling of discord interaction

Installation

npm install '@akki256/discord-interaction'
yarn add '@akki256/discord-interaction'

Usage

index.js

const discord = require('discord.js');
const client = new discord.Client({
	/* options */
});
const { DiscordInteractions, ErrorCodes, InteractionsError } = require('@akki256/discord-interaction');
const interactions = new DiscordInteractions(client);
interactions.loadInteractions('./interactions');

client.on('ready',() => {
	interactions.registerCommands({ syncWithCommand: true });
})

client.on('interactionCreate', interaction => {
	interactions.run(interaction).catch(error => {
		if (error instanceof InteractionsError && error.code === ErrorCodes.CommandHasCoolTime) {
			if(interaction.isRepliable()) interaction.reply({ content: 'This command is currently on cool time.', ephemeral: true })
		}
		console.error(error);
	});
})

client.login('token');

interactions/ping.js

const { ChatInput } = require('@akki256/discord-interaction');

const pingCommand = new ChatInput({
	name: 'ping',
	description: 'pong!'
}, interaction => {
	interaction.reply('pong!')
})

module.exports = [ pingCommand ];

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT License

3.1.1

2 years ago

3.0.2

2 years ago

3.1.0

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.0.3

2 years ago

2.1.1

2 years ago

2.0.2

2 years ago

2.0.4

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.1

3 years ago

1.0.0

3 years ago