mirror of
https://github.com/cassoule/flopobot_v2.git
synced 2026-01-18 16:37:40 +01:00
avatar and users order by coins
This commit is contained in:
18
index.js
18
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);
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user