Yassir Chebaa

Eager software engineer with a BSc in Computer Science. C++ and Rust enthusiast, always learning.

  • Posts
  • About
  • Contact
  • GitHub
  • LinkedIn

Discord Bot

discontinued2026-02-12Source

  • rust
  • discord
  • serenity
  • tokio
  • riot-api
  • bot

A Discord bot in Rust with Serenity that looks up League of Legends players through the Riot Games API.

Why

A side project to learn Rust: async code with Tokio, talking to the Discord API through Serenity, and wrapping a real third-party API (Riot Games) in typed Rust.

I played League of Legends at the time, so looking up summoners from Discord was something I actually used, not just an exercise.

I discontinued it when I got too busy to keep working on it.

How it works

Discord ──> Serenity EventHandler ──> parse_message (prefix "&")
                                         └── &lookup ──> Cache (cache/user_cache.json)
                                                           └── miss ──> RiotApiClient ──> Riot API
  • Discord layer: a Serenity EventHandler reads every message, hands it to the command parser and replies in the same channel. On connect it sets its presence (“Playing Clash Destroyer”, Do Not Disturb).
  • Riot layer: a reqwest client sends the X-Riot-Token header and deserializes responses with Serde into typed models.
  • Endpoints: each Riot API group (Account, Summoner, League, Match-V5, Champion Mastery, Clash, Spectator, …) is an enum that builds its own path, wrapped in one Endpoint enum behind a RiotEndpoint trait.
  • Cache: the Riot ID (name#tag) to PUUID mapping is stored in a JSON file, so repeat lookups skip one API call.

Commands

CommandDoes
&pingReplies Pong!
&echo <text>Repeats the text
&lookup <name>#<tag>Summoner level, profile icon and PUUID (EUW)

&lookup validates its input first: it needs both parts of the Riot ID, and the tag can be at most 5 characters.

Known limits

  • Most endpoint groups are stubs with one or two routes; only the Summoner lookup is wired to a command.
  • The region is fixed to EUW, with a hard-coded switch to the EUROPE routing host for Riot ID lookups.
  • The bot asks for all gateway intents instead of only the ones it needs.

Stack

  • Language: Rust (2024 edition).
  • Discord: Serenity 0.12.
  • Async and HTTP: Tokio, reqwest, Serde.
  • Config and logs: dotenvy (DISC_TOKEN, RIOT_TOKEN), tracing.

Links

  • Serenity
  • Riot Games API
Olderedge at Snowcrash BVNewerBambuStudio AI chat + MCP server
All projects

Source codeQuestions about this project? Contact me

Disclaimer|Privacy Policy