UPD:感谢@Tenclea解决此问题。问题在于渠道创建功能。正确的用法是message.guild.channels.create();
!
我在执行命令时遇到有关创建文本通道的问题!w
。问题是,当我尝试let USER = (message.mentions.members.first()).username;
执行时,它执行未定义,也message.member.send()
无法按预期工作。
PS [有关代码的信息]该命令不仅创建一个新的文本通道,仅对命令的执行者和所提到的用户可用,而且还将欢迎消息发送到另一个通道(message.channel.send();
)以及DM给所提到的用户(return message.member.send();
) 。
这是代码。提前致谢!
else if (message.content.startsWith(`${prefix}w`)) {
if (message.member.hasPermission('KICK_MEMBERS')) {
let random = ["test1", "test2", "test3"];
var channelname = random[Math.floor(Math.random() * random.length)];
let member = message.mentions.members.first();
let USER = (message.mentions.members.first()).username;
const channel = bot.channels.cache.get('722892241416355940');
(async() => {
message.delete();
message.guild.createChannel(`${channelname} ${USER}`, {
type: 'text',
parent: '550691726587723786',
permissionOverwrites: [{
id: message.guild.id,
deny: ['VIEW_CHANNEL', 'SEND_MESSAGES'],
}, {
id: message.member.id,
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES'],
}, {
id: message.author.id,
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES']
}]
});
message.channel.send(`:wave: we got a newcomer - <@${message.member.id}> ! Welcome!`);
return message.member.send({
embed: {
color: 1437003,
title: ":wave: Hello!",
description: `Welcome to the server!`,
footer: {
text: "Issue !help for more instructions"
}
}
})
});
} else {
return message.reply(' something went wrong!')
}
}
尝试将您的成员变量替换为:
const member = message.mentions.members.first();
然后检查用户是否存在:
if (!member) return message.reply('Could not find this member.');
然后,您的整个async
函数应如下所示:
(async() => {
message.delete();
message.guild.channels.create(`${channelname} ${member.user.username}`, {
type: 'text',
parent: '550691726587723786',
permissionOverwrites: [{
id: message.member.id,
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES'],
}, {
id: member.user.id,
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES']
}]
});
message.channel.send(`:wave: we got a newcomer - <@${message.member.id}> ! Welcome!`);
return member.send({
embed: {
color: 1437003,
title: ":wave: Hello!",
description: `Welcome to the server!`,
footer: {
text: "Issue !help for more instructions"
}
}
})
});
希望对您有所帮助:)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句