Skip to content

Commit

Permalink
feat: new commands and response types
Browse files Browse the repository at this point in the history
  • Loading branch information
sanriodev committed Feb 15, 2024
1 parent 724037f commit cc1d434
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
Binary file added src/assets/bingus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/spoingus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions src/modules/event/event.abstract.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Events } from 'discord.js';
import { ACollectionEntry } from '../../helpers/abstract/collectionEntry.abstract';
import { DiscordService } from '../discord/discord.service';

export abstract class AEvent {
abstract readonly event: Events;
Expand Down
6 changes: 6 additions & 0 deletions src/modules/event/interfaces/iresponse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export interface IResponse {
matcher: RegExp;
response: string | Object;
responseType?: ResponseType;
}

export enum ResponseType {
Reply = 'reply',
Message = 'message',
}
29 changes: 25 additions & 4 deletions src/modules/event/services/messageEvent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { Events, Message } from 'discord.js';
import { Events } from 'discord.js';
import { AEvent } from '../event.abstract';
import { IResponse } from '../interfaces/iresponse';
import { IResponse, ResponseType } from '../interfaces/iresponse';
@Injectable()
export class MessageEvent extends AEvent {
event: Events = Events.MessageCreate; // ShardEvents.Message;
Expand All @@ -11,34 +11,52 @@ export class MessageEvent extends AEvent {
{
matcher: /wag1/i,
response: 'wagwan2',
responseType: ResponseType.Reply,
},
{
matcher: /^.{150,}$/m,
response: 'halbe Bibel, ganzer huansohn ?XD',
responseType: ResponseType.Reply,
},
{
matcher: /https:\/\/.*/,
response: 'send yo virus link to someone else no?xd',
responseType: ResponseType.Reply,
},
{
matcher: /wadim/i,
response: '#goth',
responseType: ResponseType.Message,
},
{
matcher: /digga/i,
response: 'digga mich nicht',
responseType: ResponseType.Reply,
},
{
matcher: /alina/i,
response: 'Schuhgröße 36, weißer Nagellack 🥵',
responseType: ResponseType.Message,
},
{
matcher: /monke/i,
response: '🐒 🦧',
responseType: ResponseType.Message,
},
{
matcher: /hego/i,
response: { files: ['src/assets/textbox-donowall.gif'] },
responseType: ResponseType.Reply,
},
{
matcher: /bingus/i,
response: { files: ['src/assets/bingus.png'] },
responseType: ResponseType.Message,
},
{
matcher: /spoingus/i,
response: { files: ['src/assets/spoingus.png'] },
responseType: ResponseType.Message,
},
];

Expand All @@ -50,8 +68,11 @@ export class MessageEvent extends AEvent {
this.responseList.forEach((res) => {
var testRes = res.matcher.test(content);
if (testRes) {
message.reply(res.response);
// channel.send(res.response);
if (res?.responseType == ResponseType.Reply) {
message.reply(res.response);
} else {
channel.send(res.response);
}
}
});
});
Expand Down

0 comments on commit cc1d434

Please sign in to comment.