#1 물갈이 커맨드

This commit is contained in:
kdh8219 2023-05-05 18:30:22 +09:00
parent 0adfcd93d6
commit c7b270d75d
No known key found for this signature in database
GPG key ID: 2B5B609E12BB4C19
2 changed files with 97 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import {
import add_nick_super from "./commands/add_nick_super.js";
import add_nick from "./commands/add_nick.js";
import del_members_who_left_super from "./commands/del_members_who_left_super.js";
import del_nick_super from "./commands/del_nick_super.js";
import del_user_super from "./commands/del_user_super.js";
import get_blacklist from "./commands/get_blacklist.js";
@ -19,6 +20,7 @@ import search from "./commands/search.js";
const commands: TCommand[] = [
add_nick_super,
add_nick,
del_members_who_left_super,
del_nick_super,
del_user_super,
get_blacklist,

View file

@ -0,0 +1,95 @@
import {
SlashCommandBuilder,
PermissionFlagsBits,
ChatInputCommandInteraction,
EmbedBuilder,
} from "discord.js";
import firebase from "../../wrapper/firebase.js";
import { TUser, embed_to_channel } from "../../functions.js";
export default {
data: new SlashCommandBuilder()
.setName("del_members_who_left_super")
.setDescription(
"물갈이(서버에 부하가 있으므로, 과도한 사용을 지양해주세요!)"
)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.setDMPermission(false),
async execute(interaction: ChatInputCommandInteraction) {
const members_collection = firebase.collection("members");
const members = await members_collection.get();
for (const doc of members.docs) {
const data = doc.data() as TUser;
try {
await interaction.guild.members.fetch(data.discord_id);
} catch {
doc.ref.delete();
const embed = new EmbedBuilder()
.setTitle("물갈이됨")
.setDescription("deleted")
.setColor(0x0099ff)
.setFields([
{
name: "Command Sender",
value: `${interaction.user.tag}(${interaction.user.id})`,
},
{ name: " ", value: " " },
{ name: "Discord Id", value: data.discord_id },
{ name: "Minecraft Uuid", value: data.minecraft_uuid },
])
.setTimestamp(interaction.createdAt);
await embed_to_channel(
interaction.client,
process.env.LOG_CHANNEL_ID,
embed
);
}
}
// const should_remove = await members
// .where("discord_id", "==", discord_id)
// .get();
// if (!should_remove.empty) {
// should_remove.forEach((item) => {
// item.ref.delete();
// });
// let discord_tag;
// try {
// const discord_user = await interaction.client.users.fetch(discord_id);
// discord_tag = discord_user.tag;
// } catch {
// discord_tag = "Deleted User#0000";
// }
// await interaction.editReply({
// content: `삭제 완료:${discord_tag}의 계정을 모두 제거했습니다.`,
// });
// const embed = new EmbedBuilder()
// .setTitle("User deleted")
// .setColor(0x0099ff)
// .setFields([
// {
// name: "Command sender",
// value: `${interaction.user.tag}(${interaction.user.id})`,
// },
// { name: " ", value: " " },
// { name: "Target Discord Id", value: discord_id },
// ])
// .setTimestamp(interaction.createdAt);
// await embed_to_channel(
// interaction.client,
// process.env.LOG_CHANNEL_ID,
// embed
// );
// return;
// } else {
// await interaction.editReply({
// content: `\`에러\`: 해당 유저를 찾을 수 없습니다.`,
// });
// }
},
};