Ateeb Sohail
Ateeb Sohail
DIAdiscord.js - Imagine an app
Created by Ateeb Sohail on 9/29/2024 in #djs-questions
Get the date of a user joining discord
Is there a way to use the Discord API to get the date when a user joined discord (not a guild) or does discord not give out that infommation. I was unable to find any traces
4 replies
DIAdiscord.js - Imagine an app
Created by Ateeb Sohail on 2/18/2024 in #djs-questions
Thread sometimes null?
Why is thread sometimes null?
msg = await (channel as ForumChannel).threads.create({name: post.info.title,message: {embeds: [embed], components: [actionRow]}, appliedTags: tags});
(channel as ForumChannel).threads.fetch(msg.id).then(async (thread) => {thread?.send({components: [bumpBtnRow]}); updateMessage(post.id, {id: thread?.id || '', url: thread?.url || ''}); updateApproval(post.id)})
msg = await (channel as ForumChannel).threads.create({name: post.info.title,message: {embeds: [embed], components: [actionRow]}, appliedTags: tags});
(channel as ForumChannel).threads.fetch(msg.id).then(async (thread) => {thread?.send({components: [bumpBtnRow]}); updateMessage(post.id, {id: thread?.id || '', url: thread?.url || ''}); updateApproval(post.id)})
13 replies
DIAdiscord.js - Imagine an app
Created by Ateeb Sohail on 1/31/2024 in #djs-questions
Unable to delete message from DM
Error [ChannelNotCached]: Could not find the channel where this message came from in the cache!
at Message.delete (C:\Users\muqia\Documents\Projects\HaroonBot\node_modules\discord.js\src\structures\Message.js:828:30)
at C:\Users\muqia\Documents\Projects\HaroonBot\dist\index.js:477:43
at Generator.next (<anonymous>)
at C:\Users\muqia\Documents\Projects\HaroonBot\dist\index.js:35:71
at new Promise (<anonymous>)
at __awaiter (C:\Users\muqia\Documents\Projects\HaroonBot\dist\index.js:31:12)
at Client.<anonymous> (C:\Users\muqia\Documents\Projects\HaroonBot\dist\index.js:70:57)
at Client.emit (node:events:514:28)
at InteractionCreateAction.handle (C:\Users\muqia\Documents\Projects\HaroonBot\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\muqia\Documents\Projects\HaroonBot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36) {
code: 'ChannelNotCached'
}
Error [ChannelNotCached]: Could not find the channel where this message came from in the cache!
at Message.delete (C:\Users\muqia\Documents\Projects\HaroonBot\node_modules\discord.js\src\structures\Message.js:828:30)
at C:\Users\muqia\Documents\Projects\HaroonBot\dist\index.js:477:43
at Generator.next (<anonymous>)
at C:\Users\muqia\Documents\Projects\HaroonBot\dist\index.js:35:71
at new Promise (<anonymous>)
at __awaiter (C:\Users\muqia\Documents\Projects\HaroonBot\dist\index.js:31:12)
at Client.<anonymous> (C:\Users\muqia\Documents\Projects\HaroonBot\dist\index.js:70:57)
at Client.emit (node:events:514:28)
at InteractionCreateAction.handle (C:\Users\muqia\Documents\Projects\HaroonBot\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\muqia\Documents\Projects\HaroonBot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36) {
code: 'ChannelNotCached'
}
4 replies
DIAdiscord.js - Imagine an app
Created by Ateeb Sohail on 1/31/2024 in #djs-questions
Assuming I have a link button, anyway to get the URL of the button?
The title says it all. eg if i have a link button to https://google.com/ can i get the url later on by using interaction.message
3 replies
DIAdiscord.js - Imagine an app
Created by Ateeb Sohail on 1/28/2024 in #djs-questions
How do i send messages in a Forum Channel
assuming i have the channel stored in the channel variable, how would i send a message to it? Any clue? I've scoured https://discord.js.org/docs/packages/discord.js/main/ForumChannel:Class
18 replies
DIAdiscord.js - Imagine an app
Created by Ateeb Sohail on 1/26/2024 in #djs-questions
Unable to DM User despite open DMs
No description
13 replies
DIAdiscord.js - Imagine an app
Created by Ateeb Sohail on 1/26/2024 in #djs-questions
Invalid Type?
Hi, Im trying to map users from guild into a dropdown heres my code so far,
const members = await interaction.guild?.members.fetch()
if (members) {
const memberList: Array<StringSelectMenuOptionBuilder> = members.map(member => {
return new StringSelectMenuOptionBuilder({label: member.user.username, value: member.user.id})
})

const selectMenu = new StringSelectMenuBuilder({
custom_id: 'memberdropdown',
placeholder: 'Make a Selection',
max_values: 5,
options: memberList,
})
} else {
interaction.reply({content: 'There was an error while processing this request', ephemeral: true});return
}
const members = await interaction.guild?.members.fetch()
if (members) {
const memberList: Array<StringSelectMenuOptionBuilder> = members.map(member => {
return new StringSelectMenuOptionBuilder({label: member.user.username, value: member.user.id})
})

const selectMenu = new StringSelectMenuBuilder({
custom_id: 'memberdropdown',
placeholder: 'Make a Selection',
max_values: 5,
options: memberList,
})
} else {
interaction.reply({content: 'There was an error while processing this request', ephemeral: true});return
}
error:
Type 'StringSelectMenuOptionBuilder[]' is not assignable to type 'APISelectMenuOption[]'.
Type 'StringSelectMenuOptionBuilder' is missing the following properties from type 'APISelectMenuOption': label, valuets(2322)
(property) options: discord.StringSelectMenuOptionBuilder[]
Type 'StringSelectMenuOptionBuilder[]' is not assignable to type 'APISelectMenuOption[]'.
Type 'StringSelectMenuOptionBuilder' is missing the following properties from type 'APISelectMenuOption': label, valuets(2322)
(property) options: discord.StringSelectMenuOptionBuilder[]
6 replies
DIAdiscord.js - Imagine an app
Created by Ateeb Sohail on 1/25/2024 in #djs-questions
interaction.user.send() not working?
The embed with Success happens and whole thing goes to plan but i.user doesnt get logged??? nor do i get dmed
const member = await i.guild?.members.fetch(i.user)
const hasRole = member?.roles.cache.has(roles.premium)
const embed = await addPost(job, i.user.id, hasRole || false, tempId)
const dmEmbed = new InfoEmbed('Your Post has been sent in for approval', 'You will be notified when your post goes through.');
interaction.user.send({embeds: [dmEmbed]});
console.log(interaction.user)
i.reply({content: 'Success!', ephemeral: true})
return collector.stop()
const member = await i.guild?.members.fetch(i.user)
const hasRole = member?.roles.cache.has(roles.premium)
const embed = await addPost(job, i.user.id, hasRole || false, tempId)
const dmEmbed = new InfoEmbed('Your Post has been sent in for approval', 'You will be notified when your post goes through.');
interaction.user.send({embeds: [dmEmbed]});
console.log(interaction.user)
i.reply({content: 'Success!', ephemeral: true})
return collector.stop()
Heres full code : https://pastebin.com/xy0ZXRa5
16 replies
DIAdiscord.js - Imagine an app
Created by Ateeb Sohail on 1/23/2024 in #djs-questions
I've been at this for hours. Invalid Channels?
This is how im defining channels
export let channels: { paidJob: discord.Channel | null | undefined; commissionJob: discord.Channel | null | undefined; forHireJob: discord.Channel | null | undefined; unpaidJob: discord.Channel | null | undefined; vipJob: discord.Channel | null | undefined };
for (const file of commandFiles) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const command: Command = require(`./commands/${file}`);

if(!command.data || !command.execute) {
console.log(`Command ${file} is invalid. Skipping`);
break
}

console.log(`Loaded command\t${command.data.name}\t${JSON.stringify(command.options)}`)

client.commands.set(command.data.name, command);
}
client.on('interactionCreate', async interaction => {
channels.paidJob = client.channels.cache.get(channelIds.paidJob)
channels.commissionJob = client.channels.cache.get(channelIds.commissionJob)
channels.forHireJob = client.channels.cache.get(channelIds.forHireJob)
channels.unpaidJob = client.channels.cache.get(channelIds.unpaidJob)
channels.vipJob = client.channels.cache.get(channelIds.vipJob)
// Handlers
export let channels: { paidJob: discord.Channel | null | undefined; commissionJob: discord.Channel | null | undefined; forHireJob: discord.Channel | null | undefined; unpaidJob: discord.Channel | null | undefined; vipJob: discord.Channel | null | undefined };
for (const file of commandFiles) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const command: Command = require(`./commands/${file}`);

if(!command.data || !command.execute) {
console.log(`Command ${file} is invalid. Skipping`);
break
}

console.log(`Loaded command\t${command.data.name}\t${JSON.stringify(command.options)}`)

client.commands.set(command.data.name, command);
}
client.on('interactionCreate', async interaction => {
channels.paidJob = client.channels.cache.get(channelIds.paidJob)
channels.commissionJob = client.channels.cache.get(channelIds.commissionJob)
channels.forHireJob = client.channels.cache.get(channelIds.forHireJob)
channels.unpaidJob = client.channels.cache.get(channelIds.unpaidJob)
channels.vipJob = client.channels.cache.get(channelIds.vipJob)
// Handlers
for some reason my command use.ts is invalid? its all due to this line
const embed = await addPost(job, interaction.user.id, hasRole || false)
const embed = await addPost(job, interaction.user.id, hasRole || false)
Below is the function file. The error occurs due to me assigning to the channel variable.
9 replies
DIAdiscord.js - Imagine an app
Created by Ateeb Sohail on 1/23/2024 in #djs-questions
Nested Collector
If i have a button that opens up a modal, do i add the modal collector in the button collector or is there another way? Coming back to djs after a long time so my brain isnt braining.
// Button Collector
// Modal Appearing
// Modal Collector
// Button Collector
// Modal Appearing
// Modal Collector
or
// Button Collector
// Modal Appearing
// Modal Collector
// Button Collector
// Modal Appearing
// Modal Collector
16 replies