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
# IDE
/.idea

View file

@ -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;

View file

@ -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;

View file

@ -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 {

View file

@ -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;

View file

@ -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;

View file

@ -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을 확인해주세요.");
},

View file

@ -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;

View file

@ -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);
});

View file

@ -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] });
},
};

View file

@ -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,
});
},

View file

@ -11,11 +11,11 @@ export type TCommand = {
execute: (interaction: ChatInputCommandInteraction) => Promise<void>;
};
export function getCommands(): Collection<string, TCommand> {
const commandColection = new Collection<string, TCommand>();
const commandCollection = new Collection<string, TCommand>();
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 };
}

View file

@ -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 });
}

View file

@ -29,19 +29,19 @@ export default class TwoWayMap<T1, T2> {
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;
}
}

View file

@ -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<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> {
let id = this.cached.get_by_first(minecraft_uuid);