Skip to content

Commit

Permalink
Merge branch 'main' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
Behzad-rabiei authored Nov 24, 2023
2 parents 4ab4cb0 + adf3e44 commit fbbd989
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 178 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ src/config/*.env
/dist
/lib
/node_modules
/lib

#migration
migrate.json
Expand Down
6 changes: 3 additions & 3 deletions src/functions/fetchMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function getNeedDataFromMessage(message: Message, threadInfo?: threadInfo)
channelName: threadInfo?.channelName ? threadInfo?.channelName : '',
threadId: threadInfo?.threadId ? threadInfo?.threadId : null,
threadName: threadInfo?.threadName ? threadInfo?.threadName : null,
isGeneratedByWebhook: message.webhookId ? true : false
isGeneratedByWebhook: message.webhookId ? true : false,
};
} else {
return {
Expand All @@ -83,7 +83,7 @@ async function getNeedDataFromMessage(message: Message, threadInfo?: threadInfo)
channelName: message.channel instanceof TextChannel ? message.channel.name : null,
threadId: null,
threadName: null,
isGeneratedByWebhook: message.webhookId ? true : false
isGeneratedByWebhook: message.webhookId ? true : false,
};
}
}
Expand Down Expand Up @@ -169,10 +169,10 @@ async function fetchMessages(
channelName: channel.parent?.name,
})
: await pushMessagesToArray(connection, messagesToStore, [...fetchedMessages.values()]);
await rawInfoService.createRawInfos(connection, messagesToStore);
options[fetchDirection] = boundaryMessage.id;
fetchedMessages = await channel.messages.fetch(options);
}
await rawInfoService.createRawInfos(connection, messagesToStore);
} catch (err) {
logger.error(
{ guild_id: connection.name, channel_id: channel.id, fetchDirection, err },
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,19 @@ async function app() {
host: config.redis.host,
port: config.redis.port,
password: config.redis.password,
},
}
});
queue.add('cronJob', {}, {
repeat: {
cron: '0 0 * * *', // Run once 00:00 UTC
// cron: '* * * * *', // Run every minute
// every: 10000
},
jobId: 'cronJob', // Optional: Provide a unique ID for the job
attempts: 1, // Number of times to retry the job if it fails
attempts: 0, // Number of times to retry the job if it fails
backoff: {
type: 'exponential',
delay: 1000, // Initial delay between retries in milliseconds
},

} as never);

// Create a worker to process the job
Expand All @@ -201,6 +200,7 @@ async function app() {
port: config.redis.port,
password: config.redis.password,
},
lockDuration: 79200000, // 22 hours
}
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
import 'dotenv/config';
import { Client, GatewayIntentBits, } from 'discord.js';
import { Client, GatewayIntentBits } from 'discord.js';
import { guildService } from '../../database/services';
import { connectDB } from '../../database';
import config from '../../config';
import webhookLogic from '../utils/webhookLogic';
import DatabaseManager from '../../database/connection';

const {
Guilds,
GuildMembers,
GuildMessages,
GuildPresences,
DirectMessages
} = GatewayIntentBits;

const { Guilds, GuildMembers, GuildMessages, GuildPresences, DirectMessages } = GatewayIntentBits;

export const up = async () => {
const client = new Client({
intents: [Guilds, GuildMembers, GuildMessages, GuildPresences, DirectMessages],
});
const client = new Client({
intents: [Guilds, GuildMembers, GuildMessages, GuildPresences, DirectMessages],
});

await client.login(config.discord.botToken);
await connectDB();
Expand All @@ -30,7 +23,5 @@ export const up = async () => {
};

export const down = async () => {
// TODO: Implement rollback logic if needed
// TODO: Implement rollback logic if needed
};


5 changes: 2 additions & 3 deletions src/migrations/utils/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export const up = async () => {
};

export const down = async () => {
await connectDB()

};
await connectDB();
};
Loading

0 comments on commit fbbd989

Please sign in to comment.