del_user_super
This commit is contained in:
parent
ab46e7e9fa
commit
e53ee68011
|
@ -3,7 +3,14 @@ import { TCommand } from "../functions.js";
|
||||||
import add_nick_super from "./commands/add_nick_super.js";
|
import add_nick_super from "./commands/add_nick_super.js";
|
||||||
import add_nick from "./commands/add_nick.js";
|
import add_nick from "./commands/add_nick.js";
|
||||||
import del_nick_super from "./commands/del_nick_super.js";
|
import del_nick_super from "./commands/del_nick_super.js";
|
||||||
|
import del_user_super from "./commands/del_user_super.js";
|
||||||
import ping from "./commands/ping.js";
|
import ping from "./commands/ping.js";
|
||||||
|
|
||||||
const commands: TCommand[] = [add_nick_super, add_nick, del_nick_super, ping];
|
const commands: TCommand[] = [
|
||||||
|
add_nick_super,
|
||||||
|
add_nick,
|
||||||
|
del_nick_super,
|
||||||
|
del_user_super,
|
||||||
|
ping,
|
||||||
|
];
|
||||||
export default commands;
|
export default commands;
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
const { SlashCommandBuilder, PermissionFlagsBits, Client, GatewayIntentBits } = require("discord.js");
|
|
||||||
|
|
||||||
const firebase_admin = require("firebase-admin");
|
|
||||||
const { getDatabase } = require("firebase-admin/database");
|
|
||||||
const serviceAccount = require("../firebase/conf.json");
|
|
||||||
if (!firebase_admin.apps.length) {
|
|
||||||
firebase_admin.initializeApp({
|
|
||||||
credential: firebase_admin.credential.cert(serviceAccount),
|
|
||||||
databaseURL: process.env.FIREBASE_URL,
|
|
||||||
databaseAuthVariableOverride: {
|
|
||||||
uid: process.env.FIREBASE_UID,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const firebase = getDatabase().ref("/");
|
|
||||||
|
|
||||||
// const { token } = require('../config.json');
|
|
||||||
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
|
|
||||||
client.login(process.env.DISCORD_TOKEN);
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
data: new SlashCommandBuilder()
|
|
||||||
.setName("del_user_super")
|
|
||||||
.setDescription("del someone on the list")
|
|
||||||
.addUserOption((option) => option.setName("discord").setDescription("discord account").setRequired(true))
|
|
||||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
|
||||||
.setDMPermission(false),
|
|
||||||
async execute(interaction) {
|
|
||||||
await interaction.deferReply({ ephemeral: true });
|
|
||||||
let data = (await firebase.get()).val();
|
|
||||||
const discord_id = interaction.options.getUser("discord").id;
|
|
||||||
for (let discord_search_point in data["members"]) {
|
|
||||||
if (data["members"][discord_search_point].discord == discord_id) {
|
|
||||||
//이미 등록된 디코일경우
|
|
||||||
data["members"].splice(discord_search_point, 1);
|
|
||||||
await firebase.set(data);
|
|
||||||
await interaction.editReply({ content: `삭제 완료:<@${discord_id}>를 제거했습니다.`, ephemeral: true });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} //신규 디코일 경우
|
|
||||||
await interaction.editReply({ content: `\`에러\`: 해당 유저를 찾을 수 없습니다.`, ephemeral: true });
|
|
||||||
},
|
|
||||||
};
|
|
52
src/command/commands/del_user_super.ts
Executable file
52
src/command/commands/del_user_super.ts
Executable file
|
@ -0,0 +1,52 @@
|
||||||
|
import {
|
||||||
|
SlashCommandBuilder,
|
||||||
|
PermissionFlagsBits,
|
||||||
|
ChatInputCommandInteraction,
|
||||||
|
} from "discord.js";
|
||||||
|
|
||||||
|
import firebase from "../../wrapper/firebase.js";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName("del_user_super")
|
||||||
|
.setDescription("del someone on the list")
|
||||||
|
.addUserOption((option) =>
|
||||||
|
option
|
||||||
|
.setName("discord")
|
||||||
|
.setDescription("discord account")
|
||||||
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||||
|
.setDMPermission(false),
|
||||||
|
async execute(interaction: ChatInputCommandInteraction) {
|
||||||
|
const discord_id = interaction.options.getUser("discord")?.id as string;
|
||||||
|
const members = firebase.collection("members");
|
||||||
|
|
||||||
|
const should_remove = await members
|
||||||
|
.where("discord_id", "==", discord_id)
|
||||||
|
.get();
|
||||||
|
|
||||||
|
if (!should_remove.empty) {
|
||||||
|
should_remove.forEach((item) => {
|
||||||
|
members.doc(item.id).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}의 계정을 모두 제거했습니다.`,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
await interaction.editReply({
|
||||||
|
content: `\`에러\`: 해당 유저를 찾을 수 없습니다.`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
Loading…
Reference in a new issue