Night Ghost
Night Ghost
DIAdiscord.js - Imagine an app
Created by Night Ghost on 7/4/2024 in #djs-questions
[ ERROR: ]: source.on is not a function
let channelID = row.find(function (r) { return r.channeltype === 'welcome' }).channelid;
let channel = await bot.channels.cache.get(channelID)

const buffer = await canvas.toBuffer();
console.log('Buffer size:', buffer.length);

const attachment = new AttachmentBuilder(buffer, { name: 'welcome.png', description: 'welcome' });
console.log(buffer)
if (channel) {
try {
await channel.send({
content: `<@${guildMember.user.id}>`,
files: [attachment]
});
} catch (e) {
projectphil.logger({ string: e.message, type: 'error', location: __filename });
}
}
let channelID = row.find(function (r) { return r.channeltype === 'welcome' }).channelid;
let channel = await bot.channels.cache.get(channelID)

const buffer = await canvas.toBuffer();
console.log('Buffer size:', buffer.length);

const attachment = new AttachmentBuilder(buffer, { name: 'welcome.png', description: 'welcome' });
console.log(buffer)
if (channel) {
try {
await channel.send({
content: `<@${guildMember.user.id}>`,
files: [attachment]
});
} catch (e) {
projectphil.logger({ string: e.message, type: 'error', location: __filename });
}
}
`
78 replies
DIAdiscord.js - Imagine an app
Created by Night Ghost on 5/23/2024 in #djs-questions
add members to thread
case "adduser": {
await interaction.reply({ content: `Please provide the ID of the user you want to add to the thread.`, ephemeral: bot.config.discordConfig.ephemeral });

const filter = m => m.author.id === interaction.user.id;
const collector = interaction.channel.createMessageCollector({ filter, time: 1500000 });
const thread = interaction.channel;

if (!thread) {
return interaction.reply({ content: 'Thread not found.', ephemeral: true });
}

collector.on('collect', async (m) => {
if (m.content.toLowerCase() === bot.language.cancel) {
await m.delete().catch(() => { });
collector.stop();
return interaction.reply({ content: language.ticketMaxTickets.cancel, ephemeral: bot.config.discordConfig.ephemeral }).catch(() => { });
}

const userId = m.content.trim();
const userToAdd = interaction.guild.members.cache.get(userId);

if (!userToAdd) {
return interaction.followUp('User not found or invalid ID.');
}
try {
await thread.members.add(userToAdd.user.id);
interaction.channel.send(`User ${userToAdd.user.tag} added to thread ${thread.id} successfully.`);
} catch (error) {
console.error('Error adding user to thread:', error);
interaction.channel.send('Error adding user to thread. Please try again later.');
}

collector.stop();
});

collector.on('end', (collected, reason) => {
if (reason === 'time') {
interaction.followUp('No response received. Command timed out.');
}
});

break;
}
case "adduser": {
await interaction.reply({ content: `Please provide the ID of the user you want to add to the thread.`, ephemeral: bot.config.discordConfig.ephemeral });

const filter = m => m.author.id === interaction.user.id;
const collector = interaction.channel.createMessageCollector({ filter, time: 1500000 });
const thread = interaction.channel;

if (!thread) {
return interaction.reply({ content: 'Thread not found.', ephemeral: true });
}

collector.on('collect', async (m) => {
if (m.content.toLowerCase() === bot.language.cancel) {
await m.delete().catch(() => { });
collector.stop();
return interaction.reply({ content: language.ticketMaxTickets.cancel, ephemeral: bot.config.discordConfig.ephemeral }).catch(() => { });
}

const userId = m.content.trim();
const userToAdd = interaction.guild.members.cache.get(userId);

if (!userToAdd) {
return interaction.followUp('User not found or invalid ID.');
}
try {
await thread.members.add(userToAdd.user.id);
interaction.channel.send(`User ${userToAdd.user.tag} added to thread ${thread.id} successfully.`);
} catch (error) {
console.error('Error adding user to thread:', error);
interaction.channel.send('Error adding user to thread. Please try again later.');
}

collector.stop();
});

collector.on('end', (collected, reason) => {
if (reason === 'time') {
interaction.followUp('No response received. Command timed out.');
}
});

break;
}
12 replies