Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //使用者指令記錄模組
- let whoTrigger = {};
- //指令設定區
- client.on('message', (msg) => {
- let lit, command;
- lit = msg.content;
- //偵測時間設定
- function timerCleanWhoTrigger() {
- whoTrigger[msg.author].timer = setTimeout(
- function () {
- delete whoTrigger[msg.author];
- msg.reply('不說話就不要吵我!')
- }
- , 5000
- );
- };
- function timerCleanWhoTriggerStop() {
- clearTimeout(whoTrigger[msg.author].timer);
- };
- //找出命令斷點
- command = lit.split(/\s/)[0];
- //使用者限制載入
- if (userLock.includes(command)) {
- if (detect(msg.author)) {
- return;
- }
- };
- //頻道限制模組載入
- if (channelLock.includes(command)) {
- if (forbid(msg.channel)) {
- return;
- }
- };
- //第一層
- if (messageData[command] !== undefined && whoTrigger[msg.author] === undefined) {
- messageData[command].execute(msg);
- if (whoTrigger[msg.author] !== undefined) {
- timerCleanWhoTrigger();
- //使用紀錄
- console.log(
- `${msg.author.username}(${msg.author})在${msg.channel}使用了: ${command}!`
- );
- }
- }
- //其他層
- else if (whoTrigger[msg.author] !== undefined && whoTrigger[msg.author].useWhat !== undefined) {
- timerCleanWhoTriggerStop();
- let commandHandler = messageData[whoTrigger[msg.author].useWhat[0]];
- for (let i = 1; i < whoTrigger[msg.author].useWhat.length; i++) {
- commandHandler = commandHandler.submessageData[whoTrigger[msg.author].useWhat[i]]
- }
- commandHandler = commandHandler.submessageData[command];
- if (commandHandler !== undefined) {
- commandHandler.execute(msg);
- }
- else {
- msg.reply('沒有這個選項啦!');
- delete whoTrigger[msg.author];
- //使用紀錄
- console.log(
- `${msg.author.username}(${msg.author})在${msg.channel}使用了: ${command}!`
- );
- }
- }
- //非法指令處理
- else {
- delete whoTrigger[msg.author];
- }
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement