diff --git a/dashboard/dashboard.js b/dashboard/dashboard.js index b0ae2fa8..858921bf 100644 --- a/dashboard/dashboard.js +++ b/dashboard/dashboard.js @@ -1,8 +1,9 @@ const SoftUI = require("./dashboard-core/theme/dbd-soft-ui"), DBD = require("./dashboard-core/index"), + settings = require("./settings"), fs = require("fs"); -const { PermissionsBitField, ChannelType } = require("discord.js"); +const { PermissionsBitField } = require("discord.js"); /** * @@ -21,8 +22,7 @@ module.exports.load = async client => { let categories = []; commands.forEach(c => { - if (!categories.includes(c._category)) - categories.push(c._category); + if (!categories.includes(c._category)) categories.push(c._category); }); categories = categories.map(c => { @@ -37,7 +37,6 @@ module.exports.load = async client => { }; }); - const Dashboard = new DBD.Dashboard({ port: client.config.dashboard.port, client: { @@ -53,7 +52,7 @@ module.exports.load = async client => { domain: client.config.dashboard.domain, redirectUri: `${client.config.dashboard.domain}${client.config.dashboard.port !== 80 ? `:${client.config.dashboard.port}` : ""}/discord/callback`, bot: client, - ownerIDs: [ client.config.owner.id ], + ownerIDs: [client.config.owner.id], requiredPermissions: PermissionsBitField.Flags.ViewChannel, minimizedConsoleLogs: true, invite: { @@ -108,7 +107,7 @@ module.exports.load = async client => { // eslint-disable-next-line no-unused-vars index: async ({ req, res, config }) => { const user = req.session?.user; - const username = user?.username || "Guest"; + const username = (user?.discriminator === "0" ? user?.username : user?.tag) || "Guest"; const hiddenGuildMembersCount = client.guilds.cache.get("568120814776614924").memberCount; let users = 0; @@ -214,508 +213,7 @@ module.exports.load = async client => { return "https://github.com/JonnyBro/JaBa/blob/main/dashboard/docs/updates.md"; }), ], - settings: [ - { - categoryId: "main", - categoryName: "Main settings", - categoryDescription: "Setup your bot here!", - categoryPermissions: PermissionsBitField.Flags.ManageGuild, - categoryOptionsList: [ - { - optionId: "lang", - optionName: "Language", - optionDescription: "Change bot's language on the server", - optionType: DBD.formTypes.select({ - "English": "en-US", - "Russian": "ru-RU", - "Ukrainian": "uk-UA", - }), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.language; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.language = newData; - guildData.markModified("language"); - await guildData.save(); - - return; - }, - }, - { - optionId: "welcome", - optionName: "Welcome Message", - optionDescription: "Setup welcome message on the server", - optionType: SoftUI.formTypes.multiRow([ - { - optionId: "welcome_enable", - optionName: "Enabled", - optionDescription: "Toggle welcome messages sending", - optionType: DBD.formTypes.switch(), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.welcome.enabled; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.welcome.enabled = newData; - guildData.markModified("plugins.welcome"); - await guildData.save(); - - return; - }, - }, - { - optionId: "welcome_image", - optionName: "Add Image", - optionDescription: "Toggle sending an image with welcome message", - optionType: DBD.formTypes.switch(), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.welcome.withImage; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.welcome.withImage = newData; - guildData.markModified("plugins.welcome"); - await guildData.save(); - - return; - }, - }, - { - optionId: "welcome_message", - optionName: "Message", - optionDescription: "Change welcome message (You can use {user}, {server} and {membercount} wildcards)", - optionType: DBD.formTypes.input("Welcome, {user}!", 2, 100, false, false), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.welcome.message; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.welcome.message = newData !== "" ? newData : null; - guildData.markModified("plugins.welcome"); - await guildData.save(); - - return; - }, - }, - { - optionId: "welcome_channel", - optionName: "Channel", - optionDescription: "Select a channel for welcome messages", - optionType: DBD.formTypes.channelsSelect(false, [ ChannelType.GuildText ]), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.welcome.channel; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.welcome.channel = newData !== "" ? newData : null; - guildData.markModified("plugins.welcome"); - await guildData.save(); - - return; - }, - }, - ]), - }, - { - optionId: "goodbye", - optionName: "Goodbye Message", - optionDescription: "Setup goodbye message on the server", - optionType: SoftUI.formTypes.multiRow([ - { - optionId: "goodbye_enable", - optionName: "Enabled", - optionDescription: "Toggle goodbye messages sending", - optionType: DBD.formTypes.switch(), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.goodbye.enabled; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.goodbye.enabled = newData; - guildData.markModified("plugins.goodbye"); - await guildData.save(); - - return; - }, - }, - { - optionId: "goodbye_image", - optionName: "Add Image", - optionDescription: "Toggle sending an image with goodbye message", - optionType: DBD.formTypes.switch(), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.goodbye.withImage; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.goodbye.withImage = newData; - guildData.markModified("plugins.goodbye"); - await guildData.save(); - - return; - }, - }, - { - optionId: "goodbye_message", - optionName: "Message", - optionDescription: "Change goodbye message (You can use {user}, {server} and {membercount} wildcards)", - optionType: DBD.formTypes.input("goodbye, {user}!", 2, 100, false, false), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.goodbye.message; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.goodbye.message = newData !== "" ? newData : null; - guildData.markModified("plugins.goodbye"); - await guildData.save(); - - return; - }, - }, - { - optionId: "goodbye_channel", - optionName: "Channel", - optionDescription: "Select a channel for goodbye messages", - optionType: DBD.formTypes.channelsSelect(false, [ ChannelType.GuildText ]), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.goodbye.channel; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.goodbye.channel = newData !== "" ? newData : null; - guildData.markModified("plugins.goodbye"); - await guildData.save(); - - return; - }, - }, - ]), - }, - { - optionId: "autorole", - optionName: "Auto Role", - optionDescription: "Setup auto role on the server", - optionType: SoftUI.formTypes.multiRow([ - { - optionId: "autorole_enable", - optionName: "Enabled", - optionDescription: "Toggle auto role granting for new members", - optionType: DBD.formTypes.switch(), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.autorole.enabled; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.autorole.enabled = newData; - guildData.markModified("plugins.autorole"); - await guildData.save(); - - return; - }, - }, - { - optionId: "autorole_role", - optionName: "Role", - optionDescription: "Select a role for auto role", - optionType: DBD.formTypes.rolesSelect(false, false, true), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.autorole.role; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.autorole.role = newData !== "" ? newData : null; - guildData.markModified("plugins.autorole"); - await guildData.save(); - - return; - }, - }, - ]), - }, - { - optionId: "automod", - optionName: "Auto Mod", - optionDescription: "Setup auto mod on the server", - optionType: SoftUI.formTypes.multiRow([ - { - optionId: "automod_enable", - optionName: "Enabled", - optionDescription: "Toggle auto mod granting for new members", - optionType: DBD.formTypes.switch(), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.automod.enabled; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.automod.enabled = newData; - guildData.markModified("plugins.automod"); - await guildData.save(); - - return; - }, - }, - { - optionId: "automod_ignore", - optionName: "Ignore Channels", - optionDescription: "Select a channels for auto mod to ignore", - optionType: DBD.formTypes.channelsMultiSelect(false, false, [ ChannelType.GuildText ]), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.automod.ignored; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.automod.ignored = newData; - guildData.markModified("plugins.automod"); - await guildData.save(); - - return; - }, - }, - ]), - }, - { - optionId: "monitoring", - optionName: "Monitoring Channels", - optionDescription: "Setup monitoring channels on the server", - optionType: SoftUI.formTypes.multiRow([ - { - optionId: "monitoring_messageupdate", - optionName: "Message Update Channel", - optionDescription: "Select a channel for messages updates logs to go to", - optionType: DBD.formTypes.channelsSelect(false, [ ChannelType.GuildText ]), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.monitoring.messageUpdate; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.monitoring.messageUpdate = newData !== "" ? newData : null; - guildData.markModified("plugins.monitoring"); - await guildData.save(); - - return; - }, - }, - ]), - }, - { - optionId: "channels", - optionName: "Special Channels", - optionDescription: "Setup special channels on the server", - optionType: SoftUI.formTypes.multiRow([ - { - optionId: "channels_suggestions", - optionName: "Suggestions Channel", - optionDescription: "Select a channel for suggestions to go to", - optionType: DBD.formTypes.channelsSelect(false, [ ChannelType.GuildText ]), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.suggestions; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.suggestions = newData !== "" ? newData : null; - guildData.markModified("plugins.suggestions"); - await guildData.save(); - - return; - }, - }, - { - optionId: "channels_reports", - optionName: "Reports Channel", - optionDescription: "Select a channel for reports to go to", - optionType: DBD.formTypes.channelsSelect(false, [ ChannelType.GuildText ]), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.reports; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.reports = newData !== "" ? newData : null; - guildData.markModified("plugins.reports"); - await guildData.save(); - - return; - }, - }, - { - optionId: "channels_birthdays", - optionName: "Birthdays Channel", - optionDescription: "Select a channel for birthdays message to go to", - optionType: DBD.formTypes.channelsSelect(false, [ ChannelType.GuildText ]), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.birthdays; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.birthdays = newData !== "" ? newData : null; - guildData.markModified("plugins.birthdays"); - await guildData.save(); - - return; - }, - }, - { - optionId: "channels_modlogs", - optionName: "Moderation Logs Channel", - optionDescription: "Select a channel for moderation logs to go to (warns)", - optionType: DBD.formTypes.channelsSelect(false, [ ChannelType.GuildText ]), - getActualSet: async ({ guild }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - return guildData.plugins.modlogs; - }, - setNew: async ({ guild, newData }) => { - const guildData = await client.findOrCreateGuild({ - id: guild.id, - }); - - guildData.plugins.modlogs = newData !== "" ? newData : null; - guildData.markModified("plugins.modlogs"); - await guildData.save(); - - return; - }, - }, - ]), - }, - ], - }, - { - categoryId: "test", - categoryName: "test settings", - categoryDescription: "ooga booba", - categoryPermissions: PermissionsBitField.Flags.ViewChannel, - categoryOptionsList: [ - { - optionType: DBD.formTypes.embedBuilder({ - username: "JaBa", - avatarURL: "https://cdn.discordapp.com/avatars/708637495054565426/af98d49ebc9bf28b40b45ed5a0a623b4.png?size=4096", - }), - }, - ], - }, - ], + settings: settings(client), }); await Dashboard.init().then(() => { @@ -723,4 +221,4 @@ module.exports.load = async client => { }).catch(err => { client.logger.log(`Dashboard failed to initialize:\n${err}`, "error"); }); -}; \ No newline at end of file +}; diff --git a/dashboard/settings.js b/dashboard/settings.js new file mode 100644 index 00000000..89b365f0 --- /dev/null +++ b/dashboard/settings.js @@ -0,0 +1,507 @@ +const SoftUI = require("./dashboard-core/theme/dbd-soft-ui"), + DBD = require("./dashboard-core/index"); + +const { PermissionsBitField, ChannelType } = require("discord.js"); + +module.exports = client => [ + { + categoryId: "main", + categoryName: "Main settings", + categoryDescription: "Setup your bot here!", + categoryPermissions: PermissionsBitField.Flags.ManageGuild, + categoryOptionsList: [ + { + optionId: "lang", + optionName: "Language", + optionDescription: "Change bot's language on the server", + optionType: DBD.formTypes.select({ + English: "en-US", + Russian: "ru-RU", + Ukrainian: "uk-UA", + }), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.language; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.language = newData; + guildData.markModified("language"); + await guildData.save(); + + return; + }, + }, + { + optionId: "welcome", + optionName: "Welcome Message", + optionDescription: "Setup welcome message on the server", + optionType: SoftUI.formTypes.multiRow([ + { + optionId: "welcome_enable", + optionName: "Enabled", + optionDescription: "Toggle welcome messages sending", + optionType: DBD.formTypes.switch(), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.welcome.enabled; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.welcome.enabled = newData; + guildData.markModified("plugins.welcome"); + await guildData.save(); + + return; + }, + }, + { + optionId: "welcome_image", + optionName: "Add Image", + optionDescription: "Toggle sending an image with welcome message", + optionType: DBD.formTypes.switch(), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.welcome.withImage; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.welcome.withImage = newData; + guildData.markModified("plugins.welcome"); + await guildData.save(); + + return; + }, + }, + { + optionId: "welcome_message", + optionName: "Message", + optionDescription: "Change welcome message (You can use {user}, {server} and {membercount} wildcards)", + optionType: DBD.formTypes.input("Welcome, {user}!", 2, 100, false, false), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.welcome.message; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.welcome.message = newData !== "" ? newData : null; + guildData.markModified("plugins.welcome"); + await guildData.save(); + + return; + }, + }, + { + optionId: "welcome_channel", + optionName: "Channel", + optionDescription: "Select a channel for welcome messages", + optionType: DBD.formTypes.channelsSelect(false, [ChannelType.GuildText]), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.welcome.channel; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.welcome.channel = newData !== "" ? newData : null; + guildData.markModified("plugins.welcome"); + await guildData.save(); + + return; + }, + }, + ]), + }, + { + optionId: "goodbye", + optionName: "Goodbye Message", + optionDescription: "Setup goodbye message on the server", + optionType: SoftUI.formTypes.multiRow([ + { + optionId: "goodbye_enable", + optionName: "Enabled", + optionDescription: "Toggle goodbye messages sending", + optionType: DBD.formTypes.switch(), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.goodbye.enabled; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.goodbye.enabled = newData; + guildData.markModified("plugins.goodbye"); + await guildData.save(); + + return; + }, + }, + { + optionId: "goodbye_image", + optionName: "Add Image", + optionDescription: "Toggle sending an image with goodbye message", + optionType: DBD.formTypes.switch(), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.goodbye.withImage; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.goodbye.withImage = newData; + guildData.markModified("plugins.goodbye"); + await guildData.save(); + + return; + }, + }, + { + optionId: "goodbye_message", + optionName: "Message", + optionDescription: "Change goodbye message (You can use {user}, {server} and {membercount} wildcards)", + optionType: DBD.formTypes.input("goodbye, {user}!", 2, 100, false, false), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.goodbye.message; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.goodbye.message = newData !== "" ? newData : null; + guildData.markModified("plugins.goodbye"); + await guildData.save(); + + return; + }, + }, + { + optionId: "goodbye_channel", + optionName: "Channel", + optionDescription: "Select a channel for goodbye messages", + optionType: DBD.formTypes.channelsSelect(false, [ChannelType.GuildText]), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.goodbye.channel; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.goodbye.channel = newData !== "" ? newData : null; + guildData.markModified("plugins.goodbye"); + await guildData.save(); + + return; + }, + }, + ]), + }, + { + optionId: "autorole", + optionName: "Auto Role", + optionDescription: "Setup auto role on the server", + optionType: SoftUI.formTypes.multiRow([ + { + optionId: "autorole_enable", + optionName: "Enabled", + optionDescription: "Toggle auto role granting for new members", + optionType: DBD.formTypes.switch(), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.autorole.enabled; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.autorole.enabled = newData; + guildData.markModified("plugins.autorole"); + await guildData.save(); + + return; + }, + }, + { + optionId: "autorole_role", + optionName: "Role", + optionDescription: "Select a role for auto role. Select \"-\" to disable", + optionType: DBD.formTypes.rolesSelect(false, false, true), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.autorole.role; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.autorole.role = newData !== "" ? newData : null; + guildData.markModified("plugins.autorole"); + await guildData.save(); + + return; + }, + }, + ]), + }, + { + optionId: "automod", + optionName: "Auto Mod", + optionDescription: "Setup auto mod on the server", + optionType: SoftUI.formTypes.multiRow([ + { + optionId: "automod_enable", + optionName: "Enabled", + optionDescription: "Toggle auto mod. It will remove invite links from non-moderators", + optionType: DBD.formTypes.switch(), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.automod.enabled; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.automod.enabled = newData; + guildData.markModified("plugins.automod"); + await guildData.save(); + + return; + }, + }, + { + optionId: "automod_ignore", + optionName: "Ignore Channels", + optionDescription: "Select a channels for auto mod to ignore", + optionType: DBD.formTypes.channelsMultiSelect(false, false, [ChannelType.GuildText]), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.automod.ignored; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.automod.ignored = newData; + guildData.markModified("plugins.automod"); + await guildData.save(); + + return; + }, + }, + ]), + }, + { + optionId: "monitoring", + optionName: "Monitoring Channels", + optionDescription: "Setup monitoring channels on the server", + optionType: SoftUI.formTypes.multiRow([ + { + optionId: "monitoring_messageupdate", + optionName: "Message Update Channel", + optionDescription: "Select a channel for messages updates logs to go to. Select \"-\" to disable", + optionType: DBD.formTypes.channelsSelect(false, [ChannelType.GuildText]), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.monitoring.messageUpdate; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.monitoring.messageUpdate = newData !== "" ? newData : null; + guildData.markModified("plugins.monitoring"); + await guildData.save(); + + return; + }, + }, + ]), + }, + { + optionId: "channels", + optionName: "Special Channels", + optionDescription: "Setup special channels on the server. Select \"-\" to disable", + optionType: SoftUI.formTypes.multiRow([ + { + optionId: "channels_suggestions", + optionName: "Suggestions Channel", + optionDescription: "Select a channel for suggestions to go to", + optionType: DBD.formTypes.channelsSelect(false, [ChannelType.GuildText]), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.suggestions; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.suggestions = newData !== "" ? newData : null; + guildData.markModified("plugins.suggestions"); + await guildData.save(); + + return; + }, + }, + { + optionId: "channels_reports", + optionName: "Reports Channel", + optionDescription: "Select a channel for reports to go to. Select \"-\" to disable", + optionType: DBD.formTypes.channelsSelect(false, [ChannelType.GuildText]), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.reports; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.reports = newData !== "" ? newData : null; + guildData.markModified("plugins.reports"); + await guildData.save(); + + return; + }, + }, + { + optionId: "channels_birthdays", + optionName: "Birthdays Channel", + optionDescription: "Select a channel for birthdays message to go to. Select \"-\" to disable", + optionType: DBD.formTypes.channelsSelect(false, [ChannelType.GuildText]), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.birthdays; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.birthdays = newData !== "" ? newData : null; + guildData.markModified("plugins.birthdays"); + await guildData.save(); + + return; + }, + }, + { + optionId: "channels_modlogs", + optionName: "Moderation Logs Channel", + optionDescription: "Select a channel for moderation logs to go to (warns). Select \"-\" to disable", + optionType: DBD.formTypes.channelsSelect(false, [ChannelType.GuildText]), + getActualSet: async ({ guild }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + return guildData.plugins.modlogs; + }, + setNew: async ({ guild, newData }) => { + const guildData = await client.findOrCreateGuild({ + id: guild.id, + }); + + guildData.plugins.modlogs = newData !== "" ? newData : null; + guildData.markModified("plugins.modlogs"); + await guildData.save(); + + return; + }, + }, + ]), + }, + ], + }, + { + categoryId: "test", + categoryName: "test settings", + categoryDescription: "ooga booba", + categoryPermissions: PermissionsBitField.Flags.ViewChannel, + categoryOptionsList: [ + { + optionType: DBD.formTypes.embedBuilder({ + username: "JaBa", + avatarURL: "https://cdn.discordapp.com/avatars/708637495054565426/af98d49ebc9bf28b40b45ed5a0a623b4.png?size=4096", + }), + }, + ], + }, +];