This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
132 lines (126 loc) · 4.69 KB
/
index.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
const crypto = require('crypto')
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [ 'DIRECT_MESSAGES', 'GUILD_MESSAGES' ,'GUILDS' ,]});
const yts = require( 'yt-search' )
const ver = require('./package.json').version;
const token = require( "./token.json" );
const commands = require( "./commands.json" );
//const commands2 = require("./math.json")
///関数
function md5hex(str) {
const md5 = crypto.createHash('md5')
return md5.update(str, 'binary').digest('hex')
}
function sha256hex(str) {
const sha2 = crypto.createHash('sha256')
return sha2.update(str, 'binary').digest('hex')
}
function shuffle(text) {
let obj = {};
for (let i = 0; i < text.length; i++) {
let rand = Math.floor(Math.random() * 10000000);
if (!obj[rand]) {
obj[rand] = text[i];
} else {
i--;
}
}
return Object.values(obj).join('');
}
///コマンドの定義とスタートアップ
client.once("ready", async () => {
await client.application.commands.set(commands);
setInterval(() => {
client.user.setActivity({
name: `Severs:${client.guilds.cache.size}|v${ver}`
})
}, 10000)
console.log("Hello WR");
});
///コマンドの処理
client.on("interactionCreate", async (interaction) => {
if (!interaction.isCommand()) {
return;
};
switch (interaction.commandName) {
case "embed":
let titlew = interaction.options.getString("title")
let descriptionw = interaction.options.getString("description")
await interaction.reply({embeds: [{
title: titlew,
color: 0xFFFFFF,
description: descriptionw}]});
break;
case "slot":
let emoji = [":innocent: ",":poop: ",":face_with_symbols_over_mouth: ",":eyes: ",":monkey_face: ",":thinking: ",":radioactive: ",":computer: ",":cockroach: ",":face_vomiting: ",":thumbsdown: ",":nauseated_face: ",":sunglasses: ",":beer: ",":100: ",":pill: ",":gem: ",":fox: ",":hatching_chick: ",":strawberry: ",":squid: ",":chicken: ",":briefs: ",":smiling_imp: ",":avocado: ",":space_invader: ",":mechanical_arm: "];
let n = (interaction.options.getNumber("n") * 2) + 1;
let slot = "";
if (n > 11){
await interaction.reply("5以下の数値を入力してください");
return;
}
for (let i = 0; i < n; i++) {
for (let j = 0; j < n; j++) {
slot = slot + emoji[Math.floor(Math.random() * emoji.length)]
}
slot = slot + "\n";
}
await interaction.reply(slot);
break;
case "yts":
let url = yts( interaction.options.getString("string"), async function ( err, r ) {
let msg = "動画が見つかりませんでした";
try{
msg = r.videos[0].url;
}catch{
;
}
await interaction.reply(msg);
})
break;
case "crypt":
switch (interaction.options.getString("hash")) {
case "md5":
await interaction.reply(md5hex(interaction.options.getString("string")));
case "sha256":
await interaction.reply(sha256hex(interaction.options.getString("string")));
}
break;
case "rinvite":
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let args = shuffle(chars);
let result = '';
for (let i = 0; i < 8; i++){
result += args.charAt(Math.floor(Math.random() * 36));
}
await interaction.reply("discord.gg/"+result);
break;
case "info":
await interaction.reply({embeds: [{
title: "このbotについて",
color: 0xFFFFFF,
description: `${client.user.tag}`,
timestamp: new Date(),
footer: {
icon_url: client.user.displayAvatarURL,
},
fields: [
{
name: "version",
value: "v"+ver,
inline: true,
},{
name: "ping",
value: `${client.ws.ping}ms`,
inline: true,
},{
name: "製作者",
value: "Netetra",
inline: true,
}
],
}]});
break;
}
});
client.login(token["bot"]);