Spaces:
Runtime error
Runtime error
Update index.js
Browse files
index.js
CHANGED
|
@@ -39,23 +39,6 @@ function sendLeaveTransaction(guild) {
|
|
| 39 |
sendServerTransaction('leave', guild);
|
| 40 |
}
|
| 41 |
|
| 42 |
-
module.exports = { sendJoinTransaction, sendLeaveTransaction };
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
client.on('guildCreate', guild => {
|
| 48 |
-
sendJoinTransaction(guild);
|
| 49 |
-
});
|
| 50 |
-
|
| 51 |
-
client.on('guildDelete', guild => {
|
| 52 |
-
sendLeaveTransaction(guild);
|
| 53 |
-
});
|
| 54 |
-
|
| 55 |
-
module.exports = {};
|
| 56 |
-
client.on('ready', () => {
|
| 57 |
-
console.log('DEBUG_READY');
|
| 58 |
-
});
|
| 59 |
console.log(">>> [BOOT] Discord.js loaded.");
|
| 60 |
console.log(">>> [BOOT] Loading Storage...");
|
| 61 |
const storage = require('./storage');
|
|
@@ -99,7 +82,7 @@ process.on('uncaughtException', (err) => {
|
|
| 99 |
console.error('[!] Uncaught Exception:', err);
|
| 100 |
});
|
| 101 |
|
| 102 |
-
const client = new Client(
|
| 103 |
intents: [
|
| 104 |
GatewayIntentBits.Guilds,
|
| 105 |
GatewayIntentBits.GuildMessages,
|
|
@@ -2832,16 +2815,10 @@ client.on('guildMemberUpdate', async (oldMember, newMember) => {
|
|
| 2832 |
});
|
| 2833 |
|
| 2834 |
// Log server join to designated log channel
|
| 2835 |
-
client.on('guildCreate', guild => {
|
| 2836 |
sendJoinTransaction(guild);
|
| 2837 |
-
|
| 2838 |
-
|
| 2839 |
-
client.on('guildDelete', guild => {
|
| 2840 |
-
sendLeaveTransaction(guild);
|
| 2841 |
-
});
|
| 2842 |
-
console.log('DEBUG_GUILD_MEMBER_ADD');
|
| 2843 |
-
console.log('DEBUG_GUILD_MEMBER_REMOVE'); async (guild) => {
|
| 2844 |
-
try {
|
| 2845 |
console.log(`[SYSTEM] Bot joined a new guild: "${guild.name}" (${guild.id})`);
|
| 2846 |
|
| 2847 |
const logChannelId = '1508759327731875977';
|
|
@@ -2916,6 +2893,40 @@ console.log('DEBUG_GUILD_MEMBER_REMOVE'); async (guild) => {
|
|
| 2916 |
}
|
| 2917 |
});
|
| 2918 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2919 |
async function triggerOnboardingForRole(guild, role) {
|
| 2920 |
const guildId = guild.id;
|
| 2921 |
const dashboardUrl = getSpacePublicUrl() || 'https://brozy123-lineup-bot.hf.space';
|
|
|
|
| 39 |
sendServerTransaction('leave', guild);
|
| 40 |
}
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
console.log(">>> [BOOT] Discord.js loaded.");
|
| 43 |
console.log(">>> [BOOT] Loading Storage...");
|
| 44 |
const storage = require('./storage');
|
|
|
|
| 82 |
console.error('[!] Uncaught Exception:', err);
|
| 83 |
});
|
| 84 |
|
| 85 |
+
const client = new Client({
|
| 86 |
intents: [
|
| 87 |
GatewayIntentBits.Guilds,
|
| 88 |
GatewayIntentBits.GuildMessages,
|
|
|
|
| 2815 |
});
|
| 2816 |
|
| 2817 |
// Log server join to designated log channel
|
| 2818 |
+
client.on('guildCreate', async (guild) => {
|
| 2819 |
sendJoinTransaction(guild);
|
| 2820 |
+
|
| 2821 |
+
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2822 |
console.log(`[SYSTEM] Bot joined a new guild: "${guild.name}" (${guild.id})`);
|
| 2823 |
|
| 2824 |
const logChannelId = '1508759327731875977';
|
|
|
|
| 2893 |
}
|
| 2894 |
});
|
| 2895 |
|
| 2896 |
+
// Log server leave to designated log channel
|
| 2897 |
+
client.on('guildDelete', async (guild) => {
|
| 2898 |
+
sendLeaveTransaction(guild);
|
| 2899 |
+
|
| 2900 |
+
try {
|
| 2901 |
+
console.log(`[SYSTEM] Bot left a guild: "${guild.name}" (${guild.id})`);
|
| 2902 |
+
|
| 2903 |
+
const logChannelId = '1508759327731875977';
|
| 2904 |
+
const channel = await client.channels.fetch(logChannelId).catch(() => null);
|
| 2905 |
+
if (!channel) {
|
| 2906 |
+
console.warn(`[SYSTEM] Could not find the guild-leave log channel: ${logChannelId}`);
|
| 2907 |
+
return;
|
| 2908 |
+
}
|
| 2909 |
+
|
| 2910 |
+
const embed = new EmbedBuilder()
|
| 2911 |
+
.setTitle(`📤 Bot Left a Guild`)
|
| 2912 |
+
.addFields(
|
| 2913 |
+
{ name: '🌐 Server Name', value: `**${guild.name}**`, inline: true },
|
| 2914 |
+
{ name: '🆔 Server ID', value: `\`${guild.id}\``, inline: true },
|
| 2915 |
+
{ name: '👥 Member Count', value: `\`${guild.memberCount || 0}\` members`, inline: true },
|
| 2916 |
+
{ name: '📊 Total Servers Now', value: `\`${client.guilds.cache.size}\` guilds`, inline: true }
|
| 2917 |
+
)
|
| 2918 |
+
.setColor(0xED4245) // Red / Failure
|
| 2919 |
+
.setTimestamp();
|
| 2920 |
+
|
| 2921 |
+
await channel.send({ embeds: [embed] }).catch((err) => {
|
| 2922 |
+
console.error(`[SYSTEM] Failed to send guild leave embed log to channel:`, err);
|
| 2923 |
+
});
|
| 2924 |
+
|
| 2925 |
+
} catch (err) {
|
| 2926 |
+
console.error("[SYSTEM] Error inside guildDelete event handler:", err);
|
| 2927 |
+
}
|
| 2928 |
+
});
|
| 2929 |
+
|
| 2930 |
async function triggerOnboardingForRole(guild, role) {
|
| 2931 |
const guildId = guild.id;
|
| 2932 |
const dashboardUrl = getSpacePublicUrl() || 'https://brozy123-lineup-bot.hf.space';
|