Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yanukadeneth99 committed Aug 20, 2022
0 parents commit 80c70a5
Show file tree
Hide file tree
Showing 18 changed files with 969 additions and 0 deletions.
171 changes: 171 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@

# Created by https://www.toptal.com/developers/gitignore/api/node,windows
# Edit at https://www.toptal.com/developers/gitignore?templates=node,windows

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

### Node Patch ###
# Serverless Webpack directories
.webpack/

# Optional stylelint cache

# SvelteKit build / generate output
.svelte-kit

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/node,windows
30 changes: 30 additions & 0 deletions Discord-Faucet-Bot.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#8a8dc4",
"activityBar.activeBorder": "#ead5d6",
"activityBar.background": "#8a8dc4",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#ead5d6",
"activityBarBadge.foreground": "#15202b",
"sash.hoverBorder": "#8a8dc4",
"statusBar.background": "#686cb3",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#8a8dc4",
"statusBarItem.remoteBackground": "#686cb3",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#686cb3",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#686cb399",
"titleBar.inactiveForeground": "#e7e7e799",
"commandCenter.border": "#e7e7e799"
},
"peacock.color": "#686cb3"
}
}
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Discord Bot Faucet

This is a Discord Bot that dispenses Testnet ETH.

## Setup

Create a `.env` file and fill in the following info

```
# Discord Bot Token
DCB_TOKEN="aaaaaaaaaaaaaa.aaaaaaaaa"
# Discord Bot Client ID
DCB_CLIENT_ID="00000000000"
# Discord Server ID
DCB_GUILD_ID="00000000000"
# Discord Channel ID to post log
DCB_BOT_LOG_CHANNEL="000000000"
```
8 changes: 8 additions & 0 deletions client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Exporting the Client

const { Client, Intents } = require("discord.js");

// Create a new Client with these permissions
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

module.exports = client;
9 changes: 9 additions & 0 deletions commands/beep.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Respond user beep with Boop

const { SlashCommandBuilder } = require("@discordjs/builders");

module.exports = {
data: new SlashCommandBuilder()
.setName("beep")
.setDescription("Replies with boop!"),
};
15 changes: 15 additions & 0 deletions commands/echo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Replying the User with what the user typed

const { SlashCommandBuilder } = require("@discordjs/builders");

module.exports = {
data: new SlashCommandBuilder()
.setName("echo")
.setDescription("Replies with your input!")
.addStringOption((option) =>
option
.setName("input")
.setDescription("The input to echo back")
.setRequired(true)
),
};
22 changes: 22 additions & 0 deletions commands/info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Replies user with user info or server info

const { SlashCommandBuilder } = require("@discordjs/builders");

module.exports = {
data: new SlashCommandBuilder()
.setName("info")
.setDescription("Get info about a user or a server!")
.addSubcommand((subcommand) =>
subcommand
.setName("user")
.setDescription("Info about a user")
.addUserOption((option) =>
option.setName("target").setDescription("The user")
)
)
.addSubcommand((subcommand) =>
subcommand
.setName("server")
.setDescription("Info about the server")
),
};
9 changes: 9 additions & 0 deletions commands/ping.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Respond the user with the bot's ping

const { SlashCommandBuilder } = require("@discordjs/builders");

module.exports = {
data: new SlashCommandBuilder()
.setName("ping")
.setDescription("Check the ping of the bot (for admins only)"),
};
28 changes: 28 additions & 0 deletions deploy-commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const fs = require("fs");
const { REST } = require("@discordjs/rest");
const { Routes } = require("discord-api-types/v9");
require("dotenv").config({ path: ".env" });

const commands = [];
const commandFiles = fs
.readdirSync("./commands")
.filter((file) => file.endsWith(".js"));

for (const file of commandFiles) {
const command = require(`./commands/${file}`);
commands.push(command.data.toJSON());
}

const rest = new REST({ version: "9" }).setToken(process.env.DCB_TOKEN);

rest
.put(
Routes.applicationGuildCommands(
process.env.DCB_CLIENT_ID,
process.env.DCB_GUILD_ID
), //* Use for Production
//Routes.applicationCommands(process.env.DBC_CLIENT_ID) //* Use for Development as its updated instantly (no cache)
{ body: commands }
)
.then(() => console.log("Successfully registered application commands"))
.catch(console.error);
25 changes: 25 additions & 0 deletions events/interactionCreate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// For all the Interactions

module.exports = {
name: "interactionCreate",
async execute(interaction) {
if (!interaction.isCommand()) return;

if (interaction.commandName === "beep") {
await require("../responses/beep_response")(interaction);
} else if (interaction.commandName === "echo") {
await require("../responses/echo_response")(interaction);
} else if (interaction.commandName === "info") {
await require("../responses/info_response")(interaction);
} else if (interaction.commandName === "ping") {
await require("../responses/ping_response")(interaction);
}
// Final Reply if non exists
else {
await interaction.reply({
content: "This Command is either Deleted or Work in Progress!",
ephemeral: true,
});
}
},
};
26 changes: 26 additions & 0 deletions events/ready.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// When the Bot Launches

require("dotenv").config({ path: "../.env" });

module.exports = {
name: "ready",
once: true,
async execute(client) {
console.log(`Ready! Logged in as ${client.user.tag}`);

const logchannel = await client.channels.cache.get(
process.env.DCB_BOT_LOG_CHANNEL
);
logchannel.send(
`${new Date(
Date.now()
).toUTCString()} | Faucet Bot | Restarted, and set activity`
);

// Setting Status of Bot
await client.user.setActivity("a tutorial on how to be a good bot", {
type: "WATCHING",
});
await client.user.setStatus("online");
},
};
Loading

0 comments on commit 80c70a5

Please sign in to comment.