Skip to content

Commit

Permalink
patreon
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherBThai committed May 28, 2020
1 parent 16e7c57 commit ccbac03
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 32 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

// Grab tokens and secret files
const debug = false;
const debug = true;
if(!debug) var tracer = require('dd-trace').init()
if(debug) var auth = require('../tokens/scuttester-auth.json');
else var auth = require('../tokens/owo-auth.json');
Expand Down
122 changes: 94 additions & 28 deletions src/commands/commandList/patreon/alastor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const CommandInterface = require('../../CommandInterface.js');
const dateUtil = require('../../../utils/dateUtil.js');
const gif1 = "https://cdn.discordapp.com/attachments/626155987904102402/673253558577004555/image0.gif";
const gif2 = "https://cdn.discordapp.com/attachments/626155987904102402/673253769907142679/image0.gif";
const gif3 = "https://cdn.discordapp.com/attachments/626155987904102402/696858611627851787/image0.gif";
const gif4 = "https://cdn.discordapp.com/attachments/626155987904102402/696858882680684604/image0.gif";
const table = "alastor";

module.exports = new CommandInterface({
Expand All @@ -33,39 +35,103 @@ module.exports = new CommandInterface({
six:400,

execute: async function(p){
const lasttime = await p.redis.hget("cd_"+p.msg.author.id,table);
const afterMid = dateUtil.afterMidnight(lasttime);

let streak = 1;
let title = p.msg.author.username+"'s Alastor";
if (afterMid.after) {
await p.redis.hset("cd_"+p.msg.author.id,table,afterMid.now);
if (afterMid.withinDay || !lasttime) {
streak = await p.redis.hincrby(p.msg.author.id,table);
title = p.msg.author.username+" fed Alastor!";
} else {
await p.redis.hset(p.msg.author.id,table,1);
title = p.msg.author.username+", Alastor has stopped broadcasting";
if (p.args[0] === "feed") {
const lastCrown = await p.redis.hget("cd_"+p.msg.author.id,table+"_crown");
if (!lastCrown)
await p.redis.hset("cd_"+p.msg.author.id,table+"_crown",new Date());
else if (new Date() - new Date(lastCrown) > 345600000) {
displayCrown(p);
return;
}
feed(p);
} else if (p.args[0] === "crown") {
giveCrown(p);
} else {
streak = await p.redis.hget(p.msg.author.id,table);
display(p);
}
}
})

const embed = {
"author": {
"name": title,
"icon_url": p.msg.author.avatarURL
},
"color":p.config.embed_color,
"image": {
"url": afterMid.after ? gif1 : gif2
},
"footer": {
"text": `STREAK: ${streak} | Resets in: ${afterMid.hours}H ${afterMid.minutes}M ${afterMid.seconds}S`
}
async function giveCrown(p) {
let lastCrown = await p.redis.hget("cd_"+p.msg.author.id,table+"_crown");
lastCrown = lastCrown ? new Date(lastCrown) : new Date();
if (new Date() - lastCrown < 345600000) {
p.errorMsg(", Alastor doesn't need a crown");
return;
}

let result = await p.redis.incr("crown",p.msg.author.id,-1);
// Error checking
if(result==null||result<0){
if(result<0) p.redis.incr("crown",p.msg.author.id,1);
p.errorMsg(", you do not have any crowns! >:c",3000);
return;
}

await p.redis.hset("cd_"+p.msg.author.id,table+"_crown",new Date());
display(p, "That seems to have done the trick, he seems content. He will allow you to claim the daily streak.. maybe.", gif4);
}

async function displayCrown(p) {
display(p, "Alastor is ready to battle. Try calming him down with a gift, quickly! Try the crown!", gif3);
}

async function feed(p) {
const lasttime = await p.redis.hget("cd_"+p.msg.author.id,table);
const afterMid = dateUtil.afterMidnight(lasttime);

let streak = 1;
let title = p.msg.author.username+"'s Alastor";
if (afterMid.after) {
await p.redis.hset("cd_"+p.msg.author.id,table,afterMid.now);
if (afterMid.withinDay || !lasttime) {
streak = await p.redis.hincrby(p.msg.author.id,table);
title = p.msg.author.username+" fed Alastor!";
} else {
await p.redis.hset(p.msg.author.id,table,1);
title = p.msg.author.username+", Alastor has stopped broadcasting";
}
} else {
streak = await p.redis.hget(p.msg.author.id,table);
}

p.send({embed});
const embed = {
"author": {
"name": title,
"icon_url": p.msg.author.avatarURL
},
"color":p.config.embed_color,
"image": {
"url": afterMid.after ? gif1 : gif2
},
"footer": {
"text": `STREAK: ${streak} | Resets in: ${afterMid.hours}H ${afterMid.minutes}M ${afterMid.seconds}S`
}
}

})
p.send({embed});
}

async function display(p, title, gif) {
const lasttime = await p.redis.hget("cd_"+p.msg.author.id,table);
const afterMid = dateUtil.afterMidnight(lasttime);
const streak = await p.redis.hget(p.msg.author.id,table);
if (!title) title = p.msg.author.username+"'s Alastor";
if (!gif) gif = gif2

const embed = {
"author": {
"name": title,
"icon_url": p.msg.author.avatarURL
},
"color":p.config.embed_color,
"image": {
"url": gif
},
"footer": {
"text": `STREAK: ${streak} | Resets in: ${afterMid.hours}H ${afterMid.minutes}M ${afterMid.seconds}S`
}
}

p.send({embed});
}
82 changes: 82 additions & 0 deletions src/commands/commandList/patreon/lollipop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* OwO Bot for Discord
* Copyright (C) 2019 Christopher Thai
* This software is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
* For more information, see README.md and LICENSE
*/

const CommandInterface = require('../../CommandInterface.js');

const emoji = "<a:lollipop:714220336010362921>";
const owner = "370709798020448257";
const data = "lollipop";
const plural = "lollipops";

module.exports = new CommandInterface({

alias:["lollipop"],

args:"{@user}",

desc:"Give a lollipop to someone! You can only gain one if you receive it! This command was created by SleepyPanda",

example:[],

related:[],

permissions:["sendMessages"],

group:["patreon"],

cooldown:30000,
half:80,
six:400,
bot:true,

execute: async function(p){
if(p.args.length==0){
display(p);
p.setCooldown(5);
}else{
let user = p.getMention(p.args[0]);
if(!user){
user = await p.fetch.getMember(p.msg.channel.guild,p.args[0]);
if(!user){
p.errorMsg(", Invalid syntax! Please tag a user!",3000);
p.setCooldown(5);
return;
}
}
if(user.id==p.msg.author.id){
p.errorMsg(", You cannot give it yourself!!",3000);
p.setCooldown(5);
return;
}
give(p,user);
}
}
});

async function display(p){
let count = await p.redis.hget("data_"+p.msg.author.id, data);
if(!count) count = 0;

p.replyMsg(emoji, ", you currently have "+count+" "+plural+"!");
}

async function give(p,user){
if(p.msg.author.id!=owner){
let result = await p.redis.hincrby("data_"+p.msg.author.id, data, -1);

// Error checking
if(result==null||result<0){
if(result<0) p.redis.hincrby("data_"+p.msg.author.id, data, 1);
p.errorMsg(", you do not have any "+plural+" to give! >:c",3000);
p.setCooldown(5);
return;
}
}

await p.redis.hincrby("data_"+user.id, data, 2);
p.send(`${emoji} **| ${user.username}**, ${p.msg.author.username} gave you 2 ${plural}!`);
}
82 changes: 82 additions & 0 deletions src/commands/commandList/patreon/teddy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* OwO Bot for Discord
* Copyright (C) 2019 Christopher Thai
* This software is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
* For more information, see README.md and LICENSE
*/

const CommandInterface = require('../../CommandInterface.js');

const emoji = "<:teddy:714218781022617710>";
const owner = "625340848556474369";
const data = "teddy";
const plural = "teddy bears";

module.exports = new CommandInterface({

alias:["teddy"],

args:"{@user}",

desc:"Give a teddy bear to someone! You can only gain one if you receive it! This command was created by {ᗩTᒪ} StellaBear",

example:[],

related:[],

permissions:["sendMessages"],

group:["patreon"],

cooldown:30000,
half:80,
six:400,
bot:true,

execute: async function(p){
if(p.args.length==0){
display(p);
p.setCooldown(5);
}else{
let user = p.getMention(p.args[0]);
if(!user){
user = await p.fetch.getMember(p.msg.channel.guild,p.args[0]);
if(!user){
p.errorMsg(", Invalid syntax! Please tag a user!",3000);
p.setCooldown(5);
return;
}
}
if(user.id==p.msg.author.id){
p.errorMsg(", You cannot give it yourself!!",3000);
p.setCooldown(5);
return;
}
give(p,user);
}
}
});

async function display(p){
let count = await p.redis.hget("data_"+p.msg.author.id, data);
if(!count) count = 0;

p.replyMsg(emoji, ", you currently have "+count+" "+plural+"!");
}

async function give(p,user){
if(p.msg.author.id!=owner){
let result = await p.redis.hincrby("data_"+p.msg.author.id, data, -1);

// Error checking
if(result==null||result<0){
if(result<0) p.redis.hincrby("data_"+p.msg.author.id, data, 1);
p.errorMsg(", you do not have any "+plural+" to give! >:c",3000);
p.setCooldown(5);
return;
}
}

await p.redis.hincrby("data_"+user.id, data, 2);
p.send(`${emoji} **| ${user.username}**, ${p.msg.author.username} thinks you're bear-y special and sent you 2 teddies! *hugs*`);
}
1 change: 0 additions & 1 deletion src/commands/commandList/utils/feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ module.exports = new CommandInterface({
cooldown:600000,
half:15,
six:30,
bot:true,

execute: async function(p){
let message = p.args.join(" ");
Expand Down
1 change: 0 additions & 1 deletion src/commands/commandList/utils/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module.exports = new CommandInterface({
cooldown:5000,
half:100,
six:500,
bot:true,

execute: function(p){
// quick and dirty fix for function calls and tags
Expand Down
2 changes: 1 addition & 1 deletion src/owo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const dbl = new DBL(auth.dbl);
class OwO extends Base{
constructor(bot){
super(bot);
this.debug = false;
this.debug = true;
this.auth = auth;
this.dbl = dbl;

Expand Down

0 comments on commit ccbac03

Please sign in to comment.