/[sudobot]/trunk/src/commands/moderation/NotesCommand.ts
ViewVC logotype

Diff of /trunk/src/commands/moderation/NotesCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 86 by rakin, Mon Jul 29 17:28:32 2024 UTC revision 344 by rakin, Mon Jul 29 17:29:40 2024 UTC
# Line 1  Line 1 
1  import { BanOptions, CommandInteraction, EmojiIdentifierResolvable, GuildMember, Interaction, InteractionCollector, Message, MessageActionRow, MessageButton, MessageOptions, ReplyOptions, TextChannel, User } from 'discord.js';  import { CommandInteraction, Interaction, InteractionCollector, Message, MessageActionRow, MessageButton, User } from 'discord.js';
2  import BaseCommand from '../../utils/structures/BaseCommand';  import BaseCommand from '../../utils/structures/BaseCommand';
3  import DiscordClient from '../../client/Client';  import DiscordClient from '../../client/Client';
4  import CommandOptions from '../../types/CommandOptions';  import CommandOptions from '../../types/CommandOptions';
5  import InteractionOptions from '../../types/InteractionOptions';  import InteractionOptions from '../../types/InteractionOptions';
6  import MessageEmbed from '../../client/MessageEmbed';  import MessageEmbed from '../../client/MessageEmbed';
7  import getUser from '../../utils/getUser';  import getUser from '../../utils/getUser';
 import getMember from '../../utils/getMember';  
 import History from '../../automod/History';  
 import { fetchEmoji } from '../../utils/Emoji';  
 import PunishmentType from '../../types/PunishmentType';  
8  import Note from '../../models/Note';  import Note from '../../models/Note';
9    
10  export default class NotesCommand extends BaseCommand {  export default class NotesCommand extends BaseCommand {
# Line 22  export default class NotesCommand extend Line 18  export default class NotesCommand extend
18          const limit = 5;          const limit = 5;
19          const offset = ((page < 1 ? 1 : page) - 1) * limit;          const offset = ((page < 1 ? 1 : page) - 1) * limit;
20    
21          const notes = await Note.findAndCountAll({          const notes = await Note.find({
22              where: {              guild_id: msg.guild!.id,
23                  guild_id: msg.guild!.id,              user_id: user.id,
24                  user_id: user.id          }).skip(offset).limit(limit).sort("createdAt");
             },  
             order: [  
                 ['createdAt', 'DESC']  
             ],  
             limit,  
             offset  
         });  
25    
26          let str = '';          let str = '';
27          const maxPage = Math.ceil(notes.count / limit);          
28            const maxPage = Math.ceil((await Note.count({
29          for await (const note of notes.rows) {              guild_id: msg.guild!.id,
30              str += `**Note ID**: ${note.get().id}\n`;              user_id: user.id,
31              str += `Note taken by: ${note.get().mod_tag}\n`;          })) / limit);
32              str += `Date: ${note.get().createdAt.toLocaleString()}\n`;  
33              str += `Content:\n\`\`\`\n${note.get().content}\n\`\`\`\n`;          for await (const note of notes) {
34                str += `**Note ID**: ${note.id}\n`;
35                str += `Note taken by: ${note.mod_tag}\n`;
36                str += `Date: ${note.createdAt.toLocaleString()}\n`;
37                str += `Content:\n\`\`\`\n${note.content}\n\`\`\`\n`;
38              str += '\n';              str += '\n';
39          }          }
40    

Legend:
Removed from v.86  
changed lines
  Added in v.344

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26