|
Note: this guide is outdated. PM me for updated guide.
First off, this is very basic, and is intended to be. It's just for people that weren't sure how this was done, or for people looking for very basic functionality
I have written a VERY basic library that utilises the Discord4J library to make a Discord Bot.
https://discordapp.com/developers/applications/me
Follow this link and create a new Application giving it your desired name and profile picture.
Once you are finished, you will be at this screen:
Click on 'Create a Bot User', and you will now get this:
Click to reveal the token and save this somewhere. DO NOT GIVE THIS OUT OTHERWISE PEOPLE WILL BE ABLE TO LOGIN TO YOUR BOT.
Also save the client ID that is up top.
Your discord bot has now been created.
Now you need to add it to your discord channel.
Following this link will add your bot to a guild, replacing client_id with the client id we got earlier, and using this page to find out the permission flag: https://discordapp.com/developers/do...cs/permissions
Note: If you are unsure about the permission flag, using 0x00000008 will give your bot administrative permissions. Beware as this is giving your bot full access.
Also Note: Doing this requires you to have 'Manage Server' permissions on whatever channel you are trying to add it to.
https://discordapp.com/api/oauth2/au...RMISSIONS_FLAG
Now you can use this library to add it to your RSPS:
Spoiler for Download:
Make sure you add the Discord4J library to your classpath as well! Instructions can be found here: https://github.com/austinv11/Discord4J
At the moment this is very basic and will only allow you to add different commands. This cannot currently link in-game accounts with discord accounts, or anything like that, didn't feel like adding that into something this basic.
If enough people want it though I can add more functionality.
Usage: (where CLIENT_TOKEN = the token we got earlier)
This is what DefaultCommandListener looks like:Code:DiscordBot bot = new DiscordBot(DiscordSettings.build("CLIENT_TOKEN")); bot.run(); bot.registerCommandListener(new DefaultCommandListener(bot, "."));
I wrote this in about 20 minutes, but I don't really see there being any errors, it's pretty basic.Code:package com.cryo; import com.cryo.listener.CommandListener; import sx.blah.discord.handle.obj.IMessage; public class DefaultCommandListener extends CommandListener { public DefaultCommandListener(DiscordBot bot, String commandPrefix) { super(bot, commandPrefix); } @Override public void handleCommand(IMessage message, String command, String[] cmd) { cmd[0] = cmd[0].toLowerCase(); String channelId = message.getChannel().getID(); switch(cmd[0]) { case "test": String author_id = message.getAuthor().getID(); bot.deleteMessage(message); bot.sendMessage(channelId, "UserID: "+author_id); break; } } }
goodjob ! will def help some people
Thanks will help me a lot bro
nice release Cody
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |