Ok, so I am trying to make a discord.js command that essentially creates a channel for a user gives them Manage_Messages
perms in it, gets said channel's ID, and sets the ID as the user's channel in the database (I'm using quick.db).
The script is below -
const Discord = require('discord.js');
const db = require('quick.db');
module.exports = {
name: 'userchannel',
description: 'options for the user economy channels',
execute (client, message, args) {
if (!message.author.id === '559200051629654026') return;
let character = message.author;
let option = args[0];
let characterChannelID = db.get(`${character.id}.econChannelID`);
// Create channel -------------------------
if (option === 'create') {
if (characterChannelID === null) {
let econChannel = message.guild.channels.create(`${character.username}-businesses`, {
type: 'text',
permissionOverrides: [
{
id: character.id,
allow: ['MANAGE_MESSAGES'],
},
],
}).then(channel => {
let category = message.guild.channels.cache.find(c => c.id === '738079217513791578' && c.type === 'category');
channel.setParent(category.id);
}).catch(console.error)
message.guild.channels.cache.find(c => {
c.name === `${character.username}-businesses`
db.set(`${character.id}.econChannelID`, c.id);
console.log(characterChannelID)
})
message.channel.send(`Channel created! See it at <#${characterChannelID}>`);
} else if (!characterChannelID === null) {
let alreadyHasChannel = new Discord.MessageEmbed()
.setColor('RANDOM')
.setDescription(`You already have a businesses channel! Hyperlink: <#${characterChannelID}>`)
message.channel.send(alreadyHasChannel)
}
}
}
}
I'm thinking is something with the discord.js portion, however I'm not 100% sure. Been looking on stack and on codegrepper a bit, as well as just experimentation, but none of that has worked as of now. >_<
question from:
https://stackoverflow.com/questions/65837436/command-returning-null-when-it-should-be-setting-as-a-channelid 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…