module.exports.run = async (ws,user,db,msg,fun,users,connections) => { if (!user.connected) return; if (!user.channel) return; if (!users[user._id].chatbypass && !user.quotas.chat.try()) return; if (!channels[user.channel].ch.crown) return; if (channels[user.channel].ch.crown.userId !== user._id) return; if (typeof msg._id !== "string") return if (typeof msg.ms !== "number") return; if (users[msg._id].rank > users[user._id].rank) return; if (!users[msg._id]) return; var bantime = Math.floor(msg.ms) if (bantime > 18000000 && users[user._id].rank < 2) bantime = 18000000 if (bantime < 0) bantime = 0 kickbans[user.channel][msg._id] = Date.now() + bantime connections.filter(a => a.user._id === msg._id && a.user.channel === user.channel).forEach(a => protocol['ch'].run(a,a.user, db, {m: "ch", _id: user.channel}, fun, users,connections)) Object.values(connections).filter(f => f.user.channel === user.channel).forEach(f => f.sendData({m: "a", a: `Banned ${users[msg._id].p.name} from the channel for ${Math.floor(bantime / 60000)} minutes.`, p: users[user._id].p, t: Date.now()})) chat[user.channel].push({m: "a", a: `Banned ${users[msg._id].p.name} from the channel for ${Math.floor(bantime / 60000)} minutes.`, p: users[user._id].p, t: Date.now()}) if (chat[user.channel].length > 32) chat[user.channel].splice(0,1) connections.filter(a => a.user.channel === user.channel).forEach(a => a.sendData({"m":"notification","class":"short","duration":7000,"target":"#room","text":`${users[user._id].p.name} banned ${users[msg._id].p.name} from the channel for ${Math.floor(bantime / 60000)} minutes`,"title":"Notice"})) user.quotas.chat.spend(1) } module.exports.name = "kickban"