Skip to content

edited some code #3

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

Merged
merged 2 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .replit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
language = "nodejs"
run = "node ."
17 changes: 8 additions & 9 deletions commands/info/help.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const Discord = require("discord.js");
const { MessageEmbed } = require("discord.js");
const { Color, Prefix } = require("../../config.js");
const { Color, Prefix } = require("../../index");

module.exports = {
name: "help",
Expand All @@ -11,22 +10,22 @@ module.exports = {

message.delete();

let embed = new MessageEmbed()
.setColor(Color)
.setTitle(`${client.user.username} Commands!`)
.setDescription(`Use ${Prefix}Help <Command Name> For More Command Information!` +
const embed = new MessageEmbed()
.setColor(Color)
.setTitle(`${client.user.username} Commands!`)
.setDescription(`Use ${Prefix}Help <Command Name> For More Command Information!` +
"`🔐`**Moderation**\n`Clear, Mute, Unmute, Tempmute, Kick,Unban, Tempban, Warn, Warnings, ResetWarns`" + "\n\n"+
"`⌚`**Information**\n`Help")
.setFooter(`Requested By ${message.author.username}`)
.setTimestamp();
.setFooter(`Requested By ${message.author.username}`)
.setTimestamp();

if (!args.length) return message.channel.send(embed);

let cmd =
client.commands.get(args[0].toLowerCase()) ||
client.commands.get(client.aliases.get(args[0].toLowerCase()));

let embed2 = new MessageEmbed()
const embed2 = new MessageEmbed()
.setColor(Color)
.setTitle(`${cmd.name} Information!`)
.addField(`Aliases`, cmd.aliases || "None!")
Expand Down
114 changes: 62 additions & 52 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,88 +1,98 @@
const Discord = require("discord.js");
// Discord Library
const { Client, Collection } = require('discord.js')
const client = new Client();

// fs ffs!
const fs = require("fs");
const client = new Discord.Client();
const { keep_alive } = require("./keep_alive");
const { Prefix, Token, Color } = require("./config.js");
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
client.db = require("quick.db");

client.on("ready", async () => {
console.log(`DVS Tech Bot has Been Deployed!!`);
client.user
.setActivity(`$help`, { type: "LISTENING" })
.catch(error => console.log(error));
});
// Parsing Settings
const JSON5 = require('json5');
const settings = JSON5.parse(process.env.settings)

client.on("message", async message => {
if (message.channel.type === "dm") return;
if (message.author.bot) return;
if (!message.guild) return;
if (!message.member)
message.member = await message.guild.fetchMember(message);
// Secret Vars
const botToken = settings.bot.token;
const botPrefix = settings.bot.prefix;
const embedColor = settings.embeds.color;

if (message.content.match(new RegExp(`^<@!?${client.user.id}>`))) {
return message.channel.send(`Bot Prefix : ${Prefix}`);
}
});
// Exporting Secrets
module.exports = {
token: botToken,
Prefix: botPrefix,
Color: embedColor
}

let modules = ["fun", "info", "moderation"];
// Collection
client.commands = new Collection();
client.aliases = new Collection();

modules.forEach(function(module) {
fs.readdir(`./commands/${module}`, function(err, files) {
if (err)
return new Error(
"Missing Folder Of Commands! Example : Commands/<Folder>/<Command>.js"
);
files.forEach(function(file) {
if (!file.endsWith(".js")) return;
let command = require(`./commands/${module}/${file}`);
console.log(`${command.name} Command Has Been Loaded - ✅`);
if (command.name) client.commands.set(command.name, command);
if (command.aliases) {
command.aliases.forEach(alias =>
client.aliases.set(alias, command.name)
);
}
if (command.aliases.length === 0) command.aliases = null;
});
});
// On Ready
client.on("ready", () => {
console.log(`[!]: The Bot is ready, logged in as ${client.user.tag}`);
client.user.setActivity(`$help`, { type: "LISTENING" })
});

// On Message
client.on("message", async message => {
if (message.channel.type === "dm") return;
if (message.author.bot) return;
if (!message.guild) return;
if (!message.member)
if (!message.member) {
message.member = await message.guild.fetchMember(message);
}

if (message.content.match(new RegExp(`^<@!?${client.user.id}>`))) {
return message.channel.send(`Bot Prefix : ${Prefix}`);
}
const Prefix = botPrefix;
if (!message.content.startsWith(Prefix)) return;

const args = message.content
.slice(Prefix.length)
.trim()
.split(" ");
const cmd = args.shift().toLowerCase();

if (cmd.length === 0) return;

let command =
client.commands.get(cmd) || client.commands.get(client.aliases.get(cmd));
let command = client.commands.get(cmd) || client.commands.get(client.aliases.get(cmd));

if (!command) return;

if (command) {
if (!message.guild.me.hasPermission("ADMINISTRATOR"))
return message.channel.send(
"I Don't Have Enough Permission To Use This Or Any Of My Commands | Require : Administrator"
);
return message.channel.send("I Don't Have Enough Permission To Use This Or Any Of My Commands | Require : Administrator");
command.run(client, message, args);
}
console.log(
`User : ${message.author.tag} (${message.author.id}) Server : ${message.guild.name} (${message.guild.id}) Command : ${command.name}`
);
});

client.login(Token);
const modules = ["fun", "info", "moderation"];

modules.forEach((module) => {
fs.readdir(`./commands/${module}`, (err, files) => {
if (err)
return new Error(
"Missing Folder Of Commands! Example : Commands/<Folder>/<Command>.js"
);
files.forEach((file) => {
if (!file.endsWith(".js")) return;
let command = require(`./commands/${module}/${file}`);
console.log(`${command.name} Command Has Been Loaded - ✅`);
if (command.name) client.commands.set(command.name, command);
if (command.aliases) {
command.aliases.forEach(alias =>
client.aliases.set(alias, command.name)
);
}
if (command.aliases.length === 0) command.aliases = null;
});
});
});

client.login(botToken).catch((e) => { console.log(`the token is invalid!`) })

//Bot Coded by DVS Tech DONOT share WITHOUT credits!!
/*
Bot Coded by DVS Tech
DONOT share WITHOUT credits!!
*/
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
"start": "node server.js"
},
"dependencies": {
"express": "^4.17.1",
"discord.js": "^12.3.1",
"express": "^4.17.1",
"figlet": "^1.5.0",
"fs": "^0.0.2",
"json5": "^2.2.0",
"ms": "^2.1.2",
"node-fetch": "^2.6.1",
"figlet": "^1.5.0",
"util": "^0.12.3",
"novelcovid": "^3.0.0",
"quick.db": "^7.1.1",
"ms": "^2.1.2",
"util": "^0.12.3",
"weather-js": "^2.0.0"
},
"engines": {
Expand Down
9 changes: 9 additions & 0 deletions test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"bot": {
"token": "",
"prefix": ""
},
"embeds": {
"color": ""
}
}