Drake cmd, maintenance cmd

This commit is contained in:
night0721 2021-06-15 00:54:02 +08:00
parent 940fe839a1
commit 3b46b57862
8 changed files with 174 additions and 97 deletions

28
commands/Fun/drake.js Normal file
View file

@ -0,0 +1,28 @@
const {
Client,
Message,
MessageEmbed,
MessageAttachment,
} = require("discord.js");
const fetch = require("node-fetch");
module.exports = {
name: "drake",
description: "Drake meme",
usage: "(Text) (Text)",
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async (client, message, args) => {
const t1 = args[0];
const t2 = args.slice(1).join(" ");
const res = await fetch(
`https://frenchnoodles.xyz/api/endpoints/drake/?text1=${t1}&text2=${t2}`,
{}
);
let i = await res.buffer();
const drake = new MessageAttachment(i);
message.inlineReply(drake);
},
};

27
commands/Owner/status.js Normal file
View file

@ -0,0 +1,27 @@
const { Client, Message, MessageEmbed } = require("discord.js");
module.exports = {
name: "status",
usage: "(Boolean)",
description: "Maintenance mode",
category: "Owner",
Owner: true,
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async (client, message, args) => {
if (!args[0]) return message.channel.send("True or False?");
if (args[0].toLowerCase() === "true") {
await client.data.maintenance(client.user.id, "true");
message.channel.send(
`**${client.user.username}** is under maintenance now`
);
} else if (args[0].toLowerCase() === "false") {
await client.data.maintenance(client.user.id, "false");
message.channel.send(`**${client.user.username}** back online`);
} else {
message.channel.send("True or False?");
}
},
};

View file

@ -10,6 +10,11 @@ const Timeout2 = new Collection();
client.on("message", async message => {
const p = await client.prefix(message);
if (message.author.bot) return;
if (!message.content.startsWith(p)) return;
if (!message.guild) return;
if (!message.member) {
message.member = await message.guild.fetchMember(message);
}
if (message.content.match(new RegExp(`^<@!?${client.user.id}>( |)$`))) {
const _ = new MessageEmbed()
.setTitle("cath.exe")
@ -18,7 +23,6 @@ client.on("message", async message => {
"Prefix/Usage",
`My prefix in **${message.guild.name}** is **${p}**\n\nRun \`${p}help\` to start using the bot`
)
.setThumbnail(client.user.displayAvatarURL())
.setURL(client.web)
.setFooter("Made by Cath Team")
@ -26,21 +30,26 @@ client.on("message", async message => {
.setColor(client.color);
return message.inlineReply(_).then(m => m.delete({ timeout: 10000 }));
}
if (!message.content.startsWith(p)) return;
if (!message.guild) return;
if (!message.member) {
message.member = await message.guild.fetchMember(message);
}
const data = {};
let guildDB = await client.data.getGuild(message.guild.id);
if (!guildDB) return;
let userDB = await client.data.getUser(message.author.id);
if (!userDB) return;
const data = {};
let botDB = await client.data.getBot(client.user.id);
if (!botDB) return;
data.Bot = botDB;
data.Guild = guildDB;
data.User = userDB;
if (
botDB &&
botDB.Status == "true" &&
!client.owners.includes(message.author.id)
)
return message.inlineReply(
`**${client.user.username}** is currently in maintenance.\nYou can use **cath.exe#9686** or **Cath 2#7414** if it is online\nIf you need help, please contact **Cat drinking a cat#0795** or **Ń1ght#0001**`
);
if (!guildDB) {
client.data.CreateGuild(message.guild.id);
await client.data.CreateGuild(message.guild.id);
}
if (data.User) {
if (data.User.Blacklist) {
@ -96,6 +105,9 @@ client.on("message", async message => {
.then(msg => msg.delete({ timeout: 10000 }));
}
if (command) {
if (command.Owner == true) {
if (!client.owners.includes(message.author.id)) return;
}
if (command.Premium == true) {
if (data.User.Premium == false) {
return message.inlineReply(

View file

@ -3,6 +3,7 @@ const config = require("../config.json");
const prefix = config.prefix;
const version = require("../package.json").version;
const { MessageEmbed } = require("discord.js");
const m = require("../models/status");
client.on("ready", () => {
var users = client.guilds.cache
.reduce((a, b) => a + b.memberCount, 0)
@ -12,7 +13,17 @@ client.on("ready", () => {
client.web,
`with ${users} users`,
];
var interval = setInterval(function () {
async function find() {
const statusdb = await m.findOne({
Status: "true",
});
if (statusdb && statusdb.Status == "true") {
await client.user.setPresence({ status: "dnd" });
client.user.setActivity({
name: "Under Maintenance",
});
} else {
var set = setInterval(function () {
var game = Math.floor(Math.random() * playing.length + 0);
client.user.setActivity({
name: playing[game],
@ -20,6 +31,9 @@ client.on("ready", () => {
url: "https://www.twitch.tv/thekiritosgaming",
});
}, 5000);
}
}
find();
console.log(`${client.user.username}\nVersion: v${version}`);
var embed = new MessageEmbed()
.setColor(client.color)

11
models/status.js Normal file
View file

@ -0,0 +1,11 @@
const mongoose = require("mongoose");
module.exports = mongoose.model(
"status",
new mongoose.Schema({
Bot: {
type: String,
default: "null",
},
Status: { type: String, default: "false" },
})
);

View file

@ -1,51 +0,0 @@
const { MessageAttachment } = require("discord.js");
const Levels = require("discord-xp");
const canvacord = require("canvacord");
const error = require("../util/err");
require("../inlinereply");
module.exports = {
name: "rank",
description: "Shows the current level and rank of the user!",
usage: "{@User/User ID}",
timeout: 5000,
run: async (client, message, args) => {
const p = await client.prefix(message);
if (!message.guild) return;
if (message.author.bot) return;
const target =
message.mentions.users.first() ||
message.guild.members.cache.find(
r => r.user.username.toLowerCase() === args[0].toLocaleLowerCase()
) ||
message.guild.members.cache.find(
r => r.displayName.toLowerCase() === args[0].toLocaleLowerCase()
) ||
message.guild.members.cache.get(args[0]) ||
message.author;
const user = await Levels.fetch(target.id, message.guild.id, true);
if (!user)
return error(
message,
message.author,
p,
"rank",
"**{@User/User ID}**",
`'User' doesn't have any XP`
);
const neededXp = Levels.xpFor(parseInt(user.level) + 1);
const Rank = new canvacord.Rank()
.setAvatar(target.displayAvatarURL({ dynamic: false, format: "png" }))
.setCurrentXP(user.xp)
.setRank(parseInt(user.position))
.setLevel(user.level)
.setRequiredXP(neededXp)
.setStatus(target.presence.status)
.setProgressBar("BLACK", "COLOR")
.setUsername(target.username)
.setDiscriminator(target.discriminator);
Rank.build().then(data => {
const attachment = new MessageAttachment(data, "RankCard.png");
message.inlineReply(attachment);
});
},
};

View file

@ -1,23 +0,0 @@
const { Canvas } = require('canvacord')
const { Client, Message, MessageAttachment } = require('discord.js')
module.exports = {
name: 'trigger',
aliases: ['triggered'],
usage: '(?@User/ User ID)',
description: "Have a trigger effect on a user's avatar",
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async(client, message, args) => {
const user = message.mentions.users.first() || message.guild.members.cache.get(args[0]) || message.author
const ava = user.displayAvatarURL({ format: 'png' })
const imga = await Canvas.trigger(ava)
message.channel.send(
new MessageAttachment(imga, 'imgae.gif')
)
}
}

View file

@ -6,7 +6,8 @@ const cachegoose = new GooseCache(mongoose, {
mongoose.set("useFindAndModify", false);
const u = require("../../models/users");
const g = require("../../models/guilds");
const Econ = require("../../models/econ");
const e = require("../../models/econ");
const m = require("../../models/status");
module.exports = {
/**
* @param {String} URI - Mongo Connection URI
@ -118,6 +119,29 @@ module.exports = {
};
}
},
/**
* @param {String} ID - Bot ID
*/
async getBot(ID) {
if (!ID) throw new Error("Bot ID?");
const bot = await m.findOne({ Bot: ID }).lean().cache(120);
if (!bot) {
const ss = new m({ Bot: ID });
const { Bot, Status } = ss;
await ss.save().catch(error => console.log(error));
return {
Bot,
Status,
};
} else {
const Bot = bot.Bot;
const Status = bot.Status;
return {
Bot,
Status,
};
}
},
/**
* @param {String} ID - User ID
* @param {String} Reason - AFK Reason
@ -233,6 +257,13 @@ module.exports = {
await new g({ Guild: ID });
return;
},
/**
* @param {String} ID
*/
async CreateBot(ID) {
await new m({ Guild: ID });
return;
},
/**
* @param {String} ID - Guild ID
*/
@ -429,7 +460,7 @@ module.exports = {
// */
// async bal(ID) {
// new Promise(async ful => {
// const data = await Econ.findOne({ User: ID });
// const data = await e.findOne({ User: ID });
// if (!data) return ful(0);
// ful(data.CP);
// });
@ -438,7 +469,7 @@ module.exports = {
* @param {String} ID - User ID
*/
async bal(ID) {
const data = await Econ.findOne({ User: ID });
const data = await e.findOne({ User: ID });
if (!data) return 0;
else return data.CP;
},
@ -447,12 +478,12 @@ module.exports = {
* @param {Number} CP - Number
*/
async add(ID, CP) {
Econ.findOne({ User: ID }, async (err, data) => {
e.findOne({ User: ID }, async (err, data) => {
if (err) throw err;
if (data) {
data.CP += CP;
} else {
data = new Econ({ User: ID, CP });
data = new e({ User: ID, CP });
}
await data.save();
});
@ -462,14 +493,42 @@ module.exports = {
* @param {Number} CP - Number
*/
async rmv(ID, CP) {
Econ.findOne({ User: ID }, async (err, data) => {
e.findOne({ User: ID }, async (err, data) => {
if (err) throw err;
if (data) {
data.CP -= CP;
} else {
data = new Econ({ User: ID, CP: -CP });
data = new e({ User: ID, CP: -CP });
}
await data.save();
});
},
/**
* @param {String} ID - Bot ID
* @param {String} Toggle - Maintenance Toggle
*/
async maintenance(ID, Toggle) {
if (!ID) throw new Error("Please Provide a ID!");
if (!Toggle) throw new Error("Please Provide a Toggle!");
const idk = await m.findOne({ Bot: ID });
if (!idk) {
const newdb = new m({ Bot: ID });
if (Toggle === "true") {
newdb.Status === "true";
} else {
newdb.Status === "false";
}
await newdb.save().catch(error => console.log(error));
return;
} else {
if (Toggle === "true") {
idk.Status = "true";
} else {
idk.Status = "false";
}
}
await idk.save().catch(error => console.log(error));
cachegoose.clearCache();
return;
},
};