first commit

This commit is contained in:
Ale 2023-08-20 20:44:16 +02:00
commit 86764942d9
No known key found for this signature in database
GPG key ID: 284AFB134BB2E07D
11 changed files with 152 additions and 0 deletions

7
.gitignore vendored Normal file
View file

@ -0,0 +1,7 @@
node_modules
build
npm-debug.log
.nyc
.env
.DS_Store
config.json

21
package.json Normal file
View file

@ -0,0 +1,21 @@
{
"name": "cakebot-revolt",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/sqlite3": "^3.1.8",
"typescript": "^5.1.3",
"typescript-language-server": "^3.3.2"
},
"dependencies": {
"revolt.js": "^7.0.0-beta.7",
"shlex": "^2.1.2",
"sqlite3": "^5.1.6"
}
}

9
src/commands/help.ts Normal file
View file

@ -0,0 +1,9 @@
export function returnHelpText() {
return "# Howdy user, welcome to pluralcake\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." +
"The currently available commands are : \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"
}

3
src/commands/help.ts~ Normal file
View file

@ -0,0 +1,3 @@
export function returnHelpText() {
return "gum"
}

20
src/index.ts Normal file
View file

@ -0,0 +1,20 @@
import { Client, Message } from "revolt.js";
import { commandHandler } from "./utils/commandHandler"
import config from "../config.json"
const client : Client = new Client();
client.on("ready", async () => {
console.info(`Gummed in as ${client.user.username}!`)
client.user.edit({status : {text: config.prefix + "help for the help menu"}})
});
client.on("messageCreate", async (message: Message) => {
if (message.author.bot) {}
else {
if (message.content.startsWith(config.prefix)){commandHandler(message, config.prefix)}
else {}
}
});
client.loginBot(config.botKey);

18
src/index.ts~ Normal file
View file

@ -0,0 +1,18 @@
import { Client, Message } from "revolt.js";
import { commandHandler } from "./utils/commandHandler"
import config from "../config.json"
const client : Client = new Client();
client.on("ready", async () =>
console.info(`Gummed in as ${client.user.username}!`)
);
client.on("messageCreate", async (message: Message) => {
if (message.author.bot) {}
else {
if (message.content.startsWith(config.prefix)){commandHandler(message, config.prefix)}
}
});
client.loginBot(config.botKey);

View file

@ -0,0 +1,15 @@
import { Database } from 'sqlite3';
export class CharacterRepo {
db : Database
constructor() {
this.db = new Database('db.sqlite');
}
getAllCharacters(){
return this.db.get(
'SELECT * FROM CHARACTERS',
res => console.log(res)
)
}
}

View file

@ -0,0 +1,13 @@
import { CharacterRepo } from "repositories/CharacterRepo";
class CharacterService {
repo : CharacterRepo;
constructor() {
this.repo = new CharacterRepo();
}
public getCharacter() : any{
return this.repo.getAllCharacters();
}
}

View file

@ -0,0 +1,23 @@
import { Message } from "revolt.js"
import { returnHelpText } from "../commands/help"
import { split } from "shlex"
export async function commandHandler(message : Message, prefix : String) {
let args : String[] = split(message.content);
args.shift()
const command = args[0]
switch(command) {
case "help" : {
message.reply(returnHelpText());
break;
}
case "list" : {
message.reply("not yet implemented")
break;
}
case "create" : {
message.reply("not yet implemented")
}
}
}

View file

@ -0,0 +1,9 @@
import { Message } from "revolt.js"
export function commandHandler(message : Message) {
switch(message.content) {
case "help" : {
}
}
}

14
tsconfig.json Normal file
View file

@ -0,0 +1,14 @@
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"resolveJsonModule" : true,
"target": "es6",
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": "./src"
},
"lib": ["es2015"]
}