added frankenbot
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -1 +1,3 @@ | |||||||
| .env | .env | ||||||
|  | bot/node_modules | ||||||
|  | web/node_modules | ||||||
|  | |||||||
							
								
								
									
										5
									
								
								bot/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								bot/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | |||||||
|  | node_modules | ||||||
|  | # Keep environment variables out of version control | ||||||
|  | .env | ||||||
|  | build | ||||||
|  | src/json/token.json | ||||||
							
								
								
									
										25
									
								
								bot/Plugins/Commands/clear.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								bot/Plugins/Commands/clear.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | |||||||
|  | const Discord = require('discord.js'); | ||||||
|  | const ms = require('ms'); | ||||||
|  |  | ||||||
|  | module.exports.run = async function(bot, message, args){ | ||||||
|  |     message.delete(); | ||||||
|  |     //if (!message.member.hasPermission("KICK_MEMBERS")) return message.channel.send("You do not have the needed permission"); | ||||||
|  |     let toRemove = parseInt(args[0]); | ||||||
|  |  | ||||||
|  |     if(args[0] > 200) return message.channel.send("Invalid arguments"); | ||||||
|  |  | ||||||
|  |     setTimeout(function () { | ||||||
|  |         message.channel.bulkDelete(args[0]) | ||||||
|  |             .then(message.channel.send(`Ich habe ${toRemove} Nachrichten gelöscht!`) | ||||||
|  |                 .then(msg => { | ||||||
|  |                     setTimeout(() => { | ||||||
|  |                         msg.delete(); | ||||||
|  |                     },5000) | ||||||
|  |                 }) | ||||||
|  |             ); | ||||||
|  |     }, ms("500ms")); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | module.exports.help = { | ||||||
|  |     name: "clear"  | ||||||
|  | } | ||||||
							
								
								
									
										27
									
								
								bot/Plugins/Commands/help.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								bot/Plugins/Commands/help.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | |||||||
|  | const { MessageEmbed } = require('discord.js'); | ||||||
|  |  | ||||||
|  | module.exports.run = async function(bot, message, args){ | ||||||
|  |     message.delete(); | ||||||
|  |     // TODO: Figure out how to setup the helppage properly | ||||||
|  |     const userEmbed = new MessageEmbed() | ||||||
|  |     .setColor('#0099ff') | ||||||
|  |     .setTitle('Frankenbot Help') | ||||||
|  |     .setURL('https://frankenbot.io/help') | ||||||
|  |     .setAuthor({ name: 'Frankenbot', iconURL: "https://cdn.slpnetwork.de/img/sys/users/frankenbot.png", url: 'https://frankenbot.io' }) | ||||||
|  |     .setDescription('A List of Commands for Frankenbot') | ||||||
|  |     .setThumbnail("https://cdn.slpnetwork.de/img/sys/users/frankenbot.png") | ||||||
|  |     .addFields( | ||||||
|  |         { name: '**Help**', value: '`!help`' }, | ||||||
|  |     ) | ||||||
|  |     .setFooter({ text: 'commands are used as !<command in lowercase>', iconURL: "https://cdn.slpnetwork.de/img/sys/users/frankenbot.png" }); | ||||||
|  |  | ||||||
|  |     message.channel.send({ embeds: [userEmbed] }).then(msg => { | ||||||
|  |         setTimeout(() => { | ||||||
|  |             msg.delete(); | ||||||
|  |         },5000); | ||||||
|  |     }).catch(err => console.error(err)); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | module.exports.help = { | ||||||
|  |     name: "help"  | ||||||
|  | } | ||||||
							
								
								
									
										10
									
								
								bot/Plugins/Commands/settings.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								bot/Plugins/Commands/settings.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | |||||||
|  | const { MessageEmbed } = require('discord.js'); | ||||||
|  |  | ||||||
|  | module.exports.run = async function(bot, message, args){ | ||||||
|  |     message.delete(); | ||||||
|  |  | ||||||
|  |     // select settings object from existing storage | ||||||
|  | } | ||||||
|  | module.exports.help = { | ||||||
|  |     name: "settings"  | ||||||
|  | } | ||||||
							
								
								
									
										97
									
								
								bot/Plugins/Commands/stats.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								bot/Plugins/Commands/stats.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,97 @@ | |||||||
|  | const { MessageAttachment } = require('discord.js'); | ||||||
|  | const Canvas = require('canvas'); | ||||||
|  |  | ||||||
|  | module.exports.run = async function(bot, message, args){ | ||||||
|  |     // Create a 700x250 pixel canvas and get its context | ||||||
|  |     // The context will be used to modify the canvas | ||||||
|  |     const canvas = Canvas.createCanvas(700, 250); | ||||||
|  |     const context = canvas.getContext('2d'); | ||||||
|  | 	const background = await Canvas.loadImage('./background.png'); | ||||||
|  | 	const avatar = await Canvas.loadImage(message.author.displayAvatarURL({ format: 'jpg' })); | ||||||
|  | 	const progressWidth = 400; | ||||||
|  | 	let type = "image"; | ||||||
|  | 	let xp = 300; | ||||||
|  | 	let max = 1500; | ||||||
|  | 	let perc = ((xp/max)*100)/100; | ||||||
|  | 	let prog = Math.floor(progressWidth*(perc-4)); | ||||||
|  | 	let position; | ||||||
|  | 	let text; | ||||||
|  | 	let correction = 0; | ||||||
|  |  | ||||||
|  | 	if(type == "image") { | ||||||
|  | 		context.drawImage(background, 0, 0, canvas.width, canvas.height); | ||||||
|  | 	} else if(type === "solid") { | ||||||
|  | 		context.fillStyle = "#2d3436"; | ||||||
|  | 		context.fillRect(0, 0, canvas.width, canvas.height); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// Set the color of the stroke | ||||||
|  | 	context.strokeStyle = '#0099ff'; | ||||||
|  | 	 | ||||||
|  | 	// Select the font size and type from one of the natively available fonts | ||||||
|  | 	context.font = '40px sans-serif'; | ||||||
|  |  | ||||||
|  | 	// Select the style that will be used to fill the text in | ||||||
|  | 	context.fillStyle = '#ffffff'; | ||||||
|  |  | ||||||
|  | 	// Actually fill the text with a solid color | ||||||
|  | 	context.fillText(message.member.displayName, canvas.width / 2.5, canvas.height / 2); | ||||||
|  | 	// Select the font size and type from one of the natively available fonts | ||||||
|  | 	text = xp + "/" + max + "xp"; | ||||||
|  | 	context.font = '25px sans-serif'; | ||||||
|  | 	position = (canvas.width / 1.225); | ||||||
|  |  | ||||||
|  | 	// correcting level text overflow | ||||||
|  | 	if(canvas.width - ((canvas.width / 1.225) + context.measureText(text).width) <= 23){ | ||||||
|  | 		correction = (canvas.width - ((canvas.width / 1.225) + context.measureText(text).width)) - 24; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	context.fillText(text, position + correction, canvas.height / 2); | ||||||
|  |  | ||||||
|  | 	// rank banner | ||||||
|  | 	// Select the font size and type from one of the natively available fonts | ||||||
|  | 	context.font = '30px sans-serif'; | ||||||
|  | 	position = (canvas.width / 1.225); | ||||||
|  | 	text = "Level 300"; | ||||||
|  | 	correction = 0; | ||||||
|  | 	// correcting level text overflow | ||||||
|  | 	if(canvas.width - ((canvas.width / 1.225) + context.measureText(text).width) <= 23){ | ||||||
|  | 		correction = (canvas.width - ((canvas.width / 1.225) + context.measureText(text).width)) - 24; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	context.fillText(text, position + correction, canvas.height / 4); | ||||||
|  |  | ||||||
|  | 	// progressbar | ||||||
|  | 	context.fillStyle = '#636e72'; | ||||||
|  | 	context.fillRect(canvas.width / 2.5, canvas.height / 1.8, progressWidth, 50); | ||||||
|  | 	context.moveTo(220, 200); | ||||||
|  | 	context.fillStyle = '#2d3436'; | ||||||
|  | 	if(prog < 0) {prog = Math.floor(progressWidth*perc);} | ||||||
|  | 	context.fillRect(canvas.width / 2.5 + 2, (canvas.height / 1.8) + 3, prog, 44); | ||||||
|  |  | ||||||
|  | 	// Pick up the pen | ||||||
|  | 	context.beginPath(); | ||||||
|  |  | ||||||
|  | 	// Start the arc to form a circle | ||||||
|  | 	context.arc(125, 125, 100, 0, Math.PI * 2, true); | ||||||
|  |  | ||||||
|  | 	// Put the pen down | ||||||
|  | 	context.closePath(); | ||||||
|  |  | ||||||
|  | 	// Clip off the region you drew on | ||||||
|  | 	context.clip(); | ||||||
|  |  | ||||||
|  | 	// Move the image downwards vertically and constrain its height to 200, so that it's square | ||||||
|  | 	context.drawImage(avatar, 25, 25, 200, 200); | ||||||
|  |  | ||||||
|  | 	// Use the helpful Attachment class structure to process the file for you | ||||||
|  | 	const attachment = new MessageAttachment(canvas.toBuffer(), 'profile-image.png'); | ||||||
|  |      | ||||||
|  |     message.channel.send({ | ||||||
|  |         files: [attachment], | ||||||
|  |     }); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | module.exports.help = { | ||||||
|  | 	name: "stats"  | ||||||
|  | } | ||||||
							
								
								
									
										1
									
								
								bot/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								bot/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | |||||||
|  | # Frankenbot | ||||||
							
								
								
									
										
											BIN
										
									
								
								bot/background.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bot/background.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 111 KiB | 
							
								
								
									
										48
									
								
								bot/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								bot/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,48 @@ | |||||||
|  | const { Client, Intents, Collection } = require('discord.js'); | ||||||
|  |  | ||||||
|  | const fs = require('fs'); | ||||||
|  |  | ||||||
|  | let bot = new Client({ | ||||||
|  |     intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES], | ||||||
|  |     disableEveryone: true | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | bot.commands = new Collection(); | ||||||
|  |  | ||||||
|  | /* =============== | ||||||
|  |    * File Import * | ||||||
|  |    =============== */ | ||||||
|  | fs.readdir('./Plugins/Commands/', (err, files) => { | ||||||
|  |     if (err) console.log(err); | ||||||
|  |     let jsfile = files.filter(f => f.split(".").pop() == "js") | ||||||
|  |     if (jsfile.length <= 0) { | ||||||
|  |         console.log("[sys-cmd]: Befehle konnten nicht gefunden werden"); | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     jsfile.forEach((f, i) => { | ||||||
|  |         let props = require(`./Plugins/Commands/${f}`); | ||||||
|  |         console.log(`[sys-cmd]: ${f} [loaded]`); | ||||||
|  |         bot.commands.set(props.help.name, props); | ||||||
|  |     }); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | bot.on('messageCreate', message => { | ||||||
|  |     if (message.author.bot || message.channel.type === "DM") return; | ||||||
|  |  | ||||||
|  |     //Command Handler & Message Handler | ||||||
|  |     let prefix = "!"; | ||||||
|  |  | ||||||
|  |     if (!message.content.startsWith(prefix)) return; | ||||||
|  |  | ||||||
|  |     let messageArray = message.content.split(" "); | ||||||
|  |     let cmd = messageArray[0]; | ||||||
|  |     let args = messageArray.slice(1); | ||||||
|  |     let commandfile = bot.commands.get(cmd.slice(prefix.length)); | ||||||
|  |     let settings = null; | ||||||
|  |  | ||||||
|  |     if (commandfile) commandfile.run(bot, message, args); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | bot.login(require("./json/token.json").token) | ||||||
							
								
								
									
										3
									
								
								bot/json/blacklist.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								bot/json/blacklist.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | |||||||
|  | { | ||||||
|  |     "list": ["https://discord.gg","http://discord.gg","http:/discord.gg","https:/discord.gg", "https:discord.gg","http:discord.gg", "discord.gg","hgw", "@random"] | ||||||
|  | } | ||||||
							
								
								
									
										8
									
								
								bot/json/botconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								bot/json/botconfig.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | |||||||
|  | { | ||||||
|  |     "prefix":"!", | ||||||
|  |     "yellow": "#f5ff7b", | ||||||
|  |     "orange": "#ffb87b", | ||||||
|  |     "red": "#ff7b7b", | ||||||
|  |     "green": "#7bff9f", | ||||||
|  |     "blue": "#38c2ff" | ||||||
|  | } | ||||||
							
								
								
									
										11
									
								
								bot/json/settings.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								bot/json/settings.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | |||||||
|  | { | ||||||
|  |     "315176194050097152": { | ||||||
|  |         "spam": "botspam", | ||||||
|  |         "prefix": "?", | ||||||
|  |         "greet": "welcome-leave" | ||||||
|  |     }, | ||||||
|  |     "422056965041291264": { | ||||||
|  |         "spam": "mainhall", | ||||||
|  |         "prefix": "?" | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										3
									
								
								bot/json/token.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								bot/json/token.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | |||||||
|  | { | ||||||
|  |     "token":"NDE5NTI4OTU1MjMwNjgzMTM2.GZ9Nnx.yCZHtiAIiLULzx3Q1QB5cRGjNj6fM_EUSsYOKo" | ||||||
|  | } | ||||||
							
								
								
									
										1531
									
								
								bot/package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										1531
									
								
								bot/package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										29
									
								
								bot/package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								bot/package.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | |||||||
|  | { | ||||||
|  |   "name": "Frankenbot Discord Instance", | ||||||
|  |   "version": "1.0.0", | ||||||
|  |   "description": "", | ||||||
|  |   "main": "sharding.js", | ||||||
|  |   "scripts": { | ||||||
|  |     "build": "tsc", | ||||||
|  |     "start": "node build/sharding.js", | ||||||
|  |     "dev": "concurrently \"tsc -w\" \"nodemon build/sharding.js\"" | ||||||
|  |   }, | ||||||
|  |   "author": "Steev", | ||||||
|  |   "repository": { | ||||||
|  |     "type":"git", | ||||||
|  |     "url": "" | ||||||
|  |   }, | ||||||
|  |   "license": { | ||||||
|  |     "type": "frankenbot-license", | ||||||
|  |     "url": "https://path-to.license" | ||||||
|  |   }, | ||||||
|  |   "dependencies": { | ||||||
|  |     "-": "^0.0.1", | ||||||
|  |     "@prisma/client": "^3.12.0", | ||||||
|  |     "canvas": "^2.9.3", | ||||||
|  |     "discord.js": "^13.6.0", | ||||||
|  |     "g": "^2.0.1", | ||||||
|  |     "moment": "^2.29.1", | ||||||
|  |     "ms": "^2.1.3" | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										17
									
								
								bot/sharding.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								bot/sharding.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | |||||||
|  | // Include discord.js ShardingMana | ||||||
|  | const { ShardingManager } = require('discord.js'); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | // Create your ShardingManager instance | ||||||
|  | const manager = new ShardingManager("./index.js", { | ||||||
|  |     // for ShardingManager options see: | ||||||
|  |     // https://discord.js.org/#/docs/main/stable/class/ShardingManager | ||||||
|  |     totalShards: "auto", | ||||||
|  |     token: require("./json/token.json").token | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | // Emitted when a shard is created | ||||||
|  | manager.on("shardCreate", shard => console.log(`Shard ${shard.id} launched`)); | ||||||
|  |  | ||||||
|  | // Spawn your shards | ||||||
|  | manager.spawn(); | ||||||
		Reference in New Issue
	
	Block a user