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:
parent
b38c3242b2
commit
5cd65cc23c
@ -12,6 +12,8 @@ let importconfig:Config
|
||||
try{
|
||||
importconfig = require('./DB-Beta.config.json')
|
||||
console.log('Using development config : Daggerbot Beta')
|
||||
//importconfig = require('./Toast-Testbot.config.json')
|
||||
//console.log('Using development config : Toast-Testbot')
|
||||
} catch(e){
|
||||
importconfig = require('./config.json')
|
||||
console.log('Using production config')
|
||||
|
12
src/commands/randomcolor.ts
Normal file
12
src/commands/randomcolor.ts
Normal 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')
|
||||
}
|
@ -138,12 +138,10 @@ export default {
|
||||
ctx.fillText('time ->', tx, ty);
|
||||
|
||||
const yeahok = new client.attachmentBuilder(img.toBuffer(), {name: 'dailymsgs.png'})
|
||||
const embed = new client.embed()
|
||||
.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.`)
|
||||
const embed = new client.embed().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>`)
|
||||
.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')
|
||||
.setColor(client.config.embedColor)
|
||||
.setImage('attachment://dailymsgs.png').setColor(client.config.embedColor)
|
||||
interaction.reply({embeds: [embed], files: [yeahok]});
|
||||
return;
|
||||
} else if (subCmd === "view") {
|
||||
|
15
src/index.ts
15
src/index.ts
@ -43,17 +43,18 @@ client.on('ready', async()=>{
|
||||
})
|
||||
|
||||
// Handle errors
|
||||
process.on('unhandledRejection', async(error: Error)=>{
|
||||
function DZ(error: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)=>{
|
||||
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)}\``)]})
|
||||
DZ(error)
|
||||
});
|
||||
process.on('error', async(error: 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)}\``)]})
|
||||
DZ(error)
|
||||
});
|
||||
|
||||
// Daggerwin MP loop
|
||||
@ -164,7 +165,7 @@ setInterval(async()=>{
|
||||
});
|
||||
|
||||
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)){
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user