Skip to content

Commit

Permalink
feat: wip - new interactive command
Browse files Browse the repository at this point in the history
  • Loading branch information
sanriodev committed Feb 16, 2024
1 parent 1254796 commit 335a691
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
4 changes: 4 additions & 0 deletions src/modules/command/command.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { ReportedCommand } from './commands/reported';
import { BugReport } from './commands/bug';
import { CoinflipCommand } from './commands/coinflip';
import { GoldCommand } from './commands/gold';
import SomeoneOnceSaidCommand from './commands/someone-once-said';
import { SomeoneOnceSaidModule } from '../someone-once-said/modules/someone-once-said.module';

@Module({
providers: [
Expand All @@ -18,7 +20,9 @@ import { GoldCommand } from './commands/gold';
BugReport,
CoinflipCommand,
GoldCommand,
SomeoneOnceSaidCommand,
],
imports: [SomeoneOnceSaidModule],
exports: [CommandService],
})
export class CommandModule {}
5 changes: 3 additions & 2 deletions src/modules/command/command.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Injectable } from '@nestjs/common';
import { Collection } from 'discord.js';
import { PingPongCommand } from './commands/pingpong';
import { CBDCommand } from './commands/cbd';
import { HelloCommand } from './commands/hello';
import { ACommand } from './command.abstract';
import { ReportedCommand } from './commands/reported';
import { BugReport } from './commands/bug';
import { CoinflipCommand } from './commands/coinflip';
import { GoldCommand } from './commands/gold';
import SomeoneOnceSaidCommand from './commands/someone-once-said';

@Injectable()
export class CommandService {
Expand All @@ -21,6 +20,7 @@ export class CommandService {
bugReportModule: BugReport,
coinflipModule: CoinflipCommand,
goldModule: GoldCommand,
someoneOnceSaidModule: SomeoneOnceSaidCommand,
) {
const commands: ACommand[] = [
//pingpongModule,
Expand All @@ -30,6 +30,7 @@ export class CommandService {
bugReportModule,
coinflipModule,
goldModule,
someoneOnceSaidModule,
];
commands.forEach((command) => {
if (command.data.name && command.execute) {
Expand Down
12 changes: 10 additions & 2 deletions src/modules/command/commands/someone-once-said.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { CacheType, CommandInteraction, EmbedBuilder } from 'discord.js';
import {
CacheType,
CommandInteraction,
EmbedBuilder,
SlashCommandBuilder,
} from 'discord.js';
import { ACommand } from '../command.abstract';
import { SomeoneOnceSaid } from '../../../schemas/someone-once-said.schema';
import { SomeoneOnceSaidService } from '../../someone-once-said/services/someone-once-said.service';
import { Inject } from '@nestjs/common';
import { SomeoneOnceSaid } from '../../../schemas/someone-once-said.schema';

export default class SomeoneOnceSaidCommand extends ACommand {
constructor(
Expand All @@ -11,6 +16,9 @@ export default class SomeoneOnceSaidCommand extends ACommand {
) {
super();
}
data = new SlashCommandBuilder()
.setName('Quote')
.setDescription('Make it a quote');

async execute(arg: CommandInteraction<CacheType>): Promise<boolean> {
let phrase = arg.options.get('phrase');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { Module } from '@nestjs/common';
import { SomeoneOnceSaidSchema } from '../../../schemas/someone-once-said.schema';
import { MongooseModule } from '@nestjs/mongoose';
import { SomeoneOnceSaid } from '../services/someone-once-said.service';
import { SomeoneOnceSaidService } from '../services/someone-once-said.service';
import {
SomeoneOnceSaid,
SomeoneOnceSaidSchema,
} from '../../../schemas/someone-once-said.schema';

@Module({
imports: [
MongooseModule.forFeature([
{
name: 'SomeneOnceSaid',
name: SomeoneOnceSaid.name,
schema: SomeoneOnceSaidSchema,
},
]),
],
controllers: [],
providers: [SomeoneOnceSaid],
exports: [SomeoneOnceSaid],
providers: [SomeoneOnceSaidService],
exports: [SomeoneOnceSaidService],
})
export class ProductionOrderStatisticModule {}
export class SomeoneOnceSaidModule {}
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { InjectModel } from '@nestjs/mongoose';
import { Model, Error } from 'mongoose';
import { QuoteEntity } from '../../../schemas/someone-once-said-entity.model';
import { SomeoneOnceSaidEntity } from '../../../schemas/someone-once-said-entity.model';
import { SomeoneOnceSaidDocument } from '../../../schemas/someone-once-said.schema';

export class SomeoneOnceSaidService {
constructor(
@InjectModel('SomeneOnceSaid')
@InjectModel('SomeoneOnceSaid')
private readonly someoneOnceSaid: Model<SomeoneOnceSaidDocument>,
) {}

async create(quoteDto: QuoteEntity): Promise<SomeoneOnceSaidDocument> {
async create(
quoteDto: SomeoneOnceSaidEntity,
): Promise<SomeoneOnceSaidDocument> {
try {
return await this.someoneOnceSaid.create({
phrase: quoteDto.phrase,
Expand Down
2 changes: 1 addition & 1 deletion src/schemas/someone-once-said-entity.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export class QuoteEntity {
export class SomeoneOnceSaidEntity {
phrase: string;
username: string;
secName?: string;
Expand Down

0 comments on commit 335a691

Please sign in to comment.