diff --git a/.gitignore b/.gitignore index 9f6b1b1..92e176d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ replit.nix #빌드파일 /out + +# IDE +/.idea diff --git a/src/command/commands/add_nick.ts b/src/command/commands/add_nick.ts index 982a0b0..c39e46e 100755 --- a/src/command/commands/add_nick.ts +++ b/src/command/commands/add_nick.ts @@ -31,19 +31,19 @@ export default { const blacklist = firebase.collection("blacklist"); if (!(await blacklist.where("discord_id", "==", discord_id).get()).empty) { - interaction.editReply({ + await interaction.editReply({ content: "`에러`: 해당 디스코드 아이디는 블랙리스트 되었습니다.", }); return; } if (!(await blacklist.where("minecraft_uuid", "==", mcuuid).get()).empty) { - interaction.editReply({ + await interaction.editReply({ content: "`에러`: 해당 마인크래프트 계정은 블랙리스트 되었습니다.", }); return; } if (!(await members.where("minecraft_uuid", "==", mcuuid).get()).empty) { - interaction.editReply({ + await interaction.editReply({ content: "`에러`: 해당 마인크래프트 아이디는 이미 등록되었습니다.", }); return; diff --git a/src/command/commands/add_nick_super.ts b/src/command/commands/add_nick_super.ts index 38ae61b..dbf6d98 100755 --- a/src/command/commands/add_nick_super.ts +++ b/src/command/commands/add_nick_super.ts @@ -43,19 +43,19 @@ export default { const blacklist = firebase.collection("blacklist"); if (!(await blacklist.where("discord_id", "==", discord_id).get()).empty) { - interaction.editReply({ + await interaction.editReply({ content: "`에러`: 해당 디스코드 아이디는 블랙리스트 되었습니다.", }); return; } if (!(await blacklist.where("minecraft_uuid", "==", mcuuid).get()).empty) { - interaction.editReply({ + await interaction.editReply({ content: "`에러`: 해당 마인크래프트 계정은 블랙리스트 되었습니다.", }); return; } if (!(await members.where("minecraft_uuid", "==", mcuuid).get()).empty) { - interaction.editReply({ + await interaction.editReply({ content: "`에러`: 해당 마인크래프트 아이디는 이미 등록되었습니다.", }); return; diff --git a/src/command/commands/del_nick_super.ts b/src/command/commands/del_nick_super.ts index 7c3a9ec..c34984f 100755 --- a/src/command/commands/del_nick_super.ts +++ b/src/command/commands/del_nick_super.ts @@ -28,10 +28,10 @@ export default { async execute(interaction: ChatInputCommandInteraction) { const discord_id = interaction.options.getUser("discord")?.id as string; - const mcid = interaction.options.getString("minecraft_id") as string; - let mcuuid: string; + const minecraft_id = interaction.options.getString("minecraft_id") as string; + let minecraft_uuid: string; try { - mcuuid = await mojangAPI.getUUIDFromId(mcid); + minecraft_uuid = await mojangAPI.getUUIDFromId(minecraft_id); } catch { await interaction.editReply({ content: @@ -41,7 +41,7 @@ export default { } const members = firebase.collection("members"); const the_member = await members - .where("minecraft_uuid", "==", mcuuid) + .where("minecraft_uuid", "==", minecraft_uuid) .where("discord_id", "==", discord_id) .get(); if (!the_member.empty) { @@ -56,8 +56,8 @@ export default { } catch { discord_tag = "Deleted User#0000"; } - interaction.editReply({ - content: `삭제 완료:${discord_tag}(${discord_id})에게서 ${mcid}(${mcuuid})를 제거했습니다.`, + await interaction.editReply({ + content: `삭제 완료:${discord_tag}(${discord_id})에게서 ${minecraft_id}(${minecraft_uuid})를 제거했습니다.`, }); return; } else { diff --git a/src/command/commands/get_blacklist.ts b/src/command/commands/get_blacklist.ts index 7241d68..18dc08e 100755 --- a/src/command/commands/get_blacklist.ts +++ b/src/command/commands/get_blacklist.ts @@ -7,7 +7,7 @@ import mojangAPI from "../../wrapper/mojang-api.js"; export default { data: new SlashCommandBuilder() .setName("get_blacklist") - .setDescription("show blicklist") + .setDescription("show blacklist") .setDMPermission(false), async execute(interaction: ChatInputCommandInteraction) { const discord_id = interaction.user.id; @@ -16,7 +16,7 @@ export default { const blacklist = firebase.collection("blacklist"); if ((await members.where("discord_id", "==", discord_id).get()).empty) { - interaction.editReply({ + await interaction.editReply({ content: "`에러`: 하나 이상의 아이디를 등록해야 합니다.", }); return; diff --git a/src/command/commands/get_file.ts b/src/command/commands/get_file.ts index 092bf19..e3d4d43 100755 --- a/src/command/commands/get_file.ts +++ b/src/command/commands/get_file.ts @@ -15,7 +15,7 @@ export default { const blacklist = firebase.collection("blacklist"); if ((await members.where("discord_id", "==", discord_id).get()).empty) { - interaction.editReply({ + await interaction.editReply({ content: "`에러`: 하나 이상의 아이디를 등록해야 합니다.", }); return; diff --git a/src/command/commands/get_members.ts b/src/command/commands/get_members.ts index e517ffd..09c34a3 100755 --- a/src/command/commands/get_members.ts +++ b/src/command/commands/get_members.ts @@ -15,7 +15,7 @@ export default { const members = firebase.collection("members"); if ((await members.where("discord_id", "==", discord_id).get()).empty) { - interaction.editReply({ + await interaction.editReply({ content: "`에러`: 하나 이상의 아이디를 등록해야 합니다.", }); return; @@ -64,8 +64,8 @@ export default { text += "\n\n"; } const sliced = dmSlice(text); - for (const chunc of sliced) { - await interaction.user.send(chunc); + for (const chunk of sliced) { + await interaction.user.send(chunk); } await interaction.editReply("dm을 확인해주세요."); }, diff --git a/src/command/commands/get_raw_file.ts b/src/command/commands/get_raw_file.ts index 0157d91..99f6800 100755 --- a/src/command/commands/get_raw_file.ts +++ b/src/command/commands/get_raw_file.ts @@ -20,7 +20,7 @@ export default { const blacklist = firebase.collection("blacklist"); if ((await members.where("discord_id", "==", discord_id).get()).empty) { - interaction.editReply({ + await interaction.editReply({ content: "`에러`: 하나 이상의 아이디를 등록해야 합니다.", }); return; diff --git a/src/command/commands/mov_blacklist_super.ts b/src/command/commands/mov_blacklist_super.ts index 82961b7..1a0dd30 100755 --- a/src/command/commands/mov_blacklist_super.ts +++ b/src/command/commands/mov_blacklist_super.ts @@ -31,12 +31,12 @@ export default { return; } - const target_datas: TUser[] = []; + const target_data: TUser[] = []; target.forEach((doc) => { - target_datas.push(doc.data() as TUser); + target_data.push(doc.data() as TUser); members.doc(doc.id).delete(); }); - target_datas.forEach((user) => { + target_data.forEach((user) => { blacklist.add(user); }); diff --git a/src/command/commands/ping.ts b/src/command/commands/ping.ts index e269ffd..61905a5 100755 --- a/src/command/commands/ping.ts +++ b/src/command/commands/ping.ts @@ -24,12 +24,12 @@ export default { value: `${interaction.client.ws.ping}ms`, }, { - name: "Roundtrip latency", + name: "RoundTrip latency", value: `${defer.createdTimestamp - interaction.createdTimestamp}ms`, } ) .setFooter({ text: `Bot runner: ${process.env.RUNNER_NAME}` }); - interaction.editReply({ embeds: [embed] }); + await interaction.editReply({ embeds: [embed] }); }, }; diff --git a/src/command/commands/search.ts b/src/command/commands/search.ts index a5d073d..c2cdbbe 100755 --- a/src/command/commands/search.ts +++ b/src/command/commands/search.ts @@ -35,7 +35,7 @@ export default { if ( (await members.where("discord_id", "==", interaction.user.id).get()).empty ) { - interaction.editReply({ + await interaction.editReply({ content: `\`에러\`:하나 이상의 아이디를 등록해야만 합니다.`, }); return; @@ -57,7 +57,7 @@ export default { .where("minecraft_uuid", "==", minecraft_uuid) .get(); if (member.empty) { - interaction.editReply({ + await interaction.editReply({ content: `\`에러\`: 해당 마인크래프트 아이디는 등록되지 않았어요!`, }); return; @@ -67,9 +67,9 @@ export default { discord_id = interaction.options.getUser("discord").id; } - const the_datas = await members.where("discord_id", "==", discord_id).get(); - if (the_datas.empty) { - interaction.editReply({ + const the_data = await members.where("discord_id", "==", discord_id).get(); + if (the_data.empty) { + await interaction.editReply({ content: "`에러`: 해당 멤버는 등록되지 않았어요!", }); } @@ -78,14 +78,14 @@ export default { (await interaction.guild.members.fetch(discord_id)).nickname || interaction.user.username; text += ": "; - for (const user of the_datas.docs) { + for (const user of the_data.docs) { const minecraft_uuid = user.data()["minecraft_uuid"]; text += await mojangAPI.getIdFromUUID(minecraft_uuid); text += ` [${minecraft_uuid}]`; text += ", "; } text = text.slice(0, -2); - interaction.editReply({ + await interaction.editReply({ content: text, }); }, diff --git a/src/functions.ts b/src/functions.ts index f05f56c..d1dcccf 100644 --- a/src/functions.ts +++ b/src/functions.ts @@ -11,11 +11,11 @@ export type TCommand = { execute: (interaction: ChatInputCommandInteraction) => Promise; }; export function getCommands(): Collection { - const commandColection = new Collection(); + const commandCollection = new Collection(); for (const command of commands) { - commandColection.set(command.data.name, command); + commandCollection.set(command.data.name, command); } - return commandColection; + return commandCollection; } export type TUser = { @@ -35,9 +35,9 @@ export function dmSlice(raw: string): string[] { let front = txt.slice(0, 2000); let end = txt.slice(2000, txt.length); if (end) { - let tolast = front.slice(front.lastIndexOf("\n"), -1); + let toLast = front.slice(front.lastIndexOf("\n"), -1); front = front.slice(0, front.lastIndexOf("\n")); - end = tolast + end; + end = toLast + end; } return { front, end }; } diff --git a/src/main.ts b/src/main.ts index cc4561c..dbeee2e 100755 --- a/src/main.ts +++ b/src/main.ts @@ -6,7 +6,7 @@ import { getCommands } from "./functions.js"; const client = new Client({ intents: [GatewayIntentBits.Guilds] }); -const commandColection = getCommands(); +const commandCollection = getCommands(); export let onTime: Date; client.once(Events.ClientReady, (event) => { @@ -17,7 +17,7 @@ client.once(Events.ClientReady, (event) => { client.on(Events.InteractionCreate, async (interaction) => { if (!interaction.isChatInputCommand()) return; - const command = commandColection.get(interaction.commandName); + const command = commandCollection.get(interaction.commandName); if (interaction.commandName !== "ping") { await interaction.deferReply({ ephemeral: true }); } diff --git a/src/utils/two-way-map.ts b/src/utils/two-way-map.ts index c7d76b9..6848bf6 100644 --- a/src/utils/two-way-map.ts +++ b/src/utils/two-way-map.ts @@ -29,19 +29,19 @@ export default class TwoWayMap { this.secondMap.set(second, first); } remove_by_first(first: T1): T2 | undefined { - const firstget = this.firstMap.get(first); - if (!firstget) return undefined; + const t2 = this.firstMap.get(first); + if (!t2) return undefined; this.firstMap.delete(first); - this.secondMap.delete(firstget); - return firstget; + this.secondMap.delete(t2); + return t2; } remove_by_second(second: T2): T1 | undefined { - const secondget = this.secondMap.get(second); - if (!secondget) return undefined; + const t1 = this.secondMap.get(second); + if (!t1) return undefined; - this.firstMap.delete(secondget); + this.firstMap.delete(t1); this.secondMap.delete(second); - return secondget; + return t1; } } diff --git a/src/wrapper/mojang-api.ts b/src/wrapper/mojang-api.ts index 492e7aa..c02af26 100644 --- a/src/wrapper/mojang-api.ts +++ b/src/wrapper/mojang-api.ts @@ -1,9 +1,9 @@ import axios from "axios"; -import TwoWayMmap from "../utils/two-way-map.js"; +import TwoWayMap from "../utils/two-way-map.js"; class MojangAPI { - private cached: TwoWayMmap = new TwoWayMmap(); // uuid, id + private cached: TwoWayMap = new TwoWayMap(); // uuid, id async getIdFromUUID(minecraft_uuid: string): Promise { let id = this.cached.get_by_first(minecraft_uuid);