Implement basic say 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:
@@ -6,13 +6,10 @@ import net.dv8tion.jda.api.interactions.commands.Command;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import wtf.beatrice.hidekobot.Configuration;
|
||||
import wtf.beatrice.hidekobot.HidekoBot;
|
||||
import wtf.beatrice.hidekobot.utils.TimeUtil;
|
||||
import wtf.beatrice.hidekobot.utils.FormatUtil;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
|
||||
public class BotInfoCommand
|
||||
@@ -75,12 +72,12 @@ public class BotInfoCommand
|
||||
embedBuilder.addField("Author", authorMention, true);
|
||||
|
||||
// uptime field
|
||||
embedBuilder.addField("Uptime", TimeUtil.getNiceUptime(), true);
|
||||
embedBuilder.addField("Uptime", FormatUtil.getNiceUptime(), true);
|
||||
|
||||
// issue tracker field
|
||||
embedBuilder.addField("Support",
|
||||
"[Issue tracker](https://git.beatrice.wtf/mind-overflow/HidekoBot/issues)",
|
||||
true);
|
||||
true); //todo: we should probably make this a final field in the config class
|
||||
}
|
||||
|
||||
event.getHook().editOriginalEmbeds(embedBuilder.build()).queue();
|
||||
|
@@ -38,8 +38,8 @@ public class ClearChatCommand
|
||||
/* get the amount from the command args.
|
||||
NULL should not be possible because we specified them as mandatory,
|
||||
but apparently the mobile app doesn't care and still sends the command if you omit the args. */
|
||||
OptionMapping amountMapping = event.getOption("amount");
|
||||
int toDeleteAmount = amountMapping == null ? 1 : amountMapping.getAsInt();
|
||||
OptionMapping amountOption = event.getOption("amount");
|
||||
int toDeleteAmount = amountOption == null ? 1 : amountOption.getAsInt();
|
||||
|
||||
if(toDeleteAmount <= 0)
|
||||
{
|
||||
|
@@ -0,0 +1,36 @@
|
||||
package wtf.beatrice.hidekobot.commands.slash;
|
||||
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SayCommand
|
||||
{
|
||||
|
||||
public void runSlashCommand(@NotNull SlashCommandInteractionEvent event)
|
||||
{
|
||||
MessageChannel channel = event.getChannel();
|
||||
|
||||
// get the text to send
|
||||
OptionMapping textOption = event.getOption("text");
|
||||
String messageContent = "";
|
||||
if(textOption != null)
|
||||
{
|
||||
messageContent = textOption.getAsString();
|
||||
}
|
||||
|
||||
if(textOption == null || messageContent.isEmpty())
|
||||
{
|
||||
event.reply("Hey, you have to tell me what to say!")
|
||||
.setEphemeral(true)
|
||||
.queue();
|
||||
return;
|
||||
}
|
||||
|
||||
channel.sendMessage(messageContent).queue();
|
||||
event.reply("Message sent!")
|
||||
.setEphemeral(true)
|
||||
.queue();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user