async function CreateChannel(msg,channelName){
return await Promise.resolve(msg.guild.channels.create(channelName,{parent: 'PARENT_ID'})
.then((msg.channel.send(`${channelName} named channel created !!`)))
.catch(console.error));
}
function SendMessageToChannel(msg,message,channelName){
const channel = msg.guild.channels.cache.find(ch => ch.name === channelName);
if(!channel) return;
channel.send(message);
}
我将上述两个功能用于特定命令来创建频道
例如:!channel surf
用Surf创建一个新的频道名称。
我想要的是在创建频道时要自动创建的问候消息,例如
Welcome to Channel!
但是我面临的是无法通过 SendMessageToChannel 中的代码发送的原因,因为消息行会的缓存未更新。
帮我这个忙!
提前谢谢
答案 0 :(得分:0)
解决我的问题
root.findViewById(#your nav_host id)
我没有在 CreateChannel 之后调用 SendMessageToChannel ,而是在解决频道创建承诺后才打电话给我,因此在创建频道后,可以立即发送问候语/消息。