diff --git a/index.js b/index.js index f07992c..d6f5f42 100644 --- a/index.js +++ b/index.js @@ -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); diff --git a/init_database.js b/init_database.js index 8823baa..42e079c 100644 --- a/init_database.js +++ b/init_database.js @@ -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');