Discord Plugin

Started by Luckshya, Mar 05, 2019, 05:38 AM

Previous topic - Next topic

Luckshya

Introduction
After releasing a discord module for SqMod, I got certain requests to do it for official squirrel plugin as well. So, I have managed to write a multi-bot discord plugin for it.

The plugin only comes with sleepy-discord library.

Documentation
Wiki: https://github.com/Luckshya/sleepydiscord-squirrel/wiki/
Example code: Available on wiki

Source
Sleepy-Discord: https://github.com/yourWaifu/sleepy-discord
Plugin Source: https://github.com/Luckshya/sleepydiscord-squirrel

Installation/Requirements

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

Binaries: https://github.com/Luckshya/sleepydiscord-squirrel/releases

Linux
apt-get install libssl-dev
Binaries: https://github.com/Luckshya/sleepydiscord-squirrel/releases
(32 bit not available for now)

Credits

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

Luckshya

Added function Regex_Match to check for special character/symbols for discord. More details in the main post.

Milos

Very good, thanks for that.
Doubt: any way to get the level of channel users?
Report: When the bot receives a private message it crashes the server.

Luckshya

#3
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 onDiscord_Message as updated in the example code.

Make sure you update the binaries from the latest release on the repo.

Luckshya

Update v0.2.1 changelog.
  • Added param authorNick to event onDiscord_Message
  • Added function Discord_GetRoleName to get the name of role using server ID and role ID

Example scripts have been updated.
Make sure you get the latest binaries from the latest release on the repo.

Milos

Quote from: Luckshya on Mar 06, 2019, 08:54 AMA 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 onDiscord_Message as updated in the example code.

Make sure you update the binaries from the latest release on the repo.
How useful is the authorNick if author already does this?
It returns nothing

Luckshya

Quote from: Pau Grosso on Mar 07, 2019, 11:55 PMHow useful is the authorNick if author already does this?
It returns nothing
The authorNick param returns empty string if a user doesn't have any nickname set on discord.
It also returns null if a DM is received.

So, does 'Sprunk' has his nickname set in the bot's discord server?

Milos

Quote from: Luckshya on Mar 08, 2019, 02:46 AM
Quote from: Pau Grosso on Mar 07, 2019, 11:55 PMHow useful is the authorNick if author already does this?
It returns nothing
The authorNick param returns empty string if a user doesn't have any nickname set on discord.
It also returns null if a DM is received.

So, does 'Sprunk' has his nickname set in the bot's discord server?
Oh now I understand. and no, it has no nickname on server ;D
Thanks

Luckshya

#8
Update v0.2.2 changelog.
  • Added function Discord_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" or "msg1\nmsg2"

Luckshya

Sleepy-discord binaries are now available.

Luckshya

A new update v0.3 has been released that changes a lot of structure and introduces classes to manage discord session.
Refer to the main post for the changes.

A major feature added in this update are Embeds.

D4rkR420R

Quote from: Luckshya on Mar 20, 2019, 05:53 AMA new update v0.3 has been released that changes a lot of structure and introduces classes to manage discord session.
Refer to the main post for the changes.

A major feature added in this update are Embeds.

Yeah! :D

Milos

Plugin error >> LoadLibrary() 'plugins/discord04rel64.dll' failed: Code 126
Failed to load plugin: discord04rel64

Luckshya

Quote from: Milos on Mar 26, 2019, 01:56 PMPlugin error >> LoadLibrary() 'plugins/discord04rel64.dll' failed: Code 126
Failed to load plugin: discord04rel64
Did you install OpenSSL? Check the main post for the link.

Milos

#14
I was using the wrong version, but I have another problem: in Linux, the plugin loads, but I have errors
v0.4, (c) 2007-2014 VC:MP Team
Loaded plugin: squirrel04rel64
Loaded plugin: announce04rel64
Loaded plugin: sqlite04rel64
Loaded plugin: sockets04rel64
Loaded plugin: discord04rel64
Loaded plugin: hash-linux64
Loaded plugin: json04rel64
Loaded plugin: geoip04rel64
** Started VC:MP 0.4 Server **
AN ERROR HAS OCCURED [the index 'SqDiscord' does not exist]
CALLSTACK
*FUNCTION [constructor()] scripts/Discord.nut line [11]
*FUNCTION [main()] scripts/Discord.nut line [140]
*FUNCTION [dofile()] NATIVE line [-1]
*FUNCTION [onScriptLoad()] scripts/main.nut line [255]
LOCALS
[this] INSTANCE
[myDiscord] NULL
[vargv] ARRAY
[this] TABLE
[this] TABLE
AN ERROR HAS OCCURED [the index 'SqDiscord' does not exist]
CALLSTACK
*FUNCTION [onScriptLoad()] scripts/main.nut line [255]
LOCALS
[this] TABLE

double load
[MODULE] Loaded Discord Connector for VC:MP 0.4 by Luckshya.
[MODULE] Loaded Discord Connector for VC:MP 0.4 by Luckshya.