GithubHelp home page GithubHelp logo

drocsidaul's Introduction

drocsidaul - yet another Lua library for Discord

Why?

  • Litcord is synchronous.
  • Discordia requires Luvit.
  • I dislike both Luvit and synchronous code.
  • I think I can do better than both Litcord and Discordia. Sorry-not-sorry.

Dependencies

  • Lua > 5.1
  • luarocks
  • lua-websockets (scm-1)
  • copas

These dependencies can be downloaded using luarocks:

  • lua-cjson
  • luasec
  • lzlib
  • date
  • multipart

To install lua-websockets correctly, you need to install libev and run this command:

$luarocks install https://raw.githubusercontent.com/lipp/lua-websockets/master/rockspecs/lua-websockets-scm-1.rockspec

The version of copas used has been modified - to install it you should use:

$luarocks install https://raw.githubusercontent.com/FiniteReality/copas/master/rockspec/copas-cvs-4.rockspec

Usage

For basic usage as a bot, this should be all you need to do:

local copas = require("copas")
local discord = require("discord")

local myClient = discord.client.new("your.bot.token.here")

myClient:on("message_update", function(client, before, after)
	print(("Message updated\nBefore: %s\nAfter: %s\n"):format(before.contents, after.contents))
end)

myClient:on("message_receive", function(client, message)
	print(("Message received: %s %s"):format(message.author.name, message.contents))

	if message.contents:match("^!ping") then
		client:sendMessage(message.channel, ("Pong! Gateway latency: %0.5ds"):format(client.latency))
	end
end)

copas.addthread(function()
	myClient:connect()
	myClient:listen()
end)
copas.loop()

Also look at the test directory for more examples of usage.

Contributing

Feel free to open PRs and whatever. I'll get to them whenever.

drocsidaul's People

Contributors

finitereality avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.