fix: hopefully fixed the crash heeheheheheha

This commit is contained in:
Ale 2023-09-07 15:18:21 +02:00
parent c55fe93901
commit d6e2d6d787
No known key found for this signature in database
GPG key ID: 284AFB134BB2E07D
5 changed files with 32 additions and 7 deletions

5
config.json~ Normal file
View file

@ -0,0 +1,5 @@
{
"botKey" : "iK90dt8JNL3JQCKitafcTVH8pWAYCSws-4Wp348tO_7UQ3haT1B0KzfmQcAxxw0d",
"prefix" : "!rck",
"databaseName" : "PluralCakeDatabase.db"
}

View file

@ -1,14 +1,30 @@
import { AlterRepo } from "../repositories/AlterRepo" import { AlterRepo } from "../repositories/AlterRepo"
import { AlterModel } from "../models/alterModel"
export async function colorAlterChange(userId: string, args: string[]){ export async function colorAlterChange(userId: string, args: string[]){
const alterRepo = new AlterRepo(); const alterRepo = new AlterRepo();
const regexHex = /^#[0-9A-F]{6}$/i;
if (args.length == 2){
if (args.length == 2 && regexHex.test(args[1])){
const alterName = args[0]; const alterName = args[0];
const alterColor = args[1]; 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"
} }

View file

@ -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" + "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." + "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" + "The currently available commands are : \n" +
"### Alters:\n" +
"- list | allows you to see your currently available 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" + "- 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" + "- 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 )" "- color <'Alter's name'> <'color hex'> | Allows you to change the color of your alter ( may be integrated with the website )"
} }

View file

@ -14,6 +14,9 @@ client.on("messageCreate", async (message: Message) => {
try{if (!message.author) {await client.users.fetch(message.authorId)} } try{if (!message.author) {await client.users.fetch(message.authorId)} }
catch(e){console.log(e)} 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 === undefined) {return}
if (message.author?.bot) {} if (message.author?.bot) {}
else { else {

View file

@ -7,7 +7,7 @@ import { avatarAlterChange } from "../commands/avatarAlterChange"
import { colorAlterChange } from "../commands/colorAlterChange" import { colorAlterChange } from "../commands/colorAlterChange"
import { split } from "shlex" 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); let args : string[] = split(message.content);
args.shift() args.shift()
const command = args[0] const command = args[0]