我有一个脚本,用户可以在其中指定一个频道作为欢迎频道,并将其保存在quick.db中,但是当我想将嵌入内容发送到指定频道时,它不会让我使用。所以我console.log() 我看到它返回了所有内容。
TextChannel {
type: 'text',
deleted: false,
id: '730763402229841980',
name: '�┊�è�������',
rawPosition: 1,
parentID: '730762991502622752',
permissionOverwrites: Collection [Map] {},
topic: null,
nsfw: false,
lastMessageID: '739703571565641748',
rateLimitPerUser: 0,
lastPinTimestamp: null,
guild: Guild {
members: GuildMemberManager {
cacheType: [Function: Collection],
cache: [Collection [Map]],
guild: [Circular]
},
channels: GuildChannelManager {
cacheType: [Function: Collection],
cache: [Collection [Map]],
guild: [Circular]
},
roles: RoleManager {
cacheType: [Function: Collection],
cache: [Collection [Map]],
guild: [Circular]
},
presences: PresenceManager {
cacheType: [Function: Collection],
cache: [Collection [Map]]
},
voiceStates: VoiceStateManager {
cacheType: [Function: Collection],
cache: Collection [Map] {},
guild: [Circular]
},
deleted: false,
available: true,
id: '730762360272191508',
shardID: 0,
name: 'Serv sans nom',
icon: null,
splash: null,
region: 'southafrica',
memberCount: 6,
large: false,
features: [],
applicationID: null,
afkTimeout: 300,
afkChannelID: null,
systemChannelID: null,
embedEnabled: undefined,
premiumTier: 0,
premiumSubscriptionCount: 0,
verificationLevel: 'NONE',
explicitContentFilter: 'DISABLED',
mfaLevel: 0,
joinedTimestamp: 1596429038364,
defaultMessageNotifications: 'ALL',
systemChannelFlags: SystemChannelFlags { bitfield: 0 },
vanityURLCode: null,
description: null,
banner: null,
rulesChannelID: null,
publicUpdatesChannelID: null,
ownerID: '380421367704584193',
cacheType: [Function: Collection],
cache: Collection [Map] {},
guild: [Circular]
}
},
messages: MessageManager {
cacheType: [Function: LimitedCollection],
cache: LimitedCollection [Map] { maxSize: 200 },
channel: [Circular]
},
_typing: Map {}
}
我用来获取频道的方法
Client.on('guildMemberAdd', member => {
console.log(db.get(`wl_channel`))
const welcome = db.get(`wl_YN${member.guild.id}`)
const embed = new Discord.MessageEmbed()
.setTitle(`Welcome ***${member.displayName}***`)
.setColor("#2163D7")
.addFields({ name: `**${member.displayName}**`, value: 'Please read the **rules**'},{ name: `You are our ` , value: `***${member.guild.memberCount}*** th member!`})
.setImage(member.user.avatarURL())
.setThumbnail(member.user.avatarURL())
if(welcome === true){
console.log(member.guild.channels.cache.get(db.get(`wl_channel`).id))
}
});
我如何保存频道
db.set(`wl_channel`, message.mentions.channels.first().id)
感谢您的帮助
答案 0 :(得分:0)
将频道名称存储在数据库中
db.set(`wl_channel`, message.mentions.channels.first().name)
然后使用以下方法获取频道:
Client.on('guildMemberAdd', member => {
console.log(db.get(`wl_channel`))
let welcomeChannel = db.get(`wl_channel`)
const welcome = db.get(`wl_YN${member.guild.id}`)
const embed = new Discord.MessageEmbed()
.setTitle(`Welcome ***${member.displayName}***`)
.setColor("#2163D7")
.addFields({ name: `**${member.displayName}**`, value: 'Please read the **rules**'},{ name: `You are our ` , value: `***${member.guild.memberCount}*** th member!`})
.setImage(member.user.avatarURL())
.setThumbnail(member.user.avatarURL())
if(welcome === true){
let channel = message.channels.find(channel => channel.name === welcomeChannel);
channel.send(embed);
}
});