-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.js
208 lines (195 loc) · 7.43 KB
/
commands.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
const path = require('path');
const fs = require('fs');
const computerVision = require('./computerVision');
const Discord = require('discord.js');
const webp = require('webp-converter');
const filesTypes = [".png",".jpeg",".jpg",".webp"];
function onReady(){
if(!fs.existsSync('temp/')){
fs.mkdirSync('temp/');
}
}
async function randomNumb(msg, num1, num2){
msg.channel.send(Math.round(Math.random() * (num2 - num1 + 1) + num1));
}
async function listRandom(msg, message){
const list = message.split(',');
msg.channel.send(list[Math.floor(Math.random() * list.length)]);
}
async function randomizeOrder(msg, message){
let temp = message.split(',');
let result = [];
let sent = '```\n';
for(let i = temp.length; i > 0 ; i--){
const rng = Math.floor(Math.random() * i);
let item = temp[rng];
result.push(item);
temp.splice(rng, 1);
}
let x = 1;
result.forEach(a =>{
sent += `${x}.${a}\n`;
x++
});
sent += '\n```';
msg.channel.send(sent);
}
async function help(msg){
msg.channel.send(new Discord.MessageEmbed()
.setColor('#00ffd5')
.setTitle('Commands')
.setAuthor('@SteveKeller', 'https://avatars0.githubusercontent.com/u/34516255?s=460&u=34c73060337b6baf172789c1e46e8f0bd687a812&v=4', 'https://github.com/steve1442')
.setThumbnail(msg.client.user.avatarURL())
.addFields(
{
name: `!stevehelp`,
value: 'displays the list of available commands',
inline: false
},
{
name: `!dick, !dick <mention>, !dick <userID>, !dick <attachment>`,
value: 'displays specified user profile picture with a dick on the face',
inline: false
},
{
name: `!face, !face <mention>, !face <link>, !face <attachment>`,
value: 'puts a random image on faces in the image',
inline: false
},
{
name: `!impersonate <mention>, !impersonate <userID>`,
value: 'makes it look like somone said a bad word, unfortunately it also adds bot to the name',
inline: false
},
{
name: `!rng <num1> <num2>, !rng list <item,item,item...etc>, !rng listorder <item,item,item...etc>`,
value: 'plain rng sends a number between the parameters, !rng list sends an item from the list, and !rng listorder sends a ordered list',
inline: false
},
{
name: `!stevebot invite`,
value: `sends the bot invite link`,
inline: false
},
{
name: `!steve github`,
value: 'sends link to bots source code',
inline: false
}
)
);
}
async function faceSwap(msg, url){
let filePath = await computerVision.downloadImage(url,'temp/');
const stats = fs.statSync(filePath);
if(stats["size"] > 8000000){
msg.channel.send('too big sorry');
return 'too big sorry';
}
const filetype = path.extname(filePath).toLowerCase();
let flag = false;
filesTypes.forEach(type =>{
if(filetype == type){
flag = true;
}
});
if(!flag){
msg.channel.send("cant accept type" + filetype);
return ("cant accept type" + filetype);
}
webp.dwebp(filePath, 'temp/converted.jpg', "-o", async (status, error) => {
if (status == '100'){
fs.unlink(filePath,() =>{
});
console.log("succesfully deleted: " + filePath);
filePath = 'temp/converted.jpg';
}
else console.log(status, error);
await computerVision.faceReplace(filePath);
const attachment = new Discord.MessageAttachment(filePath);
await msg.channel.send(new Discord.MessageEmbed()
.setTitle('Steve Bot')
.setColor('#00ffd5')
.setAuthor('@SteveKeller', 'https://avatars0.githubusercontent.com/u/34516255?s=460&u=34c73060337b6baf172789c1e46e8f0bd687a812&v=4', 'https://github.com/steve1442')
.setFooter('this used the !face command !stevehelp for more info')
.attachFiles(attachment)
.setImage('attachment://'+ attachment.attachment.substr(5))
);
console.log('sent image');
fs.unlink(filePath, () =>{
console.log("succesfully deleted: " + filePath);
});
});
}
async function impersonate(msg, content, member){
const bot_name = member.displayName;
const bot_pfp = member.user.avatarURL();
try {
let hook = await msg.channel.createWebhook(bot_name, {
avatar: bot_pfp,
reason: 'impersonation'
});
await hook.send(content);
console.log('impersonation complete');
await hook.delete();
}
catch (e) {
try { await hook.delete(); }
catch (ee) { console.error(ee); }
console.error(e);
return 1;
}
msg.delete();
}
async function dick(msg, url){
let filePath = await computerVision.downloadImage(url,'temp/');
const stats = fs.statSync(filePath);
if(stats["size"] > 8000000){
msg.channel.send('too big sorry');
return 'too big sorry';
}
const filetype = path.extname(filePath).toLowerCase();
let flag = false;
filesTypes.forEach(type =>{
if(filetype == type){
flag = true;
}
});
if(!flag){
msg.channel.send("cant accept type" + filetype);
return ("cant accept type" + filetype);
}
await webp.dwebp(filePath, 'temp/converted.jpg', "-o", (status, error) => {
if (status == '100'){
fs.unlinkSync(filePath);
console.log("succesfully deleted: " + filePath);
filePath = 'temp/converted.jpg';
}
else console.log(status, error);
});
computerVision.dickhead(filePath);
const attachment = new Discord.MessageAttachment(filePath);
console.log(attachment.attachment.substr(5));
await msg.channel.send(new Discord.MessageEmbed()
.setTitle('Steve Bot')
.setColor('#00ffd5')
.setAuthor('@SteveKeller', 'https://avatars0.githubusercontent.com/u/34516255?s=460&u=34c73060337b6baf172789c1e46e8f0bd687a812&v=4', 'https://github.com/steve1442')
.setFooter('this used the !dick command !stevehelp for more info')
.attachFiles(attachment)
.setImage('attachment://'+ attachment.attachment.substr(5))
);
console.log('sent image');
fs.unlink(filePath, () =>{
console.log("succesfully deleted: " + filePath);
});
}
module.exports = {
dick:dick,
onReady:onReady,
help:help,
faceSwap:faceSwap,
impersonate:impersonate,
randomNumb: randomNumb,
listRandom, listRandom,
randomizeOrder,randomizeOrder
}