require("dotenv").config();
const DBD = require("discord-dashboard");
const CaprihamTheme = require("dbd-capriham-theme");
const local = require("../Outhouse/local.json");
const fs = require("fs");
const path = require("path");
const { Client } = require("discord.js");
const client = new Client({
intents: ["DIRECT_MESSAGES", "GUILDS", "GUILD_MEMBERS", "GUILD_MESSAGES"],
});
client.login(process.env.TOKEN);
function getPrefix(guildid = "guildid") {
return local.prefix[guildid] || local.prefix.guildid;
}
async function updatePrefix(guildid = "guildid", newPrefix = "??") {
const previous = local.prefix[guildid];
local.prefix[guildid] = newPrefix;
const toPut = JSON.stringify(local, null, 2);
await fs.writeFileSync(
path.join(__dirname, "..", "Outhouse", "local.json"),
toPut,
{ encoding: "utf-8" }
);
return { previous, new: newPrefix };
}
const Dashboard = new DBD.Dashboard({
port: 80,
client: {
id: process.env.CLIENT_ID,
secret: process.env.SECRET,
},
redirectUri: "http://localhost/discord/callback",
domain: "http://localhost",
bot: client,
ownerIDs: [],
theme: CaprihamTheme({
websiteName: "Website",
iconURL: "https://assistants.ga/ac_logo_v6.png",
index: {
card: {
title: "Assistants - The center of everything",
description:
"Assistants Discord Bot management panel. Assistants Bot was created to give others the ability to do what they want. Just.<br>That's an example text.<br><br><b><i>Feel free to use HTML</i></b>",
image:
"https://www.geeklawblog.com/wp-content/uploads/sites/528/2018/12/liprofile-656x369.png",
},
information: {
title: "Information",
description:
"To manage your bot, go to the <a href='/manage'>Server Management page</a>.<br><br>For a list of commands, go to the <a href='/commands'>Commands page</a>.<br><br><b><i>You can use HTML there</i></b>",
},
feeds: {
title: "Feeds",
list: [
{
icon: "fa fa-user",
text: "New user registered",
timeText: "Just now",
bg: "bg-light-info",
},
{
icon: "fa fa-server",
text: "Server issues",
timeText: "3 minutes ago",
bg: "bg-light-danger",
},
],
},
},
commands: {
pageTitle: "Commands",
table: {
title: "List",
subTitle: "All Assistants' commands",
list: [
{
commandName: "Test command",
commandUsage: "prefix.test <arg> [op]",
commandDescription: "Lorem ipsum dolor sth",
},
{
commandName: "2nd command",
commandUsage: "oto.nd <arg> <arg2> [op]",
commandDescription: "Lorem ipsum dolor sth, arg sth arg2 stuff",
},
],
},
},
}),
settings: [
{
categoryId: "guild_settings",
categoryName: "Settings",
categoryDescription: "Guild settings",
categoryOptionsList: [
{
optionId: "new_prefix",
optionName: "Change prefix",
optionDescription: "Change prefix for your guild",
optionType: DBD.formTypes.input("New prefix", 1, 5, false, true),
getActualSet: async ({ guild }) => {
return getPrefix(guild.id);
},
setNew: async ({ guild, newData }) => {
// currencyNames[guild.id] = newData;
const newUpdated = updatePrefix(guild.id, newData);
return;
},
},
],
},
],
});
Dashboard.init();