const { Client, GatewayIntentBits, Collection, Events, EmbedBuilder, PermissionsBitField, Permissions, MessageManager, Embed } = require("discord.js");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
],
});
const fs = require('fs');
client.commands = new Collection();
const paypal = require('paypal-rest-sdk');
client.config = require("./config.json");
const prefix = '!';
const functions = fs.readdirSync("./functions").filter(file => file.endsWith(".js"));
const eventFiles = fs.readdirSync("./events").filter(file => file.endsWith(".js"));
const commandFolders = fs.readdirSync("./commands");
(async () => {
for (file of functions) {
require(`./functions/${file}`)(client);
}
client.handleEvents(eventFiles, "./events");
client.handleCommands(commandFolders, "./commands");
})();
paypal.configure({
'mode': 'sandbox', // set to 'live' for production
'client_id': '',
'client_secret': ''
});
client.on('message', async (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(' ');
const command = args.shift().toLowerCase();
if (command === 'pay') {
const paymentData = {
'intent': 'sale',
'payer': {
'payment_method': 'paypal'
},
'redirect_urls': {
'return_url': 'https://example.com/success',
'cancel_url': 'https://example.com/cancel'
},
'transactions': [{
'item_list': {
'items': [{
'name': 'Payment for Discord bot',
'sku': 'DISCORDBOT01',
'price': '35.00',
'currency': 'EUR',
'quantity': 1
}]
},
'amount': {
'currency': 'EUR',
'total': '35.00'
},
'description': 'Payment for Discord bot service'
}]
};
const { Client, GatewayIntentBits, Collection, Events, EmbedBuilder, PermissionsBitField, Permissions, MessageManager, Embed } = require("discord.js");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
],
});
const fs = require('fs');
client.commands = new Collection();
const paypal = require('paypal-rest-sdk');
client.config = require("./config.json");
const prefix = '!';
const functions = fs.readdirSync("./functions").filter(file => file.endsWith(".js"));
const eventFiles = fs.readdirSync("./events").filter(file => file.endsWith(".js"));
const commandFolders = fs.readdirSync("./commands");
(async () => {
for (file of functions) {
require(`./functions/${file}`)(client);
}
client.handleEvents(eventFiles, "./events");
client.handleCommands(commandFolders, "./commands");
})();
paypal.configure({
'mode': 'sandbox', // set to 'live' for production
'client_id': '',
'client_secret': ''
});
client.on('message', async (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(' ');
const command = args.shift().toLowerCase();
if (command === 'pay') {
const paymentData = {
'intent': 'sale',
'payer': {
'payment_method': 'paypal'
},
'redirect_urls': {
'return_url': 'https://example.com/success',
'cancel_url': 'https://example.com/cancel'
},
'transactions': [{
'item_list': {
'items': [{
'name': 'Payment for Discord bot',
'sku': 'DISCORDBOT01',
'price': '35.00',
'currency': 'EUR',
'quantity': 1
}]
},
'amount': {
'currency': 'EUR',
'total': '35.00'
},
'description': 'Payment for Discord bot service'
}]
};