Discord Gateway API

Build Discord bots with real-time event handling — receive messages, manage guilds, and interact with users from Delphi.

Discord Integration

Connect to Discord's Gateway WebSocket API for real-time bot interactions and server management.

Delphi Discord Bots

The sgcWebSockets Discord component implements the Discord Gateway protocol, handling authentication, heartbeats, reconnection, and resume automatically. Receive real-time events for messages, reactions, member updates, and more. Combined with the Discord REST API, build fully featured Discord bots in Delphi.

  • Gateway WebSocket with automatic heartbeat
  • Message, reaction, and presence events
  • Guild and channel management
  • Intents-based event filtering
  • Session resume on reconnection

Delphi Discord Bot Example

Connect a bot to Discord and respond to messages.

uses
  sgcHTTP_API_Discord;

var
  Discord: TsgcHTTPAPI_Discord;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Discord := TsgcHTTPAPI_Discord.Create(nil);
  Discord.DiscordOptions.BotToken := 'your-bot-token';
  Discord.OnDiscordMessage := OnMessage;
  Discord.Connect;
end;

procedure TForm1.OnMessage(Sender: TObject;
  aChannelId, aAuthor, aContent: string);
begin
  if aContent = '!ping' then
    Discord.SendMessage(aChannelId, 'Pong!');
end;

Documentation & Demos

Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.

Ready to Build Discord Bots?

Download the free trial and create Discord bots in Delphi today.