Skip to content

Instantly share code, notes, and snippets.

@Luckshya
Last active March 7, 2019 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Luckshya/567cf81e428b298d63a9818127975d4c to your computer and use it in GitHub Desktop.
Save Luckshya/567cf81e428b298d63a9818127975d4c to your computer and use it in GitHub Desktop.
class MyDiscord extends SqDiscord.Session
{
function constructor() {
// Call the base constructor to intialize the connection
base.constructor();
// Bind our events
base.Bind(SqDiscordEvent.Ready, this, onReady);
base.Bind(SqDiscordEvent.Message, this, onMessage);
}
// Event onReady (Very first event for doing discord related stuff)
function onReady() {
SqLog.Inf("Dicord bot connection established successfully.");
this.Message("channel ID", "message string"); //used to send a message to the specified channel
}
// Event onMessage is called when a message is recieved to an acessible channel to bot
function onMessage(channelID, author, authorNick, authorID, roles, message) {
SqLog.Inf("Channel: " + channelID);
SqLog.Inf("Author: " + author);
SqLog.Inf("Author Nick: " + authorNick);
SqLog.Inf("Author ID: " + authorID);
SqLog.Inf("Message: " + message);
foreach(role in roles) {
SqLog.Inf("Role: " + role);
SqLog.Inf("Role Name: " + this.GetRoleName("server ID", role));
}
}
}
// Create an instance of our Session
myDiscord <- MyDiscord();
// Makes connection to discord
myDiscord.Connect("token here");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment