/[sudobot]/trunk/src/services/SnippetManager.ts
ViewVC logotype

Diff of /trunk/src/services/SnippetManager.ts

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

revision 51 by rakin, Mon Jul 29 17:28:23 2024 UTC revision 244 by rakin, Mon Jul 29 17:29:11 2024 UTC
# Line 1  Line 1 
1  import { readFile, writeFile } from "fs";  import { readFile, writeFile } from "fs";
2  import path from "path";  import path from "path";
3  import DiscordClient from "../client/Client";  import DiscordClient from "../client/Client";
4    import Service from "../utils/structures/Service";
5  import { deleteFile } from "../utils/util";  import { deleteFile } from "../utils/util";
6    
7  export type Snippet = {  export type Snippet = {
# Line 13  export type SnippetContainer = { Line 14  export type SnippetContainer = {
14      [guildID: string]: Snippet[];      [guildID: string]: Snippet[];
15  };  };
16    
17  export default class SnippetManager {  export default class SnippetManager extends Service {
18      snippets: SnippetContainer = {};      snippets: SnippetContainer = {};
     client: DiscordClient;  
19    
20      constructor(client: DiscordClient) {      constructor(client: DiscordClient) {
21          this.client = client;          super(client);
22          this.load();          this.load();
23      }      }
24    
# Line 45  export default class SnippetManager { Line 45  export default class SnippetManager {
45      }      }
46    
47      get(guildID: string, name: string): Snippet | null {      get(guildID: string, name: string): Snippet | null {
48            if (!this.snippets[guildID]) {
49                return null;
50            }
51            
52          for (const s of this.snippets[guildID]) {          for (const s of this.snippets[guildID]) {
53              if (s.name === name) {              if (s.name === name) {
54                  return s;                  return s;

Legend:
Removed from v.51  
changed lines
  Added in v.244

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26