Skip to content
AI NEWS JOURNAL
Hacker News Show HNAI NEWS / JOURNAL

Show HN: Discord:Client – A Discord API Library for Perl

Article URL: https://github.com/viasnake/Discord-Client Comments URL: https://news.ycombinator.com/item?id=50600681 Points: 1 # Comments: 0

Build Discord bots in Perl with slash commands, messages, buttons and forms. Uses IO::Async and Future to handle connections and rate limits. Requires Perl 5.26 or newer. The API is experimental. Unofficial; not affiliated with or endorsed by Discord. From CPAN: cpanm Discord::Client From a source checkout: A simple bot use v5.26; use warnings; use Discord::Client; # Create the bot. my $bot = Discord::Client->new(token => $ENV{DISCORD_BOT_TOKEN}); # Reply to /ping. $bot->command( ping => ( description => 'Replies with Pong', handler => sub { my ($interaction) = @_; return $interaction->reply('Pong!'); }, ), ); # Run until shutdown. $bot->run; Create a bot in the Discord Developer Portal and invite it to a test server with the bot and applications.commands scopes. Leave the Interactions Endpoint URL empty. Set DISCORD_BOT_TOKEN and TEST_GUILD_ID in your environment. Deploy the ping example once, then run it: perl examples/sync-commands.pl examples/ping.pl perl examples/ping.pl Deployment replaces this application's commands in the test server. Startup does not deploy commands. Try /ping; stop the bot with Ctrl+C. Read the installed API documentation with perldoc Discord::Client. Client API and examples Commands and Interactions REST, Gateway and HTTP delivery Models, shards and cache Contributing Apache License 2.0.

Sources

Read original ↗

Related topics

← Continue to all updates