diff --git a/config.json~ b/config.json~ new file mode 100644 index 0000000..ca5a604 --- /dev/null +++ b/config.json~ @@ -0,0 +1,5 @@ +{ + "botKey" : "iK90dt8JNL3JQCKitafcTVH8pWAYCSws-4Wp348tO_7UQ3haT1B0KzfmQcAxxw0d", + "prefix" : "!rck", + "databaseName" : "PluralCakeDatabase.db" +} diff --git a/src/commands/colorAlterChange.ts b/src/commands/colorAlterChange.ts index a9207c6..15bee40 100644 --- a/src/commands/colorAlterChange.ts +++ b/src/commands/colorAlterChange.ts @@ -1,14 +1,30 @@ import { AlterRepo } from "../repositories/AlterRepo" +import { AlterModel } from "../models/alterModel" export async function colorAlterChange(userId: string, args: string[]){ const alterRepo = new AlterRepo(); - - if (args.length == 2){ + const regexHex = /^#[0-9A-F]{6}$/i; + + if (args.length == 2 && regexHex.test(args[1])){ const alterName = args[0]; const alterColor = args[1]; + let alters: AlterModel[]; + await alterRepo.getAltersByUserId(userId).then( result => alters = result ) // fetching alters from user. + if (alters.length == 0) return "This user has no Alters." // checking if returned array is at least not 0, if len 0, then return. + + let alterToEdit: AlterModel; + alters.forEach( alter => { + if (alter.name == alterName) { + alterToEdit = alter; + } + }) + + alterToEdit.color = alterColor; + alterRepo.editAlter(alterToEdit) - - return "The Alter's colour has been changed" + return "The Alter's colour has been changed." } + + return "Error: Insufficent Arguments" } diff --git a/src/commands/help.ts b/src/commands/help.ts index 4314b71..b8a5f89 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -3,8 +3,9 @@ export function returnHelpText() { "pluralcake is a bot that allows you to send messages as your Alters, with a custom profile picture, tag and nickname. \n" + "It's pretty much a work in progress, and doesn't allow you to edit or delete messages, and to send pictures." + "The currently available commands are : \n" + + "### Alters:\n" + "- list | allows you to see your currently available alters.\n" + "- create <'name of the alter'> <'your alter s tag'>| Allows you to create your Alters\n" + - "- avatar <'Alter's name'> <'picture url'> | Allows you to edit your alter's profile picture" + - "- color <'Alter's name'> | Allows you to change the color of your alter ( may be integrated with the website )" + "- avatar <'Alter's name'> <'picture url'> | Allows you to edit your alter's profile picture\n" + + "- color <'Alter's name'> <'color hex'> | Allows you to change the color of your alter ( may be integrated with the website )" } diff --git a/src/index.ts b/src/index.ts index dac85a9..2509765 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,6 +14,9 @@ client.on("messageCreate", async (message: Message) => { try{if (!message.author) {await client.users.fetch(message.authorId)} } catch(e){console.log(e)} + try{if (!messafe.content) {await client.messages.fetch(message.id)}} + catch(e){console.log(e)} + if (message === undefined) {return} if (message.author?.bot) {} else { diff --git a/src/utils/commandHandler.ts b/src/utils/commandHandler.ts index b04b6e8..8533f1a 100644 --- a/src/utils/commandHandler.ts +++ b/src/utils/commandHandler.ts @@ -7,7 +7,7 @@ import { avatarAlterChange } from "../commands/avatarAlterChange" import { colorAlterChange } from "../commands/colorAlterChange" import { split } from "shlex" -export async function commandHandler(message : Message, prefix : String) { +export async function commandHandler(message : Message, _prefix : String) { let args : string[] = split(message.content); args.shift() const command = args[0]