8 |
import History from '../../automod/History'; |
import History from '../../automod/History'; |
9 |
import getMember from '../../utils/getMember'; |
import getMember from '../../utils/getMember'; |
10 |
import ms from 'ms'; |
import ms from 'ms'; |
11 |
|
import { fetchEmoji } from '../../utils/Emoji'; |
12 |
|
|
13 |
export async function note(client: DiscordClient, user: GuildMember | User, content: string, msg: Message | CommandInteraction) { |
export async function note(user: GuildMember | User, content: string, msg: Message | CommandInteraction) { |
14 |
await client.db.get("INSERT INTO notes(user_id, guild_id, content, date) VALUES(?, ?, ?, ?)", [user.id, msg.guild!.id, content, (new Date().toISOString())], async (err: any) => { |
const { default: Note } = await import('../../models/Note'); |
15 |
if (err) { |
|
16 |
console.log(err); |
return await Note.create({ |
17 |
} |
content, |
18 |
|
author: msg.member!.user.id, |
19 |
|
mod_tag: (msg.member!.user as User).tag, |
20 |
|
user_id: user.id, |
21 |
|
guild_id: msg.guild!.id |
22 |
}); |
}); |
23 |
} |
} |
24 |
|
|
42 |
return; |
return; |
43 |
} |
} |
44 |
|
|
45 |
let user: GuildMember; |
let user: User; |
46 |
let content: string | undefined; |
let content: string | undefined; |
47 |
|
|
48 |
if (options.isInteraction) { |
if (options.isInteraction) { |
49 |
user = await <GuildMember> options.options.getMember('member'); |
user = await <User> options.options.getUser('user'); |
50 |
|
|
51 |
if (!user) { |
if (!user) { |
52 |
await msg.reply({ |
await msg.reply({ |
64 |
} |
} |
65 |
else { |
else { |
66 |
try { |
try { |
67 |
const user2 = await getMember((msg as Message), options); |
const user2 = await getUser(client, (msg as Message), options); |
68 |
|
|
69 |
if (!user2) { |
if (!user2) { |
70 |
throw new Error('Invalid user'); |
throw new Error('Invalid user'); |
90 |
content = options.args.join(' '); |
content = options.args.join(' '); |
91 |
} |
} |
92 |
|
|
93 |
await History.create(user.id, msg.guild!, 'note', msg.member!.user.id, null, async (data2) => { |
const n = await note(user, content as string, msg); |
|
await note(client, user, content as string, msg); |
|
|
}); |
|
94 |
|
|
95 |
await msg.reply({ |
await msg.reply({ |
96 |
embeds: [ |
embeds: [ |
97 |
new MessageEmbed() |
new MessageEmbed() |
98 |
.setDescription(`A note has been added for ${user.user.tag}`) // TODO |
.setDescription(`${(await fetchEmoji('check'))?.toString()} A note has been added for ${user.tag}`) |
99 |
|
.setFooter({ |
100 |
|
text: `ID: ${n.get().id}` |
101 |
|
}) |
102 |
] |
] |
103 |
}); |
}); |
104 |
} |
} |