Skip to content

A Discordia library extension that enables receiving and responding to Discord's Interactions.

License

Notifications You must be signed in to change notification settings

Bilal2453/discordia-interactions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

discordia-interactions is a library that makes receiving Discord Interactions over WebSocket connection possible in the Luvit Discord wrapper Discordia 2, as well as providing the required methods to respond to the interaction. Although this library does not implement any specific feature such as Message Components or Slash Commands, it act as the base of supporting said features, for example, I've built discordia-components upon this library, which fully provide support for Message Components (such as buttons and select menus).

Documentation

The library is documented at the Wiki, it is mostly complete but small details are still missing.

Installing

Due to a bug in Lit, the Lit upstream version of this library won't install, you have to manually clone it.

  1. Run cd PATH replace PATH with your bot's directory path.
  2. Run git clone https://github.com/Bilal2453/discordia-interactions.git ./deps/discordia-interactions.
  3. Make sure you now have a folder discordia-interactions in your deps directory.

Examples

local discordia = require("discordia")
require("discordia-interactions") -- Modifies Discordia and adds interactionCreate event

local client = discordia.Client()
local intrType = discordia.enums.interactionType

client:on("interactionCreate", function(interaction)
  -- Ephemeral reply to an interaction
  interaction:reply("Hello There! This is ephemeral reply", true)
  -- Send a followup reply
  interaction:reply {
    -- send a file with interactions info
    file = { -- identical to the Discordia field
      "info.txt",
      "Bot received an interaction of the type " .. intrType(interaction.type) .. " from the user " .. interaction.user.name
    },
    -- try to mention the user
    mention = interaction.member or interaction.user,
    -- suppress all mentions
    allowed_mentions = { -- if Discordia's send doesn't handle said field, library'll treat it as raw
      parse = {}
    }
  }
  if interaction.type == intrType.messageComponent then
    -- update the message the component was attached to
    interaction:update {
      embed = {
        title = "Wow! You have actually used the component!",
        color = 0x00ff00,
      }
    }
  end
end)

client:run("Bot TOKEN")

About

A Discordia library extension that enables receiving and responding to Discord's Interactions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages