parent
2c4556906f
commit
958756a9d4
|
@ -2,7 +2,7 @@ import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
|||
|
||||
import firebase from "../../wrapper/firebase.js";
|
||||
import mojangAPI from "../../wrapper/mojang-api.js";
|
||||
import { TUser, dmSlice } from "../../functions.js";
|
||||
import { TUser } from "../../functions.js";
|
||||
|
||||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
|
@ -49,6 +49,7 @@ export default {
|
|||
} catch (e) {
|
||||
tag = `Deleted User#0000`;
|
||||
}
|
||||
text += "- ";
|
||||
text += `\`${nickname}\``;
|
||||
text += `【\`${tag}\`】`;
|
||||
text += `[${member[0]}]`;
|
||||
|
@ -70,3 +71,28 @@ export default {
|
|||
await interaction.editReply("dm을 확인해주세요.");
|
||||
},
|
||||
};
|
||||
|
||||
function dmSlice(raw: string): string[] {
|
||||
function slasher(txt: string): { front: string; end: string } {
|
||||
let front = txt.slice(0, 2000);
|
||||
let end = txt.slice(2000);
|
||||
if (end) {
|
||||
const IndexOfLastBlock = front.lastIndexOf("\n\n");
|
||||
end = "ㅤ" /* 공백문자 */ + front.slice(IndexOfLastBlock + 1) + end;
|
||||
front = front.slice(0, IndexOfLastBlock);
|
||||
}
|
||||
return { front, end };
|
||||
}
|
||||
|
||||
const output: string[] = [];
|
||||
|
||||
let slashed = slasher(raw);
|
||||
while (true) {
|
||||
output.push(slashed.front);
|
||||
if (slashed.end) {
|
||||
slashed = slasher(slashed.end);
|
||||
} else {
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,38 +13,6 @@ export type TUser = {
|
|||
discord_id: string; // id
|
||||
minecraft_uuid: string; //uuid
|
||||
};
|
||||
export function dmSlice(raw: string): string[] {
|
||||
const output: string[] = [];
|
||||
function slasher(txt: string): { front: string; end: string } {
|
||||
if (txt.length <= 2000) {
|
||||
return {
|
||||
front: txt,
|
||||
end: null,
|
||||
};
|
||||
}
|
||||
let front = txt.slice(0, 2000);
|
||||
let end = txt.slice(2000, txt.length);
|
||||
if (end) {
|
||||
let toLastNextLine = front.slice(front.lastIndexOf("\n"), front.length);
|
||||
front = front.slice(0, front.lastIndexOf("\n"));
|
||||
end = toLastNextLine + end;
|
||||
if (end.slice(0, 3) == "\n\n") {
|
||||
end = "ㅤ" /* 공백문자 */ + end;
|
||||
}
|
||||
}
|
||||
return { front, end };
|
||||
}
|
||||
|
||||
let slashed = slasher(raw);
|
||||
while (true) {
|
||||
output.push(slashed.front);
|
||||
if (slashed.end) {
|
||||
slashed = slasher(slashed.end);
|
||||
} else {
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function add_user(
|
||||
interaction: ChatInputCommandInteraction,
|
||||
|
|
Loading…
Reference in a new issue