improved communication system
This commit is contained in:
@@ -3,15 +3,17 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
const config = useRuntimeConfig();
|
||||
|
||||
const coll = db.collection('users')
|
||||
const doc = await coll.findOne({ 'minecraft.uuid': uuid })
|
||||
|
||||
const usersColl = db.collection('users')
|
||||
const user = await usersColl.findOne({ 'minecraft.uuid': uuid })
|
||||
|
||||
const response = await getUsernameWithTeam(user);
|
||||
|
||||
await $fetch(config.discordHost + '/minecraft/sendchatmessage', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
username: doc.discord.username + ' | ' + doc.minecraft.username,
|
||||
username: response.usernameWithoutStyle,
|
||||
// avatarURL: 'https://cdn.discordapp.com/avatars/' + doc.discord.id + '/' + doc.discord.avatarHash + '.png',
|
||||
avatarURL: 'https://api.mineatar.io/face/' + doc.minecraft.uuid + '?scale=16',
|
||||
avatarURL: 'https://api.mineatar.io/face/' + user.minecraft.uuid + '?scale=16',
|
||||
content: content,
|
||||
}
|
||||
})
|
||||
|
@@ -1,10 +1,21 @@
|
||||
import { getUsernameWithTeam } from "~/server/utils/auth";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { discordId, content } = await readBody(event);
|
||||
|
||||
const coll = db.collection('users');
|
||||
const doc = await coll.findOne({ 'discord.id': discordId });
|
||||
const user = await coll.findOne({ 'discord.id': discordId });
|
||||
|
||||
await sendRconCommand(`tellraw @a {"text":"(DC) ${doc.discord.username} > ${content}"}`)
|
||||
const response = await getUsernameWithTeam(user)
|
||||
|
||||
let tellraw;
|
||||
if (user.team) {
|
||||
tellraw = `["",{"text":"DC","color":"gray"},{"text":" ${user.username} ["},{"text":"${response.team.name}","color":"${response.team.color}"},{"text":"] > ${content}"}]`
|
||||
} else {
|
||||
tellraw = `["",{"text":"DC","color":"gray"},{"text":" ${user.username} > ${content}"}]`
|
||||
}
|
||||
|
||||
await sendRconCommand(`tellraw @a ${tellraw}`)
|
||||
|
||||
return { status: 'success' }
|
||||
});
|
||||
|
@@ -1,12 +1,22 @@
|
||||
import { getUsernameWithTeam } from "~/server/utils/auth";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { uuid } = await readBody(event)
|
||||
|
||||
const coll = db.collection('whitelist')
|
||||
const usersColl = db.collection('users')
|
||||
|
||||
const doc = await coll.findOne({ uuid: uuid })
|
||||
|
||||
if (doc && !doc.verified) return { code: doc.code, verified: false }
|
||||
if (doc && doc.verified) return { verified: true }
|
||||
|
||||
if (doc && doc.verified) {
|
||||
const user = await usersColl.findOne({ 'minecraft.uuid': uuid });
|
||||
|
||||
const response = await getUsernameWithTeam(user);
|
||||
|
||||
return { verified: true, username: response.username, usernameWithoutStyle: response.usernameWithoutStyle }
|
||||
}
|
||||
|
||||
await coll.createIndex({ code: 1 }, { unique: true })
|
||||
|
||||
|
Reference in New Issue
Block a user