Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
126 lines (110 loc) · 3.61 KB
/
Copy pathindex.js
File metadata and controls
126 lines (110 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// nah time to go to sleep
require("dotenv").config();
const { Client, GatewayIntentBits, EmbedBuilder } = require("discord.js");
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
});
// --- YOU CAN MODIFY THESE TEMPLATES BY YOUR OWN ---
const templates = {
default: [
"Login / Sign Up",
"Join Pre-Registration",
"Join Boost Lottery Event",
"DONE ✅",
],
social: [
"Follow Twitter Official",
"Retweet & Like pinned post",
"Join Telegram/Discord",
"Submit Wallet Address",
],
testnet: [
"Download & Install Wallet",
"Claim Faucet on Testnet Web",
"Do Transactions / Tasks",
"Submit Feedback to Form",
],
};
client.once("ready", () => {
console.log(`Logged in as ${client.user.tag}`);
});
client.on("interactionCreate", async (interaction) => {
if (!interaction.isCommand()) return;
if (interaction.commandName !== "airdrop") return;
const project = interaction.options.getString("project");
const linkRaw = interaction.options.getString("link");
const template = interaction.options.getString("template");
const stepsInput = interaction.options.getString("steps") || "";
const rewards =
interaction.options.getString("rewards") ||
"Early farming + Special Boost Event 🔥"; // --- YOU CAN MODIFY THIS PART AS YOU LIKE ---
const channelOpt = interaction.options.getChannel("channel");
const imageFile = interaction.options.getAttachment("image");
const thumbFile = interaction.options.getAttachment("thumbnail");
// --- CHOOSE STEPS BASED ON TEMPLATE ---
let stepsArr;
if (template === "custom") {
let stepsRaw = stepsInput.replace(/```/g, "```");
stepsArr = stepsRaw
.split(/\r?\n|[|;]+/)
.map((s) => s.trim())
.filter(Boolean);
} else {
stepsArr = templates[template] || ["(No steps yet)"];
}
// --- FORMAT STEPS TO NUMBER LIST ---
const stepsFormatted = stepsArr.map((s, i) => `${i + 1}. ${s}`).join("\n");
// --- MAKE SURE LINK STARTS WITH HTTP/HTTPS ---
let link = linkRaw;
if (!/^https?:\/\//i.test(link)) link = "https://" + link;
// --- MENTION EVERYONE ---
const mentionOpt = interaction.options.getString("mention") || "none";
let mentionText = "";
if (mentionOpt && mentionOpt.toLowerCase() === "everyone") {
mentionText += "@everyone ";
} else if (mentionOpt.toLowerCase() === "here") {
mentionText = "@here";
}
// --- EMBED ANNOUNCEMENT ---
const embed = new EmbedBuilder()
.setTitle(`📢 New Airdrop: ${project}`)
.setDescription(
`🎁 **Rewards:** ${rewards}\n\n` +
`🔗 **Register:** [Klik di sini](${link})\n\n` +
`📜 **Steps:**\n${stepsFormatted}`
)
.setColor(0x00ae86)
.setTimestamp();
if (imageFile) {
embed.setImage(imageFile.url);
}
if (thumbFile) {
embed.setThumbnail(thumbFile.url);
}
// --- SEND TO TARGET CHANNEL OR CURRENT CHANNEL ---
let target = interaction.channel;
if (channelOpt) {
if (!channelOpt.isTextBased()) {
return interaction.reply({
content: "Please choose a text channel.",
ephemeral: true,
});
}
target = channelOpt;
}
try {
await target.send({ content: mentionText || undefined, embeds: [embed] });
await interaction.reply({
content: `✅ Announcement posted in ${target}`,
ephemeral: true,
});
} catch (err) {
console.error(err);
await interaction.reply({
content:
"❌ Failed to send announcement. Make sure your bot has *Send Messages* permission in the target channel.",
ephemeral: true,
});
}
});
client.login(process.env.DISCORD_TOKEN);