Skip to content
This repository was archived by the owner on Sep 24, 2022. It is now read-only.

Commit 39cc2e4

Browse files
author
BuildTools
committed
Update #1 (that was loged)
1 parent b0b060b commit 39cc2e4

File tree

7 files changed

+130
-92
lines changed

7 files changed

+130
-92
lines changed

events/ready.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const client = require('../index');
2+
3+
client.on('ready', () => {
4+
client.user.setPresence({status: 'dnd',activity: {name: `DiamondGolurk on youtube.com`,type: "WATCHING"}})
5+
console.log(`${client.user.username} ✅`)
6+
})

events/web.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const client = require('../index');
22
const express = require("express");
33
const path = require('path');
4+
const serveIndex = require('serve-index');
45
const mongoose = require('mongoose');
56
const model = require('../models/economy');
67
const { getCommands } = require('../utils/index');
@@ -13,6 +14,8 @@ client.on('ready', async () => {
1314
users: client.users.cache.size,
1415
channels: client.channels.cache.size
1516
}
17+
app.use('/web', express.static('web'));
18+
app.use('/web', serveIndex('web'));
1619
app.get("/", (req, res) => {
1720
res.status(200).render('index.pug')
1821
})

index.js

Lines changed: 117 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
const {Collection, Client, Discord} = require('discord.js')
1+
const {
2+
Collection,
3+
Client,
4+
Discord
5+
} = require('discord.js')
26
const fs = require('fs')
37
const client = new Client({
4-
disableEveryone: true
8+
disableEveryone: true
59
});
610
require('discord-buttons')(client);
711
require('dotenv').config();
@@ -11,14 +15,16 @@ const mongo = process.env.MONGO
1115
const disturn = process.env.DISTURN;
1216
const distoken = process.env.DISTOKEN;
1317
module.exports = client;
14-
if(disturn === "true") {
18+
if (disturn === "true") {
1519
const DB = require("disbots.net");
16-
const db = new DB(distoken, { statsInterval: 4000000 }, client);
20+
const db = new DB(distoken, {
21+
statsInterval: 4000000
22+
}, client);
1723
db.on("postServers", () => {
18-
console.log("Server count ✅");
24+
console.log("Server count ✅");
1925
});
2026
db.on("postShards", () => {
21-
console.log("Shards count ✅");
27+
console.log("Shards count ✅");
2228
});
2329
}
2430
const mongoose = require('mongoose');
@@ -32,131 +38,153 @@ const Timeout = new Collection();
3238
const ms = require('ms')
3339
Levels.setURL(mongo);
3440
mongoose.connect(mongo, {
35-
useNewUrlParser: true,
36-
useUnifiedTopology: true,
37-
useFindAndModify: false,
38-
useCreateIndex: true
41+
useNewUrlParser: true,
42+
useUnifiedTopology: true,
43+
useFindAndModify: false,
44+
useCreateIndex: true
3945
}).then(console.log('Connected to mongo db!'));
4046
client.prefix = async function(message) {
41-
let custom;
42-
const data = await prefixSchema.findOne({ Guild : message.guild.id })
43-
.catch(err => console.log(err))
44-
if(data) {
45-
custom = data.Prefix;
46-
} else {
47-
custom = prefix;
48-
}
49-
return custom;
47+
let custom;
48+
const data = await prefixSchema.findOne({
49+
Guild: message.guild.id
50+
})
51+
.catch(err => console.log(err))
52+
if (data) {
53+
custom = data.Prefix;
54+
} else {
55+
custom = prefix;
56+
}
57+
return custom;
5058
}
5159
client.commands = new Collection();
5260
client.aliases = new Collection();
5361
client.categories = fs.readdirSync("./commands/");
5462
["command"].forEach(handler => {
55-
require(`./handlers/${handler}`)(client);
63+
require(`./handlers/${handler}`)(client);
5664
});
57-
client.on('ready', () => {
58-
client.user.setPresence({status: 'dnd',activity: {name: `DiamondGolurk on youtube.com`,type: "WATCHING"}})
59-
console.log(`${client.user.username} ✅`)
60-
})
61-
client.on('message', async message =>{
62-
if(message.author.bot) return;
63-
const p = await client.prefix(message)
64-
if(!message.content.startsWith(p)) return;
65-
if(!message.guild) return;
66-
if(!message.member) message.member = await message.guild.fetchMember(message);
67-
const args = message.content.slice(p.length).trim().split(/ +/g);
68-
const cmd = args.shift().toLowerCase();
69-
if(cmd.length == 0 ) return;
70-
const data = await customcom.findOne({ Guild: message.guild.id, Command: cmd });
71-
if(data) message.channel.send(data.Response);
72-
let command = client.commands.get(cmd)
73-
if(!command) command = client.commands.get(client.aliases.get(cmd));
74-
if (command) {
75-
if(!message.member.permissions.has(command.userPermission || [])) return message.channel.send("You do not have permission to use this command!");
76-
if(!message.guild.me.permissions.has(command.botPermission || [])) return message.channel.send("I do not have permission to use this command!");
77-
const blacklisted = await blacklistserver.findOne({ Server: message.guild.id });
78-
if(blacklisted) return message.reply("This server has been blacklisted.")
79-
if(command.cooldown) {
80-
if(Timeout.has(`${command.name}${message.author.id}`)) return message.channel.send(`You are on a \`${ms(Timeout.get(`${command.name}${message.author.id}`) - Date.now(), {long : true})}\` cooldown.`)
81-
command.run(client, message, args)
82-
Timeout.set(`${command.name}${message.author.id}`, Date.now() + command.cooldown)
83-
setTimeout(() => {
84-
Timeout.delete(`${command.name}${message.author.id}`)
85-
}, command.cooldown)
86-
} else command.run(client, message, args);
87-
}
65+
66+
client.on('message', async message => {
67+
if (message.author.bot) return;
68+
const p = await client.prefix(message)
69+
if (!message.content.startsWith(p)) return;
70+
if (!message.guild) return;
71+
if (!message.member) message.member = await message.guild.fetchMember(message);
72+
const args = message.content.slice(p.length).trim().split(/ +/g);
73+
const cmd = args.shift().toLowerCase();
74+
if (cmd.length == 0) return;
75+
const data = await customcom.findOne({
76+
Guild: message.guild.id,
77+
Command: cmd
78+
});
79+
if (data) message.channel.send(data.Response);
80+
let command = client.commands.get(cmd)
81+
if (!command) command = client.commands.get(client.aliases.get(cmd));
82+
if (command) {
83+
if (!message.member.permissions.has(command.userPermission || [])) return message.channel.send("You do not have permission to use this command!");
84+
if (!message.guild.me.permissions.has(command.botPermission || [])) return message.channel.send("I do not have permission to use this command!");
85+
const blacklisted = await blacklistserver.findOne({
86+
Server: message.guild.id
87+
});
88+
if (blacklisted) return message.reply("This server has been blacklisted.")
89+
if (command.cooldown) {
90+
if (Timeout.has(`${command.name}${message.author.id}`)) return message.channel.send(`You are on a \`${ms(Timeout.get(`${command.name}${message.author.id}`) - Date.now(), {long : true})}\` cooldown.`)
91+
command.run(client, message, args)
92+
Timeout.set(`${command.name}${message.author.id}`, Date.now() + command.cooldown)
93+
setTimeout(() => {
94+
Timeout.delete(`${command.name}${message.author.id}`)
95+
}, command.cooldown)
96+
} else command.run(client, message, args);
97+
}
8898
});
8999

90100
const DisTube = require('distube');
91-
const player = new DisTube(client, { searchSongs: true, emitNewSongOnly: true, leaveOnFinish: true });
101+
const player = new DisTube(client, {
102+
searchSongs: true,
103+
emitNewSongOnly: true,
104+
leaveOnFinish: true
105+
});
92106

93107
const status = (queue) => `Volume: \`${queue.volume}%\` | Filter: \`${queue.filter || "Off"}\` | Loop: \`${queue.repeatMode ? queue.repeatMode == 2 ? "All Queue" : "This Song" : "Off"}\` | Autoplay: \`${queue.autoplay ? "On" : "Off"}\``;
94108

95109
player
96-
.on("playSong", (message, queue, song) => message.channel.send(
97-
`Playing \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${song.user}\n${status(queue)}`
98-
))
99-
.on("addSong", (message, queue, song) => message.channel.send(
100-
`Added ${song.name} - \`${song.formattedDuration}\` to the queue by ${song.user}`
101-
))
102-
.on("playList", (message, queue, playlist, song) => message.channel.send(
103-
`Play \`${playlist.name}\` playlist (${playlist.songs.length} songs).\nRequested by: ${song.user}\nNow playing \`${song.name}\` - \`${song.formattedDuration}\`\n${status(queue)}`
104-
))
105-
.on("addList", (message, queue, playlist) => message.channel.send(
106-
`Added \`${playlist.name}\` playlist (${playlist.songs.length} songs) to queue\n${status(queue)}`
107-
))
108-
.on("searchResult", (message, result) => {
109-
let i = 0;
110-
message.channel.send(`**Choose an option from below**\n${result.map(song => `**${++i}**. ${song.name} - \`${song.formattedDuration}\``).join("\n")}\n*Enter anything else or wait 60 seconds to cancel*`);
111-
})
112-
.on("searchCancel", (message) => message.channel.send(`Searching canceled`))
113-
.on("error", (message, e) => {
114-
console.error(e)
115-
message.channel.send("An error encountered: " + e);
116-
})
117-
.on("finish", message => message.channel.send("No more song in queue")
118-
)
119-
.on("empty", message => message.channel.send("Channel is empty. Leaving the channel")
120-
);
110+
.on("playSong", (message, queue, song) => message.channel.send(
111+
`Playing \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${song.user}\n${status(queue)}`
112+
))
113+
.on("addSong", (message, queue, song) => message.channel.send(
114+
`Added ${song.name} - \`${song.formattedDuration}\` to the queue by ${song.user}`
115+
))
116+
.on("playList", (message, queue, playlist, song) => message.channel.send(
117+
`Play \`${playlist.name}\` playlist (${playlist.songs.length} songs).\nRequested by: ${song.user}\nNow playing \`${song.name}\` - \`${song.formattedDuration}\`\n${status(queue)}`
118+
))
119+
.on("addList", (message, queue, playlist) => message.channel.send(
120+
`Added \`${playlist.name}\` playlist (${playlist.songs.length} songs) to queue\n${status(queue)}`
121+
))
122+
.on("searchResult", (message, result) => {
123+
let i = 0;
124+
message.channel.send(`**Choose an option from below**\n${result.map(song => `**${++i}**. ${song.name} - \`${song.formattedDuration}\``).join("\n")}\n*Enter anything else or wait 60 seconds to cancel*`);
125+
})
126+
.on("searchCancel", (message) => message.channel.send(`Searching canceled`))
127+
.on("error", (message, e) => {
128+
console.error(e)
129+
message.channel.send("An error encountered: " + e);
130+
})
131+
.on("finish", message => message.channel.send("No more song in queue"))
132+
.on("empty", message => message.channel.send("Channel is empty. Leaving the channel"));
121133

122134
Client.player = player;
123135

124-
const { DiscordTogether } = require('discord-together');
136+
const {
137+
DiscordTogether
138+
} = require('discord-together');
125139
Client.discordTogether = new DiscordTogether(client);
126140

127141
Client.dashboard = new botdash.APIclient("3856da55-f3b3-462f-9186-0bf72c9b35a7");
128142

129143
client.bal = (id, coins) => new Promise(async ful => {
130-
const data = await eco.findOne({ id });
131-
if(!data) return ful[0];
144+
const data = await eco.findOne({
145+
id
146+
});
147+
if (!data) return ful[0];
132148
ful(data.coins);
133149
})
134150

135151
client.add = (id, coins) => {
136-
eco.findOne({ id }, async (err, data) => {
137-
if(err) throw err;
138-
if(data) {
152+
eco.findOne({
153+
id
154+
}, async (err, data) => {
155+
if (err) throw err;
156+
if (data) {
139157
data.coins += coins;
140158
} else {
141-
data = new eco({ id, coins });
159+
data = new eco({
160+
id,
161+
coins
162+
});
142163
}
143164
data.save();
144165
})
145166
}
146167

147168
client.rmv = (id, coins) => {
148-
eco.findOne({ id }, async (err, data) => {
149-
if(err) throw err;
150-
if(data) {
169+
eco.findOne({
170+
id
171+
}, async (err, data) => {
172+
if (err) throw err;
173+
if (data) {
151174
data.coins -= coins;
152175
} else {
153-
data = new eco({ id, coins: -coins });
176+
data = new eco({
177+
id,
178+
coins: -coins
179+
});
154180
}
155181
data.save();
156182
})
157183
}
158184

159-
const { DiscordUNO } = require("discord-uno");
185+
const {
186+
DiscordUNO
187+
} = require("discord-uno");
160188
client.discordUNO = new DiscordUNO();
161189

162190
client.login(token)

views/commands.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
<head>
55
<title>ServerSMP - Commands</title>
6-
<link rel="shortcut icon" type="image/jpg" href="/assets/disconnect.ico" />
6+
<link rel="shortcut icon" type="image/x-icon" href="web/assets/serversmp-bot.ico" />
77
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
88
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
99
</head>
1010

1111
<body>
12-
<a href="/"><img src="https://serversmp.netlify.app/assets/disconnect.png" alt="Bot's Avatar" class="avatar"></a>
12+
<a href="/"><img src="web/assets/serversmp-bot.png" alt="Bot's Avatar" class="avatar"></a>
1313
<section class="main-content">
1414
<p>To get a look of the commands in discord, use -help to view the commands!</p>
1515
<% commands.forEach(({ name, value}) => { %>

views/index.pug

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
doctype html
22
head
33
title ServerSMP - BOT
4+
link(rel='shortcut icon', type='image/x-icon', href='web/assets/serversmp-bot.ico')
45
link(rel=' preconnect' href='https://fonts.googleapis.com')
56
link(href='https://fonts.googleapis.com/css2?family=Josefin+Sans&display=swap' rel='stylesheet')
67
link(href='https://fonts.googleapis.com/css2?family=Knewave&display=swap' rel='stylesheet')
@@ -13,7 +14,7 @@ div
1314
body
1415
header
1516
h1 ServerSMP - BOT
16-
img.avatar(src='https://serversmp.netlify.app/assets/disconnect.png' alt="Bot's Avatar")
17+
img.avatar(src='web/assets/serversmp-bot.png' alt="Bot's Avatar")
1718
h3 It has fun/admin/level commands.
1819
p.description
1920
| This is a discord bot, that has a lot of stuff in it like meme&apos;s, economy, admin, extra, etc.

web/assets/serversmp-bot.ico

5.9 KB
Binary file not shown.

web/assets/serversmp-bot.png

3.32 KB
Loading

0 commit comments

Comments
 (0)