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

more progress, main bot when

This commit is contained in:
AnxietyisReal 2022-11-19 14:23:33 +11:00
parent 4a9e3be205
commit b1b48e38de
11 changed files with 171 additions and 63 deletions

View File

@ -2,10 +2,10 @@
TypeScript-based Daggerbot converted from JavaScript at [SpaceManBuzz/DaggerBot-](https://github.com/SpaceManBuzz/DaggerBot-)
### Todo list:
- [ ] Development
- [x] Development
- [x] Prepare repository
- [x] Install TypeScript dependencies and tools
- [ ] Convert JS files to TS one by one
- [x] Convert JS files to TS one by one
- [x] Plz work
- [ ] Production
- [ ] Deploy bot

View File

@ -47,7 +47,7 @@ export class TClient extends Client {
this.tokens = require('./tokens.json');
this.YTCache = {
'UCQ8k8yTDLITldfWYKDs3xFg': undefined, // Daggerwin
'UCguI73--UraJpso4NizXNzA': undefined // Machinery Restorer
'UCguI73--UraJpso4NizXNzA': undefined, // Machinery Restorer
}
this.embed = Discord.EmbedBuilder;
this.collection = Discord.Collection;
@ -182,7 +182,6 @@ 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');
const time = interaction.options.getString('time') as string;
const reason = interaction.options.getString('reason') ?? 'Reason unspecified';
if (type == 'ban'){
@ -201,7 +200,6 @@ export class TClient extends Client {
if (!client.isStaff(interaction.member as Discord.GuildMember)) return this.youNeedRole(interaction, 'dcmod');
const punishment = this.punishments._content.find((x:Punishment)=>x.id === interaction.options.getInteger('case_id'));
if (!punishment) return interaction.reply({content: 'Invalid Case #', ephemeral: true});
//if (type !== ('warn' || 'mute') && (interaction.member as Discord.GuildMember).roles.cache.has(client.config.mainServer.roles.idk)) return this.youNeedRole(interaction, 'dcmod');
const reason = interaction.options.getString('reason') ?? 'Reason unspecified';
const unpunishResult = await this.punishments.removePunishment(punishment.id, interaction.user.id, reason);
interaction.reply(unpunishResult)
@ -226,7 +224,7 @@ export class TClient extends Client {
return;
}
if (Data.feed.entry[1]['yt:videoId']._text == this.YTCache[YTChannelID]){
this.YTCache[YTChannelID] = Data.feed.entry[0]['yt:videoId']._text
this.YTCache[YTChannelID] = Data.feed.entry[0]['yt:videoId']._text;
(this.channels.resolve(DCChannelID) as Discord.TextChannel).send(`**${YTChannelName}** just uploaded a video!\n${Data.feed.entry[0].link._attributes.href}`)
}
}

View File

@ -0,0 +1,18 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import { TClient } from 'src/client';
export default {
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
if (!client.isStaff(interaction.member) && !client.config.eval.whitelist.includes(interaction.member.id)) return client.youNeedRole(interaction, 'dcmod')
const word = interaction.options.getString('word');
if (client.bannedWords._content.includes(word)) return interaction.reply({content: 'That word is already added to the list.', ephemeral: true});
client.bannedWords.addData(word).forceSave();
interaction.reply(`Successfully added \`${word}\` to the list.`)
},
data: new SlashCommandBuilder()
.setName('addbannedword')
.setDescription('Add a word to bannedWords file')
.addStringOption((opt)=>opt
.setName('word')
.setDescription('What word do you want automod to ban?')
.setRequired(true))
}

View File

@ -30,12 +30,12 @@ export default {
interaction.reply({embeds: [embed]});
} else {
// if caseid is user id, show their punishment history sorted by most recent.
const userId = (interaction.options.getUser('user') as Discord.User).id;
const userName = (interaction.options.getUser('user') as Discord.User).username;
const punishment = client.punishments._content.find((x:Punishment)=>x.member===userId);
if (!punishment) return interaction.reply(`<@${userId}> has a clean record.`)
const user = (interaction.options.getUser('user') as Discord.User);
if (user.bot) return interaction.reply(`<@${user.id}>'s punishment history cannot be viewed.`)
const punishment = client.punishments._content.find((x:Punishment)=>x.member===user.id);
if (!punishment) return interaction.reply(`<@${user.id}> has a clean record.`)
const cancels = punishment.cancels ? client.punishments._content.find((x:Punishment)=>x.id==punishment.cancels) : null;
const userPunishment = client.punishments._content.filter((x:Punishment)=>x.member==userId).sort((a:Punishment,b:Punishment)=>a.time-b.time).map((punishment:Punishment)=>{
const userPunishment = client.punishments._content.filter((x:Punishment)=>x.member==user.id).sort((a:Punishment,b:Punishment)=>a.time-b.time).map((punishment:Punishment)=>{
return {
name: `${client.formatPunishmentType(punishment, client, cancels)} | Case #${punishment.id}`,
value: `Reason: \`${punishment.reason}\`\n${punishment.duration ? `Duration: ${client.formatTime(punishment.duration, 3)}\n` : ''}Moderator: <@${punishment.moderator}>${punishment.expired ? `\nOverwritten by case #${client.punishments._content.find((x:Punishment)=>x.cancels==punishment.id).id}` : ''}${punishment.cancels ? `\nOverwrites case #${punishment.cancels}` : ''}`
@ -45,7 +45,7 @@ export default {
if (!userPunishment || userPunishment.length == 0) return interaction.reply('No punishments found for that case # or User ID');
const pageNum = interaction.options.getInteger('page') ?? 1;
const embed = new client.embed().setColor(client.config.embedColor).setTitle(`${userName}'s punishment history`).setDescription(`**ID:** \`${userId}\``).setFooter({text: `${userPunishment.length} total punishments. Viewing page ${pageNum} out of ${Math.ceil(userPunishment.length/6)}.`}).addFields(userPunishment.slice((pageNum - 1) * 6, pageNum * 6));
const embed = new client.embed().setColor(client.config.embedColor).setTitle(`${user.username}'s punishment history`).setDescription(`**ID:** \`${user.id}\``).setFooter({text: `${userPunishment.length} total punishments. Viewing page ${pageNum} out of ${Math.ceil(userPunishment.length/6)}.`}).addFields(userPunishment.slice((pageNum - 1) * 6, pageNum * 6));
return interaction.reply({embeds: [embed]});
}
},

File diff suppressed because one or more lines are too long

View File

@ -1 +1,79 @@
["fuck","fck","fů","fuk","fúck","fùck","fûck","fück","fūck","fůck","fűck","fùçk","fûćk","fucking","fųck","shit","shite","sht","shìt","shít","shît","shït","shīt","shįt","shıt","shlt","whore","pelotudo","boludo","nigger","nigga","nigs","niggas@","cunt","cnut","bitch","dick","pussy","asshole","b1tch","b!tch","blowjob","cock","c0ck","retard","fag","faggot","tits","boobs","dick","sex","porn","bjob","stfu","","­","͏","͏","؜","","","","","","","","stfu","ass","kkk","<@1011334031478100099>","<@468835415093411861>","asf","af","wtf","piss","pissed"]
[
"fuck",
"fck",
"fů",
"fuk",
"fúck",
"fùck",
"fûck",
"fück",
"fūck",
"fůck",
"fűck",
"fùçk",
"fûćk",
"fucking",
"fųck",
"shit",
"shite",
"sht",
"shìt",
"shít",
"shît",
"shït",
"shīt",
"shįt",
"shıt",
"shlt",
"whore",
"pelotudo",
"boludo",
"nigger",
"nigga",
"nigs",
"niggas@",
"cunt",
"cnut",
"bitch",
"dick",
"pussy",
"asshole",
"b1tch",
"b!tch",
"blowjob",
"cock",
"c0ck",
"retard",
"fag",
"faggot",
"tits",
"boobs",
"dick",
"sex",
"porn",
"bjob",
"stfu",
"",
"­",
"͏",
"͏",
"؜",
"",
"",
"",
"",
"",
"",
"",
"stfu",
"ass",
"kkk",
"<@1011334031478100099>",
"<@468835415093411861>",
"asf",
"af",
"wtf",
"piss",
"pissed",
"pussys"
]

View File

@ -1,22 +1,22 @@
{
"190407856527376384": {
"messages": 53027,
"messages": 53029,
"level": 59
},
"593696856165449749": {
"messages": 51469,
"messages": 51488,
"level": 58
},
"141304507249197057": {
"messages": 67635,
"messages": 67637,
"level": 67
},
"533707949831487488": {
"messages": 57043,
"messages": 57046,
"level": 61
},
"532662366354276352": {
"messages": 33790,
"messages": 33796,
"level": 47
},
"824043915539513406": {
@ -24,7 +24,7 @@
"level": 35
},
"178941218510602240": {
"messages": 6399,
"messages": 6405,
"level": 20
},
"215497515934416896": {
@ -32,7 +32,7 @@
"level": 46
},
"301350210926280704": {
"messages": 14346,
"messages": 14348,
"level": 30
},
"695323013813633076": {
@ -40,11 +40,11 @@
"level": 30
},
"389237487094071337": {
"messages": 12257,
"messages": 12259,
"level": 28
},
"716355511552966737": {
"messages": 9146,
"messages": 9148,
"level": 24
},
"633345781780185099": {
@ -64,11 +64,11 @@
"level": 18
},
"458688902102908928": {
"messages": 6237,
"messages": 6239,
"level": 20
},
"475037861725339649": {
"messages": 10207,
"messages": 10212,
"level": 26
},
"392699530912727041": {
@ -76,11 +76,11 @@
"level": 18
},
"468837263577579524": {
"messages": 7698,
"messages": 7712,
"level": 22
},
"734703851558535188": {
"messages": 20224,
"messages": 20225,
"level": 36
},
"488683638310043677": {
@ -92,7 +92,7 @@
"level": 39
},
"322835877027905547": {
"messages": 10021,
"messages": 10024,
"level": 25
},
"485793265568841728": {
@ -156,7 +156,7 @@
"level": 30
},
"472809522226790420": {
"messages": 2776,
"messages": 2784,
"level": 13
},
"763803832542035978": {
@ -164,7 +164,7 @@
"level": 6
},
"931816463113814066": {
"messages": 674,
"messages": 680,
"level": 6
},
"958108557503524904": {
@ -228,7 +228,7 @@
"level": 2
},
"645342896312156181": {
"messages": 699,
"messages": 703,
"level": 6
},
"488505753133645826": {
@ -236,11 +236,11 @@
"level": 0
},
"313461397457600512": {
"messages": 80,
"messages": 81,
"level": 2
},
"848489550065827850": {
"messages": 44,
"messages": 45,
"level": 1
},
"862138850423472128": {
@ -280,7 +280,7 @@
"level": 0
},
"509374532109336576": {
"messages": 31,
"messages": 32,
"level": 1
},
"464887328138199042": {
@ -368,8 +368,8 @@
"level": 0
},
"728486240818823210": {
"messages": 69,
"level": 0
"messages": 71,
"level": 2
},
"837811093010645033": {
"messages": 5,
@ -488,7 +488,7 @@
"level": 0
},
"834893094083362878": {
"messages": 6,
"messages": 7,
"level": 0
},
"870322903160332348": {
@ -552,7 +552,7 @@
"level": 0
},
"676167254055976970": {
"messages": 1,
"messages": 3,
"level": 0
},
"987844984596222002": {
@ -676,7 +676,7 @@
"level": 0
},
"877581891379818517": {
"messages": 4,
"messages": 6,
"level": 0
},
"668496807655112705": {
@ -1472,7 +1472,7 @@
"level": 0
},
"889624632724963329": {
"messages": 54,
"messages": 56,
"level": 1
},
"687692546314600530": {
@ -1568,7 +1568,7 @@
"level": 0
},
"712251385495814165": {
"messages": 4,
"messages": 9,
"level": 0
},
"922822659232894976": {
@ -1724,7 +1724,7 @@
"level": 0
},
"796040852400635914": {
"messages": 396,
"messages": 398,
"level": 5
},
"1011307308325818438": {
@ -1740,7 +1740,7 @@
"level": 0
},
"673289306424475659": {
"messages": 129,
"messages": 130,
"level": 2
},
"907163452043305000": {
@ -1924,7 +1924,7 @@
"level": 0
},
"813866707365265419": {
"messages": 119,
"messages": 120,
"level": 2
},
"726188513518813275": {
@ -2024,7 +2024,7 @@
"level": 0
},
"297087556116414465": {
"messages": 17,
"messages": 18,
"level": 1
},
"442373422975156235": {
@ -2320,7 +2320,7 @@
"level": 0
},
"1029465066174677132": {
"messages": 12,
"messages": 13,
"level": 0
},
"387345064927428611": {
@ -2340,7 +2340,7 @@
"level": 0
},
"938332923042598933": {
"messages": 2,
"messages": 3,
"level": 0
},
"719181129390751755": {
@ -2544,7 +2544,7 @@
"level": 0
},
"697953686487564348": {
"messages": 128,
"messages": 130,
"level": 2
},
"664233182941413427": {
@ -2592,7 +2592,7 @@
"level": 0
},
"340587045250531358": {
"messages": 90,
"messages": 91,
"level": 2
},
"911709434554777660": {
@ -2700,7 +2700,7 @@
"level": 0
},
"995622955897864272": {
"messages": 98,
"messages": 99,
"level": 2
},
"153323923633733632": {
@ -2790,5 +2790,17 @@
"288711706535002125": {
"messages": 1,
"level": 0
},
"747818593202470982": {
"messages": 1,
"level": 0
},
"748545364570800229": {
"messages": 2,
"level": 0
},
"981739292965634189": {
"messages": 3,
"level": 0
}
}

View File

@ -13,12 +13,10 @@ export default {
);
channel.send({embeds: [embed]})
}
/*
todo: role update
- howtobasic the nonexistent '._roles'
const newRoles = newMember._roles.filter(x=>!oldMember._roles.some(y=>y==x));
const oldRoles = oldMember._roles.filter(x=>!newMember._roles.some(y=>y==x));
const newRoles = newMember.roles.cache.map((x,i)=>i).filter(x=>!oldMember.roles.cache.map((x,i)=>i).some(y=>y==x));
const oldRoles = oldMember.roles.cache.map((x,i)=>i).filter(x=>!newMember.roles.cache.map((x,i)=>i).some(y=>y==x));
if (newRoles.length == 0 && oldRoles.length == 0) return;
const embed = new client.embed().setColor(client.config.embedColor).setThumbnail(newMember.user.displayAvatarURL({size: 2048})).setTitle(`Role updated: ${newMember.user.tag}`).setDescription(`<@${newMember.user.id}>\n\`${newMember.user.id}\``)
if (newRoles.length != 0){
embed.addFields({name: '🔹 Role added', value: newRoles.map((x)=>`<@&${x}>`).join(' ')})
@ -27,6 +25,5 @@ export default {
embed.addFields({name: '🔹 Role removed', value: oldRoles.map((x)=>`<@&${x}>`).join(' ')})
}
channel.send({embeds: [embed]})
*/
}
}

View File

@ -15,7 +15,7 @@ export default {
commandFile.uses ? commandFile.uses++ : commandFile.uses = 1;
} catch (error:any){
console.log(`\x1b[31mAn error occured while running command "${commandFile.name}"`, error, error.stack);
return interaction.reply('An error occured while executing this command.');
return interaction.reply('An error occured while executing that command.');
}
}
}

View File

@ -18,7 +18,9 @@ export default {
if (client.bannedWords._content.some((x)=>msgarr.includes(x)) && !message.member.roles.cache.has(client.config.mainServer.roles.dcmod) && message.guildId == client.config.mainServer.id && !Whitelist.includes(message.channelId) && client.config.botSwitches.automod){
automodded = true;
message.delete();
message.delete().catch((err)=>{
console.log('bannedWords automod; msg got possibly deleted by another bot or moderator.')
})
message.channel.send('That word is banned here.').then((x)=>setTimeout(()=>x.delete(), 5000));
if (client.repeatedMessages[message.author.id]){
// add this message to the list
@ -55,7 +57,9 @@ export default {
}
if (message.content.toLowerCase().includes('discord.gg/') && !message.member.roles.cache.has(client.config.mainServer.roles.dcmod)) {
automodded = true;
message.delete();
message.delete().catch((err)=>{
console.log('advertisement automod; msg got possibly deleted by another bot or moderator.')
})
}
if (message.guildId == client.config.mainServer.id && !automodded){

View File

@ -36,15 +36,15 @@ client.on('ready', async()=>{
// Handle errors
process.on('unhandledRejection', 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)}\``)]})
(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('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)}\``)]})
(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)=>{
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('#420420').setTitle('Error caught!').setDescription(`**Error:** \`${error.message}\`\n\n**Stack:** \`${`${error.stack}`.slice(0, 2500)}\``)]})
});
// Daggerwin MP loop
@ -134,6 +134,7 @@ setInterval(async()=>{
setInterval(async()=>{
client.YTLoop('UCQ8k8yTDLITldfWYKDs3xFg', 'Daggerwin', '904192878140608563'); // 528967918772551702 = #videos-and-streams
client.YTLoop('UCguI73--UraJpso4NizXNzA', 'Machinery Restorer', '767444045520961567') // 767444045520961567 = #machinery-restorer
console.log(`[${client.moment().format('DD/MM/YY HH:mm:ss')}] YTLoop interval`)
}, 300000)
// Event loop for punishments and daily msgs