Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JHVIW committed Oct 18, 2023
1 parent 7e59268 commit 5af5bca
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 7 deletions.
27 changes: 21 additions & 6 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ config();
const prefix = '!';

const participants = {};
const signedUpUsers = [];

const currentDirectory = path.dirname(fileURLToPath(import.meta.url));

Expand Down Expand Up @@ -86,7 +87,7 @@ client.on('messageCreate', async (message) => {
// Command: !signup
if (command === 'signup') {
// Check if the user has already signed up
if (participants[message.author.id]) {
if (signedUpUsers.includes(message.author.id)) {
const replyMessage = await message.channel.send(`<@${message.author.id}> You have already signed up for Secret Santa. Your message will be deleted!`);

// Delete the user's message to prevent flooding
Expand All @@ -96,10 +97,11 @@ client.on('messageCreate', async (message) => {
console.error('Error deleting message:', error);
}

// Delete the bot's message after 5 seconds

setTimeout(() => {
replyMessage.delete().catch(console.error);
}, 5000); // 5000 milliseconds (5 seconds)
}, 5000);

return;
}

Expand All @@ -108,7 +110,14 @@ client.on('messageCreate', async (message) => {

// Check if the required information is provided
if (!tradelink || interests.length < 3) {
message.channel.send(`<@${message.author.id}> Please provide a valid trade link and 3 interests.`);
// Send a message to the user
const userMessage = await message.channel.send(`<@${message.author.id}> Please provide a valid trade link and 3 interests.`);

// Delete the user's message and the bot's message after 5 seconds
setTimeout(() => {
message.delete().catch(console.error);
userMessage.delete().catch(console.error);
}, 3000); // 5000 milliseconds (5 seconds)
return;
}

Expand Down Expand Up @@ -159,11 +168,17 @@ client.on('messageCreate', async (message) => {
console.log('Participant added and saved to participants.json');
});
});

signedUpUsers.push(message.author.id);
await message.delete();
message.channel.send(`<@${message.author.id}> You have successfully signed up for Secret Santa!`);
} else {
message.channel.send(`<@${message.author.id}> Please provide a valid Steam trade link.`);
const userMessage = await message.channel.send(`<@${message.author.id}> Please provide a valid trade link and 3 interests.`);
// Delete the user's message and the bot's message after 5 seconds
setTimeout(() => {
message.delete().catch(console.error);
userMessage.delete().catch(console.error);
}, 3000); // 5000 milliseconds (5 seconds)
return;
}
}

Expand Down
5 changes: 5 additions & 0 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"dependencies": {
"discord.js": "^13.1.0",
"dotenv": "^16.3.1",
"https": "^1.0.0",
"node-schedule": "^2.1.1",
"steam-totp": "^2.1.2",
"steam-tradeoffer-manager": "^2.10.6",
Expand Down
33 changes: 32 additions & 1 deletion participants.json
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
[]
[
{
"userId": "143373549338361856",
"name": "saltenator",
"tradelink": "https://steamcommunity.com/tradeoffer/new/?partner=325176772&token=DmiLKZ6K",
"interests": [
"1",
"2",
"3"
],
"steamID64": "76561198285442500",
"assigned": "290404168399585280",
"sentItemClassIDs": [
"4717330486"
]
},
{
"userId": "290404168399585280",
"name": "sidcovery",
"tradelink": "https://steamcommunity.com/tradeoffer/new/?partner=341856898&token=L-uVRNVp",
"interests": [
"55",
"2",
"2"
],
"steamID64": "76561198302122626",
"assigned": "143373549338361856",
"sentItemClassIDs": [
"5189384637"
]
}
]

0 comments on commit 5af5bca

Please sign in to comment.