Luckshya

  • Jr. Member
  • Posts: 96
Discord Plugin
«  »Last edited
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/Sq-DiscordPlugin2/wiki/
Example code: https://github.com/Luckshya/Sq-DiscordPlugin2/wiki/Example-Code

Source
Sleepy-Discord: https://github.com/yourWaifu/sleepy-discord
Plugin Source: https://github.com/Luckshya/Sq-DiscordPlugin2

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/Sq-DiscordPlugin2/releases

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

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

Credits

NOTE: You need to take care of the Discord rate limit yourself.
Re: Discord Plugin
« Reply #1,  »
Added function Regex_Match to check for special character/symbols for discord. More details in the main post.

Milos

  • Jr. Member
  • Posts: 83
Re: Discord Plugin
« Reply #2,  »
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

  • Jr. Member
  • Posts: 96
Re: Discord Plugin
« Reply #3,  »Last edited
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.
Re: Discord Plugin
« Reply #4,  »
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

  • Jr. Member
  • Posts: 83
Re: Discord Plugin
« Reply #5,  »
Quote from Luckshya on March 6th, 08:54 AM
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.
How useful is the authorNick if author already does this?
It returns nothing

Luckshya

  • Jr. Member
  • Posts: 96
Re: Discord Plugin
« Reply #6,  »
Quote from Pau Grosso on March 7th, 11:55 PM
How 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

  • Jr. Member
  • Posts: 83
Re: Discord Plugin
« Reply #7,  »
Quote from Luckshya on March 8th, 02:46 AM
Quote from Pau Grosso on March 7th, 11:55 PM
How 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

  • Jr. Member
  • Posts: 96
Re: Discord Plugin
« Reply #8,  »Last edited
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"
Re: Discord Plugin
« Reply #9,  »
Sleepy-discord binaries are now available.
Re: Discord Plugin
« Reply #10,  »
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.

DarkRaZoR^

  • Full Member
  • VC:MP Battlefield Head Developer/KF Leader
  • Posts: 213
Re: Discord Plugin
« Reply #11,  »
Quote from Luckshya on March 20th, 05:53 AM
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.
Yeah! :D

Milos

  • Jr. Member
  • Posts: 83
Re: Discord Plugin
« Reply #12,  »
Plugin error >> LoadLibrary() 'plugins/discord04rel64.dll' failed: Code 126
Failed to load plugin: discord04rel64

Luckshya

  • Jr. Member
  • Posts: 96
Re: Discord Plugin
« Reply #13,  »
Quote from Milos on March 26th, 01:56 PM
Plugin 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

  • Jr. Member
  • Posts: 83
Re: Discord Plugin
« Reply #14,  »Last edited
I was using the wrong version, but I have another problem: in Linux, the plugin loads, but I have errors
Code: [Select]
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 **
Code: [Select]
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
Code: [Select]
[MODULE] Loaded Discord Connector for VC:MP 0.4 by Luckshya.
[MODULE] Loaded Discord Connector for VC:MP 0.4 by Luckshya.