mirror of
https://github.com/cassoule/flopobot_v2.git
synced 2026-01-18 16:37:40 +01:00
avatar urls in db
This commit is contained in:
@@ -3,7 +3,7 @@ import { gork } from '../../utils/ai.js';
|
||||
import {formatTime, postAPOBuy, getAPOUsers, getAkhys} from '../../utils/index.js';
|
||||
import { channelPointsHandler, slowmodesHandler, randomSkinPrice, initTodaysSOTD } from '../../game/points.js';
|
||||
import { requestTimestamps, activeSlowmodes, activePolls, skins } from '../../game/state.js';
|
||||
import { flopoDB, getUser, getAllUsers, updateManyUsers } from '../../database/index.js';
|
||||
import {flopoDB, getUser, getAllUsers, updateManyUsers, insertUser, updateUserAvatar} from '../../database/index.js';
|
||||
import {client} from "../client.js";
|
||||
|
||||
// Constants for the AI rate limiter
|
||||
@@ -190,5 +190,20 @@ async function handleAdminCommands(message) {
|
||||
break;
|
||||
case `${prefix}:fetch-data`:
|
||||
await getAkhys(client);
|
||||
break;
|
||||
case `${prefix}:avatars`:
|
||||
const guild = await client.guilds.fetch(process.env.GUILD_ID);
|
||||
const members = await guild.members.fetch();
|
||||
const akhys = members.filter(m => !m.user.bot && m.roles.cache.has(process.env.AKHY_ROLE_ID));
|
||||
|
||||
const usersToUpdate = akhys.map(akhy => ({
|
||||
id: akhy.user.id,
|
||||
avatarUrl: akhy.user.displayAvatarURL({ dynamic: true, size: 256 }),
|
||||
}));
|
||||
|
||||
usersToUpdate.forEach(user => {
|
||||
try { updateUserAvatar.run(user) } catch (err) {}
|
||||
})
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,8 @@ export const stmtUsers = flopoDB.prepare(`
|
||||
allTimeWarns INTEGER DEFAULT 0,
|
||||
totalRequests INTEGER DEFAULT 0,
|
||||
coins INTEGER DEFAULT 0,
|
||||
dailyQueried BOOLEAN DEFAULT 0
|
||||
dailyQueried BOOLEAN DEFAULT 0,
|
||||
avatarUrl TEXT DEFAULT NULL
|
||||
)
|
||||
`);
|
||||
stmtUsers.run();
|
||||
@@ -36,8 +37,9 @@ export const stmtSkins = flopoDB.prepare(`
|
||||
`);
|
||||
stmtSkins.run()
|
||||
|
||||
export const insertUser = flopoDB.prepare('INSERT INTO users (id, username, globalName, warned, warns, allTimeWarns, totalRequests) VALUES (@id, @username, @globalName, @warned, @warns, @allTimeWarns, @totalRequests)');
|
||||
export const insertUser = flopoDB.prepare('INSERT INTO users (id, username, globalName, warned, warns, allTimeWarns, totalRequests, avatarUrl) VALUES (@id, @username, @globalName, @warned, @warns, @allTimeWarns, @totalRequests, @avatarUrl)');
|
||||
export const updateUser = flopoDB.prepare('UPDATE users SET warned = @warned, warns = @warns, allTimeWarns = @allTimeWarns, totalRequests = @totalRequests WHERE id = @id');
|
||||
export const updateUserAvatar = flopoDB.prepare('UPDATE users SET avatarUrl = @avatarUrl WHERE id = @id');
|
||||
export const queryDailyReward = flopoDB.prepare(`UPDATE users SET dailyQueried = 1 WHERE id = ?`);
|
||||
export const resetDailyReward = flopoDB.prepare(`UPDATE users SET dailyQueried = 0`);
|
||||
export const updateUserCoins = flopoDB.prepare('UPDATE users SET coins = @coins WHERE id = @id');
|
||||
|
||||
@@ -8,7 +8,7 @@ import { DiscordRequest } from '../api/discord.js';
|
||||
import { initTodaysSOTD } from '../game/points.js';
|
||||
import {
|
||||
insertManyUsers, insertManySkins, resetDailyReward,
|
||||
pruneOldLogs, getAllUsers as dbGetAllUsers, getSOTD, getUser, getAllUsers, insertUser,
|
||||
pruneOldLogs, getAllUsers as dbGetAllUsers, getSOTD, getUser, getAllUsers, insertUser, stmtUsers,
|
||||
} from '../database/index.js';
|
||||
import { activeInventories, activeSearchs, activePredis, pokerRooms, skins } from '../game/state.js';
|
||||
|
||||
@@ -48,6 +48,7 @@ export async function getAkhys(client) {
|
||||
warns: 0,
|
||||
allTimeWarns: 0,
|
||||
totalRequests: 0,
|
||||
avatarUrl: akhy.user.displayAvatarURL({ dynamic: true, size: 256 }),
|
||||
}));
|
||||
|
||||
if (usersToInsert.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user