Steve Jobs
Steve Jobs
DIAdiscord.js - Imagine an app
Created by Steve Jobs on 4/7/2024 in #djs-questions
owner.send isn't working properly
Hey, for some reason when I my bot runs this if statement:
if (await isToggled(guildId2) === true) {
await guild.fetchOwner().then(async (owner) => {
const embed = new EmbedBuilder()
.setTitle('Partnership Accepted!')
.setColor('Green')
.setDescription(`${interaction.guild.name} accepted a partnership requested by ${guild.name}'s Auto-Partner module`)
.setTimestamp()
await owner.send({embeds: [embed]})
await interaction.followUp("Done!")
return
})}
if (await isToggled(guildId2) === true) {
await guild.fetchOwner().then(async (owner) => {
const embed = new EmbedBuilder()
.setTitle('Partnership Accepted!')
.setColor('Green')
.setDescription(`${interaction.guild.name} accepted a partnership requested by ${guild.name}'s Auto-Partner module`)
.setTimestamp()
await owner.send({embeds: [embed]})
await interaction.followUp("Done!")
return
})}
it doesn't work for some reason. And yes, isToggled does return to true but the owner.send() function is not sending the owner a message guild variable code:
const guild = await client.guilds.fetch(guildId)
const guild = await client.guilds.fetch(guildId)
16 replies
DIAdiscord.js - Imagine an app
Created by Steve Jobs on 4/6/2024 in #djs-questions
How to check if randomServerWithAd blacklisted the server that is running this command.
No description
4 replies
DIAdiscord.js - Imagine an app
Created by Steve Jobs on 4/6/2024 in #djs-questions
User need to be authorized bug
Hey, so everytime my partner managers try to run /partner or /partner-category they can't run because of this if statement blocking them to use it. I am a bit confused how to fix it because I have read over several stack overflow post that other users had similar bugs like me. This is my code below, and the role id is stored in a database
const roleId = interaction.guild.roles.fetch(yourGuildData.partnerRoleId);
const memberRoles = await interaction.member.fetch(interaction.user.id);
const userIsAuthorized = interaction.user.id === interaction.guild.ownerId || yourGuildData.managers?.includes(interaction.user.id) || memberRoles.roles.cache.has(roleId.id);
if (!userIsAuthorized) {
await interaction.reply("Only the server owner or authorized users can use this command.");
return;
}
const roleId = interaction.guild.roles.fetch(yourGuildData.partnerRoleId);
const memberRoles = await interaction.member.fetch(interaction.user.id);
const userIsAuthorized = interaction.user.id === interaction.guild.ownerId || yourGuildData.managers?.includes(interaction.user.id) || memberRoles.roles.cache.has(roleId.id);
if (!userIsAuthorized) {
await interaction.reply("Only the server owner or authorized users can use this command.");
return;
}
11 replies
DIAdiscord.js - Imagine an app
Created by Steve Jobs on 4/3/2024 in #djs-questions
How can I send a message to this channel?
Hey, how can I send a message to this channel?
const { Events, EmbedBuilder } = require("discord.js");
const { db } = require("../database.js");

module.exports = {
name: Events.GuildCreate,
once: false,
async execute(guild) {
const channelId = 1224860828784918528
const guildOwner = await guild.fetchOwner()
const dmEmbed = new EmbedBuilder()
.setColor('Blurple')
.setTitle('Getting Started')
.setDescription(`Thank you for choosing Bridgify! Run the **/help** command to see my available commands!`)
.setThumbnail(process.env.ICON_URL)
.setTimestamp();

await guildOwner.send({ embeds: [dmEmbed] }).catch(() => null);

db.collection("guild-data").insertOne({guildId: guild.id})
console.log(`[INFO] >>> I was just added to a new guild: ${guild.name} | ${guild.id} | Owner ID: ${guild.ownerId} | Size: ${guild.memberCount}`);

const channel = guild.channels.cache.get(channelId)

await channel.send("test worked")
}
}
const { Events, EmbedBuilder } = require("discord.js");
const { db } = require("../database.js");

module.exports = {
name: Events.GuildCreate,
once: false,
async execute(guild) {
const channelId = 1224860828784918528
const guildOwner = await guild.fetchOwner()
const dmEmbed = new EmbedBuilder()
.setColor('Blurple')
.setTitle('Getting Started')
.setDescription(`Thank you for choosing Bridgify! Run the **/help** command to see my available commands!`)
.setThumbnail(process.env.ICON_URL)
.setTimestamp();

await guildOwner.send({ embeds: [dmEmbed] }).catch(() => null);

db.collection("guild-data").insertOne({guildId: guild.id})
console.log(`[INFO] >>> I was just added to a new guild: ${guild.name} | ${guild.id} | Owner ID: ${guild.ownerId} | Size: ${guild.memberCount}`);

const channel = guild.channels.cache.get(channelId)

await channel.send("test worked")
}
}
node:events:495
throw er; // Unhandled 'error' event
^
TypeError: channel.send is not a function
at Object.execute (/home/container/src/events/guildCreate.js:30:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:398:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)
Node.js v18.20.0
node:events:495
throw er; // Unhandled 'error' event
^
TypeError: channel.send is not a function
at Object.execute (/home/container/src/events/guildCreate.js:30:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:398:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)
Node.js v18.20.0
5 replies