Skip to content

Commit

Permalink
🎉Release v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Lebyy authored Mar 5, 2021
1 parent 32581bc commit edc388d
Show file tree
Hide file tree
Showing 11 changed files with 314 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# QuickUptime-Discord.js-Example

[![downloadsBadge](https://img.shields.io/npm/dt/quickuptime?style=for-the-badge)](https://npmjs.com/quickuptime)
[![versionBadge](https://img.shields.io/npm/v/quickuptime?style=for-the-badge)](https://npmjs.com/quickuptime)
[![doc](https://img.shields.io/badge/Documentation-Click%20here-blue?style=for-the-badge)](https://quickuptime.js.org)

This is a example repo for the QuickUptime package!
QuickUptime Quick Uptime is a powerful module which allows you to ping any website with multiple http client support!

# Credits

Made by Lebyy_Dev.

### NPM
- [SmartestChatBot](https://www.npmjs.com/package/quickuptime)

### GitHub Repo
- [GitHub Repo](https://github.com/Lebyy/quickuptime)

## 🚀 Documentation

https://quickuptime.js.org/


## 📝 Support Server

<a href="https://discord.gg/anyF4j3MUu"><img src="https://invidget.switchblade.xyz/anyF4j3MUu"/></a>
<br><br>
</div>
57 changes: 57 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const config = require("./config.json");
const token = require("./token.json");
const Discord = require("discord.js");
const fs = require("fs");
const bot = new Discord.Client({disableEveryone: true});
bot.commands = new Discord.Collection();
const quickuptime = require('quickuptime')
let data = {
httpclient: "node-fetch" // wumpfetch, got, axios and superagent supported!
}
bot.uptimer = new quickuptime.Client(data)


fs.readdir("./commands/", (err, files) => {

if(err) console.log(err);

let jsfile = files.filter(f => f.split(".").pop() === "js")
if(jsfile.length <= 0){
console.log("Couldn't find commands.");
return;
}

jsfile.forEach((f, i) =>{
let props = require(`./commands/${f}`);
console.log(`${f} loaded!`);
bot.commands.set(props.help.name, props);
});

});

//Playing Message
bot.on("ready", async () => {
console.log(`${bot.user.username} is online on ${bot.guilds.cache.size} servers!`);
bot.user.setActivity("Made by Lebyy_Dev#0063", {type: "PLAYING"});
await bot.uptimer.uniquestartall(true)
});

//Command Manager
bot.on("message", async message => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;

let prefix = config.prefix;
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);

//Check for prefix
if(!cmd.startsWith(config.prefix)) return;

let commandfile = bot.commands.get(cmd.slice(prefix.length));
if(commandfile) commandfile.run(bot,message,args);

});
//Token need in token.json
bot.login(token.token);
33 changes: 33 additions & 0 deletions commands/add.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const Discord = require("discord.js");
const config = require("../config.json");
module.exports.run = async (bot, message, args) => {
let url = args[0]
const embederrlength = new Discord.MessageEmbed()
.setTitle(`❌ | **__Error__**`)
.setColor(`#FF2E30`)
.setDescription(`**The link should be less than 130 characters! Please re-run the command.**`)
.setFooter(message.guild.name, message.guild.iconURL)
const embederrprotocol = new Discord.MessageEmbed()
.setTitle(`❌ | **__Error__**`)
.setColor(`#FF2E30`)
.setDescription("**Please include the link with a protocol like `https://` or `http://`**")
.setFooter(message.guild.name, message.guild.iconURL)
if(url.length > 130) return message.channel.send(embederrlength)
if(url.startsWith("https://") === false && url.startsWith("http://") === false) return message.channel.send(embederrprotocol)

// We add the url in our quickuptime db here.
bot.uptimer.uniqueaddurl(url, message.author.id)
bot.uptimer.uniquestop(message.author.id)
await bot.uptimer.uniquestart(true, message.author.id)
let embed = new Discord.MessageEmbed()
.setDescription("✅ | **__I have successfully added "+url+" on my database!__**")
.setFooter(message.guild.name, message.guild.iconURL({dynamic: true}))
.setColor("#43FF30")
.setThumbnail(message.author.displayAvatarURL({ dynamic: true }))
message.channel.send(embed)
}

module.exports.help = {
name:"add",
description:"A command to add url(s) into the database!"
}
40 changes: 40 additions & 0 deletions commands/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const Discord = require("discord.js");
const config = require("../config.json");
module.exports.run = async (bot, message, args) => {
let interval = args[0]
let check = parseInt(interval)
const embederr1 = new Discord.MessageEmbed()
.setTitle(`❌ | **__Error__**`)
.setColor(`#FF2E30`)
.setDescription(`**Please provide an appropriate amount of interval to ping the url\'s after.**`)
.setFooter(message.guild.name, message.guild.iconURL)
if(!interval) return message.reply(embederr1)
if(isNaN(check)) return message.reply(embederr1)

let urls = bot.uptimer.uniqueallurls(message.author.id)
if(urls.length <= 0) {
const embederr = new Discord.MessageEmbed()
.setTitle(`❌ | **__Error__**`)
.setColor(`#FF2E30`)
.setDescription(`**You don't have any url\'s present in our database, please add one before continuing.**`)
.setFooter(message.guild.name, message.guild.iconURL)
return message.author.send(embederr).catch(err => {
return message.channel.send(embederr)
})
}
bot.uptimer.uniquesetinterval(interval, message.author.id)
bot.uptimer.uniquestop(message.author.id)
await bot.uptimer.uniquestart(true, message.author.id)

let embed = new Discord.MessageEmbed()
.setDescription("✅ | **__I have successfully configured "+interval+" as the interval to ping all of your url\'s after!__**")
.setFooter(message.guild.name, message.guild.iconURL({dynamic: true}))
.setColor("#43FF30")
.setThumbnail(message.author.displayAvatarURL({ dynamic: true }))
message.channel.send(embed)
}

module.exports.help = {
name:"config",
description:"A command to configure the amount of time to ping a url after."
}
26 changes: 26 additions & 0 deletions commands/help.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const Discord = require("discord.js");
const config = require("../config.json");
let prefix = config.prefix;
module.exports.run = async (bot, message, args) => {
let commands = bot.commands.array();
let helpEmbed = new Discord.MessageEmbed()
.setTitle(":tada: **__My commands!__**")
.setColor("#F8AA2A")
.setThumbnail(message.author.displayAvatarURL({ dynamic: true }))
commands.forEach((cmd) => {
helpEmbed.addField(
`**\`${prefix}${cmd.help.name}\`**`,
`${cmd.help.description}`,
true
);
});

helpEmbed.setTimestamp();

return message.channel.send(helpEmbed).catch(console.error);
}

module.exports.help = {
name:"help",
description:"This command!"
}
47 changes: 47 additions & 0 deletions commands/profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const Discord = require("discord.js");
const config = require("../config.json");
let prefix = config.prefix;
module.exports.run = async (bot, message, args) => {
let joinedurls;
let user = message.author
let urls = bot.uptimer.uniqueallurls(user.id) || []
let data = [];
if(urls.length <= 0) {
const embederr = new Discord.MessageEmbed()
.setTitle(`❌ | **__Error__**`)
.setColor(`#FF2E30`)
.setDescription(`**You don't have any url\'s present in our database, please add one before continuing.**`)
.setFooter(message.guild.name, message.guild.iconURL({dynamic: true}))
return message.author.send(embederr).catch(err => {
return message.channel.send(embederr)
})
}
if(urls.length >= 1) {
urls.splice(0, 20).map((item, index) => {
let urlpos = index + 1;
let url = item
data.push({
urlpos,
url
})
})
}

let embed = new Discord.MessageEmbed()
.setTitle(`💻 | **__Your profile__**`)
.setFooter(message.guild.name, message.guild.iconURL({dynamic: true}))
.setColor("#E3E4EA")
.setThumbnail(message.author.displayAvatarURL({ dynamic: true }))
data.forEach(d => {
embed.addField(`\`${d.urlpos}. ${d.url}\``, `\u200b`)
})
message.author.send(embed).catch(err => {
return message.channel.send(embed)
})

}

module.exports.help = {
name:"profile",
description:"A command which will return your profile"
}
34 changes: 34 additions & 0 deletions commands/remove.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const Discord = require("discord.js");
const config = require("../config.json");
module.exports.run = async (bot, message, args) => {
let url = args[0]
const embederrlength = new Discord.MessageEmbed()
.setTitle(`❌ | **__Error__**`)
.setColor(`#FF2E30`)
.setDescription(`**The link should be less than 130 characters! Please re-run the command.**`)
.setFooter(message.guild.name, message.guild.iconURL)
const embederrprotocol = new Discord.MessageEmbed()
.setTitle(`❌ | **__Error__**`)
.setColor(`#FF2E30`)
.setDescription("**Please include the link with a protocol like `https://` or `http://`**")
.setFooter(message.guild.name, message.guild.iconURL)
if(url.length > 130) return message.channel.send(embederrlength)
if(url.startsWith("https://") === false && url.startsWith("http://") === false) return message.channel.send(embederrprotocol)

// We remove the url in our quickuptime db here.
bot.uptimer.uniqueremoveurl(url, message.author.id)
bot.uptimer.uniquestop(message.author.id)
await bot.uptimer.uniquestart(true, message.author.id)

let embed = new Discord.MessageEmbed()
.setDescription("✅ | **__I have successfully removed "+url+" from my database!__**")
.setFooter(message.guild.name, message.guild.iconURL({dynamic: true}))
.setColor("#43FF30")
.setThumbnail(message.author.displayAvatarURL({ dynamic: true }))
message.channel.send(embed)
}

module.exports.help = {
name:"remove",
description:"A command to remove your url(s) from the database!"
}
19 changes: 19 additions & 0 deletions commands/removeall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const Discord = require("discord.js");
const config = require("../config.json");
module.exports.run = async (bot, message, args) => {

bot.uptimer.uniquestop(message.author.id)
await bot.uptimer.uniqueclear(message.author.id)

let embed = new Discord.MessageEmbed()
.setDescription("✅ | **__I have successfully cleared all of your url(s) from my database!__**")
.setFooter(message.guild.name, message.guild.iconURL({dynamic: true}))
.setColor("#43FF30")
.setThumbnail(message.author.displayAvatarURL({ dynamic: true }))
message.channel.send(embed)
}

module.exports.help = {
name:"removeall",
description:"A command to remove all url(s) of yours from the database!"
}
3 changes: 3 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"prefix":"!"
}
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "quickuptime-discordbot-example",
"version": "1.0.0",
"description": "A example discord.js bot using the quickuptime package!",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Lebyy/QuickUptime-Example.git"
},
"author": "lebyy_dev",
"license": "AGPL-3.0",
"bugs": {
"url": "https://github.com/Lebyy/QuickUptime-Example/issues"
},
"homepage": "https://github.com/Lebyy/QuickUptime-Example#readme",
"dependencies": {
"discord.js": "^12.5.1",
"quickuptime": "^1.0.5-Patch"
}
}
3 changes: 3 additions & 0 deletions token.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"token":"SUPER SECRET Token here!"
}

0 comments on commit edc388d

Please sign in to comment.