UNPKG

easy-discord-logs

Version:

Advanced discord logs system and easy usage!

62 lines (61 loc) 3.31 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const BaseCommand_1 = __importDefault(require("../../utils/structures/BaseCommand")); const Models_1 = require("../../utils/MongoDB/Models"); class VoiceChannelsLogsCommand extends BaseCommand_1.default { constructor() { super("voice-logs", "Logs", []); } run(client, message, args) { var _a, _b; return __awaiter(this, void 0, void 0, function* () { if (!message.guild || !message.member) return; if (!message.member.hasPermission("MANAGE_GUILD")) return message.channel.send("You need server manager permissions"); let logsConfig = client.logs.get(message.guild.id); if (!logsConfig) { logsConfig = yield Models_1.LogsSchema.create({ guildId: message.guild.id, ChannelLogs: null, BoostLogs: null, MessageLogs: null, GuildLogs: null, MemberLogs: null, RolesLogs: null, VoiceChannelsLogs: null, }); } let VoiceChannelsLogs; if (args[0] === "default") { VoiceChannelsLogs = null; } else { VoiceChannelsLogs = ((_b = (_a = message.mentions) === null || _a === void 0 ? void 0 : _a.channels) === null || _b === void 0 ? void 0 : _b.first()) || message.guild.channels.cache.find((ch) => ch.id === args[0]) || message.guild.channels.cache.find((ch) => ch.name === args.join(" ")); if (!VoiceChannelsLogs) return message.channel.send("Channel is not found!"); if (VoiceChannelsLogs.type !== "text") return message.channel.send("Text Channel required!"); } logsConfig = yield Models_1.LogsSchema.findOneAndUpdate({ guildId: message.guild.id }, { VoiceChannelsLogs: VoiceChannelsLogs === null || VoiceChannelsLogs === void 0 ? void 0 : VoiceChannelsLogs.id }, { new: true }); logsConfig && client.logs.set(message.guild.id, logsConfig); message.channel.send("Voice logs have been set to " + VoiceChannelsLogs); }); } } exports.default = VoiceChannelsLogsCommand;