forked from Fascinated/Bat
Compare commits
No commits in common. "9a1d011ff2853c05181e838d507842220c50729b" and "5c7a067f7a3a93ca98f3ec3491f1a3929aea5d26" have entirely different histories.
9a1d011ff2
...
5c7a067f7a
@ -16,7 +16,7 @@ import java.util.Objects;
|
|||||||
|
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@Log4j2(topic = "Bat")
|
@Log4j2(topic = "Ember")
|
||||||
public class BatApplication {
|
public class BatApplication {
|
||||||
public static Gson GSON = new GsonBuilder().create();
|
public static Gson GSON = new GsonBuilder().create();
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package cc.fascinated.bat.command.impl.avatar;
|
package cc.fascinated.bat.command.impl;
|
||||||
|
|
||||||
import cc.fascinated.bat.command.BatSubCommand;
|
import cc.fascinated.bat.command.BatCommand;
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
import cc.fascinated.bat.command.CommandInfo;
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
@ -15,23 +15,20 @@ import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nick (okNick)
|
* @author Fascinated (fascinated7)
|
||||||
*/
|
*/
|
||||||
@Component("avatar:user.sub")
|
@Component
|
||||||
@CommandInfo(name = "user", description = "View the avatar of a user", guildOnly = false)
|
@CommandInfo(name = "avatar", description = "Get the avatar of a user", guildOnly = false)
|
||||||
public class UserSubCommand extends BatSubCommand {
|
public class AvatarCommand extends BatCommand {
|
||||||
public UserSubCommand() {
|
public AvatarCommand() {
|
||||||
super.addOption(OptionType.USER, "user", "The user to view the avatar of", true);
|
super.addOption(OptionType.USER, "user", "The user to get the avatar of", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
||||||
OptionMapping userOption = interaction.getOption("user");
|
OptionMapping userOption = interaction.getOption("user");
|
||||||
if (userOption == null) {
|
if (userOption == null) {
|
||||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
interaction.reply("You must provide a user to get the avatar of!").queue();
|
||||||
.setDescription("You must provide a user to view the avatar of!")
|
|
||||||
.build())
|
|
||||||
.queue();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
package cc.fascinated.bat.command.impl.avatar;
|
|
||||||
|
|
||||||
import cc.fascinated.bat.command.BatCommand;
|
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Nick (okNick)
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@CommandInfo(name = "avatar", description = "View the avatar of the guild or a user")
|
|
||||||
public class AvatarCommand extends BatCommand {
|
|
||||||
@Autowired
|
|
||||||
public AvatarCommand(@NonNull ApplicationContext context) {
|
|
||||||
super.addSubCommand(context.getBean(GuildSubCommand.class));
|
|
||||||
super.addSubCommand(context.getBean(UserSubCommand.class));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
package cc.fascinated.bat.command.impl.avatar;
|
|
||||||
|
|
||||||
import cc.fascinated.bat.command.BatSubCommand;
|
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
|
||||||
import cc.fascinated.bat.model.BatUser;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
|
||||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
|
||||||
import net.dv8tion.jda.api.utils.ImageProxy;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Nick (okNick)
|
|
||||||
*/
|
|
||||||
@Component("avatar:guild.sub")
|
|
||||||
@CommandInfo(name = "guild", description = "View the avatar of the guild")
|
|
||||||
public class GuildSubCommand extends BatSubCommand {
|
|
||||||
@Override
|
|
||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
|
||||||
ImageProxy icon = guild.getDiscordGuild().getIcon();
|
|
||||||
|
|
||||||
if (icon == null) {
|
|
||||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
|
||||||
.setDescription("%s does not have an avatar!".formatted(guild.getName()))
|
|
||||||
.build())
|
|
||||||
.queue();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
interaction.replyEmbeds(EmbedUtils.genericEmbed()
|
|
||||||
.setAuthor("%s's Avatar".formatted(guild.getName()), null, guild.getDiscordGuild().getIconUrl())
|
|
||||||
.setImage(icon.getUrl(4096))
|
|
||||||
.build()
|
|
||||||
).queue();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package cc.fascinated.bat.command.impl.banner;
|
|
||||||
|
|
||||||
import cc.fascinated.bat.command.BatCommand;
|
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Nick (okNick)
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@CommandInfo(name = "banner", description = "View the banner of the guild or a user")
|
|
||||||
public class BannerCommand extends BatCommand {
|
|
||||||
@Autowired
|
|
||||||
public BannerCommand(@NonNull ApplicationContext context) {
|
|
||||||
super.addSubCommand(context.getBean(GuildSubCommand.class));
|
|
||||||
super.addSubCommand(context.getBean(UserSubCommand.class));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
package cc.fascinated.bat.command.impl.banner;
|
|
||||||
|
|
||||||
import cc.fascinated.bat.command.BatSubCommand;
|
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
|
||||||
import cc.fascinated.bat.model.BatUser;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
|
||||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
|
||||||
import net.dv8tion.jda.api.utils.ImageProxy;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Nick (okNick)
|
|
||||||
*/
|
|
||||||
@Component("banner:guild.sub")
|
|
||||||
@CommandInfo(name = "guild", description = "View the banner of the guild")
|
|
||||||
public class GuildSubCommand extends BatSubCommand {
|
|
||||||
@Override
|
|
||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
|
||||||
ImageProxy banner = guild.getDiscordGuild().getBanner();
|
|
||||||
|
|
||||||
if (banner == null) {
|
|
||||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
|
||||||
.setDescription("%s does not have a banner!".formatted(guild.getName()))
|
|
||||||
.build())
|
|
||||||
.queue();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
interaction.replyEmbeds(EmbedUtils.genericEmbed()
|
|
||||||
.setAuthor("%s's Banner".formatted(guild.getName()))
|
|
||||||
.setImage(banner.getUrl(512))
|
|
||||||
.build()
|
|
||||||
).queue();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package cc.fascinated.bat.command.impl.banner;
|
|
||||||
|
|
||||||
import cc.fascinated.bat.command.BatSubCommand;
|
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
|
||||||
import cc.fascinated.bat.model.BatUser;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
|
||||||
import net.dv8tion.jda.api.entities.User;
|
|
||||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
|
||||||
import net.dv8tion.jda.api.utils.ImageProxy;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Nick (okNick)
|
|
||||||
*/
|
|
||||||
@Component("banner:user.sub")
|
|
||||||
@CommandInfo(name = "user", description = "View the banner of a user", guildOnly = false)
|
|
||||||
public class UserSubCommand extends BatSubCommand {
|
|
||||||
public UserSubCommand() {
|
|
||||||
super.addOption(OptionType.USER, "user", "The user to view the banner of", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
|
||||||
OptionMapping userOption = interaction.getOption("user");
|
|
||||||
if (userOption == null) {
|
|
||||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
|
||||||
.setDescription("You must provide a user to view the banner of!")
|
|
||||||
.build())
|
|
||||||
.queue();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
User target = userOption.getAsUser();
|
|
||||||
ImageProxy banner = target.retrieveProfile().complete().getBanner();
|
|
||||||
|
|
||||||
if (banner == null) {
|
|
||||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
|
||||||
.setDescription("%s does not have a banner!".formatted(target.getName()))
|
|
||||||
.build())
|
|
||||||
.queue();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
interaction.replyEmbeds(EmbedUtils.genericEmbed()
|
|
||||||
.setAuthor("%s's Banner".formatted(target.getName()))
|
|
||||||
.setImage(banner.getUrl(512))
|
|
||||||
.build()
|
|
||||||
).queue();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package cc.fascinated.bat.command.impl.server;
|
|
||||||
|
|
||||||
import cc.fascinated.bat.command.BatCommand;
|
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
|
||||||
import cc.fascinated.bat.model.BatUser;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
|
||||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Nick (okNick)
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@CommandInfo(name = "membercount", description = "View the member count of the server!")
|
|
||||||
public class MemberCountCommand extends BatCommand {
|
|
||||||
@Override
|
|
||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
|
||||||
EmbedBuilder embed = EmbedUtils.genericEmbed().setAuthor("Member Count");
|
|
||||||
Guild discordGuild = guild.getDiscordGuild();
|
|
||||||
embed.setDescription(discordGuild.getName() + " has a total of " + discordGuild.getMembers().size() + " members.");
|
|
||||||
interaction.replyEmbeds(embed.build()).queue();
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,12 +3,14 @@ package cc.fascinated.bat.command.impl.server;
|
|||||||
import cc.fascinated.bat.command.BatCommand;
|
import cc.fascinated.bat.command.BatCommand;
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
import cc.fascinated.bat.command.CommandInfo;
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
|
import cc.fascinated.bat.common.TimeUtils;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||||
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
package cc.fascinated.bat.command.impl.server.channel;
|
|
||||||
|
|
||||||
import cc.fascinated.bat.command.BatCommand;
|
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Nick (okNick)
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@CommandInfo(name = "channel", description = "View or set information about a channel")
|
|
||||||
public class ChannelCommand extends BatCommand {
|
|
||||||
@Autowired
|
|
||||||
public ChannelCommand(@NonNull ApplicationContext context) {
|
|
||||||
super.addSubCommand(context.getBean(ViewTopicSubCommand.class));
|
|
||||||
super.addSubCommand(context.getBean(SetTopicSubCommand.class));
|
|
||||||
super.addSubCommand(context.getBean(RemoveTopicSubCommand.class));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
package cc.fascinated.bat.command.impl.server.channel;
|
|
||||||
|
|
||||||
import cc.fascinated.bat.command.BatSubCommand;
|
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
|
||||||
import cc.fascinated.bat.model.BatUser;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import net.dv8tion.jda.api.Permission;
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
|
||||||
import net.dv8tion.jda.api.entities.channel.Channel;
|
|
||||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
|
||||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Nick (okNick)
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@CommandInfo(name = "removetopic", description = "Remove the topic of a channel", requiredPermissions = Permission.MANAGE_CHANNEL)
|
|
||||||
public class RemoveTopicSubCommand extends BatSubCommand {
|
|
||||||
public RemoveTopicSubCommand() {
|
|
||||||
super.addOption(OptionType.CHANNEL, "channel", "The channel to remove the topic of", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
|
||||||
Channel target = interaction.getOption("channel") == null ? channel : interaction.getOption("channel").getAsChannel();
|
|
||||||
if (!(target instanceof TextChannel textChannel)) {
|
|
||||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
|
||||||
.setDescription("<#%s> is not a text channel!".formatted(target.getId()))
|
|
||||||
.build())
|
|
||||||
.queue();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (textChannel.getTopic() == null) {
|
|
||||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
|
||||||
.setDescription("<#%s> does not have a topic!".formatted(textChannel.getId()))
|
|
||||||
.build())
|
|
||||||
.queue();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
textChannel.getManager().setTopic(null).queue();
|
|
||||||
interaction.replyEmbeds(EmbedUtils.successEmbed()
|
|
||||||
.setDescription("Successfully removed the topic of <#%s>".formatted(textChannel.getId()))
|
|
||||||
.build()
|
|
||||||
).queue();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
package cc.fascinated.bat.command.impl.server.channel;
|
|
||||||
|
|
||||||
import cc.fascinated.bat.command.BatSubCommand;
|
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
|
||||||
import cc.fascinated.bat.model.BatUser;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import net.dv8tion.jda.api.Permission;
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
|
||||||
import net.dv8tion.jda.api.entities.channel.Channel;
|
|
||||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
|
||||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Nick (okNick)
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@CommandInfo(name = "settopic", description = "Set the topic of a channel", requiredPermissions = Permission.MANAGE_CHANNEL)
|
|
||||||
public class SetTopicSubCommand extends BatSubCommand {
|
|
||||||
public SetTopicSubCommand() {
|
|
||||||
super.addOption(OptionType.STRING, "topic", "The topic to set", true);
|
|
||||||
super.addOption(OptionType.CHANNEL, "channel", "The channel to set the topic of", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
|
||||||
Channel target = interaction.getOption("channel") == null ? channel : interaction.getOption("channel").getAsChannel();
|
|
||||||
if (!(target instanceof TextChannel textChannel)) {
|
|
||||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
|
||||||
.setDescription("<#%s> is not a text channel!".formatted(target.getId()))
|
|
||||||
.build())
|
|
||||||
.queue();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String topic = interaction.getOption("topic").getAsString();
|
|
||||||
if (topic.length() > 1024) {
|
|
||||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
|
||||||
.setDescription("The topic must be less than 1024 characters!")
|
|
||||||
.build())
|
|
||||||
.queue();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
textChannel.getManager().setTopic(topic).queue();
|
|
||||||
interaction.replyEmbeds(EmbedUtils.successEmbed()
|
|
||||||
.setDescription("Successfully set the topic of <#%s> to: \"%s\"".formatted(textChannel.getId(), topic))
|
|
||||||
.build()
|
|
||||||
).queue();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
package cc.fascinated.bat.command.impl.server.channel;
|
|
||||||
|
|
||||||
import cc.fascinated.bat.command.BatSubCommand;
|
|
||||||
import cc.fascinated.bat.command.CommandInfo;
|
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
|
||||||
import cc.fascinated.bat.model.BatUser;
|
|
||||||
import lombok.NonNull;
|
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
|
||||||
import net.dv8tion.jda.api.entities.channel.Channel;
|
|
||||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
|
||||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Nick (okNick)
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@CommandInfo(name = "viewtopic", description = "View the topic of a channel")
|
|
||||||
public class ViewTopicSubCommand extends BatSubCommand {
|
|
||||||
public ViewTopicSubCommand() {
|
|
||||||
super.addOption(OptionType.CHANNEL, "channel", "The channel to view the topic of", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
|
|
||||||
Channel target = interaction.getOption("channel") == null ? channel : interaction.getOption("channel").getAsChannel();
|
|
||||||
if (!(target instanceof TextChannel textChannel)) {
|
|
||||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
|
||||||
.setDescription("<#%s> is not a text channel!".formatted(target.getId()))
|
|
||||||
.build())
|
|
||||||
.queue();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String topic = textChannel.getTopic();
|
|
||||||
if (topic == null) {
|
|
||||||
interaction.replyEmbeds(EmbedUtils.errorEmbed()
|
|
||||||
.setDescription("<#%s> does not have a topic!".formatted(textChannel.getId()))
|
|
||||||
.build())
|
|
||||||
.queue();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
interaction.replyEmbeds(EmbedUtils.genericEmbed()
|
|
||||||
.setDescription("The topic of <#%s> is: \"%s\"".formatted(textChannel.getId(), topic))
|
|
||||||
.build()
|
|
||||||
).queue();
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,10 +2,12 @@ package cc.fascinated.bat.model;
|
|||||||
|
|
||||||
import cc.fascinated.bat.common.ProfileHolder;
|
import cc.fascinated.bat.common.ProfileHolder;
|
||||||
import cc.fascinated.bat.service.DiscordService;
|
import cc.fascinated.bat.service.DiscordService;
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.mongodb.core.mapping.Document;
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package cc.fascinated.bat.service;
|
package cc.fascinated.bat.service;
|
||||||
|
|
||||||
import cc.fascinated.bat.Consts;
|
import cc.fascinated.bat.Consts;
|
||||||
import cc.fascinated.bat.command.BatCommand;
|
import cc.fascinated.bat.command.*;
|
||||||
import cc.fascinated.bat.command.BatCommandExecutor;
|
|
||||||
import cc.fascinated.bat.command.BatSubCommand;
|
|
||||||
import cc.fascinated.bat.command.Category;
|
|
||||||
import cc.fascinated.bat.common.EmbedUtils;
|
import cc.fascinated.bat.common.EmbedUtils;
|
||||||
import cc.fascinated.bat.model.BatGuild;
|
import cc.fascinated.bat.model.BatGuild;
|
||||||
import cc.fascinated.bat.model.BatUser;
|
import cc.fascinated.bat.model.BatUser;
|
||||||
@ -78,10 +75,10 @@ public class CommandService extends ListenerAdapter {
|
|||||||
|
|
||||||
// Unregister all commands that Discord has but we don't
|
// Unregister all commands that Discord has but we don't
|
||||||
jda.retrieveCommands().complete().forEach(command -> {
|
jda.retrieveCommands().complete().forEach(command -> {
|
||||||
BatCommand batCommand = commands.get(command.getName());
|
CommandInfo commandInfo = commands.get(command.getName()).getCommandInfo();
|
||||||
if (batCommand == null) {
|
if (commands.containsKey(command.getName()) && (commandInfo.category().isHidden() || commandInfo.botOwnerOnly())) {
|
||||||
jda.deleteCommandById(command.getId()).complete(); // Unregister the command on Discord
|
jda.deleteCommandById(command.getId()).complete(); // Unregister the command on Discord
|
||||||
log.info("Unregistered unknown command \"{}\" from Discord", command.getName());
|
log.info("Unregistered hidden command \"{}\" from Discord", command.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (commands.containsKey(command.getName())) {
|
if (commands.containsKey(command.getName())) {
|
||||||
|
@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.context.annotation.DependsOn;
|
import org.springframework.context.annotation.DependsOn;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user