99 lines
2.2 KiB
JavaScript
99 lines
2.2 KiB
JavaScript
const {
|
|
Client,
|
|
ApplicationCommandOptionTypes,
|
|
ApplicationCommandTypes,
|
|
InteractionTypes,
|
|
ApplicationIntegrationTypes,
|
|
InteractionContextTypes,
|
|
MessageFlags,
|
|
ComponentTypes
|
|
} = 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
|
|
},
|
|
{
|
|
name: "cv2",
|
|
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");
|
|
const cv2Text = interaction.data.options.getBoolean("cv2");
|
|
|
|
if (cv2Text)
|
|
interaction.createFollowup({
|
|
flags: MessageFlags.IS_UIKIT_COMPONENTS,
|
|
components: [
|
|
{
|
|
type: ComponentTypes.TEXT,
|
|
content
|
|
}
|
|
]
|
|
});
|
|
|
|
interaction.createFollowup(
|
|
raw
|
|
? JSON.parse(content)
|
|
: {
|
|
content
|
|
}
|
|
);
|
|
}
|
|
}
|
|
});
|
|
|
|
process.on("uncaughtException", (e) => {
|
|
client.rest.channels.createMessage("1367826538665476236", {
|
|
content: "```\n" + (e.stack || e.message) + "\n```"
|
|
});
|
|
});
|
|
|
|
client.connect();
|