Skip to content

Commit

Permalink
broke the configs lol
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyzxin committed Jun 27, 2023
1 parent 6a6b8db commit f2338cd
Show file tree
Hide file tree
Showing 10 changed files with 177 additions and 21 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,5 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
config/config.json
config/channels.json
yarn.lock
.yarn.installed
4 changes: 2 additions & 2 deletions commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
if(content.toLowerCase().startsWith(`${client.config.prefix}create`)){
const tUser = await message.guild.members.cache.get(author.id);
if(!tUser.permissions.has("ADMINISTRATOR")) return message.reply({content: "⛔ | Missing Permissions to use this command.\nNeeded permission flag: `ADMINISTRATOR`"})
const channels = JSON.parse(LoadResourceFile(GetCurrentResourceName(), '/config/channels.json'));
const channels = JSON.parse(LoadResourceFile(GetCurrentResourceName(), '/configs/channels.json'));
newChannel = {}
message.delete()
channels[newChannel.name] = {
Expand Down Expand Up @@ -63,7 +63,7 @@ module.exports = {
setTimeout(() => {
if(nc){
const newChannels = JSON.stringify(channels)
SaveResourceFile(GetCurrentResourceName(), '/config/channels.json', newChannels);
SaveResourceFile(GetCurrentResourceName(), '/configs/channels.json', newChannels);
let embed = new MessageEmbed()
.setTimestamp()
.setDescription(`**Details:**\n\n**Export Channel:** \`${newChannel.name}\`\n**Discord Channel Name:** \`#・${newChannel.name}-logs\` - \`${channels[newChannel.name].channelId}\`\n**Message Icon:** ${newChannel.icon}\n**Embed Color:** \`${newChannel.color}\``)
Expand Down
4 changes: 2 additions & 2 deletions commands/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
message.react("✅");
const tUser = await message.guild.members.cache.get(author.id);
if(!tUser.permissions.has("ADMINISTRATOR")) return message.reply({content: "⛔ | Missing Permissions to use this command.\nNeeded permission flag: `ADMINISTRATOR`"})
const channels = JSON.parse(LoadResourceFile(GetCurrentResourceName(), '/config/channels.json'));
const channels = JSON.parse(LoadResourceFile(GetCurrentResourceName(), '/configs/channels.json'));
await channel.send('**Starting JD_logs Setup!**\n*ETA: 30 seconds*').then(msg => {
response = msg
})
Expand Down Expand Up @@ -281,7 +281,7 @@ module.exports = {
setTimeout(() => {
channels['newInstall'] = false
const newChannels = JSON.stringify(channels, null, 2)
SaveResourceFile(GetCurrentResourceName(), '/config/channels.json', newChannels);
SaveResourceFile(GetCurrentResourceName(), '/configs/channels.json', newChannels);
response.edit(`**Your Channels:**\n${ids}`)
}, 30000);
}
Expand Down
14 changes: 7 additions & 7 deletions commands/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {
message.react("✅");
const tUser = await message.guild.members.cache.get(author.id);
if(!tUser.permissions.has("ADMINISTRATOR")) return message.reply({content: "⛔ | Missing Permissions to use this command.\nNeeded permission flag: `ADMINISTRATOR`"})
const channels = JSON.parse(LoadResourceFile(GetCurrentResourceName(), '/config/channels.json'));
const channels = JSON.parse(LoadResourceFile(GetCurrentResourceName(), '/configs/channels.json'));
const args = content.split(" ")
if(!channels['imageStore']){
return channel.send(`Please use \`${client.config.prefix}setup\` first.`)
Expand All @@ -51,13 +51,13 @@ module.exports = {
})

const newChannels = JSON.stringify(channels, null, 2)
SaveResourceFile(GetCurrentResourceName(), '/config/channels.json', newChannels);
SaveResourceFile(GetCurrentResourceName(), '/configs/channels.json', newChannels);
channel.send(`Webhook for Image store has been reset!\n**If you set a webhook then the bot will delete the old one.**`)
}

if(content.toLowerCase().startsWith(`${client.config.prefix}uninstall`)){
message.react("✅");
const channels = JSON.parse(LoadResourceFile(GetCurrentResourceName(), '/config/channels.json'));
const channels = JSON.parse(LoadResourceFile(GetCurrentResourceName(), '/configs/channels.json'));
for (const [key, value] of Object.entries(channels)) {
let channel = await client.channels.cache.get(value.channelId);
try{
Expand Down Expand Up @@ -87,7 +87,7 @@ module.exports = {
message.react("✅");
const tUser = await message.guild.members.cache.get(author.id);
if(!tUser.permissions.has("ADMINISTRATOR")) return message.reply({content: "⛔ | Missing Permissions to use this command.\nNeeded permission flag: `ADMINISTRATOR`"})
const channels = JSON.parse(LoadResourceFile(GetCurrentResourceName(), '/config/channels.json'));
const channels = JSON.parse(LoadResourceFile(GetCurrentResourceName(), '/configs/channels.json'));
const args = content.split(" ")
message.delete()

Expand All @@ -102,21 +102,21 @@ module.exports = {
return channel.send(`⛔ **|** Could not delete channel <#${dc.id}}> for \`${args[2]}\``);
}
const newChannels = JSON.stringify(channels)
SaveResourceFile(GetCurrentResourceName(), '/config/channels.json', newChannels);
SaveResourceFile(GetCurrentResourceName(), '/configs/channels.json', newChannels);
}

if(content.toLowerCase().startsWith(`${client.config.prefix}embed`)){
message.react("✅");
const tUser = await message.guild.members.cache.get(author.id);
if(!tUser.permissions.has("ADMINISTRATOR")) return message.reply({content: "⛔ | Missing Permissions to use this command.\nNeeded permission flag: `ADMINISTRATOR`"})
const channels = JSON.parse(LoadResourceFile(GetCurrentResourceName(), '/config/channels.json'));
const channels = JSON.parse(LoadResourceFile(GetCurrentResourceName(), '/configs/channels.json'));
const args = content.split(" ");
if(args[2] == null || args[2] == undefined) return message.reply({content: "⛔ | You need to specify a channel.\nExample: `!embed chat`"})
channels[args[2]].embed = !channels[args[2]].embed
let state = 'Disabled'
if(!channels[args[2]].noEmbed) state = 'Enabled'
const newChannels = JSON.stringify(channels)
SaveResourceFile(GetCurrentResourceName(), '/config/channels.json', newChannels);
SaveResourceFile(GetCurrentResourceName(), '/configs/channels.json', newChannels);
channel.send({content:`✅ **|** Channel embeds have been \`${state}\`\n*Resource reload is required before changes can take effect.*`})
}
},
Expand Down
101 changes: 101 additions & 0 deletions configs/channels.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"newInstall": false,
"all": {
"channelId": "",
"color": "#A1A1A1",
"embed": true
},
"system": {
"channelId": "",
"icon": "🧾",
"color": "#A1A1A1",
"embed": true
},
"imageStore": {
"channelId": "",
"webhookID": "",
"webhookToken": ""
},
"chat": {
"channelId": "",
"icon": "💬",
"color": "#A1A1A1",
"logHistory": true,
"embed": true
},
"join": {
"channelId": "",
"icon": "📥",
"color": "#3AF241",
"logHistory": true,
"embed": true
},
"leave": {
"channelId": "",
"icon": "📤",
"color": "#F23A3A",
"logHistory": true,
"embed": true
},
"death": {
"channelId": "",
"icon": "💀",
"color": "#000000",
"logHistory": true,
"embed": true
},
"shooting": {
"channelId": "",
"icon": "🔫",
"color": "#2E66F2",
"logHistory": false,
"embed": true
},
"resource": {
"channelId": "",
"icon": "🔧",
"color": "#EBEE3F",
"logHistory": true,
"embed": true
},
"nameChange": {
"channelId": "",
"icon": "💠",
"color": "#03FC98",
"logHistory": true,
"embed": true
},
"explosion": {
"channelId": "",
"icon": "🧨",
"color": "#03FC98",
"logHistory": true,
"embed": true
},
"permission": {
"channelId": "",
"icon": "🔒",
"color": "#03FC98",
"logHistory": true,
"embed": true
},
"screenshot": {
"channelId": "",
"icon": "📸",
"color": "#A1A1A1",
"logHistory": false,
"embed": true
},
"txAdmin": {
"channelId": "",
"icon": "💻",
"color": "#FFFFFF",
"embed": true
},
"damage": {
"channelId": "",
"icon": "🩸",
"color": "#FF0000",
"embed": true
}
}
57 changes: 57 additions & 0 deletions configs/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"prefix":"!jdlogs ",
"token": "",
"guildId": "",
"TimezoneOffset": "+01:00",
"language": "en",

"NameChangePerms": "jd.staff",
"screenshotPerms": "jd.staff",

"allLogs": true,
"CheckTimeout": false,
"UseDiscordAcePerms": false,

"weaponLog": true,
"damageLog": true,
"deathLog": true,

"playerId": true,
"postals": true,
"playerHealth": true,
"playerArmor": true,
"playerPing": true,

"ip": true,
"steamUrl": true,
"discordId": {
"enabled": true,
"spoiler": true
},
"steamId": {
"enabled": true,
"spoiler": true
},
"license": {
"enabled": true,
"spoiler": true
},

"WebhookResetMessage": false,

"WeaponsNotLogged": [
"WEAPON_SNOWBALL",
"WEAPON_FIREEXTINGUISHER",
"WEAPON_PETROLCAN"
],
"ExplosionsNotLogged": [],

"DiscordAcePerms": {
"DISCORD_ROLE_ID": {
"groups": ["group.superadmin", "group.admin", "group.mod", "group._dev"],
"perms": ["jd.staff"]
}
},

"maxListeners": 20
}
4 changes: 2 additions & 2 deletions events/newWebhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
once: true,
async execute() {
try {
const channels = JSON.parse(LoadResourceFile(GetCurrentResourceName(), '/config/channels.json'));
const channels = JSON.parse(LoadResourceFile(GetCurrentResourceName(), '/configs/channels.json'));
if(channels['imageStore'].channelId == ''){ return }
const c = await client.channels.cache.get(channels['imageStore'].channelId);
const guild = c.guild;
Expand All @@ -24,7 +24,7 @@ module.exports = {
})

const newChannels = JSON.stringify(channels, null, 2)
SaveResourceFile(GetCurrentResourceName(), '/config/channels.json', newChannels);
SaveResourceFile(GetCurrentResourceName(), '/configs/channels.json', newChannels);
if(client.config.WebhookResetMessage){
await c.send({embeds: [new MessageEmbed().setTitle(`🧹・Webhook for Image store has been Reset!`)]})
}
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const { promisify } = require("util");
const globPromise = promisify(glob);

try {
config = require("./config/config.json");
channels = require("./config/channels.json");
config = require("./configs/config.json");
channels = require("./configs/channels.json");
} catch {}

const permissionCheck = ["MANAGE_CHANNELS", "SEND_MESSAGES", "VIEW_CHANNEL", "MANAGE_WEBHOOKS"]
Expand Down
4 changes: 2 additions & 2 deletions server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ ServerFunc.CreateLog = function(data)
end

if data.screenshot then --[[ this log requires a screenshot to be made so we will transfer to client to grab a screenshot. ]]
local channelsLoadFile = LoadResourceFile(GetCurrentResourceName(), "./config/channels.json")
local channelsLoadFile = LoadResourceFile(GetCurrentResourceName(), "./configs/channels.json")
local theFile = json.decode(channelsLoadFile)
data.url = theFile.imageStore.webhookID.."/"..theFile.imageStore.webhookToken
return TriggerClientEvent('Prefech:JD_logsV3:ClientCreateScreenshot', data.player_id, data)
end
if data.screenshot_2 then --[[ this log requires a second screenshot to be made so we will transfer to client to grab a screenshot. ]]
local channelsLoadFile = LoadResourceFile(GetCurrentResourceName(), "./config/channels.json")
local channelsLoadFile = LoadResourceFile(GetCurrentResourceName(), "./configs/channels.json")
local theFile = json.decode(channelsLoadFile)
data.url = theFile.imageStore.webhookID.."/"..theFile.imageStore.webhookToken
return TriggerClientEvent('Prefech:JD_logsV3:ClientCreateScreenshot', data.player_2_id, data)
Expand Down
4 changes: 2 additions & 2 deletions server/main.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local configRawFile = LoadResourceFile(GetCurrentResourceName(), "./config/config.json")
local configRawFile = LoadResourceFile(GetCurrentResourceName(), "./configs/config.json")
Config = json.decode(configRawFile)
local channelRawFile = LoadResourceFile(GetCurrentResourceName(), "./config/channels.json")
local channelRawFile = LoadResourceFile(GetCurrentResourceName(), "./configs/channels.json")
Channels = json.decode(channelRawFile)
if Config ~= nil then
local langFile = LoadResourceFile(GetCurrentResourceName(), "./lang/" .. Config.language .. ".json")
Expand Down

0 comments on commit f2338cd

Please sign in to comment.