This repository has been archived by the owner on Jul 30, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
689 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: npm | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
time: "06:00" | ||
timezone: Universal | ||
open-pull-requests-limit: 10 | ||
target-branch: dev | ||
assignees: | ||
- iwa | ||
labels: | ||
- dependencies | ||
ignore: | ||
- dependency-name: popyt | ||
versions: | ||
- ">= 3.1.a" | ||
- "< 3.2" | ||
- dependency-name: popyt | ||
versions: | ||
- ">= 3.3.a" | ||
- "< 3.4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Client, Message, TextChannel, MessageEmbed } from 'discord.js'; | ||
import utilities from '../utils/utilities'; | ||
import { Db } from 'mongodb'; | ||
|
||
module.exports.run = async (bot: Client, msg: Message, args: string[], db: Db) => { | ||
if (!utilities.isMod(msg) && msg.author.id != process.env.IWA && msg.author.id != process.env.QUMU) return; | ||
|
||
let message = await db.collection('suggestions').findOne({ _id: parseInt(args[0]) }); | ||
if(!message) | ||
return msg.react('❌'); | ||
|
||
let channel = await bot.channels.fetch(process.env.SUGGESTIONTC); | ||
let suggestion = await (channel as TextChannel).messages.fetch(message.msg) | ||
|
||
let embed = suggestion.embeds[0]; | ||
|
||
embed.setColor(4289797) | ||
|
||
let desc = embed.description; | ||
embed.setDescription(`${desc}\n\n**✅ Implemented by ${msg.author.username}**\n\n`); | ||
|
||
let reactions = suggestion.reactions.resolve('👀'); | ||
let users = await reactions.users.fetch(); | ||
|
||
let embedDM = new MessageEmbed(); | ||
embedDM.setTitle(`Suggestion "${embed.description.slice(0, 10)}..." has been updated!`); | ||
embedDM.setDescription(`Check it out [here](${suggestion.url})`) | ||
|
||
for(const user of users.array()) { | ||
if(!user.bot) { | ||
await user.send(embedDM).catch(() => {return}); | ||
console.log('yo') | ||
} | ||
} | ||
|
||
await suggestion.edit(embed); | ||
return msg.react('✅'); | ||
}; | ||
|
||
module.exports.help = { | ||
name: 'implemented', | ||
usage: "?implemented (id)", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Client, Message, MessageEmbed, TextChannel, MessageAttachment } from 'discord.js' | ||
import { Db, MongoClient } from 'mongodb'; | ||
|
||
export default async function suggestion (bot: Client, msg: Message, mongod:MongoClient, db: Db) { | ||
let req = msg.cleanContent; | ||
let channel = await bot.channels.fetch(process.env.SUGGESTIONTC); | ||
|
||
let embed = new MessageEmbed(); | ||
if(msg.attachments.first()) { | ||
await msg.react('🔄'); | ||
await download(msg.attachments.first().proxyURL, `download/${msg.attachments.first().name}`); | ||
await uploadFile(`${msg.attachments.first().name}`).catch(console.error); | ||
embed.setThumbnail(`https://cdn.iwa.sh/attachment/${msg.attachments.first().name}`); | ||
req = `${req}\n\n[📂attachment link](https://cdn.iwa.sh/attachment/${msg.attachments.first().name})` | ||
} | ||
embed.setDescription(req); | ||
embed.setAuthor(msg.author.username, msg.author.avatarURL({ format: 'png', dynamic: false, size: 128 })) | ||
|
||
let counter = await db.collection('suggestions').findOne({ _id: 'counter' }); | ||
if(!counter) { | ||
await db.collection('suggestions').insertOne({ _id: 'counter', count: 0 }); | ||
counter = { _id: 'counter', count: 0 }; | ||
} | ||
|
||
await db.collection('suggestions').updateOne({ _id: 'counter' }, { $inc: { count: 1 }}); | ||
embed.setFooter(`#${counter.count+1}`); | ||
|
||
await msg.delete(); | ||
let sent = await (channel as TextChannel).send(embed); | ||
await db.collection('suggestions').insertOne({ _id: counter.count+1, msg: sent.id }); | ||
|
||
await mongod.close(); | ||
|
||
await sent.react('✅'); | ||
await sent.react('❌'); | ||
return sent.react('👀'); | ||
}; | ||
|
||
const fs = require('fs'); | ||
const request = require('request'); | ||
|
||
async function download(uri: any, filename: any) { | ||
let bar = new Promise((resolve, reject) => { | ||
request.head(uri, function(err: any, res: { headers: { [x: string]: any; }; }, body: any) { | ||
request(uri).pipe(fs.createWriteStream(filename)).on('close', () => { resolve() }); | ||
}); | ||
}); | ||
return bar; | ||
}; | ||
|
||
const { Storage } = require('@google-cloud/storage'); | ||
const storage = new Storage(); | ||
|
||
async function uploadFile(filename: string) { | ||
await storage.bucket('cdn.iwa.sh').upload(`download/${filename}`, { | ||
gzip: false, | ||
destination: `attachment/${filename}`, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.