Hello,
I've created a small tutorial, how to set-up your LFSLapper to communicate with your discordbot.
This tutorial will be extended with more code examples in the future.
You can PM me, if you have usefull code examples or more tips&tricks, i can add to this tutorial.
Asking for help with Discord will be ignored. Go To: https://www.lfs.net/forum/455-General-Support
I've created a small tutorial, how to set-up your LFSLapper to communicate with your discordbot.
This tutorial will be extended with more code examples in the future.
You can PM me, if you have usefull code examples or more tips&tricks, i can add to this tutorial.
Asking for help with Discord will be ignored. Go To: https://www.lfs.net/forum/455-General-Support
#1. Create a DiscordBot @ https://discord.com/developers/applications
Here is an tutorial how to setup your bot properly
https://www.ionos.com/digitalguide/server/know-how/creating-discord-bot/
#2. Once you've added your bot to your discord server, we can now configure LFSLapper to communicate with your discordbot.
#3. Open myInc.LPR (bin\default\includes\myInc.lpr) and fill in the 3 parameters
#####DISCORD API#####
$DiscordToken = ""; # Token to connect LFSLapper with Discord , This is a token with alot of characters
Example: NTY5MjU1234567890NTMy.G12345.36as1234lT9PcdFBd-9niSnIOabcDEFGHJ
$DiscordChannelReceive = ""; # This can be blank or you can add up to 5 discordchannels ID's for receiving LFSLapper messages, seperated with a comma "," .
The Discordchannel ID's can be found when you rightclick on the channel and click on "Copy Channel ID".
$DiscordBotStatus = "Powered by LFSLapper!";
#4. Start LFSLapper
When LFSLapper is connected to your LFS Server, you should see the message : "DiscordBot Connected" in your LFSLapper console.
This message also appears in the MSS log file. 'Bin/Default/Logs/xxx.xxx.xxx.xxx-yyyyy.LOG' if you do not have access to the console.
#5. To send message from LFSLapper to your Discord Server. You use the function: sendmessagetodiscord();
You can use this function in a command,sub or event.
Here's an example:
$DiscordChannel = "123456789012345457214";
$Message = "This is a test";
sendmessagetodiscord($DiscordChannel,$Message);
#6.1. To send an message from Discord To LFSLapper, you type a message in one of the discord channels
you've set @ step 3.
Those messagew will be executed in the LapperEvent named: OnReceiveDiscordMessage()
Open LFSLapper.LPR in the default folder and look for the event you see below.
Event OnReceiveDiscordMessage($ChannelID,$ChannelName,$UNameID,$UName,$Text)
#Your code
EndEvent
#6.2. Type and place the current line between Event and EndEvent
globalmsg("^3DiscordMsg: ^3".$Text);
#6.3. Write a message in the discordchannel and press enter.
You should see the message, you've written in your discordchannel.