say/index.js
2025-04-30 20:13:19 -04:00

73 lines
1.6 KiB
JavaScript

const {
Client,
ApplicationCommandOptionTypes,
ApplicationCommandTypes,
InteractionTypes,
ApplicationIntegrationTypes,
InteractionContextTypes
} = require("oceanic.js");
const client = new Client({
auth: `Bot ${process.env.BOT_TOKEN}`
});
client.on("ready", () => {
console.log(`Logged in as ${client.user.username}`);
client.application.bulkEditGlobalCommands([
{
name: "say",
integrationTypes: [
ApplicationIntegrationTypes.GUILD_INSTALL,
ApplicationIntegrationTypes.USER_INSTALL
],
contexts: [
InteractionContextTypes.BOT_DM,
InteractionContextTypes.GUILD,
InteractionContextTypes.PRIVATE_CHANNEL
],
description: "Says whatever you provide",
options: [
{
name: "content",
description: "...",
type: ApplicationCommandOptionTypes.STRING,
required: true
},
{
name: "raw",
description: "...",
type: ApplicationCommandOptionTypes.BOOLEAN,
required: false
}
]
}
]);
});
client.on("interactionCreate", async (interaction) => {
if (InteractionTypes.APPLICATION_COMMAND === interaction.type) {
await interaction.defer();
await interaction.deleteOriginal();
if (interaction.user.id !== "886685857560539176") {
return interaction.createFollowup({
content: "@everyone"
});
}
if (interaction.data.type === ApplicationCommandTypes.CHAT_INPUT) {
const content = interaction.data.options.getString("content", true);
const raw = interaction.data.options.getBoolean("raw");
interaction.createFollowup(
raw
? JSON.parse(content)
: {
content
}
);
}
}
});
client.connect();