/[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 333 by rakin, Mon Jul 29 17:28:32 2024 UTC revision 334 by rakin, Mon Jul 29 17:29:36 2024 UTC
# Line 5  import CommandOptions from '../../types/ Line 5  import CommandOptions from '../../types/
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);          const maxPage = Math.ceil(notes.length / limit);
28    
29          for await (const note of notes.rows) {          for await (const note of notes) {
30              str += `**Note ID**: ${note.get().id}\n`;              str += `**Note ID**: ${note.id}\n`;
31              str += `Note taken by: ${note.get().mod_tag}\n`;              str += `Note taken by: ${note.mod_tag}\n`;
32              str += `Date: ${note.get().createdAt.toLocaleString()}\n`;              str += `Date: ${note.createdAt.toLocaleString()}\n`;
33              str += `Content:\n\`\`\`\n${note.get().content}\n\`\`\`\n`;              str += `Content:\n\`\`\`\n${note.content}\n\`\`\`\n`;
34              str += '\n';              str += '\n';
35          }          }
36    

Legend:
Removed from v.333  
changed lines
  Added in v.334

team@onesoftnet.eu.org
ViewVC Help
Powered by ViewVC 1.1.26