fix up dm channel hack, supress if we still have no channel
This commit is contained in:
		
							parent
							
								
									141aea9a50
								
							
						
					
					
						commit
						1b03d4093a
					
				
					 1 changed files with 7 additions and 1 deletions
				
			
		| 
						 | 
					@ -54,9 +54,15 @@ for (const file of fs.readdirSync(resolve(__dirname, "modules"))) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bot.on("messageCreate", async (msg) => {
 | 
					bot.on("messageCreate", async (msg) => {
 | 
				
			||||||
 | 
					  // fix DMs cause of gateway v8 changes
 | 
				
			||||||
  if (!(msg.channel instanceof Eris.Channel) && msg.author.id != bot.user.id) {
 | 
					  if (!(msg.channel instanceof Eris.Channel) && msg.author.id != bot.user.id) {
 | 
				
			||||||
    msg.channel = await bot.getDMChannel(msg.author.id);
 | 
					    const newChannel = await bot.getDMChannel(msg.author.id);
 | 
				
			||||||
 | 
					    if (msg.channel.id == newChannel.id) msg.channel = newChannel;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // if we still have no dm channel (threads cause this too)
 | 
				
			||||||
 | 
					  if (!(msg.channel instanceof Eris.Channel)) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await CommandDispatcher(msg);
 | 
					  await CommandDispatcher(msg);
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
bot.on("messageUpdate", (msg) => {
 | 
					bot.on("messageUpdate", (msg) => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue