avatar and users order by coins

This commit is contained in:
milo
2025-05-07 21:29:50 +02:00
parent 71ad74d08d
commit 5075840bfa
2 changed files with 19 additions and 1 deletions

View File

@@ -2460,6 +2460,24 @@ app.get('/users', (req, res) => {
res.json(users);
});
app.get('/user/:id/avatar', async (req, res) => {
try {
const userId = req.params.id; // Get the ID from route parameters
const user = await client.users.fetch(userId);
if (!user) {
return res.status(404).json({ error: 'User not found' });
}
const avatarUrl = user.displayAvatarURL({ format: 'png', size: 256 });
res.json({ avatarUrl });
} catch (error) {
console.error('Error fetching user avatar:', error);
res.status(500).json({ error: 'Failed to fetch avatar' });
}
})
app.post('/send-message', (req, res) => {
const { channelId, message } = req.body;
const channel = client.channels.cache.get(channelId);

View File

@@ -39,7 +39,7 @@ export const insertUser = flopoDB.prepare('INSERT INTO users (id, username, glob
export const updateUser = flopoDB.prepare('UPDATE users SET warned = @warned, warns = @warns, allTimeWarns = @allTimeWarns, totalRequests = @totalRequests WHERE id = @id');
export const updateUserCoins = flopoDB.prepare('UPDATE users SET coins = @coins WHERE id = @id');
export const getUser = flopoDB.prepare('SELECT * FROM users WHERE id = ?');
export const getAllUsers = flopoDB.prepare('SELECT * FROM users');
export const getAllUsers = flopoDB.prepare('SELECT * FROM users ORDER BY coins DESC');
export const insertSkin = flopoDB.prepare('INSERT INTO skins (uuid, displayName, contentTierUuid, displayIcon, user_id, tierRank, tierColor, tierText, basePrice, currentLvl, currentChroma, currentPrice, maxPrice) VALUES (@uuid, @displayName, @contentTierUuid, @displayIcon, @user_id, @tierRank, @tierColor, @tierText, @basePrice, @currentLvl, @currentChroma, @currentPrice, @maxPrice)');
export const updateSkin = flopoDB.prepare('UPDATE skins SET user_id = @user_id, currentLvl = @currentLvl, currentChroma = @currentChroma, currentPrice = @currentPrice WHERE uuid = @uuid');