|
1 | 1 | const { MessageEmbed } = require('discord.js'); |
2 | 2 |
|
3 | | -const Warn = require('../database/models/Warn'); |
4 | | - |
5 | | -// TODO: recreate richmessage embed sender to it can be sent to other servers |
6 | | - |
7 | | -// checks if server is partisipating server |
8 | | -function getServerEntry(serverID) { |
9 | | - return client.functions.get('GET_DB_server').run(serverID, true); |
10 | | -} |
11 | | - |
12 | | -// warns other servers |
13 | | -async function messageWarnedUserInGuild(channelID, userTag, userID, warnMessage, serverName) { |
14 | | - const embed = new MessageEmbed(); |
15 | | - embed.setColor(16755456); |
16 | | - embed.setFooter({ text: `For more information about this user, use '/lookup ${userID}'` }); |
17 | | - embed.setTitle(`A user on your server has been warned on '${serverName}'!`); |
18 | | - embed.setDescription(`Tag: \`${userTag}\` |
19 | | - ID: \`${userID}\` |
20 | | - Reason: \`\`\`${warnMessage || 'none'}\`\`\``); |
21 | | - const channel = await client.channels.cache.get(channelID); |
22 | | - channel.send({ embeds: [embed] }); |
23 | | -} |
24 | | - |
25 | | -// warns other servers for aliases |
26 | | -async function messageWarnedAliasUserInGuild(channelID, userTag, userID, warnMessage, serverName, orgUserTag) { |
27 | | - const embed = new MessageEmbed(); |
28 | | - embed.setColor(16755456); |
29 | | - embed.setFooter({ text: `For more information about this user, use '/lookup ${orgUserTag}'` }); |
30 | | - embed.setTitle(`An alias of a user on your server has been warned on '${serverName}'!`); |
31 | | - embed.setDescription(`**The user \`${userTag}\` is an alias of a user that has been warned!** |
32 | | -
|
33 | | - Tag: \`${orgUserTag}\` |
34 | | - ID: \`${userID}\` |
35 | | - Reason: \`\`\`${warnMessage || 'none'}\`\`\``); |
36 | | - const channel = await client.channels.cache.get(channelID); |
37 | | - channel.send({ embeds: [embed] }); |
38 | | -} |
39 | | - |
40 | | -async function checkforInfectedGuilds(guild, orgUserID, warnMessage) { |
41 | | - let aliases = await client.functions.get('GET_DB_alias').run(orgUserID); |
42 | | - if (!aliases) aliases = [orgUserID]; |
43 | | - const orgUser = await client.users.fetch(orgUserID, false); |
44 | | - // look for each of the conencted users (alias) if they are a member in the corresponding guild |
45 | | - aliases.forEach((userID) => { |
46 | | - client.guilds.cache.forEach(async (toTestGuild) => { |
47 | | - // dont post in own guild |
48 | | - // TODO: warn own server that there are aliases: let through, if user is not the same as who a warn was issued for |
49 | | - if (guild.id === toTestGuild.id) return; |
50 | | - const serverMember = toTestGuild.members.cache.get(userID); |
51 | | - if (!serverMember) return; |
52 | | - const serverID = toTestGuild.id; |
53 | | - const infectedGuild = await getServerEntry(serverID); |
54 | | - if (infectedGuild && infectedGuild.active && infectedGuild.logChannelID) { |
55 | | - if (orgUserID === userID) messageWarnedUserInGuild(infectedGuild.logChannelID, orgUser.tag, orgUserID, warnMessage, guild.name); |
56 | | - else messageWarnedAliasUserInGuild(infectedGuild.logChannelID, serverMember.user.tag, orgUserID, warnMessage, guild.name, orgUser.tag); |
57 | | - } |
58 | | - }); |
59 | | - }); |
60 | | -} |
61 | | - |
62 | 3 | module.exports.run = async (interaction) => { |
63 | 4 | // check maintainer permissions |
64 | 5 | if (!await client.functions.get('CHECK_DB_perms').run(interaction.user.id, 'staff', interaction.guild.id, interaction.member)) { |
65 | 6 | messageFail(interaction, `You are not authorized to use \`/${module.exports.data.name}\``); |
66 | 7 | return; |
67 | 8 | } |
68 | | - const subName = interaction.options.getSubcommand(true); |
69 | | - const warnMessage = interaction.options.getString('message', true); |
70 | | - client.commands.get(`${module.exports.data.name}_${subName}`).run(interaction, warnMessage, Warn, checkforInfectedGuilds); |
| 9 | + const embed = new MessageEmbed(); |
| 10 | + embed.setColor(16755456); |
| 11 | + embed.setDescription('This command has been deprecated. Use `/memo` instead'); |
| 12 | + const channel = await client.channels.cache.get(channelID); |
| 13 | + channel.send({ embeds: [embed] }); |
71 | 14 | }; |
72 | 15 |
|
73 | 16 | module.exports.data = new CmdBuilder() |
74 | 17 | .setName('warn') |
75 | | - .setDescription('Warns other servers about a specific user.') |
76 | | - .addSubcommand((SC) => SC |
77 | | - .setName('add') |
78 | | - .setDescription('Add warning.') |
79 | | - .addUserOption((option) => option.setName('user').setDescription('Provide a user.').setRequired(true)) |
80 | | - .addStringOption((option) => option |
81 | | - .setName('message') |
82 | | - .setDescription('Message this warning should be.') |
83 | | - .setRequired(true))) |
84 | | - .addSubcommand((SC) => SC |
85 | | - .setName('edit') |
86 | | - .setDescription('Edit a existing warning.') |
87 | | - .addNumberOption((option) => option |
88 | | - .setName('warnid') |
89 | | - .setDescription('Provide the warn ID of the one you want to edit.') |
90 | | - .setRequired(true)) |
91 | | - .addStringOption((option) => option |
92 | | - .setName('message') |
93 | | - .setDescription('Message this warning should be.') |
94 | | - .setRequired(true))); |
| 18 | + .setDescription('This command has been deprecated. Use /memo instead.'); |
0 commit comments