https://github.com/cryptiklemur/discord-interactions-framework
https://github.com/cryptiklemur/discord-interactions-framework
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/cryptiklemur/discord-interactions-framework
- Owner: cryptiklemur
- Created: 2020-12-19T08:29:14.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-12-20T16:48:48.000Z (over 5 years ago)
- Last Synced: 2025-02-01T15:45:20.069Z (over 1 year ago)
- Language: TypeScript
- Size: 36.1 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Discord Interactions Framework
### Install
```shell
$ npm install discord-interactions-framerwork
// or
$ yarn add discord-interactions-framework
```
### Usage
```ts
const config = new Config({
applicationId: '',
publicKey: '',
authorization: {
botToken: '',
}
});
const registry = new Registry(config, [
new Command(
'bar',
'Test command',
{
foo: {
type: ApplicationCommandOptionType.String,
description: 'Foo value',
required: true,
},
baz: {
type: ApplicationCommandOptionType.String,
description: 'Baz value',
required: true,
choices: {Dog: 'animal_dog', Cat: 'animal_cat', Penguin: 'animal_penguin'},
},
} as const,
(interaction) => {
const a = interaction.data.options.foo.value;
const b = interaction.data.options.baz.value;
if (interaction.data.options.baz.value === 'animal_cat') {
return {type: 1};
}
return {type: 1};
},
['81384788765712384']
),
]
);
async function main() {
const processor = new ExpressProcessor(config, registry);
const app = express();
await registry.initialize();
app.post('/', processor.processRequest.bind(processor));
app.listen(3000)
}
main().then(() => console.log('Finished'), console.error)
```