[MODULE] Discord module for SqMod
[SNIPPET] Anti command spam. »

Luckshya

  • Jr. Member
  • Posts: 96
[MODULE] Discord module for SqMod
«  »Last edited
Introduction
I was working on this Discord plugin since many days but I've completed the plugin for SqMod now.
The plugin won't be available for official Squirrel plugin because it is missing some very important things like some plugin commands and squirrel API functions that developers failed to provide.
Though, I have modified the squirrel plugin and made some changes and added some missing necessary things required plugins but still something is wrong with code or I don't know that makes it produce some weird errors.
For official squirrel plugin, I can provide with a simple single bot plugin.

This plugin is a multi-bot plugin.

This plugin basically has 2 versions that binds with
  • Sleepy-Discord
  • libdiscord

It is up to you to decide whether you want to use the sleepydiscord one or libdiscord one.

Documentation
The plugin doesn't really require any such sort of documentation. So, the example code would do the work.

Functions:
  • Regex_Match
  • SetActivity

Example Usage:
Code: [Select]
local matches = Regex_Match("regex string", "value string"); // returns a bool

Code: [Select]
discordHandle.SetActivity("a game");

//Playing a game



Source

Plugin Source (Sleepy-Discord) : https://github.com/Luckshya/SqMod-Discord1
Plugin Source (libdiscord) : https://github.com/Luckshya/SqMod-Discord

Installation/Requirements

Sleepy-Discord

Windows
Install OpenSSL from here: https://slproweb.com/products/Win32OpenSSL.html
Don't change any options while installing openssl.

Binaries: https://github.com/Luckshya/SqMod-Discord1/releases

Linux
Code: [Select]
apt-get install libssl-dev

Binaries: https://github.com/Luckshya/SqMod-Discord1/releases
(32 bit not available for now)

libdiscord

Windows
Binaries: https://github.com/Luckshya/SqMod-Discord/releases
(Dependencies included)

Linux
Code: [Select]
apt-get install libcpprest-dev

Binaries: https://github.com/Luckshya/SqMod-Discord/releases
(32 bit not available for now)

The most important thing:
Credits
  • @. (SLC): I've learnt a lot from his code and I've also implemented and used his code. He has also helped me throughout the problems including my stupid problems or whatever. He's just like the author of the plugin tbh.
  • @Doom_Kill3R
  • @EK.IceFlake
  • @Sebastian
  • @Xmair

NOTE: You need to take care of the Discord rate limit yourself.

Doom_Kill3R

  • VC:MP Beta Tester
  • Infinite loops defy infinity by overflowing memory
  • Posts: 1,093
[MODULE] Re: Discord module for SqMod
« Reply #1,  »Last edited
There has been alot of effort put into this, one way or the other, great job!

Luckshya

  • Jr. Member
  • Posts: 96
[MODULE] Re: Discord module for SqMod
« Reply #3,  »
Added function Regex_Match to check for special character/symbols for discord. More details in the main post.
[MODULE] Re: Discord module for SqMod
« Reply #4,  »
Fixed issue that crashes the server while closing. Make sure you update the binaries from the latest release on the repo.
[MODULE] Re: Discord module for SqMod
« Reply #5,  »
A new update 0.2 has been released that brings the following changes.
  • Fixed an issue that causes server to crash when a DM is received by the bot.
  • Added param authorID to the event onMessage as updated in the example code.

Make sure you update the binaries from the latest release on the repo.
[MODULE] Re: Discord module for SqMod
« Reply #6,  »
Update v0.2.1 changelog.
  • Added param authorNick to event onMessage
  • Added function GetRoleName to get the name of role using server ID and role ID
  • Fixed an issue of updating roles and other things in Sleepy-Discord version

Example scripts have been updated.
Make sure you get the latest binaries from the latest release on the repo.
[MODULE] Re: Discord module for SqMod
« Reply #7,  »Last edited
Update v0.2.2 changelog.
  • Added function SetActivity. More information about it in main post.
  • Fixed several bugs

NOTE: libdiscord users should not send empty messages or the message like "" or "\n" or "msg\n" or the server will crash. Support for it may be released in the next version.
Valid message can be: "\nmessage", "msg1\nmsg2"