20 lines
1.5 KiB
JavaScript
20 lines
1.5 KiB
JavaScript
module.exports.run = async (ws,user,db,msg,fun,users,connections) => {
|
|
if (!user.connected) return;
|
|
if (!user.channel) return;
|
|
if (!channels[user.channel].ch.crown) return;
|
|
if (channels[user.channel].ch.crown.userId !== user._id) return;
|
|
if (typeof msg.set !== "object") return
|
|
var validset = ['color', 'color2', 'visible', 'limit']
|
|
var oldch = channels[user.channel].ch
|
|
Object.keys(msg.set).forEach(pro => {
|
|
if (!validset.includes(pro)) return;
|
|
if (pro === "color" && typeof msg.set[pro] === "string" && msg.set[pro].startsWith('#') && msg.set[pro].length == 7) channels[user.channel].ch.settings.color = msg.set[pro]
|
|
if (pro === "color2" && typeof msg.set[pro] === "string" && msg.set[pro].startsWith('#') && msg.set[pro].length == 7) channels[user.channel].ch.settings.color2 = msg.set[pro]
|
|
if (pro === "visible" && typeof msg.set[pro] === "boolean") channels[user.channel].ch.settings.visible = msg.set[pro]
|
|
if (pro === "limit" && !isNaN(Number(msg.set[pro])) && msg.set[pro] < 100 && msg.set[pro] >= 0) channels[user.channel].ch.settings.limit = Math.floor(Number(msg.set[pro]))
|
|
})
|
|
//if (oldch.settings.color === channels[user.channel].ch.settings.color && oldch.settings.visible === channels[user.channel].ch.settings.visible && oldch.settings.color2 === channels[user.channel].ch.settings.color2) return
|
|
connections.filter(a => a.user.channel === user.channel).forEach(a => {var channel = channels[user.channel]; channel.p = a.user._id;a.sendData(fun.vanish(channel, users[a.user._id].rank))})
|
|
}
|
|
module.exports.name = "chset"
|