diff --git a/assets/logo-zoomed.png b/assets/logo-zoomed.png new file mode 100644 index 0000000..8df2c99 Binary files /dev/null and b/assets/logo-zoomed.png differ diff --git a/assets/logo.blend b/assets/logo.blend new file mode 100644 index 0000000..1999fa2 Binary files /dev/null and b/assets/logo.blend differ diff --git a/assets/logo.blend1 b/assets/logo.blend1 new file mode 100644 index 0000000..ba8c3a6 Binary files /dev/null and b/assets/logo.blend1 differ diff --git a/assets/logo.png b/assets/logo.png new file mode 100644 index 0000000..9f6671b Binary files /dev/null and b/assets/logo.png differ diff --git a/assets/server-icon.png b/assets/server-icon.png new file mode 100644 index 0000000..92147f4 Binary files /dev/null and b/assets/server-icon.png differ diff --git a/discord-bot/index.js b/discord-bot/index.js index 4208c8b..703fe17 100644 --- a/discord-bot/index.js +++ b/discord-bot/index.js @@ -26,9 +26,13 @@ require('./functions/player.js').registerEvents({ client, createEmbed }); const app = express(); app.use(express.json()); -const messageRoute = require('./routes/Message'); +const minecraftRoute = require('./routes/Minecraft'); +const userRoute = require('./routes/User'); +const teamRoute = require('./routes/Team'); -app.use('/minecraft', messageRoute); +app.use('/minecraft', minecraftRoute); +app.use('/user', userRoute); +app.use('/team', teamRoute); app.listen('4000', () => { log.Info('Express app running'); diff --git a/discord-bot/routes/Message.js b/discord-bot/routes/Minecraft.js similarity index 100% rename from discord-bot/routes/Message.js rename to discord-bot/routes/Minecraft.js diff --git a/discord-bot/routes/Team.js b/discord-bot/routes/Team.js new file mode 100644 index 0000000..dc29c47 --- /dev/null +++ b/discord-bot/routes/Team.js @@ -0,0 +1,145 @@ +const express = require('express'); +const index = require('../index'); +const { PermissionsBitField, ChannelType } = require('discord.js'); + +const router = express.Router(); + +router.post('/createchannels', async (req, res) => { + const { name, discordId } = req.body; + + if (!name || !discordId ) return res.status(400).send({ error: 'Name en discordId zijn vereist' }); + + try { + const guild = await index.client.guilds.fetch(process.env.GUILD_ID); + + const category = await guild.channels.fetch(process.env.TEAM_CATEGORY_ID); + + const member = await guild.members.fetch(discordId) + + const textChannel = await guild.channels.create({ + name: name, + type: ChannelType.GuildText, + parent: category, + permissionOverwrites: [ + { + id: guild.id, + deny: [PermissionsBitField.Flags.ViewChannel], + }, + { + id: member.id, + allow: [PermissionsBitField.Flags.ViewChannel] + } + ] + }); + + const voiceChannel = await guild.channels.create({ + name: name, + type: ChannelType.GuildVoice, + parent: category, + permissionOverwrites: [ + { + id: guild.id, + deny: [PermissionsBitField.Flags.ViewChannel], + }, + { + id: member.id, + allow: [PermissionsBitField.Flags.ViewChannel] + } + ] + }); + + res.send({ textChannel, voiceChannel }); + } catch (e) { + console.log(e); + return res.status(500).send({ error: 'Error tijdens het maken van discord channels' }) + } +}); + + +router.post('/deletechannels', async (req, res) => { + const { textChannelId, voiceChannelId } = req.body; + + if (!textChannelId, !voiceChannelId ) return res.status(400).send({ error: 'textChannelId en voiceChannelId zijn vereist' }); + + try { + const guild = await index.client.guilds.fetch(process.env.GUILD_ID); + + const textChannel = await guild.channels.fetch(textChannelId); + const voiceChannel = await guild.channels.fetch(voiceChannelId); + + await textChannel.delete() + await voiceChannel.delete() + + res.send({ status: 'success' }); + } catch (e) { + console.log(e); + return res.status(500).send({ error: 'Error tijdens het verwijderen van discord channels' }) + } +}); + +router.post('/removeteammember', async (req, res) => { + const { textChannelId, voiceChannelId, discordId } = req.body; + + if (!textChannelId, !voiceChannelId, !discordId ) return res.status(400).send({ error: 'textChannelId, voiceChannelId en discordId zijn vereist' }); + + try { + const guild = await index.client.guilds.fetch(process.env.GUILD_ID); + const member = await guild.members.fetch(discordId) + + const textChannel = await guild.channels.fetch(textChannelId); + const voiceChannel = await guild.channels.fetch(voiceChannelId); + + await textChannel.permissionOverwrites.delete(member) + await voiceChannel.permissionOverwrites.delete(member) + + res.send({ status: 'success' }); + } catch (e) { + console.log(e); + return res.status(500).send({ error: 'Error tijdens het verwijderen van een team member' }) + } +}); + +router.post('/addteammember', async (req, res) => { + const { textChannelId, voiceChannelId, discordId } = req.body; + + if (!textChannelId, !voiceChannelId, !discordId ) return res.status(400).send({ error: 'textChannelId, voiceChannelId en discordId zijn vereist' }); + + try { + const guild = await index.client.guilds.fetch(process.env.GUILD_ID); + const member = await guild.members.fetch(discordId) + + const textChannel = await guild.channels.fetch(textChannelId); + const voiceChannel = await guild.channels.fetch(voiceChannelId); + + await textChannel.permissionOverwrites.edit(member, { ViewChannel: true }) + await voiceChannel.permissionOverwrites.edit(member, { ViewChannel: true }) + + res.send({ status: 'success' }); + } catch (e) { + console.log(e); + return res.status(500).send({ error: 'Error tijdens het toevoegen van team member' }) + } +}); + +router.post('/edit', async (req, res) => { + const { textChannelId, voiceChannelId, name } = req.body; + + if (!textChannelId, !voiceChannelId, !name ) return res.status(400).send({ error: 'textChannelId, voiceChannelId en name zijn vereist' }); + + try { + const guild = await index.client.guilds.fetch(process.env.GUILD_ID); + + const textChannel = await guild.channels.fetch(textChannelId); + const voiceChannel = await guild.channels.fetch(voiceChannelId); + + await textChannel.edit({ name: name }) + await voiceChannel.edit({ name: name }) + + res.send({ status: 'success' }); + } catch (e) { + console.log(e); + return res.status(500).send({ error: 'Error tijds het veranderen van Discord channel naam' }) + } +}); + +module.exports = router; diff --git a/discord-bot/routes/User.js b/discord-bot/routes/User.js new file mode 100644 index 0000000..f8a6663 --- /dev/null +++ b/discord-bot/routes/User.js @@ -0,0 +1,27 @@ +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;