1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 00:10:58 -05:00

Add randomcolor and adjust few things

This commit is contained in:
toast-ts 2023-01-11 19:33:38 +11:00
parent b38c3242b2
commit 5cd65cc23c
4 changed files with 25 additions and 12 deletions

View File

@ -12,6 +12,8 @@ let importconfig:Config
try{ try{
importconfig = require('./DB-Beta.config.json') importconfig = require('./DB-Beta.config.json')
console.log('Using development config : Daggerbot Beta') console.log('Using development config : Daggerbot Beta')
//importconfig = require('./Toast-Testbot.config.json')
//console.log('Using development config : Toast-Testbot')
} catch(e){ } catch(e){
importconfig = require('./config.json') importconfig = require('./config.json')
console.log('Using production config') console.log('Using production config')

View File

@ -0,0 +1,12 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import { TClient } from 'src/client';
export default {
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
const embed = new client.embed().setColor(Math.floor(Math.random()*16777215));
embed.addFields({name: 'Hex code', value: `#${embed.data.color.toString(16).toUpperCase()}`});
interaction.reply({embeds: [embed]});
},
data: new SlashCommandBuilder()
.setName('randomcolor')
.setDescription('Generate a random hex code')
}

View File

@ -138,12 +138,10 @@ export default {
ctx.fillText('time ->', tx, ty); ctx.fillText('time ->', tx, ty);
const yeahok = new client.attachmentBuilder(img.toBuffer(), {name: 'dailymsgs.png'}) const yeahok = new client.attachmentBuilder(img.toBuffer(), {name: 'dailymsgs.png'})
const embed = new client.embed() const embed = new client.embed().setTitle('Ranking leaderboard')
.setTitle('Ranking leaderboard') .setDescription(`Level System was created **${timeActive}** days ago. Since then, a total of **${messageCountsTotal.toLocaleString('en-US')}** messages have been sent in this server.\nGraph updates daily @ <t:${Math.round((client.config.LRSstart+3600000)/1000)}:t>`)
.setDescription(`Level System was created **${timeActive}** days ago. Since then, a total of **${messageCountsTotal.toLocaleString('en-US')}** messages have been sent in this server.`)
.addFields({name: 'Top users by messages sent:', value: Object.entries<UserLevels>(client.userLevels._content).sort((a, b) => b[1].messages - a[1].messages).slice(0, 10).map((x, i) => `\`${i + 1}.\` <@${x[0]}>: ${x[1].messages.toLocaleString('en-US')}`).join('\n')}) .addFields({name: 'Top users by messages sent:', value: Object.entries<UserLevels>(client.userLevels._content).sort((a, b) => b[1].messages - a[1].messages).slice(0, 10).map((x, i) => `\`${i + 1}.\` <@${x[0]}>: ${x[1].messages.toLocaleString('en-US')}`).join('\n')})
.setImage('attachment://dailymsgs.png') .setImage('attachment://dailymsgs.png').setColor(client.config.embedColor)
.setColor(client.config.embedColor)
interaction.reply({embeds: [embed], files: [yeahok]}); interaction.reply({embeds: [embed], files: [yeahok]});
return; return;
} else if (subCmd === "view") { } else if (subCmd === "view") {

View File

@ -43,17 +43,18 @@ client.on('ready', async()=>{
}) })
// Handle errors // Handle errors
process.on('unhandledRejection', async(error: Error)=>{ function DZ(error:Error){
console.log(error); console.log(error);
(client.channels.resolve(client.config.mainServer.channels.errors) as Discord.TextChannel).send({embeds: [new client.embed().setColor('#420420').setTitle('Error caught!').setDescription(`**Error:** \`${error.message}\`\n\n**Stack:** \`${`${error.stack}`.slice(0, 2500)}\``)]}) (client.channels.resolve(client.config.mainServer.channels.errors) as Discord.TextChannel).send({embeds: [new client.embed().setColor('#EC5254').setTitle('Error caught!').setDescription(`**Error:** \`${error.message}\`\n\n**Stack:** \`${`${error.stack}`.slice(0, 2500)}\``)]})
}
process.on('unhandledRejection', async(error: Error)=>{
DZ(error)
}); });
process.on('uncaughtException', async(error: Error)=>{ process.on('uncaughtException', async(error: Error)=>{
console.log(error); DZ(error)
(client.channels.resolve(client.config.mainServer.channels.errors) as Discord.TextChannel).send({embeds: [new client.embed().setColor('#420420').setTitle('Error caught!').setDescription(`**Error:** \`${error.message}\`\n\n**Stack:** \`${`${error.stack}`.slice(0, 2500)}\``)]})
}); });
process.on('error', async(error: Error)=>{ process.on('error', async(error: Error)=>{
console.log(error); DZ(error)
(client.channels.resolve(client.config.mainServer.channels.errors) as Discord.TextChannel).send({embeds: [new client.embed().setColor('#420420').setTitle('Error caught!').setDescription(`**Error:** \`${error.message}\`\n\n**Stack:** \`${`${error.stack}`.slice(0, 2500)}\``)]})
}); });
// Daggerwin MP loop // Daggerwin MP loop
@ -164,7 +165,7 @@ setInterval(async()=>{
}); });
const formattedDate = Math.floor((now - lrsStart)/1000/60/60/24); const formattedDate = Math.floor((now - lrsStart)/1000/60/60/24);
const dailyMsgs = require('./database/dailyMsgs.json'); const dailyMsgs = JSON.parse(fs.readFileSync(__dirname + '/database/dailyMsgs.json', {encoding: 'utf8'}))
if (!dailyMsgs.some((x:Array<number>)=>x[0] === formattedDate)){ if (!dailyMsgs.some((x:Array<number>)=>x[0] === formattedDate)){
let total = Object.values<UserLevels>(client.userLevels._content).reduce((a,b)=>a + b.messages, 0); // sum of all users let total = Object.values<UserLevels>(client.userLevels._content).reduce((a,b)=>a + b.messages, 0); // sum of all users
const yesterday = dailyMsgs.find((x:Array<number>)=>x[0] === formattedDate - 1); const yesterday = dailyMsgs.find((x:Array<number>)=>x[0] === formattedDate - 1);