Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
v1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
iwa authored Aug 14, 2020
2 parents 113fd2e + 08bc25e commit c056e73
Show file tree
Hide file tree
Showing 78 changed files with 683 additions and 252 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,6 @@ build/

# Enmap databases
data/

# Changelog
CHANGELOG.md
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"preLaunchTask": "tsc: build",
"outFiles": [
"${workspaceFolder}/build/**/*.js"
]
],
"outputCapture": "std"
}
]
}
15 changes: 0 additions & 15 deletions CHANGELOG.md

This file was deleted.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kwako",
"version": "1.0.2",
"version": "1.0.3",
"description": "",
"main": "build/index.js",
"scripts": {
Expand All @@ -22,17 +22,22 @@
"@discordjs/opus": "^0.3.2",
"@types/mongodb": "^3.5.18",
"@types/node": "^14.0.27",
"@types/pino": "^6.3.0",
"@types/ws": "^7.2.4",
"anilist-node": "^1.4.0",
"bufferutil": "^4.0.1",
"canvas": "^2.6.1",
"discord.js": "^12.2.0",
"dotenv": "^8.2.0",
"mongodb": "^3.5.8",
"pino": "^6.5.1",
"popyt": "^4.1.1",
"sodium": "^3.0.2",
"timespan-parser": "^1.0.2",
"utf-8-validate": "^5.0.2",
"ytdl-core": "^3.1.2"
},
"devDependencies": {
"pino-pretty": "^4.1.0"
}
}
9 changes: 9 additions & 0 deletions src/Logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import logger from 'pino';

let options: any = { level: 'trace' };
if (process.env.NODE_ENV !== 'production')
options = { level: 'trace', prettyPrint: true };

const log = logger(options);

export default log;
5 changes: 3 additions & 2 deletions src/commands/actions/boop.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Client, Message } from 'discord.js'
import { Db } from 'mongodb'
import actionsRun from '../../utils/actions';
import { Logger } from 'pino';

module.exports.run = (bot: Client, msg: Message, args: string[], db: Db) => {
actionsRun(bot, msg, args, db, 'boop', 'boops', false);
module.exports.run = (bot: Client, msg: Message, args: string[], db: Db, log: Logger) => {
actionsRun(bot, msg, args, db, log, 'boop', 'boops', false);
};

module.exports.help = {
Expand Down
5 changes: 3 additions & 2 deletions src/commands/actions/cry.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Client, Message, MessageEmbed } from 'discord.js'
import utilities from '../../utils/utilities'
import { Logger } from 'pino';

let nbGifs = 9;
let lastGif = 0;

module.exports.run = async (bot: Client, msg: Message) => {
module.exports.run = async (bot: Client, msg: Message, args: any, db: any, log: Logger) => {
const embed = new MessageEmbed();
embed.setColor('#F2DEB0')
embed.setDescription(`**<@${msg.author.id}>** is crying...`)
Expand All @@ -18,7 +19,7 @@ module.exports.run = async (bot: Client, msg: Message) => {

return msg.channel.send(embed)
.then(() => {
console.log(`info: cry by ${msg.author.tag}`);
log.info({msg: 'cry', author: { id: msg.author.id, name: msg.author.tag }, guild: msg.guild.id});
})
.catch(console.error);
};
Expand Down
7 changes: 4 additions & 3 deletions src/commands/actions/facepalm.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { Client, Message, MessageEmbed } from 'discord.js'
import { Logger } from 'pino';

module.exports.run = async (bot: Client, msg: Message) => {
module.exports.run = async (bot: Client, msg: Message, args: any, db: any, log: Logger) => {
const embed = new MessageEmbed();
embed.setColor('#F2DEB0')
embed.setDescription(`**<@${msg.author.id}>**, facepalm!`)
embed.setImage('https://i.imgur.com/zqUDpIk.gif');

return msg.channel.send(embed)
.then(() => {
console.log(`info: facepalm by ${msg.author.tag}`);
log.info({msg: 'facepalm', author: { id: msg.author.id, name: msg.author.tag }, guild: msg.guild.id});
})
.catch(console.error);
.catch(log.error);
};

module.exports.help = {
Expand Down
5 changes: 3 additions & 2 deletions src/commands/actions/glare.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Client, Message } from 'discord.js'
import { Db } from 'mongodb'
import actionsRun from '../../utils/actions';
import { Logger } from 'pino';

module.exports.run = (bot: Client, msg: Message, args: string[], db: Db) => {
actionsRun(bot, msg, args, db, 'glare', 'glares', true);
module.exports.run = (bot: Client, msg: Message, args: string[], db: Db, log: Logger) => {
actionsRun(bot, msg, args, db, log, 'glare', 'glares', true);
};

module.exports.help = {
Expand Down
7 changes: 4 additions & 3 deletions src/commands/actions/highfive.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Client, Message, MessageReaction, User, MessageEmbed } from 'discord.js'
import { Db } from 'mongodb'
import utilities from '../../utils/utilities';
import { Logger } from 'pino';
let lastGif: number = 0, count: number = 9;
let lastGifFail: number = 0, countFail: number = 5;

module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db) => {
module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db, log: Logger) => {
if (msg.mentions.everyone) return;
let mention = msg.mentions.users.first()
if (!mention) return;
Expand Down Expand Up @@ -66,9 +67,9 @@ module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db) =
await db.collection('user').updateOne({ '_id': { $eq: mention.id } }, { $inc: { highfive: 1 } });
return msg.channel.send(embed)
.then(() => {
console.log(`info: highfive`);
log.info({msg: 'highfive', author: { id: msg.author.id, name: msg.author.tag }, guild: msg.guild.id});
})
.catch(console.error);
.catch(log.error);
} else {
let n = utilities.randomInt(countFail)
while (lastGifFail == n)
Expand Down
5 changes: 3 additions & 2 deletions src/commands/actions/hug.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Client, Message } from 'discord.js'
import { Db } from 'mongodb'
import actionsRun from '../../utils/actions';
import { Logger } from 'pino';

module.exports.run = (bot: Client, msg: Message, args: string[], db: Db) => {
actionsRun(bot, msg, args, db, 'hug', 'hugs', false);
module.exports.run = (bot: Client, msg: Message, args: string[], db: Db, log: Logger) => {
actionsRun(bot, msg, args, db, log, 'hug', 'hugs', false);
};

module.exports.help = {
Expand Down
5 changes: 3 additions & 2 deletions src/commands/actions/pat.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Client, Message } from 'discord.js'
import { Db } from 'mongodb'
import actionsRun from '../../utils/actions';
import { Logger } from 'pino';

module.exports.run = (bot: Client, msg: Message, args: string[], db: Db) => {
actionsRun(bot, msg, args, db, 'pat', 'pats', false);
module.exports.run = (bot: Client, msg: Message, args: string[], db: Db, log: Logger) => {
actionsRun(bot, msg, args, db, log, 'pat', 'pats', false);
};

module.exports.help = {
Expand Down
5 changes: 3 additions & 2 deletions src/commands/actions/slap.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Client, Message } from 'discord.js'
import { Db } from 'mongodb'
import actionsRun from '../../utils/actions';
import { Logger } from 'pino';

module.exports.run = (bot: Client, msg: Message, args: string[], db: Db) => {
actionsRun(bot, msg, args, db, 'slap', 'slaps', false);
module.exports.run = (bot: Client, msg: Message, args: string[], db: Db, log: Logger) => {
actionsRun(bot, msg, args, db, log, 'slap', 'slaps', false);
};

module.exports.help = {
Expand Down
5 changes: 3 additions & 2 deletions src/commands/actions/squish.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Client, Message } from 'discord.js'
import { Db } from 'mongodb'
import actionsRun from '../../utils/actions';
import { Logger } from 'pino';

module.exports.run = (bot: Client, msg: Message, args: string[], db: Db) => {
actionsRun(bot, msg, args, db, 'squish', 'squishes', false);
module.exports.run = (bot: Client, msg: Message, args: string[], db: Db, log: Logger) => {
actionsRun(bot, msg, args, db, log, 'squish', 'squishes', false);
};

module.exports.help = {
Expand Down
5 changes: 3 additions & 2 deletions src/commands/actions/tickle.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Client, Message } from 'discord.js'
import { Db } from 'mongodb'
import actionsRun from '../../utils/actions';
import { Logger } from 'pino';

module.exports.run = (bot: Client, msg: Message, args: string[], db: Db) => {
actionsRun(bot, msg, args, db, 'tickle', 'tickles', false);
module.exports.run = (bot: Client, msg: Message, args: string[], db: Db, log: Logger) => {
actionsRun(bot, msg, args, db, log, 'tickle', 'tickles', false);
};

module.exports.help = {
Expand Down
7 changes: 4 additions & 3 deletions src/commands/actions/wave.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Client, Message, MessageEmbed } from 'discord.js'
import utilities from '../../utils/utilities'
import { Logger } from 'pino';

let nbGifs = 6;
let lastGif = 0;

module.exports.run = async (bot: Client, msg: Message) => {
module.exports.run = async (bot: Client, msg: Message, args: any, db: any, log: Logger) => {
const embed = new MessageEmbed();
embed.setColor('#F2DEB0')
embed.setDescription(`**<@${msg.author.id}>** is waving!`)
Expand All @@ -18,9 +19,9 @@ module.exports.run = async (bot: Client, msg: Message) => {

return msg.channel.send(embed)
.then(() => {
console.log(`info: waving by ${msg.author.tag}`);
log.info({msg: 'wave', author: { id: msg.author.id, name: msg.author.tag }, guild: msg.guild.id});
})
.catch(console.error);
.catch(log.error);
};

module.exports.help = {
Expand Down
9 changes: 6 additions & 3 deletions src/commands/config/addembed.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Client, Message } from 'discord.js';
import { Db } from 'mongodb'
import { Logger } from 'pino';

module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db) => {
module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db, log: Logger) => {
if ((!msg.member.hasPermission('MANAGE_GUILD'))) return;
let embed = args.join(' ')
embed = JSON.parse(embed)
Expand All @@ -12,11 +13,13 @@ module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db) =
try {
await msg.delete()
} catch (ex) {
console.error(ex)
log.error(ex)
}
}

await db.collection('msg').insertOne({ _id: (await sent).id, channel: (await sent).channel.id })
await db.collection('msg').insertOne({ _id: sent.id, channel: sent.channel.id })

log.info({msg: 'addembed', author: { id: msg.author.id, name: msg.author.tag }, guild: msg.guild.id})
};

module.exports.help = {
Expand Down
5 changes: 4 additions & 1 deletion src/commands/config/addlevelrole.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Client, Message, Presence } from 'discord.js';
import { Db } from 'mongodb'
import utilities from '../../utils/utilities';
import { Logger } from 'pino';

module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db) => {
module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db, log: Logger) => {
if ((!msg.member.hasPermission('MANAGE_GUILD'))) return;
if (args.length < 2) return;
let guildConf = await db.collection('settings').findOne({ '_id': { $eq: msg.guild.id } });
Expand Down Expand Up @@ -46,6 +47,8 @@ module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db) =
await msg.channel.send(`I'll now give the role <@&${role}> to members when they reach the level **${args[0]}** and to members currently above this level.`);
if (previous)
await msg.channel.send(`When I'll give this role, I'll remove <@&${previous}>.`)

log.info({msg: 'addlevelrole', author: { id: msg.author.id, name: msg.author.tag }, guild: msg.guild.id, level: { id: args[0], role: role }})
};

module.exports.help = {
Expand Down
7 changes: 5 additions & 2 deletions src/commands/config/addrole.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Client, Message } from 'discord.js';
import { Db } from 'mongodb'
import { Logger } from 'pino';

module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db) => {
module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db, log: Logger) => {
if ((!msg.member.hasPermission('MANAGE_GUILD'))) return;
if (args.length != 3) return;

Expand Down Expand Up @@ -29,11 +30,13 @@ module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db) =
try {
await msg.delete()
} catch (ex) {
console.error(ex)
log.error(ex)
}
}

await db.collection('msg').updateOne({ _id: args[0] }, { $push: { roles: { "id": role, "emote": emote } } })

log.info({msg: 'addrole', author: { id: msg.author.id, name: msg.author.tag }, guild: msg.guild.id, role: { id: role, emote: emote }})
};

module.exports.help = {
Expand Down
7 changes: 5 additions & 2 deletions src/commands/config/delembed.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Client, Message } from 'discord.js';
import { Db } from 'mongodb'
import { Logger } from 'pino';

module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db) => {
module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db, log: Logger) => {
if ((!msg.member.hasPermission('MANAGE_GUILD'))) return;
if (args.length != 1) return;

Expand All @@ -14,11 +15,13 @@ module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db) =
await msg.delete()
await fetchMsg.delete()
} catch (ex) {
console.error(ex)
log.error(ex)
}
}

await db.collection('msg').deleteOne({ _id: args[0] })

log.info({msg: 'delembed', author: { id: msg.author.id, name: msg.author.tag }, guild: msg.guild.id})
};

module.exports.help = {
Expand Down
7 changes: 5 additions & 2 deletions src/commands/config/dellevelrole.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Client, Message } from 'discord.js';
import { Db } from 'mongodb'
import { Logger } from 'pino';

module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db) => {
module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db, log: Logger) => {
if ((!msg.member.hasPermission('MANAGE_GUILD'))) return;
if (args.length != 1) return;
let guildConf = await db.collection('settings').findOne({ '_id': { $eq: msg.guild.id } });
Expand All @@ -21,7 +22,9 @@ module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db) =

await db.collection('settings').updateOne({ _id: msg.guild.id }, { $set: { levelroles: levelroles }}, { upsert: true })

return msg.channel.send(`I'll no longer give a role when members achieve the level **${args[0]}**.`);
await msg.channel.send(`I'll no longer give a role when members achieve the level **${args[0]}**.`);

log.info({msg: 'dellevelrole', author: { id: msg.author.id, name: msg.author.tag }, guild: msg.guild.id, level: args[0]})
};

module.exports.help = {
Expand Down
5 changes: 4 additions & 1 deletion src/commands/config/delrole.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Client, Message } from 'discord.js';
import { Db } from 'mongodb'
import { Logger } from 'pino';

module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db) => {
module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db, log: Logger) => {
if ((!msg.member.hasPermission('MANAGE_GUILD'))) return;
if (args.length != 2) return;

Expand All @@ -22,6 +23,8 @@ module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db) =
}

await db.collection('msg').updateOne({ _id: args[0] }, { $pull: { roles: { "emote": emote } } })

log.info({msg: 'delrole', author: { id: msg.author.id, name: msg.author.tag }, guild: msg.guild.id})
};

module.exports.help = {
Expand Down
Loading

0 comments on commit c056e73

Please sign in to comment.