From 9913d7b89548fa900dc0137fe2bc9547b910cf9e Mon Sep 17 00:00:00 2001 From: Killian Date: Thu, 27 Aug 2020 17:53:46 +0200 Subject: [PATCH 1/4] Now give the real ping --- Commands/Bot/ping.js | 10 ++++++---- README.md | 2 +- package.json | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Commands/Bot/ping.js b/Commands/Bot/ping.js index cb29052..511616e 100644 --- a/Commands/Bot/ping.js +++ b/Commands/Bot/ping.js @@ -4,7 +4,7 @@ module.exports = class extends Command { constructor(client) { super(client, { name: "ping", - description: "Return the bot ping (just a test command for now until the real ping is added)", + description: "Return the bot ping.", category: "Bot", enabled: true, aliases: ["latency"], @@ -14,7 +14,9 @@ module.exports = class extends Command { } async run(message, args) { - message.chat.sendMessage(`Hey, my name is ${this.client.user.fullName} and i am an instagram bot.`); + message.chat.sendMessage('Calcul du ping...').then(m => { + m.delete(); + message.chat.sendMessage(`Mon ping est de ${(m.timestamp - message.timestamp) / 1000}ms`) + }) } -} - +} \ No newline at end of file diff --git a/README.md b/README.md index 11e94b0..6fc86b4 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ it means that the bot is ready to be used. 🎉 # Available commands -- !ping +- !ping: Return the bot ping # Future updates diff --git a/package.json b/package.json index 5555b4c..8b99bfd 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "author": "Mr¤KayJayDee (https://github.com/Mr-KayJayDee)", "license": "MIT", "dependencies": { - "@androz2091/insta.js": "github:androz2091/insta.js", + "@androz2091/insta.js": "github:androz2091/insta.js#develop", "@discordjs/collection": "^0.1.6", "chalk": "^4.1.0", "dotenv": "^8.2.0" From 3a5b01dadcf1f1b684385b24698dda69ec8779c7 Mon Sep 17 00:00:00 2001 From: Killian Date: Fri, 28 Aug 2020 08:20:40 +0200 Subject: [PATCH 2/4] Added images generations + myinfos command --- Commands/Images/ad.js | 23 +++++++++++++++++++ Commands/Images/affect.js | 23 +++++++++++++++++++ Commands/Images/beautiful.js | 23 +++++++++++++++++++ Commands/Images/blur.js | 23 +++++++++++++++++++ Commands/Images/circle.js | 23 +++++++++++++++++++ Commands/Images/confuedStonk.js | 23 +++++++++++++++++++ Commands/Images/delete.js | 23 +++++++++++++++++++ Commands/Images/facepalm.js | 23 +++++++++++++++++++ Commands/Images/gay.js | 23 +++++++++++++++++++ Commands/Images/greyscale.js | 23 +++++++++++++++++++ Commands/Images/hitler.js | 23 +++++++++++++++++++ Commands/Images/invert.js | 23 +++++++++++++++++++ Commands/Images/jail.js | 23 +++++++++++++++++++ Commands/Images/lisaPresentation.js | 24 ++++++++++++++++++++ Commands/Images/mms.js | 23 +++++++++++++++++++ Commands/Images/notstonk.js | 23 +++++++++++++++++++ Commands/Images/poutine.js | 23 +++++++++++++++++++ Commands/Images/rip.js | 23 +++++++++++++++++++ Commands/Images/sepia.js | 23 +++++++++++++++++++ Commands/Images/stonk.js | 23 +++++++++++++++++++ Commands/Images/tatoo.js | 23 +++++++++++++++++++ Commands/Images/thomas.js | 23 +++++++++++++++++++ Commands/Images/trash.js | 23 +++++++++++++++++++ Commands/Images/wanted.js | 23 +++++++++++++++++++ Commands/Utils/myInfos.js | 31 +++++++++++++++++++++++++ README.md | 35 +++++++++++++++++++++++++++++ package.json | 3 ++- 27 files changed, 621 insertions(+), 1 deletion(-) create mode 100644 Commands/Images/ad.js create mode 100644 Commands/Images/affect.js create mode 100644 Commands/Images/beautiful.js create mode 100644 Commands/Images/blur.js create mode 100644 Commands/Images/circle.js create mode 100644 Commands/Images/confuedStonk.js create mode 100644 Commands/Images/delete.js create mode 100644 Commands/Images/facepalm.js create mode 100644 Commands/Images/gay.js create mode 100644 Commands/Images/greyscale.js create mode 100644 Commands/Images/hitler.js create mode 100644 Commands/Images/invert.js create mode 100644 Commands/Images/jail.js create mode 100644 Commands/Images/lisaPresentation.js create mode 100644 Commands/Images/mms.js create mode 100644 Commands/Images/notstonk.js create mode 100644 Commands/Images/poutine.js create mode 100644 Commands/Images/rip.js create mode 100644 Commands/Images/sepia.js create mode 100644 Commands/Images/stonk.js create mode 100644 Commands/Images/tatoo.js create mode 100644 Commands/Images/thomas.js create mode 100644 Commands/Images/trash.js create mode 100644 Commands/Images/wanted.js create mode 100644 Commands/Utils/myInfos.js diff --git a/Commands/Images/ad.js b/Commands/Images/ad.js new file mode 100644 index 0000000..1fd727b --- /dev/null +++ b/Commands/Images/ad.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "ad", + description: "Display an ad image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Ad().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/affect.js b/Commands/Images/affect.js new file mode 100644 index 0000000..6e38544 --- /dev/null +++ b/Commands/Images/affect.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "affect", + description: "Return an affect image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Affect().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/beautiful.js b/Commands/Images/beautiful.js new file mode 100644 index 0000000..ce00756 --- /dev/null +++ b/Commands/Images/beautiful.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "beautiful", + description: "Return a beautiful image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Beautiful().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/blur.js b/Commands/Images/blur.js new file mode 100644 index 0000000..f7d3fce --- /dev/null +++ b/Commands/Images/blur.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "blur", + description: "Return a blured image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Blur().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/circle.js b/Commands/Images/circle.js new file mode 100644 index 0000000..216ee51 --- /dev/null +++ b/Commands/Images/circle.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "circle", + description: "Return a circled image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Circle().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/confuedStonk.js b/Commands/Images/confuedStonk.js new file mode 100644 index 0000000..74430e5 --- /dev/null +++ b/Commands/Images/confuedStonk.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "confusedstonk", + description: "Return a confused stonk image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.ConfusedStonk().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/delete.js b/Commands/Images/delete.js new file mode 100644 index 0000000..16b95da --- /dev/null +++ b/Commands/Images/delete.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "delete", + description: "Return a dalete image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Delete().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/facepalm.js b/Commands/Images/facepalm.js new file mode 100644 index 0000000..2a9088f --- /dev/null +++ b/Commands/Images/facepalm.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "facepalm", + description: "Return a facepalm.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Facepalm().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/gay.js b/Commands/Images/gay.js new file mode 100644 index 0000000..12a941e --- /dev/null +++ b/Commands/Images/gay.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "gay", + description: "Return a gay image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Gay().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/greyscale.js b/Commands/Images/greyscale.js new file mode 100644 index 0000000..522b6e6 --- /dev/null +++ b/Commands/Images/greyscale.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "greyscale", + description: "Return a greyscaled image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Greyscale().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/hitler.js b/Commands/Images/hitler.js new file mode 100644 index 0000000..0461614 --- /dev/null +++ b/Commands/Images/hitler.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "hitler", + description: "Return an hitler image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Hitler().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/invert.js b/Commands/Images/invert.js new file mode 100644 index 0000000..ddedc58 --- /dev/null +++ b/Commands/Images/invert.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "invert", + description: "Returnan inverted image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Invert().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/jail.js b/Commands/Images/jail.js new file mode 100644 index 0000000..034d0c1 --- /dev/null +++ b/Commands/Images/jail.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "jail", + description: "Return a jail image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Jail().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/lisaPresentation.js b/Commands/Images/lisaPresentation.js new file mode 100644 index 0000000..c8944eb --- /dev/null +++ b/Commands/Images/lisaPresentation.js @@ -0,0 +1,24 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "lisapresentation", + description: "Return a lisa presentation image.", + category: "Images", + enabled: true, + aliases: ["lisa"], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let text = args.join(" ") + if(!text) text = message.author.username; + let img = await new DIG.LisaPresentation().getImage(text); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/mms.js b/Commands/Images/mms.js new file mode 100644 index 0000000..3663b4b --- /dev/null +++ b/Commands/Images/mms.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "mms", + description: "Return an m&ms image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Mms().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/notstonk.js b/Commands/Images/notstonk.js new file mode 100644 index 0000000..70351b4 --- /dev/null +++ b/Commands/Images/notstonk.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "notstonk", + description: "Return a not stonk image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.NotStonk().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/poutine.js b/Commands/Images/poutine.js new file mode 100644 index 0000000..1275442 --- /dev/null +++ b/Commands/Images/poutine.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "poutine", + description: "Return a poutine image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Poutine().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/rip.js b/Commands/Images/rip.js new file mode 100644 index 0000000..ab56e71 --- /dev/null +++ b/Commands/Images/rip.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "rip", + description: "Return a RIP image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Rip().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/sepia.js b/Commands/Images/sepia.js new file mode 100644 index 0000000..608ee4d --- /dev/null +++ b/Commands/Images/sepia.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "sepia", + description: "Return a sepia image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Sepia().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/stonk.js b/Commands/Images/stonk.js new file mode 100644 index 0000000..0f318d5 --- /dev/null +++ b/Commands/Images/stonk.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "stonk", + description: "Return a stonk image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Stonk().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/tatoo.js b/Commands/Images/tatoo.js new file mode 100644 index 0000000..cebeb01 --- /dev/null +++ b/Commands/Images/tatoo.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "tatoo", + description: "Return a tatoo image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Tatoo().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/thomas.js b/Commands/Images/thomas.js new file mode 100644 index 0000000..e5394b7 --- /dev/null +++ b/Commands/Images/thomas.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "thomas", + description: "Return a thomas image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Thomas().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/trash.js b/Commands/Images/trash.js new file mode 100644 index 0000000..6adfa20 --- /dev/null +++ b/Commands/Images/trash.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "trash", + description: "Return a trash image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Trash().getImage(avatar); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Images/wanted.js b/Commands/Images/wanted.js new file mode 100644 index 0000000..8b4d6ae --- /dev/null +++ b/Commands/Images/wanted.js @@ -0,0 +1,23 @@ +let Command = require(`../../Structure/Command.js`); +const DIG = require("discord-image-generation"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "wanted", + description: "Return a wanted image.", + category: "Images", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + let avatar = message.author.avatarURL; + let img = await new DIG.Wanted().getImage(avatar, "$"); + message.chat.sendMessage("Please wait we're generating your image..."); + message.chat.sendPhoto(img); + } +}; \ No newline at end of file diff --git a/Commands/Utils/myInfos.js b/Commands/Utils/myInfos.js new file mode 100644 index 0000000..4b41ded --- /dev/null +++ b/Commands/Utils/myInfos.js @@ -0,0 +1,31 @@ +const Command = require(`../../Structure/Command.js`); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: `myinfos`, + description: `Return some informations about you.`, + category: `Utils`, + enabled: true, + aliases: [`me`], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + message.chat.sendMessage( +`FUll Name: ${message.author.fullName} +Username: ${message.author.username} +ID: ${message.author.id} +Biography:\n${message.author.biography} +Followers: ${message.author.followerCount} +Following: ${message.author.followingCount} +Business: ${message.author.isBusiness} +Verified: ${message.author.isVerified} +Private: ${message.author.isPrivate} +Number Of Posts: ${message.author.mediaCount} +Number Of IGTV posts: ${message.author.totalIgtvVideos} +`) + } +} \ No newline at end of file diff --git a/README.md b/README.md index 6fc86b4..5f9fd7d 100644 --- a/README.md +++ b/README.md @@ -50,8 +50,43 @@ it means that the bot is ready to be used. 🎉 # Available commands +## Bot - !ping: Return the bot ping + +## Images +- !ad: Return an ad image. +- !affect: Return an affect image. +- !beautiful: Return a beautiful image. +- !blur: Return a blured image. +- !circle: Return a circled image. +- !confuedStonk: Return a confuedStonk image. +- !delete: Return a delete image. +- !facepalm: Return a facepalm image. +- !gay: Return a gay image. +- !greyscale: Return a greyscale image. +- !hitler: Return an hitler image. +- !invert: Return an invert image. +- !jail: Return a jail image. +- !lisaPresentation: Return a lisaPresentation image. +- !mms: Return a mms image. +- !notstonk: Return a notstonk image. +- !poutine: Return a poutine image. +- !rip: Return a rip image. +- !sepia: Return a sepia image. +- !stonk: Return a stonk image. +- !tatoo: Return a tatoo image. +- !thomas: Return a thomas image. +- !trash: Return a trash image. +- !wanted: Return a wanted image. + +## Utils +- !myinfos: Return some informations about you. (missing some infos) + +# Known bugs + +- A story answer return an error (TypeError: Cannot read property 'indexOf' of undefined) + # Future updates - Ability to change the prefix on a chat diff --git a/package.json b/package.json index 8b99bfd..5e72898 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "instabot", - "version": "1.0.0", + "version": "1.1.2", "description": "A fully working instagram bot using Insta.js by androz2091", "main": "index.js", "scripts": { @@ -13,6 +13,7 @@ "@androz2091/insta.js": "github:androz2091/insta.js#develop", "@discordjs/collection": "^0.1.6", "chalk": "^4.1.0", + "discord-image-generation": "^1.3.7", "dotenv": "^8.2.0" } } From 00cdd5bebf3aae5c9e9ac2d0bdebbe9b353107a1 Mon Sep 17 00:00:00 2001 From: Killian Date: Fri, 28 Aug 2020 08:21:31 +0200 Subject: [PATCH 3/4] Fixed newFollower event --- Events/newFollower.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Events/newFollower.js b/Events/newFollower.js index 0a54bae..89fd6ed 100644 --- a/Events/newFollower.js +++ b/Events/newFollower.js @@ -4,7 +4,7 @@ module.exports = class { } async emit(user) { - console.log(`${user.fullName} (${username}) started following you.`) + console.log(`${user.fullName} (${user.username}) started following you.`) user.follow(); } } From 0f6b6042c7843bb5997cd98dd8178e22b8cb7d1e Mon Sep 17 00:00:00 2001 From: Killian Date: Fri, 28 Aug 2020 16:15:50 +0200 Subject: [PATCH 4/4] Fixed myInfos and added help command --- .env.example | 3 +- Commands/Bot/help.js | 19 ++++++++++ Commands/Utils/myInfos.js | 6 ++-- Events/connected.js | 10 +++--- Events/messageCreate.js | 15 +++++++- Models/GroupMembers.js | 7 ++++ Models/Groups.js | 10 ++++++ Models/Users.js | 10 ++++++ README.md | 4 +-- Structure/Client.js | 74 ++++++++++++++++++++++++++++++++++----- index.js | 9 ++++- package.json | 7 ++-- 12 files changed, 152 insertions(+), 22 deletions(-) create mode 100644 Commands/Bot/help.js create mode 100644 Models/GroupMembers.js create mode 100644 Models/Groups.js create mode 100644 Models/Users.js diff --git a/.env.example b/.env.example index 44639e8..4bf59b1 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,3 @@ BOTUSERNAME=Your bot account username -PASSWORD=Your bot account password \ No newline at end of file +PASSWORD=Your bot account password +DATABASEURL=The url of your mongoDB database (can be local or cluster and need to be URL friendly) \ No newline at end of file diff --git a/Commands/Bot/help.js b/Commands/Bot/help.js new file mode 100644 index 0000000..67181a1 --- /dev/null +++ b/Commands/Bot/help.js @@ -0,0 +1,19 @@ +const Command = require("../../Structure/Command.js"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "help", + description: "Return the commands list.", + category: "Bot", + enabled: true, + aliases: ["?"], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args) { + message.chat.sendMessage("Here are the commands you can use ! https://github.com/Mr-KayJayDee/instagram-bot#available-commands") + } +} \ No newline at end of file diff --git a/Commands/Utils/myInfos.js b/Commands/Utils/myInfos.js index 4b41ded..333dcd5 100644 --- a/Commands/Utils/myInfos.js +++ b/Commands/Utils/myInfos.js @@ -14,8 +14,9 @@ module.exports = class extends Command { } async run(message, args) { - message.chat.sendMessage( -`FUll Name: ${message.author.fullName} + message.author.fetch().then(e => { + message.chat.sendMessage( + `Full Name: ${message.author.fullName} Username: ${message.author.username} ID: ${message.author.id} Biography:\n${message.author.biography} @@ -27,5 +28,6 @@ Private: ${message.author.isPrivate} Number Of Posts: ${message.author.mediaCount} Number Of IGTV posts: ${message.author.totalIgtvVideos} `) + }) } } \ No newline at end of file diff --git a/Events/connected.js b/Events/connected.js index 1cffda9..fa85980 100644 --- a/Events/connected.js +++ b/Events/connected.js @@ -5,10 +5,10 @@ module.exports = class { async emit() { this.client.logger.log(`Logged in as ${this.client.user.fullName} (${this.client.user.username}).`, "ready"); - this.client.logger.log(`Followers: ${this.client.user.followerCount}`, "ready") - this.client.logger.log(`Following: ${this.client.user.followingCount}`, "ready") - this.client.logger.log(`Business : ${this.client.user.isBusiness}`, "ready") - this.client.logger.log(`Verified: ${this.client.user.isVerified}`, "ready") - this.client.logger.log(`Private: ${this.client.user.isPrivate}`, "ready") + this.client.logger.log(`Followers: ${this.client.user.followerCount}`, "ready"); + this.client.logger.log(`Following: ${this.client.user.followingCount}`, "ready"); + this.client.logger.log(`Business : ${this.client.user.isBusiness}`, "ready"); + this.client.logger.log(`Verified: ${this.client.user.isVerified}`, "ready"); + this.client.logger.log(`Private: ${this.client.user.isPrivate}`, "ready"); } } diff --git a/Events/messageCreate.js b/Events/messageCreate.js index 476656e..57ef323 100644 --- a/Events/messageCreate.js +++ b/Events/messageCreate.js @@ -6,8 +6,21 @@ module.exports = class { } async emit(message) { + const data = {}; + data.config = this.client.config; + if (message.authorID === this.client.user.id) return; message.markSeen(); + if (message.chat.isGroup) { + const groupMembersData = await this.client.findOrCreateGroupMember({ id: message.author.id, groupID: message.chat.id }); + data.groupMembers = groupMembersData; + console.log(groupMembersData) + const groupsData = await this.client.findOrCreateGroup({ groupID: message.chat.id }); + data.groups = groupsData; + } else { + const usersData = await this.client.findOrCreateUser({ id: message.author.id }); + data.users = usersData; + } let prefixes = this.client.config.defaultPrefix; if (message.content.indexOf(prefixes) !== 0) return; @@ -46,6 +59,6 @@ module.exports = class { tStamps.set(message.authorID, timeNow); setTimeout(() => tStamps.delete(message.authorID), cdAmount); - cmd.run(message, args); + cmd.run(message, args, data); } } diff --git a/Models/GroupMembers.js b/Models/GroupMembers.js new file mode 100644 index 0000000..4d8e7b1 --- /dev/null +++ b/Models/GroupMembers.js @@ -0,0 +1,7 @@ +const mongoose = require("mongoose"), + Schema = mongoose.Schema; + +module.exports = mongoose.model("GroupMembers", new Schema({ + id: String, + groupID: String, +})); diff --git a/Models/Groups.js b/Models/Groups.js new file mode 100644 index 0000000..333aada --- /dev/null +++ b/Models/Groups.js @@ -0,0 +1,10 @@ +const mongoose = require("mongoose"), + Schema = mongoose.Schema; + +module.exports = mongoose.model("Groups", new Schema({ + groupID: String, + reminds: { + type: Array, + default: [] + }, +})); diff --git a/Models/Users.js b/Models/Users.js new file mode 100644 index 0000000..c4863d4 --- /dev/null +++ b/Models/Users.js @@ -0,0 +1,10 @@ +const mongoose = require("mongoose"), + Schema = mongoose.Schema; + +module.exports = mongoose.model("Users", new Schema({ + id: String, + reminds: { + type: Array, + default: [] + }, +})); diff --git a/README.md b/README.md index 5f9fd7d..79d8433 100644 --- a/README.md +++ b/README.md @@ -85,13 +85,13 @@ it means that the bot is ready to be used. 🎉 # Known bugs -- A story answer return an error (TypeError: Cannot read property 'indexOf' of undefined) +- A story answer return an error (TypeError: Cannot read property 'indexOf' of undefined, same for all system messages) # Future updates - Ability to change the prefix on a chat - Ability to change the lang -- Ability to make reminders +- Ability to make reminders (working on it) - Ability to get the informations about an user Feel free to make a pull request if you have any edit to do in the code or just open an issue if you don't know how to fix it. diff --git a/Structure/Client.js b/Structure/Client.js index 6d70ace..f8c0b64 100644 --- a/Structure/Client.js +++ b/Structure/Client.js @@ -1,20 +1,27 @@ const { Client } = require("@androz2091/insta.js"), -Collection = require("@discordjs/collection") + Collection = require("@discordjs/collection") path = require("path"); class InstaBot extends Client { constructor(options) { super(options); - ["commands", "aliases", "cooldowns"].forEach(x => this[x] = new Collection()); + ["commands", "aliases", "cooldowns"].forEach(x => this[x] = new Collection()); this.config = require("../config"); this.logger = require("../Helpers/logger"); + this.usersData = require("../Models/Users"); + this.groupsData = require("../Models/Groups") + this.groupMembersData = require("../Models/GroupMembers") + this.databaseCache = {}; + this.databaseCache.users = new Collection(); + this.databaseCache.groups = new Collection(); + this.databaseCache.groupMembers = new Collection(); } loadCommand(commandPath, commandName) { try { const props = new (require(`.${commandPath}${path.sep}${commandName}`))(this); props.conf.location = commandPath; - if (props.init){ + if (props.init) { props.init(this); } this.commands.set(props.help.name, props); @@ -27,22 +34,73 @@ class InstaBot extends Client { } } - async unloadCommand (commandPath, commandName) { + async unloadCommand(commandPath, commandName) { let command; - if(this.commands.has(commandName)) { + if (this.commands.has(commandName)) { command = this.commands.get(commandName); - } else if(this.aliases.has(commandName)){ + } else if (this.aliases.has(commandName)) { command = this.commands.get(this.aliases.get(commandName)); } - if(!command){ + if (!command) { return `The command \`${commandName}\` doesn't seem to exist, nor is it an alias. Try again!`; } - if(command.shutdown){ + if (command.shutdown) { await command.shutdown(this); } delete require.cache[require.resolve(`.${commandPath}${path.sep}${commandName}.js`)]; return false; } + + async findOrCreateUser({ id: userID }, isLean) { + if (this.databaseCache.users.get(userID)) { + return isLean ? this.databaseCache.users.get(userID).toJSON() : this.databaseCache.users.get(userID); + } else { + let userData = (isLean ? await this.usersData.findOne({ id: userID }).populate("members").lean() : await this.usersData.findOne({ id: userID }).populate("members")); + if (userData) { + if (!isLean) this.databaseCache.users.set(userID, userData); + return userData; + } else { + userData = new this.usersData({ id: userID }); + await userData.save(); + this.databaseCache.users.set(userID, userData); + return isLean ? userData.toJSON() : userData; + } + } + } + + async findOrCreateGroupMember({ id: userID, groupID: groupID }, isLean) { + if (this.databaseCache.groupMembers.get(`${userID}-${groupID}`)) { + return isLean ? this.databaseCache.groupMembers.get(`${userID}-${groupID}`).toJSON() : this.databaseCache.groupMembers.get(`${userID}-${groupID}`); + } else { + let groupMemberData = (isLean ? await this.groupMembersData.findOne({ id: userID, groupID: groupID }).populate("members").lean() : await this.groupMembersData.findOne({ id: userID, groupID: groupID }).populate("members")); + if (groupMemberData) { + if (!isLean) this.databaseCache.groupMembers.set(`${userID}-${groupID}`, groupMemberData); + return groupMemberData; + } else { + groupMemberData = new this.groupMembersData({ id: userID, groupID: groupID }); + await groupMemberData.save(); + this.databaseCache.groupMembers.set(`${userID}-${groupID}`, groupMemberData); + return isLean ? groupMemberData.toJSON() : groupMemberData; + } + } + } + + async findOrCreateGroup({ groupID: groupID }, isLean) { + if (this.databaseCache.groups.get(groupID)) { + return isLean ? this.databaseCache.groupMembers.get(groupID).toJSON() : this.databaseCache.groupMembers.get(groupID); + } else { + let groupData = (isLean ? await this.groupMembersData.findOne({ groupID: groupID }).populate("members").lean() : await this.groupMembersData.findOne({ groupID: groupID }).populate("members")); + if (groupData) { + if (!isLean) this.databaseCache.groupMembers.set(groupID, groupData); + return groupData; + } else { + groupData = new this.groupMembersData({ groupID: groupID }); + await groupData.save(); + this.databaseCache.groupMembers.set(groupID, groupData); + return isLean ? groupData.toJSON() : groupData; + } + } + } } module.exports = InstaBot; \ No newline at end of file diff --git a/index.js b/index.js index f547392..162f559 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,8 @@ const InstaBot = require("./Structure/Client"), const util = require("util"), fs = require("fs"), - readdir = util.promisify(fs.readdir); + readdir = util.promisify(fs.readdir), + mongoose = require("mongoose"); require("dotenv").config(); const initialize = async () => { @@ -26,5 +27,11 @@ const initialize = async () => { delete require.cache[require.resolve(`./Events/${file}`)]; }); client.login(process.env.BOTUSERNAME, process.env.PASSWORD); + + mongoose.connect(process.env.DATABASEURL, { useNewUrlParser: true, useUnifiedTopology: true }).then(() => { + client.logger.log("Connected to the Mongodb database.", "ready"); + }).catch((err) => { + client.logger.log("Unable to connect to the Mongodb database. Error:"+err, "error"); + }); }; initialize(); \ No newline at end of file diff --git a/package.json b/package.json index 5e72898..3c3b89b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "instabot", - "version": "1.1.2", + "version": "1.1.5", "description": "A fully working instagram bot using Insta.js by androz2091", "main": "index.js", "scripts": { @@ -14,6 +14,9 @@ "@discordjs/collection": "^0.1.6", "chalk": "^4.1.0", "discord-image-generation": "^1.3.7", - "dotenv": "^8.2.0" + "dotenv": "^8.2.0", + "mongoose": "^5.10.1", + "ms": "^2.1.2", + "node-fetch": "^2.6.0" } }