Implement invite link command
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
b14850acaa
commit
18db0282d5
@ -12,6 +12,11 @@ public class Configuration
|
||||
// todo: allow people to set their own user id
|
||||
private static final long botOwnerId = 979809420714332260L;
|
||||
|
||||
private final static String defaultInviteLink =
|
||||
"https://discord.com/api/oauth2/authorize?client_id=%userid%&scope=bot+applications.commands&permissions=8";
|
||||
|
||||
private static String botUserId = "";
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the bot has been started with the verbose argument.
|
||||
@ -54,4 +59,15 @@ public class Configuration
|
||||
*/
|
||||
public static long getBotOwnerId() { return botOwnerId; }
|
||||
|
||||
public static void seBotUserId(String id)
|
||||
{
|
||||
botUserId = id;
|
||||
}
|
||||
|
||||
public static String getBotUserId() { return botUserId; }
|
||||
|
||||
public static String getInviteUrl() {
|
||||
return defaultInviteLink.replace("%userid%", botUserId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,9 +20,6 @@ import java.util.concurrent.TimeUnit;
|
||||
public class HidekoBot
|
||||
{
|
||||
private static String botToken;
|
||||
private static String standardInviteLink =
|
||||
"https://discord.com/oauth2/authorize?client_id=%userid%&scope=bot+applications.commands&permissions=8";
|
||||
private static String botUserId;
|
||||
private static final String version = "0.0.2-slash"; // we should probably find a way to make this consistent with Maven
|
||||
|
||||
private static JDA jda;
|
||||
@ -64,8 +61,8 @@ public class HidekoBot
|
||||
}
|
||||
|
||||
// find the bot's user id and generate an invite-link.
|
||||
botUserId = jda.getSelfUser().getId();
|
||||
standardInviteLink = standardInviteLink.replace("%userid%", botUserId);
|
||||
String botUserId = jda.getSelfUser().getId();
|
||||
Configuration.seBotUserId(botUserId);
|
||||
|
||||
// register listeners
|
||||
jda.addEventListener(new MessageListener());
|
||||
@ -94,7 +91,7 @@ public class HidekoBot
|
||||
|
||||
// log the invite-link to console so noob users can just click on it.
|
||||
logger.log("Bot User ID: " + botUserId, 3);
|
||||
logger.log("Invite Link: " + standardInviteLink, 4);
|
||||
logger.log("Invite Link: " + Configuration.getInviteUrl(), 4);
|
||||
|
||||
}
|
||||
public static JDA getAPI()
|
||||
|
@ -20,7 +20,7 @@ public class MessageListener extends ListenerAdapter
|
||||
if(eventMessage.equalsIgnoreCase("hideko"))
|
||||
{
|
||||
MessageChannel channel = event.getChannel();
|
||||
channel.sendMessage("Hello there! :sparkles:").queue();
|
||||
channel.sendMessage("Hello there! ✨").queue();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,7 @@ package wtf.beatrice.hidekobot.listeners;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import wtf.beatrice.hidekobot.slashcommands.ClearChatCommand;
|
||||
import wtf.beatrice.hidekobot.slashcommands.CoinFlipCommand;
|
||||
import wtf.beatrice.hidekobot.slashcommands.DieCommand;
|
||||
import wtf.beatrice.hidekobot.slashcommands.PingCommand;
|
||||
import wtf.beatrice.hidekobot.slashcommands.*;
|
||||
|
||||
public class SlashCommandListener extends ListenerAdapter
|
||||
{
|
||||
@ -18,6 +15,7 @@ public class SlashCommandListener extends ListenerAdapter
|
||||
case "clear" -> new ClearChatCommand(event);
|
||||
case "coinflip" -> new CoinFlipCommand(event);
|
||||
case "die" -> new DieCommand(event);
|
||||
case "invite" -> new InviteCommand(event);
|
||||
case "ping" -> new PingCommand(event);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class DieCommand
|
||||
{
|
||||
event.reply("Sorry, only the bot owner can run this command!").setEphemeral(true).queue();
|
||||
} else {
|
||||
event.reply("Going to sleep! Cya :sparkles:").queue();
|
||||
event.reply("Going to sleep! Cya ✨").queue();
|
||||
Executors.newSingleThreadScheduledExecutor().schedule(HidekoBot::shutdown, 3, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package wtf.beatrice.hidekobot.slashcommands;
|
||||
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import wtf.beatrice.hidekobot.Configuration;
|
||||
|
||||
public class InviteCommand
|
||||
{
|
||||
public InviteCommand(@NotNull SlashCommandInteractionEvent event)
|
||||
{
|
||||
event.reply("Here's your link ✨ " + Configuration.getInviteUrl()).setEphemeral(true).queue();
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@ public class SlashCommandsUtil
|
||||
.addOption(OptionType.INTEGER, "amount", "The amount of messages to delete.")
|
||||
.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MESSAGE_MANAGE)));
|
||||
add(Commands.slash("coinflip", "Flip a coin and get head or tails."));
|
||||
add(Commands.slash("invite", "Get an invite link for the bot."));
|
||||
add(Commands.slash("ping", "Test if the bot is responsive."));
|
||||
}};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user