-
Notifications
You must be signed in to change notification settings - Fork 0
/
function.js
198 lines (178 loc) Β· 6.61 KB
/
function.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
const config = require("./config/botconfig.json")
const {
sotikade,
meme,
music,
romance,
question,
fun
} = config.Channels.React
const {
msg_user,
user_msg,
msg_channel
} = config.Channels.msgGenesis
const {
guild_id,
channel_id,
guild_id_test,
channel_id_test
} = config.Channels.voice
const {
Log_Bot,
} = config.Channels.log
const moment1 = require('moment-jalaali')
const moment = require('moment')
module.exports = {
async React(message) {
try {
if (message.channel.id == music) {
message.react("πΆ")
}
if (message.channel.id == romance) {
message.react("β€οΈβπ©Ή")
message.react("π")
}
if (message.channel.id == sotikade) {
message.react("π")
message.react("π")
}
if (message.channel.id == meme) {
message.react("π")
}
if (message.channel.id == question) {
message.react("β")
}
if (message.channel.id == fun) {
message.react("π")
message.react("πΆβπ«οΈ")
}
} catch (e) {
return console.log(e)
}
},
async joinVoice(client) {
let server = client.guilds.cache.get(guild_id);
let channel = server.channels.cache.get(channel_id);
await channel.join().then(connection => {
connection.voice.setSelfMute(false)
connection.voice.setSelfDeaf(true)
})
},
async Status(client) {
let server = client.guilds.cache.get(guild_id);
function randomStatus() {
let status = ["π π π π π π π", `${server.memberCount} Member's`]
let rstatus = Math.floor(Math.random() * status.length);
let type = [1,2,3,4,5]
let typestatus = Math.floor(Math.random() * type.length);
client.user.setPresence({
activity: {
name: status[rstatus],
type: type[typestatus],
},
status: "dnd"
})
//client.user.setActivity(status[rstatus], { type: "WATCHING" });
}; setInterval(randomStatus, 11000)
},
async commandsFun(fs, client) {
const ascii = require("ascii-table");
// Create a new Ascii table
let table = new ascii("Commands");
table.setHeading("Command", "Load status");
fs.readdirSync("./commands/").forEach(dir => {
const commands = fs.readdirSync(`./commands/${dir}/`).filter(file => file.endsWith(".js"));
for (let file of commands) {
let pull = require(`./commands/${dir}/${file}`)
if (pull.name) {
client.commands.set(pull.name, pull);
table.addRow(file, 'β
');
} else {
table.addRow(file, `β -> missing a help.name, or help.name is not a string.`);
continue;
}
// If there's an aliases key, read the aliases.
if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
}
console.log(table.toString());
});
},
async commandrun(message, client, prefix) {
if (message.author.bot) return;
if (!message.guild) return;
if (!message.content.startsWith(prefix)) return;
if (!message.member)
message.member = message.guild.fetchMember(message);
const args = message.content
.slice(prefix.length)
.trim()
.split(/ +/g);
const cmd = args.shift().toLowerCase();
if (cmd.length === 0) return;
let command = client.commands.get(cmd);
if (!command) command = client.commands.get(client.aliases.get(cmd));
if (command) command.run(client, message, args);
},
async msgUser(message, client) {
if (message.channel.id == msg_user) {
setTimeout(() => {
if (!message.author.bot) message.delete()
}, 8000);
if (message.author.bot) return;
const args = message.content.split(/ +/g);
if (args[0].length <= 16) return message.channel.send(`<@${message.author.id}> ` + " ID user ra vared konid.")
.then((mssg) => {
setTimeout(() => {
mssg.delete()
}, 5000)
})
try {
client.users.cache.get(args[0])
.send(args.join(" ").split(args[0]))
.then(() => {
message.channel.send(`<@${message.author.id}> Done.`)
.then((msg) => {
setTimeout(() => {
msg.delete()
}, 5000);
})
.catch((err) => {
return message.channel.send("```js" + err + "```")
})
})
} catch (e) {
return message.channel.send("```js" + e + "```")
}
}
},
async userMsg(message, client) {
if (message.author.bot) return;
if (message.channel.type === "dm") {
if (message.author.id == client.user.id) return;
const User_Msg = client.channels.cache.get(user_msg);
let User_id = message.author.id
let User_name = message.author.username
let Message_Data = message.content
User_Msg.send("β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬" + `<@${User_id}>` + "\n" + `**User:** __ ${User_name} (${User_id}) __` + "\n" + `Message in DM :\n${Message_Data}\n` + "β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬β¬")
}
},
async Reconnect(newState, oldState, client) {
const channel_Log = client.channels.cache.get(Log_Bot)
const User_bot = client.user.id
if (oldState.id === User_bot) {
if (!oldState.channelID && newState.channelID) {
let server = client.guilds.cache.get(guild_id);
let channel = server.channels.cache.get(channel_id);
let Time = moment().utcOffset("+04:30").format("LTS")
await channel.join().then(connection => {
connection.voice.setSelfMute(true)
connection.voice.setSelfDeaf(true)
channel_Log.send(Time + " Reconneted...!")
})
}
} else {
return;
}
}
}