diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..db61057 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,71 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + schedule: + - cron: '44 22 * * 6' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 \ No newline at end of file diff --git a/commands/help.js b/commands/help.js new file mode 100644 index 0000000..75c0ff6 --- /dev/null +++ b/commands/help.js @@ -0,0 +1,41 @@ +const message = require('../utils/messages'); +const { + MessageEmbed, + MessageActionRow, + MessageButton +} = require('discord.js'); + +module.exports = { + name: "help", + description: "Get all Bot Commands", + run: async (client, interaction) => { + + let helpembed = new MessageEmbed() + helpembed.setColor("RANDOM") + helpembed.setAuthor( + `Commands of ${client.user.username}` + ) + helpembed.setColor("#2f3136") + helpembed.setThumbnail("https://cdn.discordapp.com/avatars/608119997713350679/d71c7cbb2ba132867367ed47261aea6d.png") + client.commands.map((cmd) => { + helpembed.addField( + `\`${cmd.name}\``, + `${cmd.description}`, + true + ); + }) + helpembed.setTimestamp() + helpembed.setFooter(`© EmotionChild | Have a nice day!`); + + const row = new MessageActionRow() + .addComponents( + new MessageButton() + .setEmoji('865572290065072128') + .setLabel(`Invite ${client.user.username}`) + .setURL(`https://discord.com/api/oauth2/authorize?client_id=726333575091454002&permissions=8&scope=bot%20applications.commands`) + .setStyle('LINK'), + ); + + await interaction.reply({ embeds: [helpembed],components: [row], ephemeral: true }); + }, +}; \ No newline at end of file diff --git a/commands/invite.js b/commands/invite.js new file mode 100644 index 0000000..d054474 --- /dev/null +++ b/commands/invite.js @@ -0,0 +1,29 @@ +const messages = require('../utils/messages'); +const { + MessageEmbed, + MessageActionRow, + MessageButton +} = require('discord.js'); + +module.exports = { + name: "invite", + description: "Get Invite Link for Giveaway Child", + run: async (client, interaction) => { + + let invite = new MessageEmbed() + .setAuthor(`Invite of ${client.user.username}`, `${client.user.displayAvatarURL({ format: 'png' })}`) + .setColor("#2f3136") + .setFooter(`© EmotionChild | Have a nice day!`); + + const row = new MessageActionRow() + .addComponents( + new MessageButton() + .setEmoji('865572290065072128') + .setLabel(`Invite ${client.user.username}`) + .setURL(`https://discord.com/api/oauth2/authorize?client_id=726333575091454002&permissions=8&scope=bot%20applications.commands`) + .setStyle('LINK'), + ); + + await interaction.reply({ embeds: [invite],components: [row], ephemeral: true }); + }, +}; \ No newline at end of file diff --git a/commands/ping.js b/commands/ping.js new file mode 100644 index 0000000..6c7b63a --- /dev/null +++ b/commands/ping.js @@ -0,0 +1,39 @@ +const messages = require('../utils/messages'); +const { MessageEmbed } = require("discord.js"); + +module.exports = { + name: "ping", + description: "Tells the bot's latency,", + run: async (client, interaction) => { + // If the member doesn't have enough permissions + if (!interaction.member.permissions.has("SEND_MESSAGES")) { + return interaction.reply({ + content: + ":x: You need to have the manage messages permissions to start giveaways.", + ephemeral: true, + }); + } + + let circles = { + green: "<:online:885049752297824276>", + yellow: "<:idle:885049726460899339>", + red: "<:offline:885049312877346817>", + }; + + let botping = new MessageEmbed() + .setTitle(`${client.user.name} Ping`) + .setColor("2f3136") + .addFields({ + name: "<:link:911514727375577088> Bot Ping:", + value: `${ + client.ws?.ping <= 200 + ? circles.green + : client.ws?.ping <= 400 + ? circles.yellow + : circles.red + } ${client.ws?.ping}ms`, + }) + .setTimestamp(); + await interaction.reply({ embeds: [botping] }); + }, +}; \ No newline at end of file diff --git a/commands/stats.js b/commands/stats.js new file mode 100644 index 0000000..3e2c95d --- /dev/null +++ b/commands/stats.js @@ -0,0 +1,85 @@ +const os = require('os'); +const { MessageEmbed } = require('discord.js'); +const feroms = require('fero-ms'); + +module.exports = { + name: 'stats', + description: 'Sends bot physical statistics', + run: async(client, interaction) => { + let uptime = client.uptime; + let shortUptime = feroms.ms(uptime); + let model = os.cpus()[0].model; + let cores = os.cpus().length; + let platform = os.platform(); + let nodejs = process.version; + let djs = require('discord.js').version; + let botversion = require('../package.json').version; + let server = client.guilds.cache.size; + let user = client.users.cache.size; + let channel = client.channels.cache.size; + + let statsembed = new MessageEmbed() + .addFields( + { + name: '<:live2:896715171882500106> I have been online for?', + value: `\`\`\`${shortUptime}\`\`\`` + }, + { + name: '<:globe:896718155416760340> Guilds', + value: `\`${server}\``, + inline: true + }, + { + name: '<:mention:896718358672707584> Users', + value: `\`${user}\``, + inline: true + }, + { + name: '<:channel:896717996326809641> Channels', + value: `\`${channel}\``, + inline: true + }, + { + name: 'Bot Version', + value: `\`v${botversion}\``, + inline: true + }, + { + name: '<:prime:896718399776886816> Arch', + value: `\`${os.arch()}\``, + inline: true + }, + { + name: '<:info:896718244461826140> Platform', + value: `\`${platform}\``, + inline: true + }, + { + name: '<:desktop:896718080821047346> Cores', + value: `\`${cores}\``, + inline: true + }, + { + name: ' Discord.js Version', + value: `\`v${djs}\``, + inline: true + }, + { + name: '<:jss:896718571491704852> Node.js Version', + value: `\`${nodejs}\``, + inline: true + }, + { + name: '<:ram:896715172029276180> Ram Usage', + value: `\`${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)}MB/ ${(os.totalmem() / 1024 / 1024).toFixed(2)}MB\``, + inline: true + }, + { + name: '<:desktop:896718080821047346> CPU Model', + value: `\`\`\`${model}\`\`\`` + } + ) + .setTimestamp() + await interaction.reply({ embeds: [statsembed] }); + } + } \ No newline at end of file diff --git a/package.json b/package.json index 0d54604..396a5a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "giveaway-child", - "version": "1.0.0", + "version": "2.0.0", "description": "", "main": "index.js", "scripts": { @@ -25,6 +25,7 @@ "discord-giveaways": "^5.0.1", "discord-sync-commands": "^0.3.0", "discord.js": "^13.2.0", + "fero-ms": "^2.0.7", "ms": "^2.1.3", "quickdb": "^1.0.5", "quickmongo": "^4.0.0"