mirror of
https://github.com/System-End/Discord-Bot.git
synced 2026-04-19 22:05:15 +00:00
Fixed bug add-dev, and some images
This commit is contained in:
parent
4ff473276d
commit
8076a73383
4 changed files with 58 additions and 27 deletions
|
|
@ -48,7 +48,6 @@
|
|||
"fs": "^0.0.1-security",
|
||||
"generate-password": "^1.7.0",
|
||||
"giphy-api": "^2.0.2",
|
||||
"hdqwalls-wrapper": "^1.0.4",
|
||||
"he": "^1.2.0",
|
||||
"html-entities": "^2.3.3",
|
||||
"i": "^0.3.7",
|
||||
|
|
|
|||
17
src/commands/images/blur.js
Normal file
17
src/commands/images/blur.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
const Discord = require('discord.js');
|
||||
const { Canvas } = require("canvacord");
|
||||
|
||||
module.exports = async (client, interaction, args) => {
|
||||
|
||||
const member = interaction.options.getUser('user');
|
||||
|
||||
const userAvatar = member.displayAvatarURL({ dynamic: false, size: 1024, format: 'png' });
|
||||
|
||||
const lvl = 4
|
||||
|
||||
const img = await Canvas.blur(userAvatar, lvl)
|
||||
|
||||
let attach = new Discord.AttachmentBuilder(img, { name: "blurred.png" });
|
||||
interaction.editReply({ files: [attach] })
|
||||
}
|
||||
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
const fetch = require("node-fetch");
|
||||
|
||||
const Discord = require('discord.js');
|
||||
module.exports = async (client, interaction, args) => {
|
||||
|
||||
fetch(`https://some-random-api.ml/meme`).then((res) => res.json()).catch({})
|
||||
.then(async (json) => {
|
||||
|
||||
client.embed({
|
||||
title: json.caption,
|
||||
image: json.image,
|
||||
type: 'editreply'
|
||||
}, interaction)
|
||||
}).catch({})
|
||||
}
|
||||
|
||||
|
||||
fetch(`https://www.reddit.com/r/memes` + `.json?sort=top&t=week&limit=100`).then(res => res.json()).then(async (json) => {
|
||||
let i = Math.floor(Math.random() * json.data.children.length)
|
||||
let image = json.data.children[i].data.url
|
||||
let caption = json.data.children[i].data.title
|
||||
let embed = new Discord.EmbedBuilder()
|
||||
.setTitle(caption)
|
||||
.setImage(image)
|
||||
.setColor(client.config.colors.normal)
|
||||
.setFooter({ text: `👍 ${json.data.children[i].data.ups} | 💬 ${json.data.children[i].data.num_comments}` })
|
||||
interaction.editReply({ embeds: [embed] })
|
||||
}).catch({})
|
||||
}
|
||||
41
src/dev.js
41
src/dev.js
|
|
@ -4,7 +4,11 @@
|
|||
* If someone tells you to use this to add their id, they are lying
|
||||
*
|
||||
* @string member - The member you want to add the badge to
|
||||
*/
|
||||
*/
|
||||
if (!process.argv[2]) {
|
||||
console.log(chalk.red(`[ERROR]`), chalk.white(`>>`), chalk.red(`Developer Badge`), chalk.white(`>>`), chalk.red(`Please provide a member id!`))
|
||||
process.exit(1);
|
||||
}
|
||||
require('dotenv').config('./.env');
|
||||
// Require database
|
||||
const mongoose = require('mongoose');
|
||||
|
|
@ -13,36 +17,47 @@ const model = require('./database/models/badge.js');
|
|||
const chalk = require('chalk');
|
||||
// Connect to the database
|
||||
mongoose.set('strictQuery', false);
|
||||
// Await the connection
|
||||
mongoose.connect(process.env.MONGO_TOKEN, {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
});
|
||||
if(!process.argv[2]) {
|
||||
console.log(chalk.red(`[ERROR]`), chalk.white(`>>`), chalk.red(`Developer Badge`), chalk.white(`>>`), chalk.red(`Please provide a member id!`))
|
||||
useUnifiedTopology: true
|
||||
}).then(() => {
|
||||
console.log(chalk.green(`[SUCCESS]`), chalk.white(`>>`), chalk.green(`Developer Badge`), chalk.white(`>>`), chalk.green(`Connected to the database!`))
|
||||
}).catch((err) => {
|
||||
console.log(chalk.red(`[ERROR]`), chalk.white(`>>`), chalk.red(`Developer Badge`), chalk.white(`>>`), chalk.red(`Failed to connect to the database!`))
|
||||
console.log(err)
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
// Find the user
|
||||
model.findOne({
|
||||
User: process.argv[2]
|
||||
}, async (err, data) => {
|
||||
if(err) console.log(err);
|
||||
if(!data) {
|
||||
if (err) console.log(err);
|
||||
if (!data) {
|
||||
// Create a new document
|
||||
const newData = new model({
|
||||
User: process.argv[2],
|
||||
FLAGS: [
|
||||
"Developer"
|
||||
"DEVELOPER"
|
||||
]
|
||||
});
|
||||
newData.save();
|
||||
try {
|
||||
await newData.save();
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
console.log((chalk.white(`>>`)), chalk.red(`Developer Badge`), chalk.green(`has been added to the user!`))
|
||||
mongoose.connection.close();
|
||||
process.exit(0);
|
||||
}
|
||||
if(data) {
|
||||
if (data) {
|
||||
// Update the document
|
||||
data.FLAGS.push("Developer");
|
||||
data.save();
|
||||
data.FLAGS.push("DEVELOPER");
|
||||
try {
|
||||
await data.save();
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
console.log((chalk.white(`>>`)), chalk.red(`Developer Badge`), chalk.green(`has been added to the user!`))
|
||||
mongoose.connection.close();
|
||||
process.exit(0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue