Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 01bfd0d
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 22:58:06 2022 +0530

    Finished getting balance for setup tokens

commit 6114bf1
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 20:41:36 2022 +0530

    Fix up balance

commit 5dea12d
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 19:51:12 2022 +0530

    Setup getting balance for rinkeby,mumbai and goerli

commit 00d6b47
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 19:44:32 2022 +0530

    Moved to json

commit d082de6
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 16:42:34 2022 +0530

    Worked on getting the balance of goerli

commit 4d83345
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 15:34:47 2022 +0530

    Worked on Feedback

commit 84e42c8
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 02:05:14 2022 +0530

    Removed website command

commit 1421fa9
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 00:22:56 2022 +0530

    Removed unwanted packages and moved to discord.js

commit 4d897b0
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 00:10:15 2022 +0530

    Checking Webhook discord github

commit bd0ddcb
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sat Aug 20 23:30:42 2022 +0530

    Updated code
  • Loading branch information
yanukadeneth99 committed Aug 21, 2022
1 parent a771777 commit f16c240
Show file tree
Hide file tree
Showing 14 changed files with 378 additions and 100 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,7 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/node,windows
# End of https://www.toptal.com/developers/gitignore/api/node,windows

# Configuration File
config.json
26 changes: 7 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,11 @@ This is a Discord Bot that dispenses Testnet ETH.

## Setup

Create a `.env` file and fill in the following info
Change the `example.config.json` into `config.json`, and fill in the required fields.

```
# 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_LOG_CHANNEL="000000000"
# Discord Admin Role ID
DCB_ADMIN_ROLE_ID="00000000"
# Discord Feedback Channel ID
DCB_FEEDBACK_CHANNEL="00000000000"
# Goerli Alchemy Key
ALCHEMY_GOERLI_URL="https://eth-goerli.g.alchemy.com/v2/xxxxxxxxxxxxxxxxxxxx"
# Own Wallet Address
WALLET_ADDRESS="xxxxxxxxxxxxxxxxxxxxx"
```
## Adding Features

1. Fork the project
2. Create a new branch
3. Commit the changes
4. Yeet the changes
24 changes: 17 additions & 7 deletions commands/balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,29 @@ module.exports = {
.setName("network")
.setDescription("Select the network to view balance")
.setRequired(true)
.addChoices({
name: "Goerli",
value: "goerli",
})
.addChoices(
{
name: "Goerli",
value: "goerli",
},
{
name: "Rinkeby",
value: "rinkeby",
},
{
name: "Mumbai",
value: "mumbai",
}
)
)
.addStringOption((option) =>
option
.setName("token")
.setDescription("Token Type to search")
.setDescription("External ERC20 tokens if applicable")
.setRequired(false)
.addChoices({
name: "ETH",
value: "eth",
name: "LINK",
value: "link",
})
),
};
10 changes: 5 additions & 5 deletions delete-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

const { REST } = require("@discordjs/rest");
const { Routes } = require("discord.js");
require("dotenv").config();
const { bot } = require("./config.json");

// Get the REST
const rest = new REST({ version: "10" }).setToken(process.env.DCB_TOKEN);
const rest = new REST({ version: "10" }).setToken(bot.token);

//* Use to remove all commands from the Guild
// rest
// .put(
// Routes.applicationGuildCommands(
// process.env.DCB_CLIENT_ID,
// process.env.DCB_GUILD_ID
// bot.clientId,
// bot.guildId
// ),
// { body: [] }
// )
Expand All @@ -21,6 +21,6 @@ const rest = new REST({ version: "10" }).setToken(process.env.DCB_TOKEN);

//* Use to remove all commands publically
rest
.put(Routes.applicationCommands(process.env.DCB_CLIENT_ID), { body: [] })
.put(Routes.applicationCommands(bot.clientId), { body: [] })
.then(() => console.log("Successfully deleted all application commands."))
.catch(console.error);
16 changes: 6 additions & 10 deletions deploy-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require("node:fs");
const path = require("node:path");
const { REST } = require("@discordjs/rest");
const { Routes } = require("discord.js");
require("dotenv").config();
const { bot } = require("./config.json");

// Get the commands from the `/commands` folder and to the array
const commands = [];
Expand All @@ -20,23 +20,19 @@ for (const file of commandFiles) {
}

// Get the REST
const rest = new REST({ version: "10" }).setToken(process.env.DCB_TOKEN);
const rest = new REST({ version: "10" }).setToken(bot.token);

//* Use for Development (Updates only the passed guild data)
rest
.put(
Routes.applicationGuildCommands(
process.env.DCB_CLIENT_ID,
process.env.DCB_GUILD_ID
),
{ body: commands }
)
.put(Routes.applicationGuildCommands(bot.clientId, bot.guildId), {
body: commands,
})
.then(() => console.log("Successfully registered application commands"))
.catch(console.error);

//* Use for Production as it updates the commands public
// rest
// .put(Routes.applicationCommands(process.env.DCB_CLIENT_ID), {
// .put(Routes.applicationCommands(bot.clientId), {
// body: commands,
// })
// .then(() => console.log("Successfully registered application commands"))
Expand Down
5 changes: 2 additions & 3 deletions events/interactionCreate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// For all the Interactions

const { InteractionType } = require("discord.js");
const { channels } = require("../config.json");

module.exports = {
name: "interactionCreate",
Expand All @@ -25,9 +26,7 @@ module.exports = {
else if (interaction.type === InteractionType.ModalSubmit) {
if (interaction.customId === "feedbackModal") {
// Get the Feedback Channel
const fdChannel = await client.channels.cache.get(
process.env.DCB_FEEDBACK_CHANNEL
);
const fdChannel = await client.channels.cache.get(channels.feedback);
// Get the value of the sent messages and send on the feedback channel
const subject = interaction.fields.getTextInputValue("subject");
const description = interaction.fields.getTextInputValue("description");
Expand Down
6 changes: 2 additions & 4 deletions events/ready.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// When the Bot Launches

require("dotenv").config({ path: "../.env" });
const { channels } = require("../config.json");

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_LOG_CHANNEL
);
const logchannel = await client.channels.cache.get(channels.log);
// logchannel.send(
// `[LOGIN] | ${new Date(
// Date.now()
Expand Down
40 changes: 40 additions & 0 deletions example.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"bot": {
"clientId": "00000000000000",
"guildId": "00000000000",
"token": "xxxxxxxxxxxxx"
},
"channels": {
"feedback": "00000000000",
"log": "00000000000"
},
"roles": {
"admin": {
"id": "000000000000000"
}
},
"networks": {
"goerli": {
"nativeCurrency": "eth",
"ALCHEMY_URL": "https://eth-goerli.g.alchemy.com/v2/xxxxxxxxxxx"
},
"rinkeby": {
"nativeCurrency": "eth",
"ALCHEMY_URL": "https://eth-rinkeby.alchemyapi.io/v2/xxxxxxxxxx"
},
"mumbai": {
"nativeCurrency": "matic",
"ALCHEMY_URL": "https://polygon-mumbai.g.alchemy.com/v2/xxxxxxxxxxxx"
}
},
"tokens": {
"link": {
"goerli": "0x326C977E6efc84E512bB9C30f76E30c160eD06FB",
"rinkeby": "0x01BE23585060835E02B77ef475b0Cc51aA1e0709",
"mumbai": "0x326C977E6efc84E512bB9C30f76E30c160eD06FB"
}
},
"stats": {
"walletAddress": "xxxxxx"
}
}
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const fs = require("node:fs");
const path = require("node:path");
const { Collection } = require("discord.js");
require("dotenv").config({ path: ".env" });
const { bot } = require("./config.json");
const client = require("./client"); // Get Client

// Run the Events depending on whether it's once or on.
Expand Down Expand Up @@ -41,7 +41,7 @@ for (const file of commandFiles) {

// Login to the Bot
try {
client.login(process.env.DCB_TOKEN);
client.login(bot.token);
} catch (error) {
console.error(error);
}
Loading

0 comments on commit f16c240

Please sign in to comment.