🐛 fixed work command and removed dashboard
This commit is contained in:
parent
e60c205097
commit
d9f0c951e7
9 changed files with 92 additions and 304 deletions
|
@ -18,12 +18,12 @@ module.exports = async (interaction) => {
|
||||||
timeoutId: 3,
|
timeoutId: 3,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const guild = await guilds.findOne({
|
||||||
|
guildId: interaction.member.guild.id,
|
||||||
|
});
|
||||||
|
|
||||||
// If user is not on timeout
|
// If user is not on timeout
|
||||||
if (!isTimeout) {
|
if (!isTimeout) {
|
||||||
const guild = await guilds.findOne({
|
|
||||||
guildId: interaction.member.guild.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Make a variable of how much credits user will earn based on random multiplied with work rate
|
// Make a variable of how much credits user will earn based on random multiplied with work rate
|
||||||
const creditsEarned = Math.floor(Math.random() * guild.credits.workRate);
|
const creditsEarned = Math.floor(Math.random() * guild.credits.workRate);
|
||||||
|
|
||||||
|
|
|
@ -66,14 +66,7 @@ module.exports = async (interaction) => {
|
||||||
lng: await user.language,
|
lng: await user.language,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
description: i18next.t(
|
description: `You have given ${target} a ${type} reputation!`,
|
||||||
'commands:reputation:addons:give:version02:embed:description',
|
|
||||||
{
|
|
||||||
lng: await user.language,
|
|
||||||
user: target,
|
|
||||||
type,
|
|
||||||
}
|
|
||||||
),
|
|
||||||
timestamp: new Date(),
|
timestamp: new Date(),
|
||||||
color: config.colors.success,
|
color: config.colors.success,
|
||||||
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
footer: { iconURL: config.footer.icon, text: config.footer.text },
|
||||||
|
|
|
@ -1,259 +0,0 @@
|
||||||
let DBD = require('discord-dashboard');
|
|
||||||
const config = require('../../config.json');
|
|
||||||
|
|
||||||
const DarkDashboard = require('dbd-dark-dashboard');
|
|
||||||
const { guilds, apis } = require('../helpers/database/models');
|
|
||||||
|
|
||||||
module.exports = async (client) => {
|
|
||||||
await DBD.useLicense(config.dashboard.licenseKey);
|
|
||||||
|
|
||||||
DBD.Dashboard = DBD.UpdatedClass();
|
|
||||||
|
|
||||||
const Dashboard = new DBD.Dashboard({
|
|
||||||
port: config.dashboard.port,
|
|
||||||
client: {
|
|
||||||
id: config.bot.clientId,
|
|
||||||
secret: config.bot.clientSecret,
|
|
||||||
},
|
|
||||||
acceptPrivacyPolicy: true,
|
|
||||||
redirectUri: `${config.dashboard.url}/discord/callback`,
|
|
||||||
domain: `${config.dashboard.url}`,
|
|
||||||
bot: client,
|
|
||||||
theme: DarkDashboard({
|
|
||||||
information: {
|
|
||||||
createdBy: 'Zyner',
|
|
||||||
websiteTitle: 'Xyter',
|
|
||||||
websiteName: 'Xyter',
|
|
||||||
websiteUrl: 'https://zyner.org',
|
|
||||||
dashboardUrl: `${config.dashboard.url}`,
|
|
||||||
supporteMail: 'contact@zyner.org',
|
|
||||||
supportServer: 'https://discord.gg/Ve9ug2zkbt',
|
|
||||||
imageFavicon:
|
|
||||||
'https://avatars.githubusercontent.com/u/83163073?s=200&v=4',
|
|
||||||
iconURL: 'https://avatars.githubusercontent.com/u/83163073?s=200&v=4',
|
|
||||||
pageBackGround: 'linear-gradient(#2CA8FF, #155b8d)',
|
|
||||||
loggedIn: 'Successfully signed in.',
|
|
||||||
mainColor: '#2CA8FF',
|
|
||||||
subColor: '#ebdbdb',
|
|
||||||
},
|
|
||||||
index: {
|
|
||||||
card: {
|
|
||||||
category: 'Xyter Panel',
|
|
||||||
title: `Welcome to the Xyter panel.`,
|
|
||||||
image: 'https://i.imgur.com/axnP93g.png',
|
|
||||||
footer: 'Zyner',
|
|
||||||
},
|
|
||||||
information: {
|
|
||||||
category: 'Self-host',
|
|
||||||
title: 'Open Source',
|
|
||||||
description: `The source code is available at https://github.com/ZynerOrg/xyter`,
|
|
||||||
footer: 'Zyner',
|
|
||||||
},
|
|
||||||
feeds: {
|
|
||||||
category: 'Support',
|
|
||||||
title: 'Information',
|
|
||||||
description: `If you need help, contact me on discord: Vermium#9649.`,
|
|
||||||
footer: 'Zyner',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
commands: [
|
|
||||||
{
|
|
||||||
category: 'Commands',
|
|
||||||
subTitle: 'All helpful commands',
|
|
||||||
aliasesDisabled: false,
|
|
||||||
list: [],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
settings: [
|
|
||||||
{
|
|
||||||
categoryId: 'credits',
|
|
||||||
categoryName: 'Credits',
|
|
||||||
categoryDescription: 'Setup your bot with credit settings!',
|
|
||||||
categoryOptionsList: [
|
|
||||||
{
|
|
||||||
optionId: 'status',
|
|
||||||
optionName: 'Status',
|
|
||||||
optionDescription: 'Toggle credits',
|
|
||||||
optionType: DBD.formTypes.switch(),
|
|
||||||
getActualSet: async ({ guild, user }) => {
|
|
||||||
const guildData = await guilds.findOne({ guildId: guild.id });
|
|
||||||
return guildData.credits.status;
|
|
||||||
},
|
|
||||||
setNew: async ({ guild, newData }) => {
|
|
||||||
const guildData = await guilds.findOne({ guildId: guild.id });
|
|
||||||
|
|
||||||
guildData.credits.status = newData ? true : false;
|
|
||||||
|
|
||||||
await guildData.save();
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
optionId: 'rate',
|
|
||||||
optionName: 'Rate',
|
|
||||||
optionDescription: 'Rate',
|
|
||||||
optionType: DBD.formTypes.input('1'),
|
|
||||||
getActualSet: async ({ guild, user }) => {
|
|
||||||
const guildData = await guilds.findOne({ guildId: guild.id });
|
|
||||||
|
|
||||||
return guildData.credits.rate;
|
|
||||||
},
|
|
||||||
setNew: async ({ guild, newData }) => {
|
|
||||||
const guildData = await guilds.findOne({ guildId: guild.id });
|
|
||||||
|
|
||||||
if (newData.match(/^[0-9]+$/) == null) {
|
|
||||||
return { error: 'Needs to be a number.' };
|
|
||||||
}
|
|
||||||
|
|
||||||
guildData.credits.rate = newData;
|
|
||||||
await guildData.save();
|
|
||||||
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
optionId: 'minimumLength',
|
|
||||||
optionName: 'Minimum Length',
|
|
||||||
optionDescription: 'Minimum length to earn credits',
|
|
||||||
optionType: DBD.formTypes.input('5'),
|
|
||||||
getActualSet: async ({ guild, user }) => {
|
|
||||||
const guildData = await guilds.findOne({ guildId: guild.id });
|
|
||||||
|
|
||||||
return guildData.credits.minimumLength;
|
|
||||||
},
|
|
||||||
setNew: async ({ guild, newData }) => {
|
|
||||||
const guildData = await guilds.findOne({ guildId: guild.id });
|
|
||||||
|
|
||||||
if (newData.match(/^[0-9]+$/) == null) {
|
|
||||||
return { error: 'Needs to be a number.' };
|
|
||||||
}
|
|
||||||
|
|
||||||
guildData.credits.minimumLength = newData;
|
|
||||||
await guildData.save();
|
|
||||||
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
optionId: 'timeout',
|
|
||||||
optionName: 'Timeout',
|
|
||||||
optionDescription: 'Timeout between earnings (milliseconds)',
|
|
||||||
optionType: DBD.formTypes.input('5000'),
|
|
||||||
getActualSet: async ({ guild, user }) => {
|
|
||||||
const guildData = await guilds.findOne({ guildId: guild.id });
|
|
||||||
|
|
||||||
return guildData.credits.timeout;
|
|
||||||
},
|
|
||||||
setNew: async ({ guild, newData }) => {
|
|
||||||
const guildData = await guilds.findOne({ guildId: guild.id });
|
|
||||||
|
|
||||||
if (newData.match(/^[0-9]+$/) == null) {
|
|
||||||
return { error: 'Needs to be a number.' };
|
|
||||||
}
|
|
||||||
|
|
||||||
guildData.credits.timeout = newData;
|
|
||||||
await guildData.save();
|
|
||||||
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
optionId: 'workRate',
|
|
||||||
optionName: 'Work Rate',
|
|
||||||
optionDescription: 'Work Rate',
|
|
||||||
optionType: DBD.formTypes.input('15'),
|
|
||||||
getActualSet: async ({ guild, user }) => {
|
|
||||||
const guildData = await guilds.findOne({ guildId: guild.id });
|
|
||||||
|
|
||||||
return guildData.credits.workRate;
|
|
||||||
},
|
|
||||||
setNew: async ({ guild, newData }) => {
|
|
||||||
const guildData = await guilds.findOne({ guildId: guild.id });
|
|
||||||
|
|
||||||
if (newData.match(/^[0-9]+$/) == null) {
|
|
||||||
return { error: 'Needs to be a number.' };
|
|
||||||
}
|
|
||||||
|
|
||||||
guildData.credits.workRate = newData;
|
|
||||||
await guildData.save();
|
|
||||||
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
optionId: 'workTimeout',
|
|
||||||
optionName: 'Work Timeout',
|
|
||||||
optionDescription: 'Work Timeout (milliseconds)',
|
|
||||||
optionType: DBD.formTypes.input('900000'),
|
|
||||||
getActualSet: async ({ guild, user }) => {
|
|
||||||
const guildData = await guilds.findOne({ guildId: guild.id });
|
|
||||||
|
|
||||||
return guildData.credits.workTimeout;
|
|
||||||
},
|
|
||||||
setNew: async ({ guild, newData }) => {
|
|
||||||
const guildData = await guilds.findOne({ guildId: guild.id });
|
|
||||||
|
|
||||||
if (newData.match(/^[0-9]+$/) == null) {
|
|
||||||
return { error: 'Needs to be a number.' };
|
|
||||||
}
|
|
||||||
|
|
||||||
guildData.credits.workTimeout = newData;
|
|
||||||
await guildData.save();
|
|
||||||
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
categoryId: 'pterodactyl',
|
|
||||||
categoryName: 'Pterodactyl',
|
|
||||||
categoryDescription: 'Setup your bot with pterodactyl settings!',
|
|
||||||
categoryOptionsList: [
|
|
||||||
{
|
|
||||||
optionId: 'url',
|
|
||||||
optionName: 'URL',
|
|
||||||
optionDescription: 'Configure your controlpanel.gg URL',
|
|
||||||
optionType: DBD.formTypes.input('https://bg.zyner.org/api/'),
|
|
||||||
getActualSet: async ({ guild, user }) => {
|
|
||||||
const api = await apis.findOne({ guildId: guild.id });
|
|
||||||
|
|
||||||
return api.url;
|
|
||||||
},
|
|
||||||
setNew: async ({ guild, newData }) => {
|
|
||||||
const api = await apis.findOne({ guildId: guild.id });
|
|
||||||
|
|
||||||
api.url = newData || api.url;
|
|
||||||
|
|
||||||
await api.save();
|
|
||||||
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
optionId: 'token',
|
|
||||||
optionName: 'Token',
|
|
||||||
optionDescription: 'Configure your controlpanel.gg Token',
|
|
||||||
optionType: DBD.formTypes.input('1'),
|
|
||||||
getActualSet: async ({ guild, user }) => {
|
|
||||||
const api = await apis.findOne({ guildId: guild.id });
|
|
||||||
|
|
||||||
return api.token;
|
|
||||||
},
|
|
||||||
setNew: async ({ guild, newData }) => {
|
|
||||||
const api = await apis.findOne({ guildId: guild.id });
|
|
||||||
|
|
||||||
api.token = newData || api.token;
|
|
||||||
|
|
||||||
await api.save();
|
|
||||||
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
Dashboard.init();
|
|
||||||
};
|
|
|
@ -1,6 +1,6 @@
|
||||||
const logger = require('../handlers/logger');
|
const logger = require('../handlers/logger');
|
||||||
|
|
||||||
const { database, deployCommands } = require('../helpers');
|
const { deployCommands } = require('../helpers');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'ready',
|
name: 'ready',
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
const mongoose = require('mongoose');
|
|
||||||
|
|
||||||
const profileSchema = new mongoose.Schema(
|
|
||||||
{
|
|
||||||
userId: {
|
|
||||||
type: mongoose.SchemaTypes.Decimal128,
|
|
||||||
required: true,
|
|
||||||
unique: false,
|
|
||||||
index: true,
|
|
||||||
},
|
|
||||||
url: {
|
|
||||||
type: mongoose.SchemaTypes.String,
|
|
||||||
required: true,
|
|
||||||
unique: false,
|
|
||||||
index: true,
|
|
||||||
},
|
|
||||||
token: {
|
|
||||||
type: mongoose.SchemaTypes.String,
|
|
||||||
required: true,
|
|
||||||
unique: false,
|
|
||||||
index: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ timestamps: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
module.exports = mongoose.model('profile', profileSchema);
|
|
21
src/helpers/dbGuildFix.js
Normal file
21
src/helpers/dbGuildFix.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
// TODO This file will make sure that all guilds always has at least one entry in all collections with "guildId"
|
||||||
|
|
||||||
|
const { apis, guilds } = require('./database/models');
|
||||||
|
const logger = require('../handlers/logger');
|
||||||
|
|
||||||
|
module.exports = async (guild) => {
|
||||||
|
const api = await apis.findOne({ guildId: guild.id });
|
||||||
|
const guildData = await guilds.find({ guildId: guild.id });
|
||||||
|
if (!api) {
|
||||||
|
apis.create({ guildId: guild.id });
|
||||||
|
logger.debug(`Guild: ${guild.id} added api collection`);
|
||||||
|
} else {
|
||||||
|
logger.debug(`Guild: ${guild.id} already in api collection`);
|
||||||
|
}
|
||||||
|
if (!guildData) {
|
||||||
|
guilds.create({ guildId: guild.id });
|
||||||
|
logger.debug(`Guild: ${guild.id} added guild collection`);
|
||||||
|
} else {
|
||||||
|
logger.debug(`Guild: ${guild.id} already in guild collection`);
|
||||||
|
}
|
||||||
|
};
|
57
src/helpers/dbMemberFix.js
Normal file
57
src/helpers/dbMemberFix.js
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
// TODO This file will make sure that all guilds always has at least one entry in all collections with "guildId"
|
||||||
|
|
||||||
|
const { users, experiences, credits } = require('./database/models');
|
||||||
|
const logger = require('../handlers/logger');
|
||||||
|
|
||||||
|
module.exports = async (user, guild) => {
|
||||||
|
const userData = await users.findOne({ userId: user.id });
|
||||||
|
if (!userData) {
|
||||||
|
users.create({ userId: user.id });
|
||||||
|
logger.debug(`User: ${user.id} added user collection`);
|
||||||
|
} else {
|
||||||
|
logger.debug(`User: ${user.id} already in user collection`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (guild) {
|
||||||
|
const credit = await credits.findOne({
|
||||||
|
userId: user.id,
|
||||||
|
guildId: guild.id,
|
||||||
|
});
|
||||||
|
if (!credit) {
|
||||||
|
await credits.create({ userId: user.id, guildId: guild.id });
|
||||||
|
await logger.debug(
|
||||||
|
`Guild: ${guild.id} User: ${user.id} added credit collection`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await logger.debug(
|
||||||
|
`Guild: ${guild.id} User: ${user.id} already in credit collection`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const experience = await experiences.findOne({
|
||||||
|
userId: user.id,
|
||||||
|
guildId: guild.id,
|
||||||
|
});
|
||||||
|
if (!experience) {
|
||||||
|
await experiences.create({ userId: user.id, guildId: guild.id });
|
||||||
|
await logger.debug(
|
||||||
|
`Guild: ${guild.id} User: ${user.id} added experience collection`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await logger.debug(
|
||||||
|
`Guild: ${guild.id} User: ${user.id} already in experience collection`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// const guilds = client.guilds.cache;
|
||||||
|
// await guilds.map(async (guild) => {
|
||||||
|
// await guild.members.fetch().then(async (members) => {
|
||||||
|
// await members.forEach(async (member) => {
|
||||||
|
// const { user } = member;
|
||||||
|
// dbMemberFix(user, guild);
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// await dbGuildFix(guild);
|
||||||
|
// });
|
||||||
|
};
|
|
@ -1,4 +1,6 @@
|
||||||
const database = require('./database');
|
const database = require('./database');
|
||||||
const deployCommands = require('./deployCommands');
|
const deployCommands = require('./deployCommands');
|
||||||
|
const dbGuildFix = require('./dbGuildFix');
|
||||||
|
const dbMemberFix = require('./dbMemberFix');
|
||||||
|
|
||||||
module.exports = { database, deployCommands };
|
module.exports = { database, deployCommands, dbGuildFix, dbMemberFix };
|
||||||
|
|
|
@ -4,17 +4,18 @@ const { Client, Intents } = require('discord.js'); // discord.js
|
||||||
const { database } = require('./helpers'); // helpers
|
const { database } = require('./helpers'); // helpers
|
||||||
const { events, commands, locale, schedules } = require('./handlers'); // handlers
|
const { events, commands, locale, schedules } = require('./handlers'); // handlers
|
||||||
|
|
||||||
const dashboard = require('./dashboard');
|
|
||||||
|
|
||||||
const config = require('../config.json'); // config.json
|
const config = require('../config.json'); // config.json
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
// Initialize discord.js client
|
// Initialize discord.js client
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
|
intents: [
|
||||||
|
Intents.FLAGS.GUILDS,
|
||||||
|
Intents.FLAGS.GUILD_MESSAGES,
|
||||||
|
Intents.FLAGS.GUILD_MEMBERS,
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
await dashboard(client);
|
|
||||||
await database();
|
await database();
|
||||||
await locale();
|
await locale();
|
||||||
await events(client);
|
await events(client);
|
||||||
|
|
Loading…
Add table
Reference in a new issue