Step 1. Create a discord bot and invite it to your server. [Only registered and activated users can see links. Click Here To Register...] Make sure to take note of your bot token (should look something like this: NzEyODgxMDE4HTgxNDQ5NzQ4.XsYAFQ.wBlWybN5UHDHL1XG35 imelotpCw! )
Step 2. Create separate channels for whatever you want in discord. I'll go over logging regular chat to discord, logging in and out of the server, clan chat to discord, joining and leaving a clan, as well as sending messages back from discord to the server or to a clan chat.
if (!VencillioConstants.DEV_MODE) {
try {
MembershipRewards.prepare();
HiscoreUpdater.prepare();
VoteUpdater.prepare();
} catch (Exception ex) {
ex.printStackTrace();
}
Add this bit of code and get ready to modify some stuff:
Code:
//discord
GameDataLoader.discord = new DiscordApiBuilder().setToken("THE BOT TOKEN YOU SAVED IN THE BEGINNING").login().join();
TextChannel mainChannel = (TextChannel) GameDataLoader.discord.getChannelById("ID OF WHATEVER CHANNEL(THIS IS MY MAIN CHAT)").get();
TextChannel helpChannel = (TextChannel) GameDataLoader.discord.getChannelById("ID OF WHATEVER CHANNEL(THIS IS A HELP CLAN CHAT CHANNEL)").get();
GameDataLoader.discord.addMessageCreateListener(event -> {
if (event.isServerMessage() && event.getChannel().equals(mainChannel)) {
//yell
if(!event.getMessageAuthor().isBotUser()) {
String text = "[Discord]"+event.getMessageAuthor().getDisplayName()+": "+event.getMessageContent().toString();
String[] strings = text.split("(?<=\\G.{75,}\\s)");
if(strings.length > 4) {
event.getChannel().sendMessage("Your message was too long and therefore not sent, "+event.getMessageAuthor().asUser().get().getMentionTag());
} else {
Boolean tooLong = false;
for (String s : strings) {
if (s.length() > 100) {
tooLong = true;
}
}
if (tooLong) {
event.getChannel().sendMessage("Your message was too long and therefore not sent, "+event.getMessageAuthor().asUser().get().getMentionTag());
} else {
for (String s : strings) {
World.sendGlobalMessage("@[email protected]"+s);
}
}
}
}
}
if (event.isServerMessage() && event.getChannel().equals(helpChannel)) {
if(!event.getMessageAuthor().isBotUser()) {
Clan helpcc = clanManager.getClan("OWNER OF CLAN");
String text = "</col>[@[email protected]" + helpcc.getTitle() + "</col>] "+"[Discord]"+event.getMessageAuthor().getDisplayName()+": @[email protected]"+event.getMessageContent().toString();
String[] strings = text.split("(?<=\\G.{75,}\\s)");
if(strings.length > 4) {
event.getChannel().sendMessage("Your message was too long and therefore not sent, "+event.getMessageAuthor().asUser().get().getMentionTag());
}
else {
Boolean tooLong = false;
for (String s : strings) {
if (s.length() > 100) {
tooLong = true;
}
}
if (tooLong) {
event.getChannel().sendMessage("Your message was too long and therefore not sent, "+event.getMessageAuthor().asUser().get().getMentionTag());
} else {
for (String s : strings) {
You will need to change 4 strings:
1. "THE BOT TOKEN YOU SAVED IN THE BEGINNING"
2. "ID OF WHATEVER CHANNEL(THIS IS MY MAIN CHAT)"
3. "ID OF WHATEVER CHANNEL(THIS IS A HELP CLAN CHAT CHANNEL)"
4. "OWNER OF CLAN"
Step 4. Public chat messages going to discord.
Open com/vencillio/rs2/entity/player/net/in/impl/PublicChatPacket.java
paramPlayer.getClient().queueOutgoingPacket(new SendString("Leave chat", 18135));
paramPlayer.getClient().queueOutgoingPacket(new SendString("</col>Talking in: <col=FFFF64><shad=0>" + getTitle(), 18139));
paramPlayer.getClient().queueOutgoingPacket(new SendString("</col>Owner: <col=FFFF64><shad=0>" + Utility.formatPlayerName(getFounder()), 18140));
paramPlayer.getClient().queueOutgoingPacket(new SendMessage("Attempting to join clan channel..."));
paramPlayer.getClient().queueOutgoingPacket(new SendMessage("Now talking in clan chat <col=FFFF64><shad=0>" + getTitle() + "</shad></col>."));
paramPlayer.getClient().queueOutgoingPacket(new SendMessage("To talk, start each line of chat with the / symbol."));
updateMembers();
Add this bit of code and change "OWNER OF CLAN" to the owner of the clan chat you want discord messages sent to and from, and change "DISCORD CLAN CHANNEL ID" to the id of the clan channel on discord.
Code:
if (this.founder.equalsIgnoreCase("OWNER OF CLAN")) {
//discord
Player player = paramPlayer;
TextChannel channel = (TextChannel) GameDataLoader.discord.getChannelById("DISCORD CLAN CHANNEL ID").get();
String ts = "";
ts = ts + player.getUsername()+" has joined the clan chat.";
channel.sendMessage("**"+ts+"**");
}
Under this bit of code:
Code:
public void removeMember(Player paramPlayer) {
for (int i = 0; i < this.activeMembers.size(); i++) {
if (this.activeMembers.get(i).equalsIgnoreCase(paramPlayer.getUsername())) {
Add this bit of code and change "OWNER OF CLAN" to the owner of the clan chat you want discord messages sent to and from, and change "DISCORD CLAN CHANNEL ID" to the id of the clan channel on discord.
Code:
if (this.founder.equalsIgnoreCase("OWNER OF CLAN")) {
//discord
Player player = paramPlayer;
TextChannel channel = (TextChannel) GameDataLoader.discord.getChannelById("DISCORD CLAN CHANNEL ID").get();
String ts = "";
ts = ts + player.getUsername()+" has left the clan chat.";
channel.sendMessage("**"+ts+"**");
}
Under this bit of code:
Code:
public void removeMember(String paramString) {
for (int i = 0; i < this.activeMembers.size(); i++) {
if (this.activeMembers.get(i).equalsIgnoreCase(paramString)) {
Player localPlayer = World.getPlayerByName(paramString);
if (localPlayer != null) {
Add this bit of code and change "OWNER OF CLAN" to the owner of the clan chat you want discord messages sent to and from, and change "DISCORD CLAN CHANNEL ID" to the id of the clan channel on discord.
Code:
if (this.founder.equalsIgnoreCase("OWNER OF CLAN")) {
//discord
Player player = localPlayer;
TextChannel channel = (TextChannel) GameDataLoader.discord.getChannelById("DISCORD CLAN CHANNEL ID").get();
String ts = "";
ts = ts + player.getUsername()+" has left the help chat.";
channel.sendMessage("**"+ts+"**");
}
Under this bit of code:
Code:
if (paramPlayer.isMuted()) {
if (paramPlayer.getMuteLength() == -1) {
paramPlayer.send(new SendMessage("You are permanently muted on this account."));
return;
} else {
long muteHours = TimeUnit.MILLISECONDS.toMinutes(paramPlayer.getMuteLength() - System.currentTimeMillis());
String timeUnit = "hour" + (muteHours > 1 ? "s" : "");
if (muteHours < 60) {
if (muteHours <= 0) {
paramPlayer.send(new SendMessage("Your mute has been lifted!"));
paramPlayer.setMuted(false);
}
timeUnit = "minute" + (muteHours > 1 ? "s" : "");
} else {
muteHours = TimeUnit.MINUTES.toHours(muteHours);
}
if (paramPlayer.isMuted()) {
paramPlayer.send(new SendMessage("You are muted, you will be unmuted in " + muteHours + " " + timeUnit + "."));
return;
}
}
}
Add this bit of code and change "OWNER OF CLAN" to the owner of the clan chat you want discord messages sent to and from, and change "DISCORD CLAN CHANNEL ID" to the id of the clan channel on discord.
Code:
if (this.founder.equalsIgnoreCase("OWNER OF CLAN")) {
//discord
Player player = paramPlayer;
TextChannel channel = (TextChannel) GameDataLoader.discord.getChannelById("DISCORD CLAN CHANNEL ID").get();
String ts = "";
ts = ts + player.getUsername()+": ";
channel.sendMessage("**"+ts+"**"+"`"+paramString+"`");
}
If you have any questions feel free to post them below, I will try my best to answer. If there are any bugs or other problems like missed imports please let me know so I can update the guide. If you want me to do this with another source base, comment the link to the downloads section post of the source (I won't do anything that doesn't have many downloads just to be safe of viruses and such)
Thanks for sharing man, this is pretty cool. I'm going to try it out :)
05-27-2020, 07:02 PM
Herb
Credits for using my name? :kappa:
Looks dank!
05-27-2020, 09:23 PM
Nes
This is pretty cool haha!
05-28-2020, 12:44 AM
Pharaoh
Quote:
Originally Posted by Herb[Only registered and activated users can see links. Click Here To Register...]
Credits for using my name? :kappa:
Looks dank!
Lol, I re-used a bot I had made for a weed-related minecraft server I was dev on for a little while cuz I didn't feel like making a new one :P
Quote:
Originally Posted by Nes[Only registered and activated users can see links. Click Here To Register...]
This is pretty cool haha!
Thanks! Glad you like it :D
Quote:
Originally Posted by i dds you[Only registered and activated users can see links. Click Here To Register...]
Thanks for sharing man, this is pretty cool. I'm going to try it out :)
No problem and good luck!
05-28-2020, 03:14 AM
EliyahuRSPS
A HUGE Vouch for Pharaoh, easy to setup, easy to read. Definitely recommending this! ;)
05-28-2020, 07:20 PM
i dds you
Big thanks and vouch for this guy! I got a little confused over Discord ID's and he was kind enough to point me back on the right path, Works really well