diff --git a/src/commands/active.ts b/src/commands/active.ts index 043d1129..e7ace445 100644 --- a/src/commands/active.ts +++ b/src/commands/active.ts @@ -77,7 +77,7 @@ export default new app.Command({ intervals[message.guild.id] = setInterval( async () => { - if (await app.hasActivity(config._id, message.args.interval)) + if (!(await app.hasActivity(config._id, message.args.interval))) return await app.sendLog( message.guild, `Ignored automated active list update, no activity detected in the last period.`, diff --git a/src/namespaces/active.ts b/src/namespaces/active.ts index 6fb6f69a..162d1db6 100644 --- a/src/namespaces/active.ts +++ b/src/namespaces/active.ts @@ -190,19 +190,18 @@ export async function hasActivity( guild_id: number, period: number, ): Promise { - return true - // return app.orm - // .raw( - // `select - // count(*) > 0 as hasActivity - // from message - // where - // guild_id = ${guild_id} - // and - // unixepoch(datetime(created_at, 'localtime')) > - // unixepoch(datetime('now', '-${period} hours', 'localtime'))` - // ) - // .then((result) => !!result[0]?.hasActivity) + return app.orm + .raw( + `select + count(*) > 0 as hasActivity + from message + where + guild_id = ${guild_id} + and + unixepoch(datetime(created_at, 'localtime')) > + unixepoch(datetime('now', '-${period} hours', 'localtime'))`, + ) + .then((result) => !!result[0]?.hasActivity) } export interface ActiveLadderLine {