1
0
Fork 0

Updated and added stuff

This commit is contained in:
EmotionChild 2022-01-13 23:21:37 +13:00
parent d1c30ccc31
commit 05505b0468
No known key found for this signature in database
GPG key ID: 23DC06AC32786520
7 changed files with 612 additions and 160 deletions

View file

@ -1,11 +1,14 @@
{
"name": "EllieBot",
"name": "elliebot",
"version": "1.0.0",
"main": "index.js",
"license": "GPL-3.0",
"dependencies": {
"discord.js": "^13.5.0",
"dotenv": "^10.0.0"
"discord.js": "^13.5.1",
"dotenv": "^11.0.0",
"mysql2": "^2.3.3",
"reflect-metadata": "^0.1.13",
"typeorm": "^0.2.41"
},
"devDependencies": {
"@types/node": "^17.0.8",

View file

@ -0,0 +1,32 @@
// https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-guildCreate
import { Guild } from 'discord.js';
import BaseEvent from '../utils/structures/BaseEvent';
import DiscordClient from '../client/client';
import { getRepository } from 'typeorm';
import { GuildConfiguration } from '../typeorm/entities/GuildConfiguration';
export default class GuildCreateEvent extends BaseEvent {
constructor(
private readonly guildConfigRepository = getRepository (GuildConfiguration)
) {
super('guildCreate');
}
async run(client: DiscordClient, guild: Guild) {
console.log('Hellp World!');
console.log(`Joined ${guild.name}`);
const config = await this.guildConfigRepository.findOne({
guildId: guild.id,
});
if (config) {
console.log('A configuration was found!');
} else {
console.log('A configuration was not found. Creating One.');
const newConfig = this.guildConfigRepository.create({
guildId: guild.id,
})
return this.guildConfigRepository.save(newConfig);
}
}
}

View file

@ -4,7 +4,7 @@ import DiscordClient from '../../client/client';
export default class MessageEvent extends BaseEvent {
constructor() {
super('message');
super('messageCreate');
}
async run(client: DiscordClient, message: Message) {

View file

@ -1,11 +1,24 @@
require('dotenv').config();
import 'reflect-metadata';
import { registerCommands, registerEvents } from './utils/registry';
import config from '../slappey.json';
import DiscordClient from './client/client';
import { Intents } from 'discord.js';
import { createConnection } from 'typeorm';
import { GuildConfiguration } from './typeorm/entities/GuildConfiguration';
const client = new DiscordClient({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES ] });
(async () => {
await createConnection({
type: 'mysql',
host: process.env.MYSQL_DB_HOST,
port: 3306,
username: process.env.MYSQL_DB_USERNAME,
password: process.env.MYSQL_DB_PASSWORD,
database: process.env.MYSQL_DB_DATABASE,
synchronize: true,
entities: [GuildConfiguration]
});
client.prefix = config.prefix || client.prefix;
await registerCommands(client, '../commands');
await registerEvents(client, '../events');

View file

@ -0,0 +1,16 @@
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
@Entity({ name: 'guild_configurations' })
export class GuildConfiguration {
@PrimaryGeneratedColumn()
id: number;
@Column({ unique: true, name: 'guild_id' })
guildId: string;
@Column({ default: '?' })
prefix: string;
@Column({name: 'welcome_channel_id', nullable: true})
welcomeChannelId: string;
}

View file

@ -14,8 +14,8 @@
"target": "es6", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
"experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
"emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
@ -79,7 +79,7 @@
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
"strictPropertyInitialization": false, /* Check for class properties that are declared but not set in the constructor. */
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */

694
yarn.lock

File diff suppressed because it is too large Load diff