Skip to content

Commit e676152

Browse files
committed
change: Renaming warns to memos
1 parent 9b6585e commit e676152

14 files changed

Lines changed: 137 additions & 126 deletions

File tree

changelog.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
**Changelog:**
2+
__3.1.0 - Renaming warns to memos__
3+
4+
New Stuff:
5+
- None
6+
7+
Important Changes:
8+
- Renaming warns to memos
9+
- This makes the usage of the command more open and doesn't restrict to only warnings.
10+
11+
Boring Bug Fixes:
12+
- None
13+
14+
Planned for the Future:
15+
- Hard mode: kick/ban everyone on global ban list; kick every unverified bot;...
16+
- everything else

changelog.txt

Lines changed: 0 additions & 23 deletions
This file was deleted.

commands/archive/lookup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async function postUserinfo(message, userID, bans, warns) {
4242
.addField('Account Creation Date', discordUser.createdAt, true)
4343
.setThumbnail(discordUser.displayAvatarURL({ format: 'png', dynamic: true, size: 1024 }));
4444
if (bans) embed.addField('Bans', bans, true);
45-
if (warns) embed.addField('Warns', warns, true);
45+
if (warns) embed.addField('Memos', warns, true);
4646
if (sharedServers.size) embed.addField(`Shared servers - ${sharedServers.size}`, `\`\`\`${sharedServers.map((sharedMember) => sharedMember.name).join('\n')}\`\`\``, false);
4747
return message.channel.send({ embed });
4848
}

commands/checkallusers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ module.exports.run = async (interaction) => {
6868
if (allBans.length < 5) return postBans(allBans, interaction);
6969

7070
const message = await new MessageEmbed()
71-
.setDescription(`The bot is about to spam ${allBans.length} listed bans into this channel! This action can not be stopped midway through. \nAre you sure?`)
71+
.setDescription(`The bot is about to spam ${allBans.length} listed bans into this channel! This action can not be stopped midway through.\nAre you sure?`)
7272
.setColor('ORANGE');
7373
const confirmMessage = await reply(interaction, {
7474
embeds: [message], components: [buttons], fetchReply: true, ephemeral: true,

commands/lookup.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async function postUserinfo(interaction, userID, bans, warns, followUp = false)
4343
.addField('Account Creation Date', date(discordUser.createdAt), true)
4444
.setThumbnail(discordUser.displayAvatarURL({ format: 'png', dynamic: true, size: 1024 }));
4545
if (bans) embed.addField('Bans', `${bans}`, true);
46-
if (warns) embed.addField('Warns', `${warns}`, true);
46+
if (warns) embed.addField('Memos', `${warns}`, true);
4747
if (sharedServers.size) {
4848
// FIXME: check if it really only shows one server
4949
const serverlist = sharedServers.map((sharedMember) => sharedMember.name).join('\n');
@@ -111,13 +111,13 @@ function postWarns(interaction, warns) {
111111
warns.forEach(async (warn) => {
112112
const serverName = await getServerName(warn.serverID);
113113
const embed = new MessageEmbed()
114-
.setColor(16755456) // yellow
114+
.setColor('YELLOW') // yellow
115115
.setDescription(`**Reason**:\n\`\`\`${warn.reason || 'None'}\`\`\``)
116-
.setAuthor({ name: `Warned on ${serverName}` })
116+
.setAuthor({ name: `Memo created in ${serverName}` })
117117
.addField('ServerID', `\`${warn.serverID}\``, true)
118-
.addField('WarnID', `\`${warn.warnID}\``, true)
119-
.addField('Warning creation date', date(warn.createdAt));
120-
if (date(warn.createdAt) !== date(warn.updatedAt)) embed.addField('Warning updated date', date(warn.updatedAt));
118+
.addField('MemoID', `\`${warn.warnID}\``, true)
119+
.addField('Memo creation date', date(warn.createdAt));
120+
if (date(warn.createdAt) !== date(warn.updatedAt)) embed.addField('Memo updated date', date(warn.updatedAt));
121121
reply(interaction, { embeds: [embed] }, true);
122122
});
123123
}

commands/memo.js

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
const { MessageEmbed } = require('discord.js');
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 memo was added to a user in your server in '${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(`A memo was added to an alias of a user in your server in '${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+
module.exports.run = async (interaction) => {
63+
// check maintainer permissions
64+
if (!await client.functions.get('CHECK_DB_perms').run(interaction.user.id, 'staff', interaction.guild.id, interaction.member)) {
65+
messageFail(interaction, `You are not authorized to use \`/${module.exports.data.name}\``);
66+
return;
67+
}
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);
71+
};
72+
73+
module.exports.data = new CmdBuilder()
74+
.setName('memo')
75+
.setDescription('Managed memos about a user for other servers to see.')
76+
.addSubcommand((SC) => SC
77+
.setName('add')
78+
.setDescription('Add Memo.')
79+
.addUserOption((option) => option.setName('user').setDescription('Provide a user.').setRequired(true))
80+
.addStringOption((option) => option
81+
.setName('message')
82+
.setDescription('Memo text.')
83+
.setRequired(true)))
84+
.addSubcommand((SC) => SC
85+
.setName('edit')
86+
.setDescription('Edit a existing memo.')
87+
.addNumberOption((option) => option
88+
.setName('memoid')
89+
.setDescription('Provide the memo ID of the one you want to edit.')
90+
.setRequired(true))
91+
.addStringOption((option) => option
92+
.setName('message')
93+
.setDescription('New memo text.')
94+
.setRequired(true)));
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ module.exports.run = async (interaction, warnMessage, Warn, checkforInfectedGuil
88
const user = interaction.options.getUser('user', true);
99
const userID = user.id;
1010
// check if user is a bot
11-
if (user.bot) return messageFail(interaction, 'This user is a bot and cannot be warned.');
11+
if (user.bot) return messageFail(interaction, 'This user is a bot and you can\'t add a memo to them.');
1212
// checking if user is AB
13-
if (userID === client.user.id) return messageFail(interaction, 'You can\'t warn the bot itself!');
13+
if (userID === client.user.id) return messageFail(interaction, 'You can\'t add a memo the bot itself!');
1414
// add warn
1515
await addWarn(Warn, interaction.guild.id, userID, warnMessage);
16-
messageSuccess(interaction, `The user with the ID \`${userID}\` got a new warning added.\nWarning other servers.\nPlease keep in mind: The warning feature is not a way to reach out to the user!`);
16+
messageSuccess(interaction, `The memo got added to the user with the ID \`${userID}\`.\nWarning other servers.\nPlease keep in mind: The memo feature is not a way to reach out to the user!`);
1717
checkforInfectedGuilds(interaction.guild, userID, warnMessage);
1818
};
1919

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ module.exports.run = async (interaction, warnMessage, Warn, checkforInfectedGuil
1414
// messageFail(interaction, 'This is not a warn-ID!');
1515
// return;
1616
// }
17-
const warnID = interaction.options.getNumber('warnid', true);
17+
const warnID = interaction.options.getNumber('memoid', true);
1818
const serverID = interaction.guild.id;
1919
const warning = await getWarning(Warn, warnID);
2020
// check if warn is existent
21-
if (!warning) return messageFail(interaction, 'A Warning with this ID doesn\'t exist!');
21+
if (!warning) return messageFail(interaction, 'A memo with this ID doesn\'t exist!');
2222
// check if warn is from the same server
2323
if (warning.serverID !== serverID) {
24-
messageFail(interaction, 'You can only edit warnings form the server where they have been issued from.');
24+
messageFail(interaction, 'You can only edit memos form the server where they have been issued from.');
2525
return;
2626
}
2727
// add warn
2828
await editWarn(Warn, warnID, warnMessage);
29-
messageSuccess(interaction, `The warning with the the ID ${warnID} has been edited. Warning other servers.`);
29+
messageSuccess(interaction, `The memo with the the ID ${warnID} has been edited. Warning other servers.`);
3030
checkforInfectedGuilds(interaction.guild, warning.userID, warnMessage);
3131
};
3232

commands/warn.js

Lines changed: 6 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,18 @@
11
const { MessageEmbed } = require('discord.js');
22

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-
623
module.exports.run = async (interaction) => {
634
// check maintainer permissions
645
if (!await client.functions.get('CHECK_DB_perms').run(interaction.user.id, 'staff', interaction.guild.id, interaction.member)) {
656
messageFail(interaction, `You are not authorized to use \`/${module.exports.data.name}\``);
667
return;
678
}
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] });
7114
};
7215

7316
module.exports.data = new CmdBuilder()
7417
.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.');

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"text": "./about.txt"
1919
},
2020
"changelog": {
21-
"text": "./changelog.txt"
21+
"text": "./changelog.md"
2222
}
2323
},
2424
"functions": {

0 commit comments

Comments
 (0)