1 |
const MessageEmbed = require("../src/MessageEmbed"); |
import { BanOptions, CommandInteraction, Guild, GuildMember, Interaction, Message, User } from 'discord.js'; |
2 |
|
import BaseCommand from '../../utils/structures/BaseCommand'; |
3 |
|
import DiscordClient from '../../client/Client'; |
4 |
|
import CommandOptions from '../../types/CommandOptions'; |
5 |
|
import InteractionOptions from '../../types/InteractionOptions'; |
6 |
|
import MessageEmbed from '../../client/MessageEmbed'; |
7 |
|
import getUser from '../../utils/getUser'; |
8 |
|
import History from '../../automod/History'; |
9 |
|
import getMember from '../../utils/getMember'; |
10 |
|
import ms from 'ms'; |
11 |
|
|
12 |
module.exports = { |
export default class WarningCommand extends BaseCommand { |
13 |
async handle(msg, cm) { |
supportsInteractions: boolean = true; |
14 |
if (typeof cm.args[0] === 'undefined') { |
|
15 |
|
constructor() { |
16 |
|
super('warning', 'moderation', []); |
17 |
|
} |
18 |
|
|
19 |
|
async run(client: DiscordClient, msg: Message | CommandInteraction, options: CommandOptions | InteractionOptions) { |
20 |
|
if (!options.isInteraction && typeof options.args[0] === 'undefined') { |
21 |
await msg.reply({ |
await msg.reply({ |
22 |
embeds: [ |
embeds: [ |
23 |
new MessageEmbed() |
new MessageEmbed() |
29 |
return; |
return; |
30 |
} |
} |
31 |
|
|
32 |
await app.db.get('SELECT * FROM warnings WHERE id = ?', [cm.args[0]], async (err, data) => { |
let id: string; |
33 |
|
|
34 |
|
if (options.isInteraction) { |
35 |
|
id = await options.options.getNumber('id')?.toString()!; |
36 |
|
} |
37 |
|
else { |
38 |
|
id = options.args[0]; |
39 |
|
} |
40 |
|
|
41 |
|
await client.db.get('SELECT * FROM warnings WHERE id = ?', [id], async (err: any, data: any) => { |
42 |
if (err) { |
if (err) { |
43 |
console.log(err); |
console.log(err); |
44 |
} |
} |
60 |
console.log('here1'); |
console.log('here1'); |
61 |
|
|
62 |
try { |
try { |
63 |
user = await msg.guild.members.fetch(data.user_id); |
user = await msg.guild!.members.fetch(data.user_id); |
64 |
} |
} |
65 |
catch(e) { |
catch(e) { |
66 |
console.log(e); |
console.log(e); |
74 |
console.log(data); |
console.log(data); |
75 |
|
|
76 |
try { |
try { |
77 |
by = await msg.guild.members.fetch(data.warned_by); |
by = await msg.guild!.members.fetch(data.warned_by); |
78 |
} |
} |
79 |
catch(e) { |
catch(e) { |
80 |
console.log(e); |
console.log(e); |
104 |
embed |
embed |
105 |
] |
] |
106 |
}); |
}); |
107 |
}); |
}); |
108 |
} |
} |
|
}; |
|
109 |
|
} |