mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 12:21:00 -05:00
Improve areas of the bot and update deps & faq
This commit is contained in:
parent
8ffb0072a5
commit
fc7746eb01
10
package.json
10
package.json
@ -24,18 +24,18 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "1.2.1",
|
||||
"canvas": "2.10.2",
|
||||
"canvas": "2.11.0",
|
||||
"discord.js": "14.7.1",
|
||||
"moment": "2.29.4",
|
||||
"ms": "2.1.3",
|
||||
"sequelize": "6.26.0",
|
||||
"sqlite3": "5.1.2",
|
||||
"systeminformation": "5.16.4",
|
||||
"sequelize": "6.28.0",
|
||||
"sqlite3": "5.1.4",
|
||||
"systeminformation": "5.16.9",
|
||||
"typescript": "4.9.4",
|
||||
"xml-js": "1.6.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "18.11.12",
|
||||
"@types/node": "18.11.18",
|
||||
"ts-node": "10.9.1"
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ export default {
|
||||
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
|
||||
const options = interaction.options.getString('question')
|
||||
if (options == 'srp'){
|
||||
const embed = new client.embed().setColor(client.config.embedColor).setTitle('When will SRP (Survival Roleplay) return?').setImage('https://cdn.discordapp.com/attachments/898252602603610142/1013097505094893698/Screenshot_20220827-153617_YouTube.jpg');
|
||||
const embed = new client.embed().setColor(client.config.embedColor).setTitle('When will SRP (Survival Roleplay) return?').setImage('https://cdn.discordapp.com/attachments/1023338018720989305/1059259250242752562/IMG_8964.png');
|
||||
interaction.reply({embeds: [embed]})
|
||||
} else if (options == 'dlskin'){
|
||||
const embed1 = new client.embed().setColor(client.config.embedColor).setTitle('Hex code for Daggerwin Logistics').setDescription('The main color will be Onyx (`#353839`) with red bumpers').setImage('https://cdn.discordapp.com/attachments/801965516947324969/806871878736019456/image0.png');
|
||||
|
@ -3,8 +3,11 @@ import { TClient } from '../client';
|
||||
export default {
|
||||
name: 'guildMemberAdd',
|
||||
execute: async(client:TClient, member:Discord.GuildMember)=>{
|
||||
if (member.partial) return;
|
||||
if (member.guild?.id != client.config.mainServer.id) return;
|
||||
//if (member.partial) return;
|
||||
if (
|
||||
member.partial
|
||||
|| member.guild?.id != client.config.mainServer.id
|
||||
) return;
|
||||
const index = member.guild.memberCount;
|
||||
const suffix = ((index)=>{
|
||||
const numbers = index.toString().split('').reverse(); // eg 1850 --> [0,5,8,1]
|
||||
|
@ -4,8 +4,11 @@ export default {
|
||||
name: 'guildMemberRemove',
|
||||
execute: async(client:TClient, member:Discord.GuildMember)=>{
|
||||
if (!client.config.botSwitches.logs) return;
|
||||
if (!member.joinedTimestamp) return;
|
||||
if (member.guild?.id != client.config.mainServer.id) return;
|
||||
if (
|
||||
!member.joinedTimestamp
|
||||
|| member.guild?.id != client.config.mainServer.id
|
||||
) return;
|
||||
// if (member.guild?.id != client.config.mainServer.id) return;
|
||||
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048}) as string).setTitle(`Member Left: ${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: '🔹 Server Join Date', value: `<t:${Math.round(member.joinedTimestamp/1000)}>\n<t:${Math.round(member.joinedTimestamp/1000)}:R>`},
|
||||
|
@ -7,9 +7,8 @@ export default {
|
||||
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} 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 (!client.config.botSwitches.commands && !client.config.eval.whitelist.includes(interaction.user.id)) return interaction.reply({content: 'Bot is currently being run in development mode.', ephemeral: true});
|
||||
if (commandFile){
|
||||
if (commandFile.disabled) return interaction.reply({content: 'This command is currently disabled.', ephemeral: true});
|
||||
try{
|
||||
commandFile.default.run(client, interaction);
|
||||
commandFile.uses ? commandFile.uses++ : commandFile.uses = 1;
|
||||
|
@ -3,8 +3,11 @@ import { TClient } from '../client';
|
||||
export default {
|
||||
name: 'messageCreate',
|
||||
execute: async(client:TClient, message:Discord.Message)=>{
|
||||
if (message.author.bot) return;
|
||||
if (message.channel.type === ChannelType.DM) return;
|
||||
if (
|
||||
message.author.bot
|
||||
|| message.channel.type === ChannelType.DM
|
||||
) return;
|
||||
// if (message.channel.type === ChannelType.DM) return;
|
||||
const msgarr = message.content.toLowerCase().split(' ');
|
||||
let automodded: boolean;
|
||||
|
||||
@ -149,10 +152,9 @@ export default {
|
||||
if (NightArray.some(e=>message.content.toLowerCase().startsWith(e))){
|
||||
message.reply(`Night **${message.member.displayName}**`)
|
||||
}
|
||||
|
||||
// Failsafe thingy (Toastproof maybe)
|
||||
if (message.content.startsWith('!!!_wepanikfrfr') && client.config.eval.whitelist.includes(message.author.id)){
|
||||
client.application.commands.set(client.registry);
|
||||
message.reply({content: 'How could you manage to lose the commands??? Anyways, it\'s re-registered now.'})
|
||||
(client.guilds.cache.get(message.guildId) as Discord.Guild).commands.set(client.registry).then(()=>message.reply('How did you manage to lose the commands??? Anyways, it\'s re-registered now.')).catch((e:Error)=>message.reply(`Failed to deploy slash commands:\n\`\`\`${e.message}\`\`\``));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,18 @@ export default {
|
||||
execute: async(client:TClient, msg:Discord.Message)=>{
|
||||
if (!client.config.botSwitches.logs) return;
|
||||
const channel = client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel;
|
||||
const disabledChannels = ['548032776830582794', '541677709487505408']
|
||||
if (msg.guild?.id != client.config.mainServer.id) return;
|
||||
if (msg.partial) return;
|
||||
if (msg.author.bot) return;
|
||||
if (disabledChannels.includes(msg.channelId)) return;
|
||||
const disabledChannels = [
|
||||
'548032776830582794', '541677709487505408'
|
||||
]
|
||||
if (
|
||||
msg.guild?.id != client.config.mainServer.id
|
||||
|| msg.partial
|
||||
|| msg.author.bot
|
||||
|| disabledChannels.includes(msg.channelId)
|
||||
) return;
|
||||
// if (msg.partial) return;
|
||||
// if (msg.author.bot) return;
|
||||
// if (disabledChannels.includes(msg.channelId)) return;
|
||||
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setAuthor({name: `Author: ${msg.author.tag} (${msg.author.id})`, iconURL: `${msg.author.displayAvatarURL()}`}).setTitle('Message deleted').setDescription(`<@${msg.author.id}>\n\`${msg.author.id}\``);
|
||||
if (msg.content.length != 0) embed.addFields({name: 'Content', value: `\`\`\`\n${msg.content.slice(0,1000)}\n\`\`\``});
|
||||
embed.addFields(
|
||||
|
@ -4,14 +4,24 @@ export default {
|
||||
name: 'messageUpdate',
|
||||
execute: async(client:TClient, oldMsg:Discord.Message, newMsg:Discord.Message)=>{
|
||||
if (!client.config.botSwitches.logs) return;
|
||||
const disabledChannels = ['548032776830582794', '541677709487505408']
|
||||
if (oldMsg.guild?.id != client.config.mainServer.id) return;
|
||||
if (oldMsg.author == null) return;
|
||||
if (oldMsg?.author.bot) return;
|
||||
if (oldMsg.partial) return;
|
||||
if (newMsg.partial) return;
|
||||
if (!newMsg.member) return;
|
||||
if (disabledChannels.includes(newMsg.channelId)) return;
|
||||
const disabledChannels = [
|
||||
'548032776830582794', '541677709487505408'
|
||||
]
|
||||
if (
|
||||
oldMsg.guild?.id != client.config.mainServer.id
|
||||
|| oldMsg.author == null
|
||||
|| oldMsg?.author.bot
|
||||
|| oldMsg.partial
|
||||
|| newMsg.partial
|
||||
|| !newMsg.member
|
||||
|| disabledChannels.includes(newMsg.channelId)
|
||||
) return;
|
||||
// if (oldMsg.author == null) return;
|
||||
// if (oldMsg?.author.bot) return;
|
||||
// if (oldMsg.partial) return;
|
||||
// if (newMsg.partial) return;
|
||||
// if (!newMsg.member) return;
|
||||
// if (disabledChannels.includes(newMsg.channelId)) return;
|
||||
const msgarr = newMsg.content.toLowerCase().split(' ');
|
||||
if (client.bannedWords._content.some((word:string)=>msgarr.includes(word)) && (!client.isStaff(newMsg.member))) newMsg.delete();
|
||||
if (newMsg.content === oldMsg.content) return;
|
||||
|
13
src/index.ts
13
src/index.ts
@ -9,10 +9,17 @@ import {Punishment, UserLevels, FSData, FSCareerSavegame} from './typings/interf
|
||||
client.on('ready', async()=>{
|
||||
client.guilds.cache.forEach(async(e)=>{await e.members.fetch()});
|
||||
setInterval(async()=>{
|
||||
client.user.setPresence({activities: [{ name: 'Happy new year!', type: 1, url: 'https://www.youtube.com/watch?v=KY1N-ZYe8xA' }], status: 'online'});
|
||||
client.user.setPresence({activities: [{ name: '#general-chat', type: 1, url: 'https://www.youtube.com/watch?v=nhB5WoUYQbc' }], status: 'idle'});
|
||||
// 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.application.commands.set(client.registry).catch((e)=>{console.log(`Couldn't register slash commands: ${e}`)})
|
||||
// ['929807948748832798', '468835415093411861', '1058183358267543552', '549114074273677314'] - 0=Dev Server, 1=Main Server, 2=Throne, 3=Toast's test server
|
||||
if (client.config.botSwitches.registerCommands){
|
||||
['929807948748832798', '468835415093411861', '1058183358267543552'].forEach((guildId)=>(client.guilds.cache.get(guildId) as Discord.Guild).commands.set(client.registry).catch((e:Error)=>{
|
||||
console.log(`Couldn't register slash commands for ${guildId} because`, e.stack);
|
||||
(client.channels.resolve(client.config.mainServer.channels.errors) as Discord.TextChannel).send(`Cannot register slash commands for **${client.guilds.cache.get(guildId).name}** (\`${guildId}\`):\n\`\`\`${e.message}\`\`\``)
|
||||
}));
|
||||
};
|
||||
|
||||
setInterval(()=>{
|
||||
const guild = client.guilds.cache.get(client.config.mainServer.id) as Discord.Guild;
|
||||
guild.invites.fetch().then((invs)=>{
|
||||
@ -164,6 +171,6 @@ setInterval(async()=>{
|
||||
dailyMsgs.push([formattedDate, total]);
|
||||
fs.writeFileSync(__dirname + '/database/dailyMsgs.json', JSON.stringify(dailyMsgs))
|
||||
console.log(`[${client.moment().format('DD/MM/YY HH:mm:ss')}]`, `Pushed [${formattedDate}, ${total}] to dailyMsgs`);
|
||||
client.application.commands.fetch().then((commands)=>(client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send(`:pencil: Pushed \`[${formattedDate}, ${total}]\` to </rank leaderboard:${commands.find(x=>x.name == 'rank').id}>`))
|
||||
client.application.commands.fetch().then((commands)=>(client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send(`:pencil: Pushed \`[${formattedDate}, ${total}]\` to </rank leaderboard:${commands.find(x=>x.name == 'rank').id}>`).catch((e)=>{(client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send(`:pencil: Pushed \`[${formattedDate}, ${total}]\` to dailyMsgs`)}))
|
||||
}
|
||||
}, 5000)
|
||||
|
Loading…
Reference in New Issue
Block a user