const express = require('express'); const index = require('../index') const router = express.Router(); router.post('/changenickname', async (req, res) => { const { nickname, discordId } = req.body; if (!nickname || !discordId ) return res.status(400).send({ error: 'Nickname en discordId zijn vereist' }); const nick = nickname.length > 32 ? nickname.slice(0, 32) : nickname try { const guild = await index.client.guilds.fetch(process.env.GUILD_ID); const member = await guild.members.fetch(discordId) await member.edit({ nick: nick }) } catch (e) { console.log(e); return res.status(500).send({ error: 'Error tijds het veranderen van de nickname' }) } res.send({ status: 'success' }); }); module.exports = router;