This repository was archived by the owner on Jul 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
178 lines (167 loc) · 7.85 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
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
console.log(require('discord.js').version)
const prefix = '!'
LOG_CHANNEL_ID = '937190204693958706'
const { Client, Intents, MessageEmbed } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
const discord_job = require("discord-job-panel");
discord_job.db_type({ id: 1, label: "db", key: "mongodb://localhost:27017" });
discord_job.custom_id("HOGEHOGE");
client.on("interactionCreate", async i => {
if (i.customId == "HOGEHOGE") {
const select = discord_job(i);
await i.deferReply({ ephemeral: true });
if (select.bol) {
const role = await i.member.roles.add(select.info).catch(() => { });
if (!role) return i.followUp("エラー");
i.followUp("ロール追加");
} else {
const role = await i.member.roles.remove(select.info).catch(() => { });
if (!role) return i.followUp("エラー");
i.followUp("ロール削除");
}
}
if (i.isCommand() && i.applicationId === client.application.id) {
command(i.commandName, [i.options.get("role1"), i.options.get("role2"), i.options.get("role3")]);
}
});
client.on('ready', () => {
const servers = client.guilds.cache.size
console.log(`Botは今 ${servers} 個のサーバーに入ってるよー`)
client.user.setActivity(`/help | 導入数 ${servers} `, {
type: 'PLAYING',
})
client.application.commands.set([
{name: "support", description: "サポートサーバーのリンクを表示します"},
{name: "privacy", description: "プライバシーポリシーのリンクを表示します"},
{name: "help", description: "botのヘルプを表示します"},
{name: "ping", description: "Pingを表示します"},
{name: "job", description: "パネルを作成します", options: [{name: "role1", type: "ROLE", description: "ロール1", required: false},{name: "role2", type: "ROLE", description: "ロール2", required: false},{name: "role3", type: "ROLE", description: "ロール3", required: false}]},
{name: "addjob", description: "前回作成したパネルに追加します", options: [{name: "role1", type: "ROLE", description: "ロール1", required: false},{name: "role2", type: "ROLE", description: "ロール2", required: false},{name: "role3", type: "ROLE", description: "ロール3", required: false}]},
{name: "deletejob", description: "前回のデータを削除します"}
])
})
client.on('messageCreate', async message => {
async function sendError(err) {
const err_embed = new MessageEmbed({
description: '```\n' + err.toString() + '\n```',
footer: {
text: `サーバー: ${message.guild.id} | ${message.content}`
}
})
const ch = await client.channels.fetch(LOG_CHANNEL_ID)
if (ch) {
ch.send({ embeds: [err_embed] })
}
}
if (message.author.bot) {
return;
}
if (message.content.indexOf(prefix) !== 0) return;
const [command_name, ...args] = message.content.slice(prefix.length).split(' ')
command(command_name, args)
})
async function command(command, args) {
switch (command) {
case 'support':
var embed = new MessageEmbed({
title: "サポートサーバーです",
description: "SupportServer",
color: 0xffff00,
fields: [{
name: "URL",
value: "https://discord.gg/Y6w5Jv3EAR",
inline: false,
}]
})
message.reply({ embeds: [embed] });
break;
case 'PrivacyPolicy':
var embed = new MessageEmbed({
title: "プライバシーポリシーです",
description: "SupportServer",
color: 0xffff00,
fields: [{
name: "URL",
value: "https://kuroneko6423.com/PrivacyPolicy",
inline: false,
}]
})
message.reply({ embeds: [embed] });
break;
case 'help':
var embed = new MessageEmbed({
title: "helpです",
description: "This is Help commands",
color: 0xffff12,
fields: [{
name: "!help",
value: "今、表示しているやつです"
},
{
name: "!job @ロール @ロール. . .",
value: "役職パネルを作成します"
},
{
name: "!addjob",
value: "前回作成したパネルに追加します"
},
{
name: "!deletejob",
value: "前回のデータを削除します"
},
{
name: "!ping",
value: "応答速度を表示します"
},
{
name: "!support",
value: "サポートサーバーのリンクを表示します"
},
{
name: "!PrivacyPolicy",
value: "botのPrivacyPolicyを表示します"
}
]
})
message.reply({ embeds: [embed] })
break;
case 'ping':
message.reply({ content: ` Ping を確認しています...` })
.then((pingcheck) => {
pingcheck.edit(
`botの速度|${pingcheck.createdTimestamp - message.createdTimestamp} ms`
)
});
break;
case "job":
getdata = await discord_job.add_panel({ role: args, in: message, title: "ロールを選ぼう" });
if (getdata == 1) return message.reply("入力されていません");
if (getdata == 2) return message.reply("ロールが見つかりませんでした");
for (let i = 0; i < getdata.content.length; i++) message.reply({ embeds: [{ description: getdata.content[i].join("\n") }], components: [getdata.select[i]] });
break;
case "addjob":
getdata = await discord_job.add_panel({ role: args, in: message, title: "ロールを選ぼう" });
if (getdata == 1) return message.reply("入力がされていません");
if (getdata == 2) return message.reply("前回のデータが見つかりません");
if (getdata == 3) return message.reply("ロールが見つかりません");
for (let i = 0; i < getdata.content.length; i++)message.reply({ embeds: [{ description: getdata.content[i].join("\n") }], components: [getdata.select[i]] });
break
case 'deletedb':
const deletedb = await discord_job.delete_db(message.guild.id);
if (deletedb == 1) return message.reply("何も保存されていません");
if (deletedb == 2) return message.reply("完了");
break
case "deletejob":
const getdata = await discord_job.remove_panel({ num: args, title: "ロールを選ぼう", in: message });
if (getdata == 1) return message.reply("前回のデータが見つかりませんでした");
if (getdata == 2) return message.reply("前回のパネルの範囲内の数値を入れてください");
if (getdata == 3) return message.reply("すべてのコンテンツがなくなりました");
message.reply({ embeds: [{ description: getdata.content.join("\n") }], components: [getdata.select] });
break
case "cleardb":
await discord_job.clear_db();
message.reply("完了しました");
break
}
}
client.login("TOKEN");