fix typo errors

This commit is contained in:
kdh8219 2023-04-29 23:34:55 +09:00
parent 9ba3fafc7f
commit a2aa1bb0db
15 changed files with 51 additions and 48 deletions

3
.gitignore vendored
View file

@ -10,3 +10,6 @@ replit.nix
#빌드파일 #빌드파일
/out /out
# IDE
/.idea

View file

@ -31,19 +31,19 @@ export default {
const blacklist = firebase.collection("blacklist"); const blacklist = firebase.collection("blacklist");
if (!(await blacklist.where("discord_id", "==", discord_id).get()).empty) { if (!(await blacklist.where("discord_id", "==", discord_id).get()).empty) {
interaction.editReply({ await interaction.editReply({
content: "`에러`: 해당 디스코드 아이디는 블랙리스트 되었습니다.", content: "`에러`: 해당 디스코드 아이디는 블랙리스트 되었습니다.",
}); });
return; return;
} }
if (!(await blacklist.where("minecraft_uuid", "==", mcuuid).get()).empty) { if (!(await blacklist.where("minecraft_uuid", "==", mcuuid).get()).empty) {
interaction.editReply({ await interaction.editReply({
content: "`에러`: 해당 마인크래프트 계정은 블랙리스트 되었습니다.", content: "`에러`: 해당 마인크래프트 계정은 블랙리스트 되었습니다.",
}); });
return; return;
} }
if (!(await members.where("minecraft_uuid", "==", mcuuid).get()).empty) { if (!(await members.where("minecraft_uuid", "==", mcuuid).get()).empty) {
interaction.editReply({ await interaction.editReply({
content: "`에러`: 해당 마인크래프트 아이디는 이미 등록되었습니다.", content: "`에러`: 해당 마인크래프트 아이디는 이미 등록되었습니다.",
}); });
return; return;

View file

@ -43,19 +43,19 @@ export default {
const blacklist = firebase.collection("blacklist"); const blacklist = firebase.collection("blacklist");
if (!(await blacklist.where("discord_id", "==", discord_id).get()).empty) { if (!(await blacklist.where("discord_id", "==", discord_id).get()).empty) {
interaction.editReply({ await interaction.editReply({
content: "`에러`: 해당 디스코드 아이디는 블랙리스트 되었습니다.", content: "`에러`: 해당 디스코드 아이디는 블랙리스트 되었습니다.",
}); });
return; return;
} }
if (!(await blacklist.where("minecraft_uuid", "==", mcuuid).get()).empty) { if (!(await blacklist.where("minecraft_uuid", "==", mcuuid).get()).empty) {
interaction.editReply({ await interaction.editReply({
content: "`에러`: 해당 마인크래프트 계정은 블랙리스트 되었습니다.", content: "`에러`: 해당 마인크래프트 계정은 블랙리스트 되었습니다.",
}); });
return; return;
} }
if (!(await members.where("minecraft_uuid", "==", mcuuid).get()).empty) { if (!(await members.where("minecraft_uuid", "==", mcuuid).get()).empty) {
interaction.editReply({ await interaction.editReply({
content: "`에러`: 해당 마인크래프트 아이디는 이미 등록되었습니다.", content: "`에러`: 해당 마인크래프트 아이디는 이미 등록되었습니다.",
}); });
return; return;

View file

@ -28,10 +28,10 @@ export default {
async execute(interaction: ChatInputCommandInteraction) { async execute(interaction: ChatInputCommandInteraction) {
const discord_id = interaction.options.getUser("discord")?.id as string; const discord_id = interaction.options.getUser("discord")?.id as string;
const mcid = interaction.options.getString("minecraft_id") as string; const minecraft_id = interaction.options.getString("minecraft_id") as string;
let mcuuid: string; let minecraft_uuid: string;
try { try {
mcuuid = await mojangAPI.getUUIDFromId(mcid); minecraft_uuid = await mojangAPI.getUUIDFromId(minecraft_id);
} catch { } catch {
await interaction.editReply({ await interaction.editReply({
content: content:
@ -41,7 +41,7 @@ export default {
} }
const members = firebase.collection("members"); const members = firebase.collection("members");
const the_member = await members const the_member = await members
.where("minecraft_uuid", "==", mcuuid) .where("minecraft_uuid", "==", minecraft_uuid)
.where("discord_id", "==", discord_id) .where("discord_id", "==", discord_id)
.get(); .get();
if (!the_member.empty) { if (!the_member.empty) {
@ -56,8 +56,8 @@ export default {
} catch { } catch {
discord_tag = "Deleted User#0000"; discord_tag = "Deleted User#0000";
} }
interaction.editReply({ await interaction.editReply({
content: `삭제 완료:${discord_tag}(${discord_id})에게서 ${mcid}(${mcuuid})를 제거했습니다.`, content: `삭제 완료:${discord_tag}(${discord_id})에게서 ${minecraft_id}(${minecraft_uuid})를 제거했습니다.`,
}); });
return; return;
} else { } else {

View file

@ -7,7 +7,7 @@ import mojangAPI from "../../wrapper/mojang-api.js";
export default { export default {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
.setName("get_blacklist") .setName("get_blacklist")
.setDescription("show blicklist") .setDescription("show blacklist")
.setDMPermission(false), .setDMPermission(false),
async execute(interaction: ChatInputCommandInteraction) { async execute(interaction: ChatInputCommandInteraction) {
const discord_id = interaction.user.id; const discord_id = interaction.user.id;
@ -16,7 +16,7 @@ export default {
const blacklist = firebase.collection("blacklist"); const blacklist = firebase.collection("blacklist");
if ((await members.where("discord_id", "==", discord_id).get()).empty) { if ((await members.where("discord_id", "==", discord_id).get()).empty) {
interaction.editReply({ await interaction.editReply({
content: "`에러`: 하나 이상의 아이디를 등록해야 합니다.", content: "`에러`: 하나 이상의 아이디를 등록해야 합니다.",
}); });
return; return;

View file

@ -15,7 +15,7 @@ export default {
const blacklist = firebase.collection("blacklist"); const blacklist = firebase.collection("blacklist");
if ((await members.where("discord_id", "==", discord_id).get()).empty) { if ((await members.where("discord_id", "==", discord_id).get()).empty) {
interaction.editReply({ await interaction.editReply({
content: "`에러`: 하나 이상의 아이디를 등록해야 합니다.", content: "`에러`: 하나 이상의 아이디를 등록해야 합니다.",
}); });
return; return;

View file

@ -15,7 +15,7 @@ export default {
const members = firebase.collection("members"); const members = firebase.collection("members");
if ((await members.where("discord_id", "==", discord_id).get()).empty) { if ((await members.where("discord_id", "==", discord_id).get()).empty) {
interaction.editReply({ await interaction.editReply({
content: "`에러`: 하나 이상의 아이디를 등록해야 합니다.", content: "`에러`: 하나 이상의 아이디를 등록해야 합니다.",
}); });
return; return;
@ -64,8 +64,8 @@ export default {
text += "\n\n"; text += "\n\n";
} }
const sliced = dmSlice(text); const sliced = dmSlice(text);
for (const chunc of sliced) { for (const chunk of sliced) {
await interaction.user.send(chunc); await interaction.user.send(chunk);
} }
await interaction.editReply("dm을 확인해주세요."); await interaction.editReply("dm을 확인해주세요.");
}, },

View file

@ -20,7 +20,7 @@ export default {
const blacklist = firebase.collection("blacklist"); const blacklist = firebase.collection("blacklist");
if ((await members.where("discord_id", "==", discord_id).get()).empty) { if ((await members.where("discord_id", "==", discord_id).get()).empty) {
interaction.editReply({ await interaction.editReply({
content: "`에러`: 하나 이상의 아이디를 등록해야 합니다.", content: "`에러`: 하나 이상의 아이디를 등록해야 합니다.",
}); });
return; return;

View file

@ -31,12 +31,12 @@ export default {
return; return;
} }
const target_datas: TUser[] = []; const target_data: TUser[] = [];
target.forEach((doc) => { target.forEach((doc) => {
target_datas.push(doc.data() as TUser); target_data.push(doc.data() as TUser);
members.doc(doc.id).delete(); members.doc(doc.id).delete();
}); });
target_datas.forEach((user) => { target_data.forEach((user) => {
blacklist.add(user); blacklist.add(user);
}); });

View file

@ -24,12 +24,12 @@ export default {
value: `${interaction.client.ws.ping}ms`, value: `${interaction.client.ws.ping}ms`,
}, },
{ {
name: "Roundtrip latency", name: "RoundTrip latency",
value: `${defer.createdTimestamp - interaction.createdTimestamp}ms`, value: `${defer.createdTimestamp - interaction.createdTimestamp}ms`,
} }
) )
.setFooter({ text: `Bot runner: ${process.env.RUNNER_NAME}` }); .setFooter({ text: `Bot runner: ${process.env.RUNNER_NAME}` });
interaction.editReply({ embeds: [embed] }); await interaction.editReply({ embeds: [embed] });
}, },
}; };

View file

@ -35,7 +35,7 @@ export default {
if ( if (
(await members.where("discord_id", "==", interaction.user.id).get()).empty (await members.where("discord_id", "==", interaction.user.id).get()).empty
) { ) {
interaction.editReply({ await interaction.editReply({
content: `\`에러\`:하나 이상의 아이디를 등록해야만 합니다.`, content: `\`에러\`:하나 이상의 아이디를 등록해야만 합니다.`,
}); });
return; return;
@ -57,7 +57,7 @@ export default {
.where("minecraft_uuid", "==", minecraft_uuid) .where("minecraft_uuid", "==", minecraft_uuid)
.get(); .get();
if (member.empty) { if (member.empty) {
interaction.editReply({ await interaction.editReply({
content: `\`에러\`: 해당 마인크래프트 아이디는 등록되지 않았어요!`, content: `\`에러\`: 해당 마인크래프트 아이디는 등록되지 않았어요!`,
}); });
return; return;
@ -67,9 +67,9 @@ export default {
discord_id = interaction.options.getUser("discord").id; discord_id = interaction.options.getUser("discord").id;
} }
const the_datas = await members.where("discord_id", "==", discord_id).get(); const the_data = await members.where("discord_id", "==", discord_id).get();
if (the_datas.empty) { if (the_data.empty) {
interaction.editReply({ await interaction.editReply({
content: "`에러`: 해당 멤버는 등록되지 않았어요!", content: "`에러`: 해당 멤버는 등록되지 않았어요!",
}); });
} }
@ -78,14 +78,14 @@ export default {
(await interaction.guild.members.fetch(discord_id)).nickname || (await interaction.guild.members.fetch(discord_id)).nickname ||
interaction.user.username; interaction.user.username;
text += ": "; text += ": ";
for (const user of the_datas.docs) { for (const user of the_data.docs) {
const minecraft_uuid = user.data()["minecraft_uuid"]; const minecraft_uuid = user.data()["minecraft_uuid"];
text += await mojangAPI.getIdFromUUID(minecraft_uuid); text += await mojangAPI.getIdFromUUID(minecraft_uuid);
text += ` [${minecraft_uuid}]`; text += ` [${minecraft_uuid}]`;
text += ", "; text += ", ";
} }
text = text.slice(0, -2); text = text.slice(0, -2);
interaction.editReply({ await interaction.editReply({
content: text, content: text,
}); });
}, },

View file

@ -11,11 +11,11 @@ export type TCommand = {
execute: (interaction: ChatInputCommandInteraction) => Promise<void>; execute: (interaction: ChatInputCommandInteraction) => Promise<void>;
}; };
export function getCommands(): Collection<string, TCommand> { export function getCommands(): Collection<string, TCommand> {
const commandColection = new Collection<string, TCommand>(); const commandCollection = new Collection<string, TCommand>();
for (const command of commands) { for (const command of commands) {
commandColection.set(command.data.name, command); commandCollection.set(command.data.name, command);
} }
return commandColection; return commandCollection;
} }
export type TUser = { export type TUser = {
@ -35,9 +35,9 @@ export function dmSlice(raw: string): string[] {
let front = txt.slice(0, 2000); let front = txt.slice(0, 2000);
let end = txt.slice(2000, txt.length); let end = txt.slice(2000, txt.length);
if (end) { 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")); front = front.slice(0, front.lastIndexOf("\n"));
end = tolast + end; end = toLast + end;
} }
return { front, end }; return { front, end };
} }

View file

@ -6,7 +6,7 @@ import { getCommands } from "./functions.js";
const client = new Client({ intents: [GatewayIntentBits.Guilds] }); const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const commandColection = getCommands(); const commandCollection = getCommands();
export let onTime: Date; export let onTime: Date;
client.once(Events.ClientReady, (event) => { client.once(Events.ClientReady, (event) => {
@ -17,7 +17,7 @@ client.once(Events.ClientReady, (event) => {
client.on(Events.InteractionCreate, async (interaction) => { client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isChatInputCommand()) return; if (!interaction.isChatInputCommand()) return;
const command = commandColection.get(interaction.commandName); const command = commandCollection.get(interaction.commandName);
if (interaction.commandName !== "ping") { if (interaction.commandName !== "ping") {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
} }

View file

@ -29,19 +29,19 @@ export default class TwoWayMap<T1, T2> {
this.secondMap.set(second, first); this.secondMap.set(second, first);
} }
remove_by_first(first: T1): T2 | undefined { remove_by_first(first: T1): T2 | undefined {
const firstget = this.firstMap.get(first); const t2 = this.firstMap.get(first);
if (!firstget) return undefined; if (!t2) return undefined;
this.firstMap.delete(first); this.firstMap.delete(first);
this.secondMap.delete(firstget); this.secondMap.delete(t2);
return firstget; return t2;
} }
remove_by_second(second: T2): T1 | undefined { remove_by_second(second: T2): T1 | undefined {
const secondget = this.secondMap.get(second); const t1 = this.secondMap.get(second);
if (!secondget) return undefined; if (!t1) return undefined;
this.firstMap.delete(secondget); this.firstMap.delete(t1);
this.secondMap.delete(second); this.secondMap.delete(second);
return secondget; return t1;
} }
} }

View file

@ -1,9 +1,9 @@
import axios from "axios"; import axios from "axios";
import TwoWayMmap from "../utils/two-way-map.js"; import TwoWayMap from "../utils/two-way-map.js";
class MojangAPI { class MojangAPI {
private cached: TwoWayMmap<string, string> = new TwoWayMmap<string, string>(); // uuid, id private cached: TwoWayMap<string, string> = new TwoWayMap<string, string>(); // uuid, id
async getIdFromUUID(minecraft_uuid: string): Promise<string> { async getIdFromUUID(minecraft_uuid: string): Promise<string> {
let id = this.cached.get_by_first(minecraft_uuid); let id = this.cached.get_by_first(minecraft_uuid);