Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 6m16s
40 lines
1.8 KiB
TypeScript
40 lines
1.8 KiB
TypeScript
import { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits, ChannelType } from "discord.js"
|
|
import type { ChatInputCommandInteraction } from "discord.js"
|
|
import { t } from "@/utils/i18n"
|
|
import { logConsole } from "@/utils/console"
|
|
|
|
export const data = new SlashCommandBuilder()
|
|
.setName("boost")
|
|
.setDescription("Test the server boost")
|
|
.setDescriptionLocalizations({ fr: "Tester le boost du serveur" })
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
|
|
|
export async function execute(interaction: ChatInputCommandInteraction) {
|
|
if (interaction.guild?.id !== "796327643783626782") return interaction.reply({ content: t(interaction.locale, "boost.not_authorized") }) // Jujul Community
|
|
|
|
const member = interaction.member
|
|
if (!member) { logConsole('discordjs', 'boost.no_member'); return }
|
|
|
|
const guild = interaction.guild
|
|
if (!guild.members.me) { logConsole('discordjs', 'boost.not_in_guild'); return }
|
|
|
|
const channel = await guild.channels.fetch("924353449930412153")
|
|
if (!channel || (channel.type !== ChannelType.GuildText && channel.type !== ChannelType.GuildAnnouncement)) {
|
|
logConsole('discordjs', 'boost.no_channel', { channelId: "924353449930412153" })
|
|
return
|
|
}
|
|
|
|
const boostRole = guild.roles.premiumSubscriberRole
|
|
if (!boostRole) { logConsole('discordjs', 'boost.no_boost_role'); return }
|
|
|
|
const embed = new EmbedBuilder()
|
|
.setColor(guild.members.me.displayHexColor)
|
|
.setTitle(t(interaction.locale, "boost.new_boost_title", { username: member.user.username }))
|
|
.setDescription(t(interaction.locale, "boost.new_boost_description", { count: (guild.premiumSubscriptionCount ?? 0).toString() }))
|
|
.setThumbnail(member.user.avatar)
|
|
.setTimestamp(new Date())
|
|
|
|
await channel.send({ embeds: [embed] })
|
|
return interaction.reply({ content: t(interaction.locale, "boost.check_channel", { channelId: "924353449930412153" }) })
|
|
}
|