Answer the question
In order to leave comments, you need to log in
Why are actions not being taken?
I made a bot that, when donating, adds information to MySQL and Rich Presense.
But when someone sends a donation, the bot writes in the cli:
(node:12916) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body
user_id: Value "Amogus" is not snowflake.
at C:\Users\Vlad\Desktop\1\donatealerts_watcher-master\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85:15
at C:\Users\Vlad\Desktop\1\donatealerts_watcher-master\node_modules\snekfetch\src\index.js:215:21
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:12916) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:12916) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
const
configuration = require('./config.json'),
io = require('socket.io-client'),
socket = io('wss://socket.donationalerts.ru:443'),
Discord = require('discord.js'),
client = new Discord.Client(),
id = require('uniqid'),
mysql = require('mysql2/promise'),
con = mysql.createPool(configuration.mysql);
socket.emit('add-user', { token: configuration.key, type: "minor" });
client.login(configuration.token)
socket.on('donation', async message => {
const cheque = id('cheque-');
message = JSON.parse(message);
user = await client.fetchUser(message.username);
if (!user) return;
const [data] = await con.query(`SELECT * FROM users WHERE user_id = ?`, [user.id]);
if (data[0]) {
await con.query(`UPDATE users SET balance = balance + ? WHERE user_id = ?`, [message.amount_main, user.id])
} else {
await con.query(`INSERT INTO users (user_id, balance) VALUES (?,?)`, [user.id, message.amount_main]);
}
await con.query(`INSERT INTO donates (authorID, revieced, currency, transform, message, cheque) VALUES (?, ?, ?, ?, ?, ?)`, [message.username, +message.amount, message.currency, +message.amount_main, message.message, cheque])
const embed = new Discord.RichEmbed()
.setAuthor(`Получен новый донат от ${user.tag}!`, user.displayAvatarURL)
.setDescription(`Получено **\`${message.amount}${message.currency} => ${message.amount_main}RUB\`**\nЧЕК АЙДИ: ${cheque}\n\n${message.message}`, true)
let channel = client.channels.get(configuration.channel);
if (channel) channel.send(embed).catch(e => {});
})
{
"token": "discord token",
"key": "donationalerts token",
"mysql": {
"host": "",
"user": "",
"password": "",
"database": "",
"charset": "utf8mb4",
"insecureAuth": true
},
"channel": "840897171746455593"
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question