Created
March 10, 2019 10:52
-
-
Save Luckshya/a6554f7e655a8b38d459e3f2482a1828 to your computer and use it in GitHub Desktop.
Example discord code for official squirrel plugin (sleepy-discord)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//open connection to discord | |
discordConn <- Discord_Open("token here"); | |
//event onDiscord_Ready indicating that the bot has connected successfully | |
function onDiscord_Ready(discordHandle) { | |
//retrieve our connection ID | |
local connID = Discord_ConnID(discordHandle); | |
print("Discord bot at ID: " + connID + " is ready."); | |
//send a messsage | |
Discord_Message(discordConn, "channel ID", "message here"); //you can use discordHandle as well | |
} | |
//event onDiscord_Message when a message to recieved to an accessible channel to bot | |
function onDiscord_Message(discordHandle, channelID, authorID, authorNick, author, roles, message) { | |
//retrieve our connection ID | |
local connID = Discord_ConnID(discordHandle); | |
print("Discord bot at ID: " + connID + " has recieved a message."); | |
print("ChannelID: " + channelID); | |
print("Author: " + author); | |
print("Author Nick: " + authorNick); | |
print("Author ID: " + authorID); | |
print("Message: " + message); | |
foreach(role in roles) { | |
print("Role: " + role); | |
print("Role Name: " + Discord_GetRoleName(discordHandle, "server ID", role)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment