1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-12-25 23:15:38 -05:00

bot is alive yes. interfaces need sorting

This commit is contained in:
toast-ts 2022-11-17 05:53:42 +11:00
parent 178286c189
commit 49af49423b
26 changed files with 302 additions and 380 deletions

2
.gitignore vendored
View File

@ -5,4 +5,4 @@ package-lock.json
# TypeScript stuff
dist/
# Bot stuff
database/MPDB.dat
src/database/MPDB.dat

View File

@ -6,6 +6,6 @@ TypeScript-based Daggerbot converted from JavaScript at [SpaceManBuzz/DaggerBot-
- [x] Prepare repository
- [x] Install TypeScript dependencies and tools
- [ ] Convert JS files to TS one by one
- [ ] Plz work
- [x] Plz work
- [ ] Production
- [ ] Deploy bot

View File

@ -1,9 +1,10 @@
{
"name": "daggerbot-ts",
"description": "TypeScript version of the original JavaScript-based bot for Official Daggerwin Discord.",
"main": "./src/index.ts",
"main": "src/Sharding.ts",
"scripts": {
"start": "ts-node src/Sharding.ts"
"start": "ts-node src/Sharding.ts",
"startDev": "ts-node src/index.ts"
},
"repository": {
"type": "git",
@ -26,14 +27,14 @@
"node": ">=17.0.0"
},
"dependencies": {
"axios": "1.1.3",
"axios": "1.1.2",
"canvas": "2.10.2",
"discord.js": "14.6.0",
"moment": "2.29.4",
"ms": "2.1.3",
"sequelize": "6.25.5",
"sequelize": "7.0.0-alpha.9",
"sqlite3": "5.1.2",
"xml-js": "^1.6.11"
"xml-js": "1.6.11"
},
"devDependencies": {
"@types/node": "18.11.9",

View File

@ -1,5 +1,5 @@
import {token_main} from './tokens.json'
import { ShardingManager } from "discord.js";
const sharder = new ShardingManager('./index.ts',{token: token_main, totalShards: 1, mode: 'worker'})
sharder.on('shardCreate',async(shard)=>{console.log(`Shard ${shard.id} launched`)})
import {token_toast} from './tokens.json';
import {ShardingManager} from 'discord.js';
const sharder = new ShardingManager('src/index.ts',{token: token_toast, totalShards: 1, mode: 'worker'});
sharder.on('shardCreate',async(shard)=>{console.log(`Shard ${shard.id} launched`)});
sharder.spawn();

View File

@ -37,7 +37,7 @@ export class TClient extends Client {
Partials.Reaction,
Partials.Message
],
allowedMentions: { repliedUser: false, parse: ['roles', 'users'] }
allowedMentions: { users: [], roles: [] } // idk if it would work but requires testing...
})
this.invites = new Map();
this.commands = new Discord.Collection();
@ -52,10 +52,10 @@ export class TClient extends Client {
this.collection = Discord.Collection;
this.messageCollector = Discord.MessageCollector;
this.attachmentBuilder = Discord.AttachmentBuilder;
this.moment = import('moment');
this.xjs = import('xml-js');
this.axios = import('axios');
this.ms = import('ms');
this.moment = require('moment');
this.xjs = require('xml-js');
this.axios = require('axios');
this.ms = require('ms');
this.memberCount_LastGuildFetchTimestamp = 0;
this.userLevels = new userLevels(this);
this.bonkCount = new bonkCount(this);
@ -70,11 +70,11 @@ export class TClient extends Client {
this.bannedWords.initLoad();
this.bonkCount.initLoad();
this.userLevels.initLoad().intervalSave(15000).disableSaveNotifs();
const commandFiles = fs.readdirSync('./commands/slash').filter(file=>file.endsWith('.ts'));
const commandFiles = fs.readdirSync('src/commands').filter(file=>file.endsWith('.ts'));
for (const file of commandFiles){
const command = require(`./commands/slash/${file}`);
this.commands.set(command.data.name, command)
this.registry.push(command.data.toJSON())
const command = require(`./commands/${file}`);
this.commands.set(command.default.data.name, command)
this.registry.push(command.default.data.toJSON())
}
}
formatPunishmentType(punishment: Punishment, client: TClient, cancels: Punishment){
@ -182,7 +182,7 @@ export class TClient extends Client {
async punish(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>, type: string){
let result: any;
if (!client.isStaff(interaction.member as Discord.GuildMember)) return this.youNeedRole(interaction, 'dcmod')
//if (type !== ('warn' || 'mute') && (interaction.member as Discord.GuildMember).roles.cache.has(client.config.mainServer.roles.idk)) return this.youNeedRole(interaction, 'dcmod');
if (type !== ('warn' || 'mute') && (interaction.member as Discord.GuildMember).roles.cache.has(client.config.mainServer.roles.idk)) return this.youNeedRole(interaction, 'dcmod');
const time = this.ms(interaction.options.getString('time'));
const reason = interaction.options.getString('reason') ?? 'Reason unspecified';
if (type == 'ban'){
@ -226,14 +226,14 @@ export class TClient extends Client {
class bannedWords extends Database {
client: TClient;
constructor(client: TClient){
super('./database/bannedWords.json', 'array');
super('src/database/bannedWords.json', 'array');
this.client = client;
}
}
class punishments extends Database {
client: TClient;
constructor(client: TClient){
super('./database/punishments.json', 'array');
super('src/database/punishments.json', 'array');
this.client = client;
}
createId(){
@ -289,7 +289,7 @@ class punishments extends Database {
class userLevels extends Database {
client: TClient;
constructor(client: TClient){
super('./database/userLevels.json', 'object');
super('src/database/userLevels.json', 'object');
this.client = client
}
incrementUser(userid: string){
@ -321,7 +321,7 @@ class userLevels extends Database {
class bonkCount extends Database {
client: TClient;
constructor(client: TClient){
super('./database/bonkCount.json', 'object')
super('src/database/bonkCount.json', 'object')
this.client = client
}
_incrementUser(userid: string){

View File

@ -1,12 +1,22 @@
import Discord from 'discord.js';
import { TClient } from 'src/client';
import Discord,{SlashCommandBuilder} from 'discord.js';
import { TClient } from 'src/client';
export default {
async run(client: TClient, message: Discord.Message, args: any){
if (!message.inGuild() || !message.channel) return;
client.punish(client, message, args, 'ban');
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
client.punish(client, interaction, 'ban');
},
name: 'ban',
description: 'Ban a member from server.',
usage: ['user mention or id', '?time', '?reason'],
category: 'moderation'
data: new SlashCommandBuilder()
.setName('ban')
.setDescription('Ban a member from the server')
.addUserOption((opt)=>opt
.setName('member')
.setDescription('Which member to ban?')
.setRequired(true))
.addStringOption((opt)=>opt
.setName('time')
.setDescription('How long the ban will be?')
.setRequired(false))
.addStringOption((opt)=>opt
.setName('reason')
.setDescription('Reason for the ban')
.setRequired(false))
}

View File

@ -1,12 +1,12 @@
import Discord from 'discord.js';
import Discord,{SlashCommandBuilder} from 'discord.js';
import { TClient } from 'src/client';
export default {
async run(client: TClient, message: Discord.Message){
if (!client.config.eval.whitelist.includes(message.author.id)) return message.reply('You\'re not allowed to use this command');
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
if (!client.config.eval.whitelist.includes(interaction.user.id)) return client.youNeedRole(interaction, 'bottech');
(client.channels.resolve(client.config.mainServer.channels.console) as Discord.TextChannel).send({content: `Uploaded the current console dump as of <t:${Math.round(Date.now()/1000)}:R>`, files: ['../.pm2/logs/Daggerbot-out.log']})
await message.reply({content: 'It has been uploaded to dev server.'})
await interaction.reply('It has been uploaded to dev server.')
},
name: 'botlog',
description: 'Retrieves the bot\'s log from host and sends it to appropriate channel.',
category: 'bot'
data: new SlashCommandBuilder()
.setName('botlog')
.setDescription('Retrieves the log from host and sends it to appropriate channel.')
}

View File

@ -1,4 +1,4 @@
import Discord from 'discord.js';
import Discord,{SlashCommandBuilder} from 'discord.js';
import { TClient } from 'src/client';
import * as util from 'node:util';
const removeUsername = (text: string)=>{
@ -16,25 +16,25 @@ const removeUsername = (text: string)=>{
} return array.join('\/');
};
export default {
async run(client: TClient, message: Discord.Message, args: any) {
if (!client.config.eval.allowed) return message.channel.send('Eval is disabled.');
if (!client.config.eval.whitelist.includes(message.author.id)) return message.reply('You\'re not allowed to use this command.');
const code = message.content.slice(client.config.prefix.length+args[0].length+1);
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>) {
if (!client.config.eval.allowed) return interaction.reply({content: 'Eval is disabled.', ephemeral: true});
if (!client.config.eval.whitelist.includes(interaction.user.id)) return interaction.reply({content: 'You\'re not allowed to use this command.', ephemeral: true});
const code = interaction.options.getString('code') as string;
let output = 'error';
let error = false;
try {
output = await eval(code)
output = await eval(code);
} catch (err: any) {
error = true
const embed = new client.embed().setColor('#ff0000').setTitle('__Eval__').addFields(
{name: 'Input', value: `\`\`\`js\n${code.slice(0, 1010)}\n\`\`\``},
{name: 'Output', value: `\`\`\`\n${err}\`\`\``}
)
message.channel.send({embeds: [embed]}).then(errorEmbedMessage=>{
const filter = x=>x.content === 'stack' && x.author.id === message.author.id
const messagecollector = message.channel.createMessageCollector({filter, max: 1, time: 60000});
messagecollector.on('collect',collected=>{
collected.channel.send(`\`\`\`\n${removeUsername(err.stack)}\n\`\`\``);
interaction.reply({embeds: [embed]}).catch(()=>(interaction.channel as Discord.TextChannel).send({embeds: [embed]})).then(errorEmbedMessage=>{
const filter = (x:any)=>x.content === 'stack' && x.author.id === interaction.user.id
const messagecollector = (interaction.channel as Discord.TextChannel).createMessageCollector({filter, max: 1, time: 60000});
messagecollector.on('collect', collected=>{
collected.reply({content: `\`\`\`\n${removeUsername(err.stack)}\n\`\`\``, allowedMentions: {repliedUser: false}});
});
});
}
@ -45,16 +45,20 @@ export default {
output = '\n' + String(output);
}
[client.tokens.token_main,client.tokens.token_beta,client.tokens.token_toast,client.tokens.token_tae].forEach((x)=>{
const regexp = new RegExp(x,'g');
const regexp = new RegExp(x as string,'g');
output = output.replace(regexp, 'TOKEN_LEAK');
})
const embed = new client.embed().setColor(client.config.embedColor).setTitle('__Eval__').addFields(
{name: 'Input', value: `\`\`\`js\n${code.slice(0,1010)}\n\`\`\``},
{name: 'Output', value: `\`\`\`${removeUsername(output).slice(0,1016)}\n\`\`\``}
);
message.channel.send({embeds: [embed]})
interaction.reply({embeds: [embed]}).catch(()=>(interaction.channel as Discord.TextChannel).send({embeds: [embed]}))
},
name: 'eval',
description: 'Run code for debugging purposes',
category: 'bot'
data: new SlashCommandBuilder()
.setName('eval')
.setDescription('Run code for debugging purposes')
.addStringOption((opt)=>opt
.setName('code')
.setDescription('Execute your code')
.setRequired(true))
}

View File

@ -1,78 +0,0 @@
import Discord,{ActionRowBuilder,ButtonBuilder} from 'discord.js';
import { TClient } from 'src/client';
let msg;
function helpPage(pageNumber: number, client: TClient, message: Discord.Message<boolean>, args: any, toEdit = false){
async function onEnd(msg){
await msg.edit({content: '_Removed to save space._', embeds: [], components: []});
};
let pageIndex = pageNumber || 0;
const pageInfo = client.commandPages[pageIndex];
let text = '';
client.commands.filter(command=>!command.hidden && command.category === pageInfo.category && command.page === pageInfo.page).forEach(command=>{
text += client.commandInfo(client, command, client.helpDefaultOptions);
});
const embed = new client.embed().setColor(client.config.embedColor).setTitle(`__Commands: ${pageInfo.name}__`).setDescription(text);
if (toEdit){
return embed;
} else {
message.reply({embeds: [embed], fetchReply: true, components: [new ActionRowBuilder().addComponents(new ButtonBuilder().setStyle('Secondary').setCustomId('back').setEmoji('◀'), new ButtonBuilder().setStyle('Secondary').setCustomId('forward').setEmoji('▶'))]})
// add buttons to go forward or backwards
.then(async botMessage=>{
let endTimestamp = Date.now()+90000;
const filter = (interaction: Discord.ChatInputCommandInteraction)=>{
return message.author.id === interaction.user.id;
};
const collector = botMessage.createMessageComponentCollector({filter, time: 90000});;
collector.on('collect', async(button: Discord.ButtonInteraction)=>{
endTimestamp = Date.now()+60000;
if (button.customId === 'back'){
if (pageIndex - 1<0) pageIndex = client.commandPages.length;
pageIndex--;
button.update({embeds: [helpPage(pageIndex, client, message, args, true)]})
} else if (button.customId === 'forward'){
if (pageIndex + 1>=client.commandPages.length) pageIndex = -1;
pageIndex++;
button.update({embeds: [helpPage(pageIndex, client, message, args, true)]})
}
});
async function onEnd(){
await botMessage.edit({content: '_Removed to save space._', embeds: [], components: []})
}
const interval = setInterval(()=>{
if (Date.now()>endTimestamp){
collector.stop();
onEnd();
}
},5000);
collector.on('end', async()=>{
onEnd();
clearInterval(interval)
})
})
}
}
export default {
async run(client: TClient, message: Discord.Message, args: any){
// if they ask for specific page #
if (parseInt(args[1])){
if (!client.commandPages[parseInt(args[1]) - 1]) return message.reply('That page number doesn\'t exist.');
return helpPage(parseInt(args[1]) - 1, client, message, args);
}
// category (name)
if (client.commandPages.some(x=>x.category.toLowerCase() === args.slice(1).join(' ').toLowerCase())){
return helpPage(client.commandPages.map(x=>x.category.toLowerCase()).indexOf(args.slice(1).join(' ').toLowerCase()), client, message, args)
}
// or command (name)
const command = client.commands.find(x=>x.name === args[1] || x.alias?.includes(args[1]));
if (command){
const embed = new client.embed().setColor(client.config.embedColor).setTitle(`__Commands: ${command.name}__`).setDescription(client.commandInfo(client, command, {insertNewline: true, parts: ['name', 'usage', 'description', 'shortDescription', 'alias', 'category', 'autores'], titles: ['name', 'usage', 'shortDescription', 'alias', 'category', 'autores']}));
return message.reply({embeds: [embed]});
}
// if run() still hasnt been returned, send category 0 page 1
return helpPage(undefined, client, message, args);
},
name: 'help',
description: 'Command information and their usage.',
usage: ['?command / ?category / ?page'],
category: 'bot'
}

View File

@ -1,12 +1,18 @@
import Discord from 'discord.js';
import { TClient } from 'src/client';
import Discord,{SlashCommandBuilder} from 'discord.js';
import { TClient } from 'src/client';
export default {
async run(client: TClient, message: Discord.Message, args: any){
if (!message.inGuild() || !message.channel) return;
client.punish(client, message, args, 'kick');
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
client.punish(client, interaction, 'kick');
},
name: 'kick',
description: 'Kick a member from server.',
usage: ['user mention or id', '?reason'],
category: 'moderation'
data: new SlashCommandBuilder()
.setName('kick')
.setDescription('Boot a member from the server')
.addUserOption((opt)=>opt
.setName('member')
.setDescription('Which member to kick?')
.setRequired(true))
.addStringOption((opt)=>opt
.setName('reason')
.setDescription('Reason for the kick')
.setRequired(false))
}

View File

@ -1,12 +1,12 @@
import { TClient } from "src/client";
import Discord from 'discord.js';
import Discord,{SlashCommandBuilder} from 'discord.js';
import { TClient } from 'src/client';
export default {
async run(client: TClient, message: Discord.Message){
const msg = await message.reply(`Pinging...`)
const time = msg.createdTimestamp - message.createdTimestamp;
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
const msg = await interaction.reply({content: 'Pinging...', fetchReply: true})
const time = msg.createdTimestamp - interaction.createdTimestamp;
msg.edit(`Websocket: \`${client.ws.ping}\`ms\nBot: \`${time}\``)
},
name: 'ping',
description: 'Check bot\'s latency',
category: 'bot'
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Check bot\'s latency')
}

View File

@ -1,60 +0,0 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import { TClient } from 'src/client';
import * as util from 'node:util';
const removeUsername = (text: string)=>{
let matchesLeft = true;
const array = text.split('\/');
while (matchesLeft){
let usersIndex = array.indexOf('home');
if (usersIndex<1) matchesLeft = false;
else {
let usernameIndex = usersIndex+1;
if(array[usernameIndex].length == 0) usernameIndex += 1;
array[usernameIndex] = '*'.repeat(array[usernameIndex].length);
array[usersIndex] = 'ho\u200bme';
}
} return array.join('\/');
};
export default {
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>) {
if (!client.config.eval.allowed) return interaction.reply({content: 'Eval is disabled.', ephemeral: true});
if (!client.config.eval.whitelist.includes(interaction.user.id)) return interaction.reply({content: 'You\'re not allowed to use this command.', ephemeral: true});
const code = interaction.options.getString('code') as string;
let output = 'error';
let error = false;
try {
output = await eval(code);
} catch (err: any) {
error = true
const embed = new client.embed().setColor('#ff0000').setTitle('__Eval__').addFields(
{name: 'Input', value: `\`\`\`js\n${code.slice(0, 1010)}\n\`\`\``},
{name: 'Output', value: `\`\`\`\n${err}\`\`\``}
)
interaction.reply({embeds: [embed]}).catch(()=>(interaction.channel as Discord.TextChannel).send({embeds: [embed]})).then(errorEmbedMessage=>{
const filter = (x:any)=>x.content === 'stack' && x.author.id === interaction.user.id
const messagecollector = (interaction.channel as Discord.TextChannel).createMessageCollector({filter, max: 1, time: 60000});
messagecollector.on('collect', collected=>{
collected.reply({content: `\`\`\`\n${removeUsername(err.stack)}\n\`\`\``, allowedMentions: {repliedUser: false}});
});
});
}
if (error) return;
if (typeof output == 'object') {
output = 'js\n'+util.formatWithOptions({depth: 1}, '%O', output)
} else {
output = '\n' + String(output);
}
[client.tokens.token_main,client.tokens.token_beta,client.tokens.token_toast,client.tokens.token_tae].forEach((x)=>{
const regexp = new RegExp(x as string,'g');
output = output.replace(regexp, 'TOKEN_LEAK');
})
const embed = new client.embed().setColor(client.config.embedColor).setTitle('__Eval__').addFields(
{name: 'Input', value: `\`\`\`js\n${code.slice(0,1010)}\n\`\`\``},
{name: 'Output', value: `\`\`\`${removeUsername(output).slice(0,1016)}\n\`\`\``}
);
interaction.reply({embeds: [embed]}).catch(()=>(interaction.channel as Discord.TextChannel).send({embeds: [embed]}))
},
name: 'eval',
description: 'Run code for debugging purposes',
category: 'bot'
}

View File

@ -1,12 +1,18 @@
import Discord from 'discord.js';
import { TClient } from 'src/client';
import Discord,{SlashCommandBuilder} from 'discord.js';
import { TClient } from 'src/client';
export default {
async run(client: TClient, message: Discord.Message, args: any){
client.unPunish(client, message, args);
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
client.unPunish(client, interaction)
},
name: 'unpunish',
description: 'Remove an active punishment from a user or an entry from their punishment history.',
usage: ['case id', '?reason'],
alias: ['unban', 'unmute', 'unwarn'],
category: 'moderation'
data: new SlashCommandBuilder()
.setName('unpunish')
.setDescription('Remove the active punishment from a member')
.addIntegerOption((opt)=>opt
.setName('case_id')
.setDescription('Case # of the punishment to be overwritten')
.setRequired(true))
.addStringOption((opt)=>opt
.setName('reason')
.setDescription('Reason for removing the punishment')
.setRequired(false))
}

View File

@ -1,10 +1,10 @@
import Discord from 'discord.js';
import Discord,{SlashCommandBuilder} from 'discord.js';
import { TClient } from 'src/client';
import { exec } from 'node:child_process';
export default {
async run(client: TClient, message: Discord.Message, args: any){
if (!client.config.eval.whitelist.includes(message.author.id)) return message.reply('You\'re not allowed to use this command')
const msg = await message.reply({content: 'Pulling...', fetchReply: true})
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
if (!client.config.eval.whitelist.includes(interaction.user.id)) return client.youNeedRole(interaction, 'bottech');
const msg = await interaction.reply({content: 'Pulling...', fetchReply: true})
exec(
'git pull',(err:Error,stdout)=>{
if (err){
@ -17,7 +17,7 @@ export default {
}
)
},
name: 'update',
description: 'Pull from repository and restart.',
category: 'bot'
data: new SlashCommandBuilder()
.setName('update')
.setDescription('Pull from repository and restart')
}

View File

@ -1,12 +1,18 @@
import Discord from 'discord.js';
import { TClient } from 'src/client';
import Discord,{SlashCommandBuilder} from 'discord.js';
import { TClient } from 'src/client';
export default {
async run(client: TClient, message: Discord.Message, args: any){
if (!message.inGuild() || !message.channel) return;
client.punish(client, message, args, 'warn');
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
client.punish(client, interaction, 'warn');
},
name: 'kick',
description: 'Warn a member.',
usage: ['user mention or id', '?reason'],
category: 'moderation'
data: new SlashCommandBuilder()
.setName('warn')
.setDescription('Warn a member')
.addUserOption((opt)=>opt
.setName('member')
.setDescription('Which member to warn?')
.setRequired(true))
.addStringOption((opt)=>opt
.setName('reason')
.setDescription('Reason for the warning')
.setRequired(false))
}

View File

@ -6,11 +6,12 @@
"embedColorBCA": "#ff69b4",
"LRSstart": 1661236321433,
"botSwitches": {
"registerCommands": false,
"registerCommands": true,
"commands": false,
"logs": false,
"automod": false,
"logs": true,
"automod": true,
"mpstats": false,
"mpstatsDebug": false,
"autores": false
},
"eval": {

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
[[0,674965],[1,675885],[2,676639],[3,677245],[4,677609],[5,678188],[6,678916],[7,679465],[8,679938],[9,680540],[10,681614],[11,682079],[12,682780],[13,683187],[14,683547],[15,683900],[16,684592],[17,685466],[18,686078],[19,686481],[20,676748],[21,676968],[22,677427],[23,677592],[24,677894],[25,678116],[26,676785],[27,677570],[28,678491],[29,679137],[30,679818],[31,680094],[32,680417],[33,680783],[34,681563],[35,682070],[36,682670],[37,683504],[38,684078],[39,684383],[40,684692],[41,685448],[42,685664],[43,685994],[44,686366],[45,687118],[46,687626],[47,688008],[48,688754],[49,688942],[50,689107],[51,689472],[52,690143],[53,690644],[54,691124],[55,692196],[56,692624],[57,692906],[58,693456],[59,693952],[60,694586],[61,695070],[62,696163],[63,696564],[64,697315],[65,698548],[66,699138],[67,699558],[68,700307],[69,701063],[70,701394],[71,701868],[72,702453],[73,702917],[76,705187],[77,705243],[78,705488],[79,705961],[80,706585],[81,707467],[82,708212],[83,709024],[84,709773]]
[[0,674965],[1,675885],[2,676639],[3,677245],[4,677609],[5,678188],[6,678916],[7,679465],[8,679938],[9,680540],[10,681614],[11,682079],[12,682780],[13,683187],[14,683547],[15,683900],[16,684592],[17,685466],[18,686078],[19,686481],[20,676748],[21,676968],[22,677427],[23,677592],[24,677894],[25,678116],[26,676785],[27,677570],[28,678491],[29,679137],[30,679818],[31,680094],[32,680417],[33,680783],[34,681563],[35,682070],[36,682670],[37,683504],[38,684078],[39,684383],[40,684692],[41,685448],[42,685664],[43,685994],[44,686366],[45,687118],[46,687626],[47,688008],[48,688754],[49,688942],[50,689107],[51,689472],[52,690143],[53,690644],[54,691124],[55,692196],[56,692624],[57,692906],[58,693456],[59,693952],[60,694586],[61,695070],[62,696163],[63,696564],[64,697315],[65,698548],[66,699138],[67,699558],[68,700307],[69,701063],[70,701394],[71,701868],[72,702453],[73,702917],[76,705187],[77,705243],[78,705488],[79,705961],[80,706585],[81,707467],[82,708212],[83,709024],[84,709773],[85,710256]]

View File

@ -1,30 +1,30 @@
{
"190407856527376384": {
"messages": 52961,
"messages": 53012,
"level": 59
},
"593696856165449749": {
"messages": 51388,
"messages": 51421,
"level": 58
},
"141304507249197057": {
"messages": 67550,
"messages": 67626,
"level": 67
},
"533707949831487488": {
"messages": 56984,
"messages": 56992,
"level": 61
},
"532662366354276352": {
"messages": 33675,
"messages": 33701,
"level": 47
},
"824043915539513406": {
"messages": 18434,
"messages": 18442,
"level": 35
},
"178941218510602240": {
"messages": 6372,
"messages": 6375,
"level": 20
},
"215497515934416896": {
@ -32,11 +32,11 @@
"level": 46
},
"301350210926280704": {
"messages": 14306,
"messages": 14317,
"level": 30
},
"695323013813633076": {
"messages": 14072,
"messages": 14076,
"level": 30
},
"389237487094071337": {
@ -44,11 +44,11 @@
"level": 28
},
"716355511552966737": {
"messages": 9122,
"messages": 9138,
"level": 24
},
"633345781780185099": {
"messages": 29364,
"messages": 29365,
"level": 44
},
"711527768185372742": {
@ -64,27 +64,27 @@
"level": 18
},
"458688902102908928": {
"messages": 6190,
"messages": 6209,
"level": 20
},
"475037861725339649": {
"messages": 10192,
"messages": 10194,
"level": 26
},
"392699530912727041": {
"messages": 4928,
"messages": 4937,
"level": 18
},
"468837263577579524": {
"messages": 7631,
"messages": 7677,
"level": 22
},
"734703851558535188": {
"messages": 20200,
"messages": 20203,
"level": 36
},
"488683638310043677": {
"messages": 15456,
"messages": 15457,
"level": 32
},
"606595407769894995": {
@ -92,11 +92,11 @@
"level": 39
},
"322835877027905547": {
"messages": 10018,
"messages": 10019,
"level": 25
},
"485793265568841728": {
"messages": 37880,
"messages": 37883,
"level": 50
},
"837979120142778388": {
@ -108,7 +108,7 @@
"level": 0
},
"257954059988893720": {
"messages": 5392,
"messages": 5393,
"level": 18
},
"690090143008555064": {
@ -124,11 +124,11 @@
"level": 0
},
"452576735494406175": {
"messages": 1676,
"messages": 1679,
"level": 10
},
"763055599654666291": {
"messages": 969,
"messages": 971,
"level": 8
},
"623176215800446976": {
@ -148,7 +148,7 @@
"level": 0
},
"169891949464125441": {
"messages": 518,
"messages": 521,
"level": 5
},
"718453763932946432": {
@ -160,7 +160,7 @@
"level": 13
},
"763803832542035978": {
"messages": 679,
"messages": 683,
"level": 6
},
"931816463113814066": {
@ -200,7 +200,7 @@
"level": 0
},
"615761944154210305": {
"messages": 2997,
"messages": 3063,
"level": 14
},
"397101726047666197": {
@ -228,7 +228,7 @@
"level": 2
},
"645342896312156181": {
"messages": 679,
"messages": 684,
"level": 6
},
"488505753133645826": {
@ -236,11 +236,11 @@
"level": 0
},
"313461397457600512": {
"messages": 78,
"messages": 79,
"level": 2
},
"848489550065827850": {
"messages": 40,
"messages": 42,
"level": 1
},
"862138850423472128": {
@ -280,7 +280,7 @@
"level": 0
},
"509374532109336576": {
"messages": 28,
"messages": 29,
"level": 1
},
"464887328138199042": {
@ -300,7 +300,7 @@
"level": 2
},
"813156260563910696": {
"messages": 26,
"messages": 27,
"level": 1
},
"236902492955344898": {
@ -348,7 +348,7 @@
"level": 0
},
"549295707304099846": {
"messages": 45,
"messages": 46,
"level": 1
},
"759390179064283178": {
@ -424,7 +424,7 @@
"level": 0
},
"281518331427553280": {
"messages": 27,
"messages": 28,
"level": 1
},
"708758234407895050": {
@ -500,11 +500,7 @@
"level": 0
},
"367051844004085780": {
"messages": 5,
"level": 0
},
"414413764931354624": {
"messages": 23,
"messages": 6,
"level": 0
},
"611055992121327617": {
@ -544,7 +540,7 @@
"level": 0
},
"869718328313278555": {
"messages": 96,
"messages": 97,
"level": 2
},
"772197160372404234": {
@ -712,7 +708,7 @@
"level": 0
},
"493045512480751626": {
"messages": 18,
"messages": 19,
"level": 1
},
"475058155903123467": {
@ -768,15 +764,15 @@
"level": 0
},
"552473047144071168": {
"messages": 19,
"level": 0
"messages": 20,
"level": 1
},
"587377817893994538": {
"messages": 1,
"level": 0
},
"916695915736207381": {
"messages": 20,
"messages": 21,
"level": 1
},
"457390648568315904": {
@ -824,7 +820,7 @@
"level": 0
},
"513009978315898891": {
"messages": 18,
"messages": 20,
"level": 1
},
"667815332047486978": {
@ -1056,7 +1052,7 @@
"level": 0
},
"781289786143932499": {
"messages": 106,
"messages": 107,
"level": 2
},
"348617165135544321": {
@ -1344,7 +1340,7 @@
"level": 0
},
"98464148379148288": {
"messages": 1396,
"messages": 1436,
"level": 9
},
"1025723411680460840": {
@ -1428,7 +1424,7 @@
"level": 0
},
"1028204452328517703": {
"messages": 67,
"messages": 68,
"level": 2
},
"179671371931058176": {
@ -1476,7 +1472,7 @@
"level": 0
},
"889624632724963329": {
"messages": 37,
"messages": 38,
"level": 1
},
"687692546314600530": {
@ -1728,7 +1724,7 @@
"level": 0
},
"796040852400635914": {
"messages": 354,
"messages": 367,
"level": 4
},
"1011307308325818438": {
@ -1744,7 +1740,7 @@
"level": 0
},
"673289306424475659": {
"messages": 117,
"messages": 122,
"level": 2
},
"907163452043305000": {
@ -2040,7 +2036,7 @@
"level": 0
},
"273183233674444801": {
"messages": 1,
"messages": 4,
"level": 0
},
"745931688005206098": {
@ -2052,7 +2048,7 @@
"level": 0
},
"1023915974690340946": {
"messages": 20,
"messages": 21,
"level": 1
},
"871113268633174128": {
@ -2096,7 +2092,7 @@
"level": 0
},
"123080080946757632": {
"messages": 27,
"messages": 37,
"level": 1
},
"1001530115148226711": {
@ -2124,7 +2120,7 @@
"level": 0
},
"969867332304400404": {
"messages": 4,
"messages": 6,
"level": 0
},
"881867367418826812": {
@ -2312,7 +2308,7 @@
"level": 0
},
"406582522697482241": {
"messages": 2,
"messages": 3,
"level": 0
},
"231907580748759040": {
@ -2324,7 +2320,7 @@
"level": 0
},
"1029465066174677132": {
"messages": 9,
"messages": 10,
"level": 0
},
"387345064927428611": {
@ -2504,7 +2500,7 @@
"level": 0
},
"490183428990304286": {
"messages": 65,
"messages": 75,
"level": 2
},
"787352638811013151": {
@ -2588,15 +2584,15 @@
"level": 0
},
"1030163323414650880": {
"messages": 1,
"messages": 3,
"level": 0
},
"104048450017951744": {
"messages": 1,
"messages": 5,
"level": 0
},
"340587045250531358": {
"messages": 79,
"messages": 84,
"level": 2
},
"911709434554777660": {
@ -2672,7 +2668,7 @@
"level": 0
},
"972906041295634462": {
"messages": 1,
"messages": 3,
"level": 0
},
"980710517817614336": {
@ -2684,7 +2680,7 @@
"level": 0
},
"999736341220839464": {
"messages": 5,
"messages": 7,
"level": 0
},
"901565970974392331": {
@ -2692,23 +2688,23 @@
"level": 0
},
"388211913621897216": {
"messages": 3,
"level": 0
"messages": 21,
"level": 1
},
"1039241529912475729": {
"messages": 1,
"level": 0
},
"562257805927776286": {
"messages": 7,
"messages": 8,
"level": 0
},
"995622955897864272": {
"messages": 42,
"level": 1
"messages": 70,
"level": 2
},
"153323923633733632": {
"messages": 6,
"messages": 8,
"level": 0
},
"190028480786726913": {
@ -2720,11 +2716,11 @@
"level": 0
},
"590595536537518091": {
"messages": 1,
"messages": 2,
"level": 0
},
"576383133763764225": {
"messages": 1,
"messages": 10,
"level": 0
},
"995778519571378266": {
@ -2746,5 +2742,17 @@
"846431793715871749": {
"messages": 1,
"level": 0
},
"838471706871988234": {
"messages": 1,
"level": 0
},
"259798326705127435": {
"messages": 1,
"level": 0
},
"910647475570901054": {
"messages": 2,
"level": 0
}
}

View File

@ -27,7 +27,7 @@ export default {
newInvites.forEach((inv:any)=>client.invites.set(inv.code,{uses: inv.uses, creator: inv.inviter.id}));
const embed1 = new client.embed().setColor(client.config.embedColorGreen).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`Member Joined: ${member.user.tag}`).setDescription(`<@${member.user.id}>\n\`${member.user.id}\``).addFields(
{name: '🔹 Account Creation Date', value: `<:t${Math.round(member.user.createdTimestamp/1000)}>\n<t:${Math.round(member.user.createdTimestamp/1000)}:R>`},
{name: '🔹 Account Creation Date', value: `<t:${Math.round(member.user.createdTimestamp/1000)}>\n<t:${Math.round(member.user.createdTimestamp/1000)}:R>`},
{name: '🔹 Invite Data:', value: usedInvite ? `Invite: \`${usedInvite.code}\`\nCreated by: **${usedInvite.inviter?.tag}**` : 'I couldn\'t find out how they joined!'}
);
(client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [embed1]})

View File

@ -6,12 +6,12 @@ export default {
if (!interaction.inGuild() || !interaction.inCachedGuild() || !interaction.command) return;
if (interaction.isCommand()){
const commandFile = client.commands.get(interaction.commandName);
console.log(`[${client.moment().format('DD/MM/YY HH:mm:ss')}] ${interaction.user.tag} used /${interaction.commandName} ${interaction.options.getSubcommand() ?? ''} in #${interaction.channel.name}`);
console.log(`[${client.moment().format('DD/MM/YY HH:mm:ss')}] ${interaction.user.tag} used /${interaction.commandName} in #${interaction.channel.name}`);
if (!client.config.botSwitches.commands && !client.config.eval.whitelist.includes(interaction.user.id)) return interaction.reply({content: 'Commands are currently disabled.', ephemeral: true});
if (commandFile){
if (commandFile.disabled) return interaction.reply({content: 'This command is currently disabled.', ephemeral: true});
try{
commandFile.run(client, interaction);
commandFile.default.run(client, interaction);
commandFile.uses ? commandFile.uses++ : commandFile.uses = 1;
} catch (error:any){
console.log(`\x1b[31mAn error occured while running command "${commandFile.name}"`, error, error.stack);

View File

@ -66,6 +66,7 @@ export default {
const bannedChannels = [
'516344221452599306', // #mp-moderators
'742324777934520350', // #discord-moderators
'904192878140608563'
]
if (message.content.toLowerCase().includes('tenor.com/view') || message.content.toLowerCase().includes('giphy.com/gifs/') || message.content.toLowerCase().includes('giphy.com/media/') && bannedChannels.includes(message.channelId)) {
message.reply('Gifs are not allowed in this channel.').then((msg: any)=>message.delete())
@ -95,17 +96,20 @@ export default {
message.reply('https://cdn.discordapp.com/attachments/925589318276382720/1011333656167579849/F57G5ZS.png')
}
if (message.content.toLowerCase().includes('nawdic') && (message.content.toLowerCase().includes('break') || message.content.toLowerCase().includes('broke') || message.content.toLowerCase().includes('broken'))){
const embed = new client.embed().setTitle('*Nawdic done an oopsie*').setImage('https://c.tenor.com/JSj9ie_MD9kAAAAC/kopfsch%C3%BCtteln-an-kopf-fassen-oh-no.gif').setColor(client.config.embedColor)
const embed = new client.embed().setTitle('*Nawdic has done an oopsie*').setImage('https://c.tenor.com/JSj9ie_MD9kAAAAC/kopfsch%C3%BCtteln-an-kopf-fassen-oh-no.gif').setColor(client.config.embedColor)
message.reply({embeds: [embed]})
}
if (message.content.toLowerCase().startsWith('good morning') || message.content.toLowerCase().startsWith('morning all') || message.content.toLowerCase().startsWith('morning everyone')){
message.reply(`Good morning ${message.author.username}!`)
message.reply(`Good morning **${message.member.displayName}**!`)
}
if (message.content.toLowerCase().startsWith('good afternoon') || message.content.toLowerCase().startsWith('afternoon all') || message.content.toLowerCase().startsWith('good evening') || message.content.toLowerCase().startsWith('evening all')){
message.reply(`Good afternoon/evening ${message.author.username}!`)
if (message.content.toLowerCase().startsWith('good afternoon') || message.content.toLowerCase().startsWith('afternoon all')){
message.reply(`Afternoon **${message.member.displayName}**!`)
}
if (message.content.toLowerCase().startsWith('good evening') || message.content.toLowerCase().startsWith('evening all')){
message.reply(`Good evening **${message.member.displayName}**!`)
}
if (message.content.toLowerCase().startsWith('night all') || message.content.toLowerCase().startsWith('night everyone')){
message.reply(`Night ${message.author.username}`)
message.reply(`Night **${message.member.displayName}**`)
}
}
}

View File

@ -1,14 +1,14 @@
import Discord = require('discord.js');
import Discord from 'discord.js';
import { TClient } from './client';
const client = new TClient;
client.init();
import fs = require('node:fs');
import ServerDB from './models/MPServer';
import fs from 'node:fs';
import MPDB from './models/MPServer';
client.on('ready', async()=>{
client.guilds.cache.forEach(async(e: { members: { fetch: () => any; }; })=>{await e.members.fetch()});
setInterval(async()=>{
client.user.setPresence({activities: [{ name: 'Running under TS', type: 0 }], status: 'online'});
client.user.setPresence({activities: [{ name: 'TypeScript is pog', type: 0 }], status: 'online'});
// Playing: 0, Streaming (Requires YT/Twitch URL to work): 1, Listening to: 2, Watching: 3, Competing in: 5
}, 60000);
if (client.config.botSwitches.registerCommands) (client.guilds.cache.get(client.config.mainServer.id) as Discord.Guild).commands.set(client.registry).catch((e)=>{console.log(`Couldn't register slash commands: ${e}`)})
@ -22,13 +22,13 @@ client.on('ready', async()=>{
}, 500000);
console.log(`${client.user.tag} has logged into Discord API and now ready for operation`);
console.log(client.config.botSwitches);
(client.channels.resolve(client.config.mainServer.channels.bot_status) as Discord.TextChannel).send(`${client.user.username} is active`);
(client.channels.resolve(client.config.mainServer.channels.bot_status) as Discord.TextChannel).send(`${client.user.username} is active\n\`\`\`json\n${Object.entries(client.config.botSwitches).map((hi)=>`${hi[0]}: ${hi[1]}`).join('\n')}\`\`\``);
// Event handler
const eventFiles = fs.readdirSync('./events').filter(file=>file.endsWith('.js'));
const eventFiles = fs.readdirSync('src/events').filter(file=>file.endsWith('.ts'));
eventFiles.forEach((file)=>{
const event = require(`./events/${file}`);
client.on(event.name, async(...args: any)=>event.execute(client, ...args))
client.on(event.default.name, async(...args)=>event.default.execute(client, ...args));
});
})
@ -49,28 +49,32 @@ process.on('error', async(error: Error)=>{
// Daggerwin MP loop
setInterval(async()=>{
if (!client.config.botSwitches.mpstats) return;
const msg = await (client.channels.resolve('ChannelID') as Discord.TextChannel).messages.fetch('MessageID')
const msg = await (client.channels.resolve('904192878140608563') as Discord.TextChannel).messages.fetch('1042464209709051974')
const embed = new client.embed();
let Players = [];
let Server: any;
let CSG: void;
let CSG;
let xmlData = undefined;
// Connect to DB to retrieve the Gameserver info to fetch data.
ServerDB.sync();
MPDB.sync();
const newServerId = client.config.mainServer.id
const ServerURL = await ServerDB.findOne({where: {serverId: newServerId}})
const DBURL = ServerURL.get('ip')
const DBCode = ServerURL.get('code')
const ServerURL = MPDB.findOne({where: {serverId: newServerId}})
const DBURL = (await ServerURL).ip
const DBCode = (await ServerURL).code // vv todo: strip 'http://' from ServerURL
const completedURL_DSS = DBURL + '/feed/dedicated-server-stats.json?code=' + DBCode
const completedURL_CSG = DBURL + '/feed/dedicated-server-savegame.html?code=' + DBCode + '&file=careerSavegame'
console.log(DBURL + '\n' + DBCode)
try {
Server = await client.axios.get(completedURL_DSS, {timeout: 4000})
} catch (err){
console.log(`[${client.moment().format('DD/MM/YY HH:mm:ss')}] dag mp dss fail`)
embed.setTitle('Data could not be retrieved, the host may not be responding.').setColor(client.config.embedColorRed)
msg.edit({embeds: [embed]})
if (client.config.botSwitches.mpstatsDebug) {
console.log(err)
} else {
console.log(`[${client.moment().format('DD/MM/YY HH:mm:ss')}] dag mp dss fail`)
}
embed.setTitle('Host is not responding.').setColor(client.config.embedColorRed)
msg.edit({content: null, embeds: [embed]})
return;
}
try {
@ -78,17 +82,25 @@ setInterval(async()=>{
xmlData = client.xjs.xml2js(xml.data, {compact: true, spaces: 2}).careerSavegame;
})
} catch (err){
console.log(`[${client.moment().format('DD/MM/YY HH:mm:ss')}] dag mp csg fail`)
if (client.config.botSwitches.mpstatsDebug) {
console.log(err)
} else {
console.log(`[${client.moment().format('DD/MM/YY HH:mm:ss')}] dag mp csg fail`)
}
}
if (xmlData == undefined){
console.log(`[${client.moment().format('DD/MM/YY HH:mm:ss')}] dag mp csg failed to convert`)
if (client.config.botSwitches.mpstatsDebug) {
console.log(xmlData)
} else {
console.log(`[${client.moment().format('DD/MM/YY HH:mm:ss')}] dag mp csg failed to convert`)
}
embed.setFooter({text: 'XML Data retrieve failed. Retrying in next minute.'})
msg.edit({embeds: [embed]})
}
const DB = require(`./database/MPPlayerData.json`);
DB.push(Server.data.slots.used)
fs.writeFileSync(__dirname + `./database/MPPlayerData.json`, JSON.stringify(DB))
fs.writeFileSync(__dirname + `/database/MPPlayerData.json`, JSON.stringify(DB))
// Number format function
function formatNumber(number: any, digits: any, icon: any){
@ -99,28 +111,28 @@ setInterval(async()=>{
if (Server.data.server.name.length == 0){
embed.setTitle('The server seems to be offline.').setColor(client.config.embedColorRed);
msg.edit({embeds: [embed]})
msg.edit({content: 'This embed will resume when server is back online.', embeds: [embed]})
} else {
const embed1 = new client.embed().setColor(client.config.embedColor).setTitle('Server details').addFields(
{name: '| Current Map |', value: `${Server.data.server.mapName.length == 0 ? '\u200b' : Server.data.server.mapName}`, inline: true},
{name: '| Game Version |', value: `${Server.data.server.version.length == 0 ? '0.0.0.0' : Server.data.server.version}`, inline: true},
{name: '| In-game Time |', value: `${('0' + Math.floor((Server.data.server.dayTime/3600/1000))).slice(-2)}:${('0' + Math.floor((Server.data.server.dayTime/60/1000)%60)).slice(-2)}`, inline: true},
{name: '| Slot Usage |', value: `${Number(xmlData?.slotSystem?._attributes?.slotUsage).toLocaleString('en-US')}`, inline: true},
{name: '| Timescale |', value: `${formatNumber(timeScale, 0, 'x')}`, inline: true}
{name: 'Current Map', value: `${Server.data.server.mapName.length == 0 ? '\u200b' : Server.data.server.mapName}`, inline: true},
{name: 'Game Version', value: `${Server.data.server.version.length == 0 ? '\u200b' : Server.data.server.version}`, inline: true},
{name: 'In-game Time', value: `${('0' + Math.floor((Server.data.server.dayTime/3600/1000))).slice(-2)}:${('0' + Math.floor((Server.data.server.dayTime/60/1000)%60)).slice(-2)}`, inline: true},
{name: 'Slot Usage', value: `${Number(xmlData?.slotSystem?._attributes?.slotUsage).toLocaleString('en-US')}`, inline: true},
{name: 'Timescale', value: `${formatNumber(timeScale, 0, 'x')}`, inline: true}
);
await Server.data.slots.players.filter((x)=>x.isUsed !== false).forEach(player=>{
Players.push(`**| ${player.name} | ${player.isAdmin ? 'admin |' : ''}**\nFarming for ${(Math.floor(player.uptime/60))} hr & ${('0' + (player.uptime % 60)).slice(-2)} min`)
Players.push(`**${player.name} ${player.isAdmin ? '| admin' : ''}**\nFarming for ${(Math.floor(player.uptime/60))} hr & ${('0' + (player.uptime % 60)).slice(-2)} min`)
})
embed.setDescription(`${Server.data.slots.used == 0 ? '*No players online*' : Players.join('\n\n')}`).setTitle(Server.data.server.name).setColor(client.config.embedColor)
embed.setAuthor({name: `${Server.data.slots.used}/${Server.data.slots.capacity}`});
msg.edit({embeds: [embed1, embed]})
msg.edit({content: 'This embed updates every minute.', embeds: [embed1, embed]})
}
}, 60000)
// YouTube Upload notification
setInterval(async()=>{
client.YTLoop('UCQ8k8yTDLITldfWYKDs3xFg', 'Daggerwin', '528967918772551702');
client.YTLoop('UCguI73--UraJpso4NizXNzA', 'Machinery Restorer', '767444045520961567')
client.YTLoop('UCQ8k8yTDLITldfWYKDs3xFg', 'Daggerwin', '528967918772551702'); // 528967918772551702 = #videos-and-streams
client.YTLoop('UCguI73--UraJpso4NizXNzA', 'Machinery Restorer', '767444045520961567') // 767444045520961567 = #machinery-restorer
}, 300000)
// Event loop for punishments and daily msgs
@ -147,7 +159,7 @@ setInterval(async()=>{
total = yesterday
}
dailyMsgs.push([formattedDate, total]);
fs.writeFileSync(__dirname + './database/dailyMsgs.json', JSON.stringify(dailyMsgs))
fs.writeFileSync(__dirname + 'dailyMsgs.json', JSON.stringify(dailyMsgs))
console.log(`\x1b[36m[${client.moment().format('DD/MM/YY HH:mm:ss')}] \x1b[33m`, `Pushed [${formattedDate}, ${total}] to dailyMsgs`)
}
}, 5000)

View File

@ -1,15 +1,18 @@
import {Sequelize, DataTypes} from 'sequelize';
import {Sequelize, DataTypes, Model, InferAttributes, InferCreationAttributes} from 'sequelize';
var db = new Sequelize('database', 'daggerbot', 'toastsus', {
host: 'localhost',
dialect: 'sqlite',
logging: false,
storage: '../database/MPDB.dat'
storage: 'src/database/MPDB.dat'
})
var ServerDB = db.define('urls', {
class MPDB extends Model<InferAttributes<MPDB>, InferCreationAttributes<MPDB>>{
declare serverId: string | null;
declare ip: string | null;
declare code: string | null;
}
MPDB.init({
serverId: {
type: DataTypes.STRING,
defaultValue: 'Missing ID',
allowNull: false,
unique: true
},
ip: {
@ -22,5 +25,5 @@ var ServerDB = db.define('urls', {
defaultValue: 'Missing Code',
allowNull: false
}
}, {timestamps: false})
export default ServerDB;
}, { sequelize: db, modelName: 'urls', timestamps: false });
export default MPDB

View File

@ -1,16 +1,11 @@
interface createTableOpt {
columnAlign: any,
columnSeparator: any,
columnEmptyChar: any
}
interface formatTimeOpt {
longNames: boolean,
commas: boolean
}
interface CommandInfoOpt {
insertNewline: boolean,
parts: string[], //idfk
titles: string[]
interface createTableOpt {
columnAlign: any,
columnSeparator: any,
columnEmptyChar: any
}
interface punOpt {
time?: string,

View File

@ -1,18 +1,22 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"sourceMap": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"target": "ESNext",
"module": "CommonJS",
"baseUrl": "./",
"rootDir": "src/",
"outDir": "dist/",
"moduleResolution": "node",
"typeRoots": [ "node_modules/@types" ],
"ts-node": {
"transpileOnly": true,
"compilerOptions": {
"esModuleInterop": true,
"resolveJsonModule": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "ESNext",
"module": "NodeNext",
"baseUrl": "./",
"rootDir": "src/",
"outDir": "dist/",
"moduleResolution": "Node",
"declarationDir": "src/typings",
"typeRoots": [ "node_modules/@types", "src/typings" ],
},
},
"include": [ "./**/*.ts" ],
"include": [ "node_modules/@types", "src/**/*" ],
"exclude": [ "dist", "node_modules" ],
}