mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 04:10:59 -05:00
700th commit, add new dev subcmd.
This commit is contained in:
parent
9516c7b098
commit
bbef3da0cc
@ -122,6 +122,22 @@ export default class Developer {
|
|||||||
const message = interaction.options.getString('message');
|
const message = interaction.options.getString('message');
|
||||||
const int = await interaction.reply({content: '*Sending...*', fetchReply: true});
|
const int = await interaction.reply({content: '*Sending...*', fetchReply: true});
|
||||||
client.users.cache.get(member.id).send(`${message}\n╰ ${interaction.member.displayName}`).then(()=>int.edit(`Successfully sent a DM to **${member.user.username}** with the following message:\n\`\`\`${message}\`\`\``)).catch((e:Error)=>int.edit(`\`${e.message}\``))
|
client.users.cache.get(member.id).send(`${message}\n╰ ${interaction.member.displayName}`).then(()=>int.edit(`Successfully sent a DM to **${member.user.username}** with the following message:\n\`\`\`${message}\`\`\``)).catch((e:Error)=>int.edit(`\`${e.message}\``))
|
||||||
|
},
|
||||||
|
modify_rank_msgs: async()=>{
|
||||||
|
const member = interaction.options.getMember('member');
|
||||||
|
const messages = interaction.options.getInteger('new-messages-count');
|
||||||
|
const oldData = await client.userLevels.fetchUser(member.id);
|
||||||
|
const newData = await client.userLevels.modifyUser(member.id, messages);
|
||||||
|
await interaction.reply({embeds:[new client.embed()
|
||||||
|
.setColor(client.config.embedColorGreen)
|
||||||
|
.setDescription(MessageTool.concatMessage(
|
||||||
|
`Successfully modified the messages count of **${member.displayName}**`,
|
||||||
|
`╰ Old: **${oldData.dataValues.messages.toLocaleString('en-US')}**`,
|
||||||
|
`╰ New: **${newData.messages.toLocaleString('en-US')}**`,
|
||||||
|
`╰ Difference: **${(newData.messages - oldData.dataValues.messages).toLocaleString('en-US')}**`,
|
||||||
|
'Although if you set the number too high or low, it will have a bigger impact on the leaderboard graph.'
|
||||||
|
))
|
||||||
|
]})
|
||||||
}
|
}
|
||||||
} as any)[interaction.options.getSubcommand()]();
|
} as any)[interaction.options.getSubcommand()]();
|
||||||
}
|
}
|
||||||
@ -190,4 +206,17 @@ export default class Developer {
|
|||||||
.setName('message')
|
.setName('message')
|
||||||
.setDescription('Message to send')
|
.setDescription('Message to send')
|
||||||
.setRequired(true)))
|
.setRequired(true)))
|
||||||
|
.addSubcommand(x=>x
|
||||||
|
.setName('modify_rank_msgs')
|
||||||
|
.setDescription('Modify the messages count of a member')
|
||||||
|
.addUserOption(x=>x
|
||||||
|
.setName('member')
|
||||||
|
.setDescription('Member to modify the messages count of')
|
||||||
|
.setRequired(true))
|
||||||
|
.addIntegerOption(x=>x
|
||||||
|
.setName('new-messages-count')
|
||||||
|
.setDescription('Replace the messages count of the member with this number')
|
||||||
|
.setRequired(true)
|
||||||
|
.setMinValue(5)
|
||||||
|
.setMaxValue(1999999999)))
|
||||||
}
|
}
|
||||||
|
@ -5,18 +5,14 @@ import CanvasBuilder from '../components/CanvasGraph.js';
|
|||||||
export default class Rank {
|
export default class Rank {
|
||||||
static async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
static async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||||
if (interaction.guildId !== client.config.dcServer.id) return interaction.reply({content: 'This command doesn\'t work in this server.', ephemeral: true});
|
if (interaction.guildId !== client.config.dcServer.id) return interaction.reply({content: 'This command doesn\'t work in this server.', ephemeral: true});
|
||||||
// const allData = await client.userLevels._content.find();
|
|
||||||
const allData = await client.userLevels.fetchEveryone();
|
const allData = await client.userLevels.fetchEveryone();
|
||||||
({
|
({
|
||||||
view: async()=>{
|
view: async()=>{
|
||||||
// fetch user or user interaction sender
|
|
||||||
const member = interaction.options.getMember('member') ?? interaction.member as Discord.GuildMember;
|
const member = interaction.options.getMember('member') ?? interaction.member as Discord.GuildMember;
|
||||||
if (member.user.bot) return interaction.reply('Bots don\'t level up, try viewing the rank data from the users instead.');
|
if (member.user.bot) return interaction.reply('Bots don\'t level up, try again with an actual member instead.');
|
||||||
// information about users progress on level roles
|
|
||||||
// const userData = await client.userLevels._content.findById(member.user.id);
|
|
||||||
const userData = await client.userLevels.fetchUser(member.user.id);
|
const userData = await client.userLevels.fetchUser(member.user.id);
|
||||||
|
|
||||||
const pronounBool = (you: string, they: string) => { // takes 2 words and chooses which to use based on if user did this command on themself
|
const pronounBool = (you: string, they: string) => { // takes 2 words and chooses which to use based on if user did this command on themselves
|
||||||
if (interaction.user.id === member.user.id) return you || true;
|
if (interaction.user.id === member.user.id) return you || true;
|
||||||
else return they || false;
|
else return they || false;
|
||||||
};
|
};
|
||||||
@ -26,13 +22,13 @@ export default class Rank {
|
|||||||
const memberDifference = userData.dataValues.messages - client.userLevels.algorithm(userData.dataValues.level);
|
const memberDifference = userData.dataValues.messages - client.userLevels.algorithm(userData.dataValues.level);
|
||||||
const levelDifference = client.userLevels.algorithm(userData.dataValues.level+1) - client.userLevels.algorithm(userData.dataValues.level);
|
const levelDifference = client.userLevels.algorithm(userData.dataValues.level+1) - client.userLevels.algorithm(userData.dataValues.level);
|
||||||
let ptText = 'Ping toggle ';
|
let ptText = 'Ping toggle ';
|
||||||
interaction.reply({embeds: [new client.embed().setColor(member.displayColor).setTitle(`Level: **${userData.dataValues.level}**\nRank: **${index ? '#' + index : 'last'}**\nProgress: **${memberDifference}/${levelDifference} (${(memberDifference/levelDifference*100).toFixed(2)}%)**\nTotal: **${userData.dataValues.messages/* .toLocaleString('en-US') */}**`).setThumbnail(member.avatarURL({extension:'png',size:1024}) || member.user.avatarURL({extension:'png',size:1024}) || member.user.defaultAvatarURL).setFooter({text: userData.pingToggle === true ? ptText += 'enabled' : ptText += 'disabled'})]})
|
interaction.reply({embeds: [new client.embed().setColor(member.displayColor).setTitle(`Level: **${userData.dataValues.level}**\nRank: **${index ? '#' + index : 'last'}**\nProgress: **${memberDifference}/${levelDifference} (${(memberDifference/levelDifference*100).toFixed(2)}%)**\nTotal: **${userData.dataValues.messages.toLocaleString('en-US')}**`).setThumbnail(member.avatarURL({extension:'png',size:1024}) || member.user.avatarURL({extension:'png',size:1024}) || member.user.defaultAvatarURL).setFooter({text: userData.pingToggle === true ? ptText += 'enabled' : ptText += 'disabled'})]})
|
||||||
},
|
},
|
||||||
leaderboard: async()=>{
|
leaderboard: async()=>{
|
||||||
const data = (await client.dailyMsgs.fetchDays()).map(x=>[x.dataValues.day, x.dataValues.total]).sort((a,b)=>a[0]-b[0]).slice(-60).map((x: number[], i: number, a: any)=>{
|
const data = (await client.dailyMsgs.fetchDays()).map(x=>[x.dataValues.day, x.dataValues.total]).sort((a,b)=>a[0]-b[0]).slice(-60).map((x: number[], i: number, a: any)=>{
|
||||||
return x[1] - ((a[i - 1] || [])[1] || x[1])
|
return x[1] - ((a[i - 1] || [])[1] || x[1])
|
||||||
});
|
});
|
||||||
if (data.length < 3) return interaction.reply('Not enough data to generate graph.');
|
if (data.length < 2) return interaction.reply('Not enough data to generate graph.');
|
||||||
|
|
||||||
const graph = await new CanvasBuilder().generateGraph(data, 'leaderboard');
|
const graph = await new CanvasBuilder().generateGraph(data, 'leaderboard');
|
||||||
interaction.reply({
|
interaction.reply({
|
||||||
@ -44,18 +40,18 @@ export default class Rank {
|
|||||||
name: 'Top users sorted by messages sent:',
|
name: 'Top users sorted by messages sent:',
|
||||||
value: allData.sort((a,b)=>b.messages - a.messages).slice(0,15).map((x,i)=>`${i+1}. <@${x.dataValues.id}>: ${x.messages.toLocaleString('en-US')}`).join('\n')
|
value: allData.sort((a,b)=>b.messages - a.messages).slice(0,15).map((x,i)=>`${i+1}. <@${x.dataValues.id}>: ${x.messages.toLocaleString('en-US')}`).join('\n')
|
||||||
}).setImage('attachment://dailyMessages.jpg').setFooter({text: 'Graph updates daily'})],
|
}).setImage('attachment://dailyMessages.jpg').setFooter({text: 'Graph updates daily'})],
|
||||||
files: [new client.attachment(graph.toBuffer(),{name: 'dailyMessages.jpg'})]
|
files: [new client.attachment(graph.toBuffer(), {name: 'dailyMessages.jpg'})]
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
notification: async()=>{
|
notification: async()=>{
|
||||||
const findUserInDatabase = await client.userLevels.fetchUser(interaction.user.id);
|
const findUserInDatabase = await client.userLevels.fetchUser(interaction.user.id);
|
||||||
const textDeco = ' be pinged for level-up notification in the future.'
|
const textDeco = 'be pinged for level-up notifications.'
|
||||||
if (!findUserInDatabase.pingToggle) {
|
if (!findUserInDatabase.pingToggle) {
|
||||||
await findUserInDatabase.update({pingToggle: true}, {where: {id: interaction.user.id}})
|
await findUserInDatabase.update({pingToggle: true}, {where: {id: interaction.user.id}})
|
||||||
interaction.reply({content: 'You will'+textDeco, ephemeral: true})
|
interaction.reply({content: 'You will '+textDeco, ephemeral: true})
|
||||||
} else if (findUserInDatabase.pingToggle) {
|
} else if (findUserInDatabase.pingToggle) {
|
||||||
await findUserInDatabase.update({pingToggle: false}, {where: {id: interaction.user.id}})
|
await findUserInDatabase.update({pingToggle: false}, {where: {id: interaction.user.id}})
|
||||||
interaction.reply({content: 'You won\'t'+textDeco, ephemeral: true})
|
interaction.reply({content: 'You won\'t '+textDeco, ephemeral: true})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} as any)[interaction.options.getSubcommand()]();
|
} as any)[interaction.options.getSubcommand()]();
|
||||||
|
@ -31,10 +31,8 @@ export default class MessageCreate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (message.guildId === client.config.dcServer.id && !automodded) client.userLevels.messageIncremental(message.author.id);
|
if (message.guildId === client.config.dcServer.id && !automodded) client.userLevels.messageIncremental(message.author.id);
|
||||||
// Mop gifs from banned channels without Monster having to mop them.
|
// Mop gifs from banned channels without admins having to mop them.
|
||||||
const bannedChannels = [
|
const bannedChannels = []
|
||||||
'742324777934520350', // #discord-moderators
|
|
||||||
]
|
|
||||||
if (['tenor.com/view', 'giphy.com/gifs', 'giphy.com/media'].some(e=>message.content.toLowerCase().includes(e)) && bannedChannels.includes(message.channelId)) message.reply('Gifs are not allowed in this channel.').then(()=>message.delete())
|
if (['tenor.com/view', 'giphy.com/gifs', 'giphy.com/media'].some(e=>message.content.toLowerCase().includes(e)) && bannedChannels.includes(message.channelId)) message.reply('Gifs are not allowed in this channel.').then(()=>message.delete())
|
||||||
|
|
||||||
// Autoresponse:tm:
|
// Autoresponse:tm:
|
||||||
|
Loading…
Reference in New Issue
Block a user