Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v5.0.0 #553

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
21a4d7f
:recycle: Start rewrite
Androz2091 Aug 25, 2021
330bdb0
:bug: Some fixes
Androz2091 Aug 26, 2021
62d0ae1
:recycle: Rewrite all message#error with interaction#reply
Androz2091 Aug 26, 2021
aa4ebd0
:recycle: Rewrite all message#success and message#sendT with interact…
Androz2091 Aug 26, 2021
445bee6
:recycle: Rewrite all params
Androz2091 Aug 26, 2021
6a24ea7
:fire: Remove extenders
Androz2091 Aug 26, 2021
8d9829e
:recycle: Rewrite birthdate command
Androz2091 Aug 26, 2021
a0f38c6
:bug: Fix birthdate option
Androz2091 Aug 26, 2021
ded6fa1
:recycle: Rewrite deposit command
Androz2091 Aug 26, 2021
6002044
:recycle: Replace some common bugs
Androz2091 Aug 26, 2021
7d2b61e
:fire: Remove useless usage language key
Androz2091 Aug 26, 2021
eb5b464
:recycle: Rewrite some commands
Androz2091 Aug 26, 2021
952f13f
:art: Clean up code
Androz2091 Aug 26, 2021
0affe77
:art: Add eol last eslint rule
Androz2091 Aug 26, 2021
adbcd71
:recycle: Rewrite marry command
Androz2091 Aug 26, 2021
0a7c18a
:fire: Remove aliases
Androz2091 Aug 26, 2021
5a1b76d
:recycle: Rewrite money command
Androz2091 Aug 26, 2021
1bdd2ac
:recycle: Rewrite pay command
Androz2091 Aug 26, 2021
f1b823b
:recycle: Rewrite profile command
Androz2091 Aug 26, 2021
98dcd6e
:recycle: Rewrite rep command
Androz2091 Aug 26, 2021
41646df
:recycle: Rewrite rob command
Androz2091 Aug 26, 2021
5b43bbb
:recycle: Rewrite bio command
Androz2091 Aug 26, 2021
dbad911
:recycle: Rewrite slot command
Androz2091 Aug 26, 2021
1e7efa3
:lipstick: Clean up slots command
Androz2091 Aug 26, 2021
58fb99e
:recycle: Rewrite withdraw command
Androz2091 Aug 26, 2021
a7bd26c
:recycle: Rewrite work command
Androz2091 Aug 26, 2021
cb367c6
:recycle: Rewrite ban command
Androz2091 Aug 29, 2021
c43c326
:fire: Remove announcement command
Androz2091 Aug 29, 2021
d46d3e6
:recycle: Rename data#guild to data#guildData
Androz2091 Aug 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions atlanta.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
require("./helpers/extenders");

const Sentry = require("@sentry/node"),
util = require("util"),
fs = require("fs"),
readdir = util.promisify(fs.readdir),
mongoose = require("mongoose"),
chalk = require("chalk");
chalk = require("chalk"),
synchronizeSlashCommands = require("discord-sync-commands");

const config = require("./config");
if(config.apiKeys.sentryDSN){
Expand All @@ -23,17 +22,42 @@ const Atlanta = require("./base/Atlanta"),

const init = async () => {

const languages = require("./helpers/languages");
client.translations = await languages();

// Search for all commands
const directories = await readdir("./commands/");
client.logger.log(`Loading a total of ${directories.length} categories.`, "log");
directories.forEach(async (dir) => {
await Promise.all(directories.map(async (dir) => {
const commands = await readdir("./commands/"+dir+"/");
commands.filter((cmd) => cmd.split(".").pop() === "js").forEach((cmd) => {
const response = client.loadCommand("./commands/"+dir, cmd);
if(response){
client.logger.log(response, "error");
}
});
}));

const slashCommands = client.commands.filter((c) => c.conf.options);
synchronizeSlashCommands(client, slashCommands.map((command) => ({
name: command.help.name,
type: "CHAT_INPUT",
description: client.translations.get("en-US")(`${command.help.category.toLowerCase()}/${command.help.name}:DESCRIPTION`),
options: command.conf.options.map((opt) => ({
...opt,
type: opt.type,
description: client.translations.get("en-US")(`${command.help.category.toLowerCase()}/${command.help.name}:OPT_${opt.name.toUpperCase()}_DESCRIPTION`),
options: opt.options?.map((o) => ({
...o,
type: opt.type,
description: client.translations.get("en-US")(`${command.help.category.toLowerCase()}/${command.help.name}:OPT_${o.name.toUpperCase()}_DESCRIPTION`)
})
)
})
)
})), {
debug: true,
guildId: config.support.id
});

// Then we load events, which will include our message and ready event.
Expand All @@ -55,9 +79,6 @@ const init = async () => {
}).catch((err) => {
client.logger.log("Unable to connect to the Mongodb database. Error:"+err, "error");
});

const languages = require("./helpers/languages");
client.translations = await languages();

const autoUpdateDocs = require("./helpers/autoUpdateDocs.js");
autoUpdateDocs.update(client);
Expand Down
4 changes: 0 additions & 4 deletions base/Atlanta.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class Atlanta extends Client {
this.customEmojis = require("../emojis.json"); // load the bot's emojis
this.languages = require("../languages/language-meta.json"); // Load the bot's languages
this.commands = new Collection(); // Creates new commands collection
this.aliases = new Collection(); // Creates new command aliases collection
this.logger = require("../helpers/logger"); // Load the logger file
this.wait = util.promisify(setTimeout); // client.wait(1000) - Wait 1 second
this.functions = require("../helpers/functions"); // Load the functions file
Expand Down Expand Up @@ -201,9 +200,6 @@ class Atlanta extends Client {
props.init(this);
}
this.commands.set(props.help.name, props);
props.help.aliases.forEach((alias) => {
this.aliases.set(alias, props.help.name);
});
return false;
} catch (e) {
return `Unable to load command ${commandName}: ${e}`;
Expand Down
7 changes: 3 additions & 4 deletions base/Command.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ module.exports = class Command {
dirname = false,
enabled = true,
guildOnly = false,
aliases = new Array(),
botPermissions = new Array(),
memberPermissions = new Array(),
nsfw = false,
ownerOnly = false,
cooldown = 3000
options = null
})
{
const category = (dirname ? dirname.split(path.sep)[parseInt(dirname.split(path.sep).length-1, 10)] : "Other");
this.client = client;
this.conf = { enabled, guildOnly, memberPermissions, botPermissions, nsfw, ownerOnly, cooldown};
this.help = { name, category, aliases };
this.conf = { enabled, guildOnly, memberPermissions, botPermissions, nsfw, ownerOnly, options };
this.help = { name, category };
}
};
2 changes: 1 addition & 1 deletion base/Log.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ module.exports = mongoose.model("Log", new mongoose.Schema({
id: null
}}

}));
}));
2 changes: 1 addition & 1 deletion base/Member.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ module.exports = mongoose.model("Member", new mongoose.Schema({
endDate: null
}},

}));
}));
2 changes: 1 addition & 1 deletion base/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ userSchema.method("getAchievements", async function(){
return canvas.toBuffer();
});

module.exports = mongoose.model("User", userSchema);
module.exports = mongoose.model("User", userSchema);
28 changes: 16 additions & 12 deletions commands/Administration/addcommand.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const Command = require("../../base/Command.js");

class Addcommand extends Command {
module.exports = class extends Command {

constructor (client) {
super(client, {
name: "addcommand",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: [ "custom-command" ],

memberPermissions: [ "MANAGE_GUILD" ],
botPermissions: [ "SEND_MESSAGES", "EMBED_LINKS" ],
nsfw: false,
Expand All @@ -17,17 +17,20 @@ class Addcommand extends Command {
});
}

async run (message, args, data) {
async run (interaction, translate, data) {

if (!args[0])
return message.error("administration/addcommand:MISSING_NAME");
return interaction.reply({
content: translate("administration/addcommand:MISSING_NAME"),
ephemeral: true
});

const name = args[0].split("\n")[0];

if (
this.client.commands.get(name) ||
this.client.aliases.get(name) ||
data.guild.customCommands.find((c) => c.name === name)
data.guildData.customCommands.find((c) => c.name === name)
) {
return message.error(
"administration/addcommand:COMMAND_ALREADY_EXISTS"
Expand All @@ -36,21 +39,22 @@ class Addcommand extends Command {

const answer = (args[0].split("\n")[1] || "") + args.slice(1).join(" ");
if (!answer) {
return message.error("administration/addcommand:MISSING_ANSWER");
return interaction.reply({
content: translate("administration/addcommand:MISSING_ANSWER"),
ephemeral: true
});
}

data.guild.customCommands.push({
data.guildData.customCommands.push({
name: name.toLowerCase(),
answer: answer
});
data.guild.save();
data.guildData.save();

message.success("administration/addcommand:SUCCESS", {
commandName: name,
prefix: data.guild.prefix
prefix: data.guildData.prefix
});
}

}

module.exports = Addcommand;
};
25 changes: 16 additions & 9 deletions commands/Administration/addemoji.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const Command = require("../../base/Command.js");

class Addemoji extends Command {
module.exports = class extends Command {

constructor (client) {
super(client, {
name: "addemoji",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: [],
,
memberPermissions: [ "MANAGE_GUILD" ],
botPermissions: [ "SEND_MESSAGES", "EMBED_LINKS" ],
nsfw: false,
Expand All @@ -17,19 +17,28 @@ class Addemoji extends Command {
});
}

async run (message, args) {
async run (interaction, translate) {

const URL = args[0];
if (!URL) {
return message.error("administration/addemoji:MISSING_URL");
return interaction.reply({
content: translate("administration/addemoji:MISSING_URL"),
ephemeral: true
});
}

const name = args[1] ? args[1].replace(/[^a-z0-9]/gi, "") : null;
if (!name) {
return message.error("administration/addemoji:MISSING_NAME");
return interaction.reply({
content: translate("administration/addemoji:MISSING_NAME"),
ephemeral: true
});
}
if (name.length < 2 || name > 32) {
return message.error("administration/addemoji:INVALID_NAME");
return interaction.reply({
content: translate("administration/addemoji:INVALID_NAME"),
ephemeral: true
});
}

message.guild.emojis
Expand All @@ -46,6 +55,4 @@ class Addemoji extends Command {
});
}

}

module.exports = Addemoji;
};
41 changes: 22 additions & 19 deletions commands/Administration/automod.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const Command = require("../../base/Command.js");

class Automod extends Command {
module.exports = class extends Command {

constructor (client) {
super(client, {
name: "automod",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: [],
,
memberPermissions: [ "MANAGE_GUILD" ],
botPermissions: [ "SEND_MESSAGES", "EMBED_LINKS" ],
nsfw: false,
Expand All @@ -17,38 +17,41 @@ class Automod extends Command {
});
}

async run (message, args,data) {
async run (interaction, translate,data) {

const status = args[0];
if(!status || (status !== "on" && status !== "off")){
return message.error("administration/automod:MISSING_STATUS");
return interaction.reply({
content: translate("administration/automod:MISSING_STATUS"),
ephemeral: true
});
}

if(status === "on"){
data.guild.plugins.automod = { enabled: true, ignored: [] };
data.guild.markModified("plugins.automod");
data.guild.save();
data.guildData.plugins.automod = { enabled: true, ignored: [] };
data.guildData.markModified("plugins.automod");
data.guildData.save();
message.success("administration/automod:ENABLED", {
prefix: data.guild.prefix
prefix: data.guildData.prefix
});
} else if (status === "off"){
if(message.mentions.channels.filter((ch) => ch.type === "text" && ch.guild.id === message.guild.id).first()){
if(message.mentions.channels.filter((ch) => ch.type === "text" && ch.guild.id === interaction.guild.id).first()){
const channel = message.mentions.channels.first();
data.guild.plugins.automod.ignored.push(channel);
data.guild.markModified("plugins.automod");
data.guild.save();
data.guildData.plugins.automod.ignored.push(channel);
data.guildData.markModified("plugins.automod");
data.guildData.save();
message.success("administration/automod:DISABLED_CHANNEL", {
channel: channel.toString()
});
} else {
data.guild.plugins.automod = { enabled: false, ignored: [] };
data.guild.markModified("plugins.automod");
data.guild.save();
message.success("administration/automod:DISABLED");
data.guildData.plugins.automod = { enabled: false, ignored: [] };
data.guildData.markModified("plugins.automod");
data.guildData.save();
interaction.reply({
content: translate("administration/automod:DISABLED")
});
}
}
}

}

module.exports = Automod;
};
Loading