fix dm channel grabbing
This commit is contained in:
		
							parent
							
								
									3be78312e1
								
							
						
					
					
						commit
						c9faaab317
					
				
					 2 changed files with 6 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -72,7 +72,7 @@ bot.once("ready", async () => {
 | 
			
		|||
  logger.info("hf:main", "Connected to Discord.");
 | 
			
		||||
  logger.info("hf:main", `Logged in as: ${bot.user.tag} (${bot.user.id})`);
 | 
			
		||||
 | 
			
		||||
  const channel = await bot.users.get(config.owner_id)?.createDM();
 | 
			
		||||
  const channel = await bot.getDMChannel(config.owner_id);
 | 
			
		||||
  if (channel) {
 | 
			
		||||
    channel.createMessage({
 | 
			
		||||
      content: "<:ms_tick:503341995348066313> Loaded HiddenPhox.",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,6 +20,7 @@ if (!fs.existsSync(resolve(__dirname, "..", "..", "private_reminders.json")))
 | 
			
		|||
  return;
 | 
			
		||||
 | 
			
		||||
const tzFormatterCache = {};
 | 
			
		||||
const dmCache = {};
 | 
			
		||||
 | 
			
		||||
const reminderData = require(resolve(
 | 
			
		||||
  __dirname,
 | 
			
		||||
| 
						 | 
				
			
			@ -83,7 +84,10 @@ hf.bot.once("ready", () => {
 | 
			
		|||
          });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const channel = await hf.bot.users.get(data.user)?.createDM();
 | 
			
		||||
        if (!dmCache[data.user]) {
 | 
			
		||||
          dmCache[data.user] = await hf.bot.getDMChannel(data.user);
 | 
			
		||||
        }
 | 
			
		||||
        const channel = dmCache[data.user];
 | 
			
		||||
 | 
			
		||||
        const [date, time] = tzFormatterCache[data.tz]
 | 
			
		||||
          .format(Date.now())
 | 
			
		||||
| 
						 | 
				
			
			@ -103,9 +107,6 @@ hf.bot.once("ready", () => {
 | 
			
		|||
              content: ":alarm_clock: " + data.message,
 | 
			
		||||
            });
 | 
			
		||||
            await setLastRun(data.user, date);
 | 
			
		||||
            logger.verbose("privateReminders", "successfully sent");
 | 
			
		||||
          } else {
 | 
			
		||||
            logger.verbose("privateReminders", "dm channel is null");
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue