Skip to content

Commit 0bf1098

Browse files
committed
refactor: update colours
1 parent 5565d59 commit 0bf1098

File tree

8 files changed

+71
-15
lines changed

8 files changed

+71
-15
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"references.preferredLocation": "view",
66
"editor.suggest.maxVisibleSuggestions": 5,
77
"editor.rulers": [80],
8+
"editor.defaultFormatter": "esbenp.prettier-vscode",
89
"editor.formatOnSave": true,
910
"eslint.packageManager": "yarn",
1011
"search.exclude": {

src/v2/commands/warn/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ function permutations<T>(items: T[][]) {
119119
}
120120

121121
function comb(items: { name: string; value: string }[]) {
122-
console.log(items);
123122
const names = [...pluckʹ(items, 'name')];
124123
const values = [...pluckʹ(items, 'value')];
125124

@@ -130,7 +129,6 @@ function comb(items: { name: string; value: string }[]) {
130129
}
131130

132131
function removeRepeated<T>(arr: Fuse.FuseResult<T>[][]) {
133-
console.log(arr)
134132
return arr.filter(x => {
135133
const s = new Set(x.map(i=>i.refIndex))
136134
if(s.size !== x.length) {return false}
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
import type {
2-
EmbedField,
3-
GuildMember,
4-
GuildMemberRoleManager} from 'discord.js';
5-
import { MessageEmbed } from 'discord.js';
6-
71
import { closeCommand } from './close';
2+
import { initiateModmail } from './initiateModmail';
83
import { reportMessage } from './reportMsg';
94
import { reportUser } from './reportUser';
105
import { sendCommand } from './send';
116

127

13-
export const commands = [sendCommand, reportMessage, reportUser, closeCommand ];
8+
export const commands = [sendCommand, reportMessage, initiateModmail, reportUser, closeCommand ];
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type { GuildMember} from "discord.js";
2+
3+
import type { CommandDataWithHandler } from "../../../../types";
4+
import { SERVER_ID, MOD_ROLE_ID } from "../../../env";
5+
import { createModMailThread } from "../util/createModMailThread";
6+
import { createReporteeEmbed, createInitialEmbed, createInitiatorEmbed } from "../util/embeds";
7+
8+
9+
export const initiateModmail: CommandDataWithHandler = {
10+
type: 'USER',
11+
name: 'Initiate Modmail',
12+
guildValidate: guild => guild.id === SERVER_ID,
13+
async handler(client, interaction) {
14+
if (!interaction.isUserContextMenu()) {
15+
return;
16+
}
17+
18+
await interaction.deferReply({ ephemeral: true });
19+
20+
const thread = await createModMailThread(
21+
interaction.guild,
22+
interaction.targetUser
23+
);
24+
25+
const initialMsg = await thread.send({
26+
content: `<@&${MOD_ROLE_ID}>`,
27+
embeds: [
28+
createInitialEmbed(),
29+
createInitiatorEmbed(interaction.member as GuildMember),
30+
createReporteeEmbed(interaction.targetMember as GuildMember),
31+
],
32+
});
33+
34+
await initialMsg.pin();
35+
interaction.editReply({
36+
content: `Created thread <#${thread.id}>`
37+
})
38+
},
39+
};

src/v2/modules/modmail/commands/send.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { MessageActionRow, MessageButton, MessageEmbed } from "discord.js";
33
import type { CommandDataWithHandler } from "../../../../types";
44
import { SERVER_ID, MOD_ROLE_ID } from "../../../env";
55
import { ModMailThread } from "../db/modmail_thread";
6+
import { COLOR_DELETED_MSG } from "../util/colors";
67

78
export const sendCommand: CommandDataWithHandler = {
89
type: 'CHAT_INPUT',
@@ -115,9 +116,9 @@ export const sendCommand: CommandDataWithHandler = {
115116
await message.delete()
116117
if("edit" in interaction.message) {
117118
interaction.message.edit({
118-
content: `*The message below was deleted by <@${interaction.user.id}> at <t:${Date.now()/1000}>*`,
119+
content: `*The message below was deleted by <@${interaction.user.id}> at <t:${Math.floor(Date.now()/1000)}>*`,
119120
embeds: [
120-
interaction.message.embeds[0].setColor(0x90_00_00)
121+
interaction.message.embeds[0].setColor(COLOR_DELETED_MSG)
121122
],
122123
components: []
123124
})

src/v2/modules/modmail/util/colors.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// colors are hex, the seperators stop color highlighting with extensions.
2+
/* eslint-disable unicorn/numeric-separators-style */
3+
export const COLOR_MOD = 0x42b883
4+
export const COLOR_REPORTER = 0x50a000
5+
export const COLOR_REPORTEE = 0xfcba03
6+
export const COLOR_USER_EMBED = 0x4287f5
7+
export const COLOR_DELETED_MSG = 0x900000

src/v2/modules/modmail/util/embeds.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { EmbedField, GuildMember, GuildMemberRoleManager } from 'discord.js';
22
import { MessageEmbed } from 'discord.js';
33

4+
import { COLOR_MOD, COLOR_REPORTEE, COLOR_REPORTER, COLOR_USER_EMBED } from './colors';
5+
46

57
export function createInitialEmbed(): MessageEmbed {
68
return new MessageEmbed().setTitle('New Ticket')
@@ -24,21 +26,35 @@ export function createReporterEmbed(member: GuildMember): MessageEmbed {
2426
return new MessageEmbed()
2527
.setTitle('Reporter')
2628
.setDescription('Below is information regarding the reporter')
27-
.setColor(5_283_840)
29+
.setColor(COLOR_REPORTER)
2830
.setAuthor({
2931
name: `${member.user.username}#${member.user.discriminator}`,
3032
iconURL: member.user.avatarURL(),
3133
})
3234
.setThumbnail(member.user.avatarURL())
3335
.addFields(createUserFields(member));
3436
}
37+
export function createInitiatorEmbed(member: GuildMember) : MessageEmbed{
38+
return new MessageEmbed()
39+
.setTitle('Initiator')
40+
.setDescription(
41+
`This modmail was intiated by a ${member.user.toString()} at <t:${Date.now()/1000}>`
42+
)
43+
.setColor(COLOR_MOD)
44+
.setAuthor({
45+
name: `${member.user.username}#${member.user.discriminator}`,
46+
iconURL: member.user.avatarURL(),
47+
})
48+
.setThumbnail(member.user.avatarURL())
49+
}
50+
3551
export function createReporteeEmbed(member: GuildMember) : MessageEmbed{
3652
return new MessageEmbed()
3753
.setTitle('Reportee')
3854
.setDescription(
3955
'Below is information regarding the user that has been reported'
4056
)
41-
.setColor(16_750_080)
57+
.setColor(COLOR_REPORTEE)
4258
.setAuthor({
4359
name: `${member.user.username}#${member.user.discriminator}`,
4460
iconURL: member.user.avatarURL(),
@@ -53,7 +69,7 @@ export function createUserEmbed(member: GuildMember): MessageEmbed {
5369
.setDescription(
5470
'Information about the user'
5571
)
56-
.setColor(16_750_080)
72+
.setColor(COLOR_USER_EMBED)
5773
.setAuthor({
5874
name: `${member.user.username}#${member.user.discriminator}`,
5975
iconURL: member.user.avatarURL(),

src/v2/modules/modmail/util/getModMailThread.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export const getModMailThread = async (guild: Guild, user: User): Promise<Thread
88
const cachedThread = cache.get(`${guild.id}|${user.id}`);
99

1010
if (cachedThread) {
11-
console.log("Cached from",`${guild.id}|${user.id}`)
1211
return cachedThread;
1312
}
1413

0 commit comments

Comments
 (0)