add invite command

This commit is contained in:
Lee 2024-06-27 13:11:58 +01:00
parent 84dfe5a119
commit b50e30ffc5
2 changed files with 35 additions and 2 deletions

@ -0,0 +1,32 @@
package cc.fascinated.bat.command.impl;
import cc.fascinated.bat.command.BatCommand;
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 org.springframework.stereotype.Component;
/**
* @author Fascinated (fascinated7)
*/
@Component
public class InviteCommand extends BatCommand {
private static final String INVITE_URL = "https://discord.com/oauth2/authorize?client_id=1254161119975833652&permissions=8&integration_type=0&scope=bot+applications.commands";
public InviteCommand() {
super("invite", "Invite the bot to your server!");
}
@Override
public void execute(BatGuild guild, @NonNull BatUser user, @NonNull MessageChannel channel, Member member, @NonNull SlashCommandInteraction interaction) {
interaction.replyEmbeds(EmbedUtils.genericEmbed()
.setDescription("You can invite the bot to your server by clicking [here](%s)".formatted(INVITE_URL))
.build())
.setEphemeral(true)
.queue();
}
}

@ -83,7 +83,8 @@ public class GuildService extends ListenerAdapter {
@Override @Override
public final void onGuildJoin(GuildJoinEvent event) { public final void onGuildJoin(GuildJoinEvent event) {
log.info("Joined guild \"{}\"", event.getGuild().getId()); Guild guild = event.getGuild();
getGuild(event.getGuild().getId()); // Ensure the guild is in the database log.info("Joined guild \"{}\"", guild.getId());
getGuild(guild.getId()); // Ensure the guild is in the database
} }
} }