Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mataku/discord_slash_command_sample
Discord slash command handler sample with Ruby and sinatra
https://github.com/mataku/discord_slash_command_sample
discord ruby
Last synced: 12 days ago
JSON representation
Discord slash command handler sample with Ruby and sinatra
- Host: GitHub
- URL: https://github.com/mataku/discord_slash_command_sample
- Owner: mataku
- Created: 2021-06-29T14:54:36.000Z (over 3 years ago)
- Default Branch: develop
- Last Pushed: 2021-06-30T09:18:58.000Z (over 3 years ago)
- Last Synced: 2024-12-24T00:38:49.449Z (12 days ago)
- Topics: discord, ruby
- Language: Ruby
- Homepage:
- Size: 528 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Discord slash command handler sample
with Ruby and sinatra
## Command registration
[Guild command registration sample](/scripts/register_command.rb)
```shell
DISCORD_APPLICATION_ID="123" DISCORD_GUILD_ID="123" DISCORD_BOT_TOKEN="bot_token" bundle exec ruby script/register_command.rb
```## Startup
Set up a server to handle events from Discord. [bot.rb](/bot.rb) is handling the `POST /discord/events` endpoint, returning a response to the command `/echo`.
```shell
bundle exec rackup config.ru -p PORT_NUMBER
```## Register your endpoint to app
Go to https://discord.com/developers/applications/{your_app_id}/information
![](/static/interactions_endpoint_url.png)
### Demo
Here is `/echo` outputs.
![](/static/command_sample.gif)