beaubhp / synthwave

Discord music bot with playback commands and easy setup.
0 stars 0 forks source link

I want to add a new feature that spams Shrek image memes #1

Open beaubhp opened 2 months ago

ghost commented 2 months ago

To add a new feature that spams Shrek image memes, you'll need to create a new command that sends Shrek images to a Discord channel. Follow these steps to implement this feature:

  1. Create a New Command File: In your ./commands/ directory, create a new JavaScript file called shrek.js. This file will handle the logic for spamming Shrek memes.

  2. Add Content to shrek.js: Populate the shrek.js file with the command logic. Below is an example implementation:

const Discord = require("discord.js");

exports.run = async (client, message, args) => {
    // List of Shrek meme URLs
    const shrekMemes = [
        "https://example.com/shrek1.jpg",
        "https://example.com/shrek2.jpg",
        "https://example.com/shrek3.jpg"
        // Add more URLs as needed
    ];

    // Number of times to send the image
    const spamCount = parseInt(args[0]) || 5; // Default to 5 if no number is specified

    if (spamCount > 10) {
        return message.channel.send('Sorry, you can only send up to 10 memes at once to prevent spam.');
    }

    for (let i = 0; i < spamCount; i++) {
        // Choose a random Shrek meme from the list
        const randomMeme = shrekMemes[Math.floor(Math.random() * shrekMemes.length)];

        // Send the Shrek meme
        message.channel.send(randomMeme);
    }
};
  1. Register the New Command: Ensure your bot loads this new command by registering it within your client.commands setup in your main bot file. This is likely set up automatically by your file reading logic already present. Just ensure the file shrek.js is in the correct directory.

  2. Update bot.json: Optionally, add a new command entry in your bot.json for easy reference and configuration if needed, although this isn't strictly necessary for the command to function.

  3. Update Help Command: If you want users to be able to discover the new command, update your help command to include it:

// Inside your help command setup in the existing help command file
.addField("**Fun - (1)**", "`shrek <number>`")
  1. Testing: Run your bot and execute the command !shrek 3 (assuming your prefix is !) in one of your Discord channels to make sure it works correctly and that the images are sent.

Remember, spamming in any form should be done with caution, ensuring it adheres to server rules and etiquette to prevent the feature from being used abusively.