mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-16 20:00:59 -05:00
Improvements to index.ts
This commit is contained in:
parent
32f7bfcdca
commit
0b8a89acee
@ -1,7 +1,7 @@
|
||||
services:
|
||||
cache:
|
||||
container_name: daggerbot-redis
|
||||
image: redis/redis-stack-server:7.2.0-v10
|
||||
image: redis/redis-stack-server:7.4.0-rc2
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 6379:6379/tcp
|
||||
|
@ -46,7 +46,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ms": "0.7.34",
|
||||
"@types/node": "20.14.11",
|
||||
"@types/node": "20.14.12",
|
||||
"@types/node-cron": "3.0.11",
|
||||
"typescript": "5.4.5"
|
||||
}
|
||||
|
26
src/index.ts
26
src/index.ts
@ -75,14 +75,17 @@ setInterval(async()=>{
|
||||
Logger.console('log', 'DailyMsgs', `Pushed [${formattedDate}, ${total}]`)
|
||||
|
||||
// Send notification to #bot-log that the data has been pushed to database.
|
||||
const commands = await client.guilds.cache.get(client.config.dcServer.id)?.commands.fetch();
|
||||
if (commands) (client.channels.resolve(client.config.dcServer.channels.bot_log) as Discord.TextChannel).send({embeds: [
|
||||
new client.embed().setDescription(`Pushed the following\ndata to </rank leaderboard:${commands.find(x=>x.name === 'rank').id}>`).setFields(
|
||||
{name: 'Day', value: formattedDate.toString(), inline: true},
|
||||
{name: 'Messages', value: Intl.NumberFormat('en-us').format(total).toString(), inline: true}
|
||||
).setColor(client.config.embedColor)
|
||||
]});
|
||||
else Logger.console('log', 'DailyMsgs', 'Rank command not found, cannot send notification in channel')
|
||||
try {
|
||||
const commands = await client.guilds.cache.get(client.config.dcServer.id)?.commands.fetch();
|
||||
if (commands) (client.channels.cache.get(client.config.dcServer.channels.bot_log) as Discord.TextChannel).send({embeds: [
|
||||
new client.embed().setDescription(`Pushed the following\ndata to </rank leaderboard:${commands.find(x=>x.name === 'rank').id}>`).setFields(
|
||||
{name: 'Day', value: formattedDate.toString(), inline: true},
|
||||
{name: 'Messages', value: Intl.NumberFormat('en-us').format(total).toString(), inline: true}
|
||||
).setColor(client.config.embedColor)
|
||||
]});
|
||||
} catch {
|
||||
Logger.console('log', 'DailyMsgs', 'Rank command not found, cannot send notification in channel');
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 5000)
|
||||
@ -104,18 +107,15 @@ if (!client.config.botSwitches.logs) {
|
||||
};
|
||||
client.on('raw', async (packet:RawGatewayPacket<RawMessageUpdate>)=>{
|
||||
if (rawSwitches[packet.t] || packet.t !== 'MESSAGE_UPDATE') return;
|
||||
if (packet.d.guild_id != client.config.dcServer.id || disabledChannels.includes(packet.d.channel_id) || typeof packet.d.content === 'undefined') return;
|
||||
|
||||
const channel = client.channels.cache.get(packet.d.channel_id) as Discord.TextBasedChannel;
|
||||
if (packet.d.guild_id != client.config.dcServer.id || disabledChannels.includes(packet.d.channel_id) || typeof packet.d.content === undefined) return;
|
||||
|
||||
// Switched to console.log to prevent useless embed creation that has same content as the original message.
|
||||
if (!rawSwitches.MESSAGE_UPDATE && !packet.d.author.bot) return Logger.console('log', 'RawEvent:Edit', `Message was edited in #${(channel as Discord.TextChannel).name}`);
|
||||
if (!rawSwitches.MESSAGE_UPDATE && !packet.d.author.bot) return;
|
||||
});
|
||||
|
||||
client.on('raw', async (packet:RawGatewayPacket<RawMessageDelete>)=>{
|
||||
if (rawSwitches[packet.t]) return;
|
||||
if (packet.t !== 'MESSAGE_DELETE' || packet.d.guild_id != client.config.dcServer.id || disabledChannels.includes(packet.d.channel_id)) return;
|
||||
|
||||
Logger.console('log', 'RawEvent:Del', `Message was deleted in #${(client.channels.resolve(packet.d.channel_id) as Discord.TextChannel).name}`);
|
||||
rawSwitches[packet.t] = true;
|
||||
});
|
||||
|
10
yarn.lock
10
yarn.lock
@ -531,12 +531,12 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/node@npm:*, @types/node@npm:20.14.11":
|
||||
version: 20.14.11
|
||||
resolution: "@types/node@npm:20.14.11"
|
||||
"@types/node@npm:*, @types/node@npm:20.14.12":
|
||||
version: 20.14.12
|
||||
resolution: "@types/node@npm:20.14.12"
|
||||
dependencies:
|
||||
undici-types: "npm:~5.26.4"
|
||||
checksum: 10/344e1ce1ed16c86ed1c4209ab4d1de67db83dd6b694a6fabe295c47144dde2c58dabddae9f39a0a2bdd246e95f8d141ccfe848e464884b48b8918df4f7788025
|
||||
checksum: 10/9205bf46ef6a99d99cdde9efeb8218cd15803cc407249c2336557cd630b006380dad68c03ee574934414639f8e450044f45530c92788a8e82078bae45ee40f93
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@ -663,7 +663,7 @@ __metadata:
|
||||
"@sequelize/postgres": "npm:7.0.0-alpha.41"
|
||||
"@toast/tokenservice-client": "npm:1.2.8"
|
||||
"@types/ms": "npm:0.7.34"
|
||||
"@types/node": "npm:20.14.11"
|
||||
"@types/node": "npm:20.14.12"
|
||||
"@types/node-cron": "npm:3.0.11"
|
||||
ansi-colors: "npm:4.1.3"
|
||||
dayjs: "npm:1.11.12"
|
||||
|
Loading…
Reference in New Issue
Block a user