0% found this document useful (0 votes)
28 views5 pages

Message

This document is a Discord bot implementation using discord.js that includes various commands for moderation, utility, messaging, giveaways, and more. The bot responds to commands prefixed with '&', providing functionalities such as mute, kick, ban, warn, and giveaway management. It also features a help command that lists available commands and their descriptions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views5 pages

Message

This document is a Discord bot implementation using discord.js that includes various commands for moderation, utility, messaging, giveaways, and more. The bot responds to commands prefixed with '&', providing functionalities such as mute, kick, ban, warn, and giveaway management. It also features a help command that lists available commands and their descriptions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

const { Client, GatewayIntentBits, Partials, EmbedBuilder, PermissionsBitField } =

require('[Link]');
const ms = require('ms');

const client = new Client({


intents: [
[Link],
[Link],
[Link],
[Link]
],
partials: [[Link]]
});

const prefix = '&';

[Link]('ready', () => {
[Link](`Logged in as ${[Link]}`);
[Link]('your server', { type: 0 });
});

// Help Command and Command Handler


[Link]('messageCreate', async (message) => {
if (![Link](prefix) || [Link]) return;

const args = [Link]([Link]).trim().split(/ +/);


const command = [Link]().toLowerCase();

// Help Command
if (command === 'help') {
const embed = new EmbedBuilder()
.setTitle('Bot Command Help')
.setColor('Blue')
.setDescription('Here are the available commands:')
.addFields(
{ name: 'Moderation', value: '`ban`, `kick`, `mute`, `unmute`, `warn`,
`lock`, `unlock`, `purge`, `slowmode`' },
{ name: 'Utility', value: '`userinfo`, `serverinfo`, `avatar`, `addrole`,
`removerole`' },
{ name: 'Messaging', value: '`announce`, `dm`, `spam`' },
{ name: 'Giveaways', value: '`giveaway`, `end`, `reroll`' },
{ name: 'Fun/Other', value: '`profile`, `status`, `activity`' }
)
.setFooter({ text: 'Use &<command> to use a command.' });

[Link]({ embeds: [embed] });


return;
}

// Mute Command
if (command === 'mute') {
const member = [Link]();
if (!member) return [Link]('Please mention a user to mute!');
const duration = args[1];
if (!duration) return [Link]('Please specify a duration!');

const muteRole = [Link](role => [Link] === 'Muted');


if (!muteRole) return [Link]('Muted role not found.');
await [Link](muteRole);
[Link](`${[Link]} has been muted for ${duration}.`);
setTimeout(() => {
[Link](muteRole);
[Link](`${[Link]} has been unmuted.`);
}, ms(duration));
return;
}

// Kick Command
if (command === 'kick') {
const member = [Link]();
if (!member) return [Link]('Please mention a user to kick!');
await [Link]();
[Link](`${[Link]} has been kicked.`);
return;
}

// Ban Command
if (command === 'ban') {
const member = [Link]();
if (!member) return [Link]('Please mention a user to ban!');
await [Link]();
[Link](`${[Link]} has been banned.`);
return;
}

// Unmute Command
if (command === 'unmute') {
const member = [Link]();
if (!member) return [Link]('Please mention a user to unmute!');
const muteRole = [Link](role => [Link] === 'Muted');
if (!muteRole) return [Link]('Muted role not found.');
await [Link](muteRole);
[Link](`${[Link]} has been unmuted.`);
return;
}

// Warn Command
if (command === 'warn') {
const member = [Link]();
if (!member) return [Link]('Please mention a user to warn!');
const reason = [Link](1).join(' ') || 'No reason specified';
[Link](`${[Link]} has been warned. Reason: ${reason}`);
return;
}

// Lock Command
if (command === 'lock') {
const channel = [Link];
await [Link]([Link],
{ SEND_MESSAGES: false });
[Link]('The channel has been locked.');
return;
}

// Unlock Command
if (command === 'unlock') {
const channel = [Link];
await [Link]([Link],
{ SEND_MESSAGES: true });
[Link]('The channel has been unlocked.');
return;
}

// Purge Command
if (command === 'purge') {
const amount = parseInt(args[0]);
if (isNaN(amount) || amount < 1 || amount > 100) return [Link]('Please
specify a valid number of messages to delete (1-100).');
await [Link](amount);
[Link](`${amount} messages have been deleted.`);
return;
}

// Slowmode Command
if (command === 'slowmode') {
const time = parseInt(args[0]);
if (isNaN(time) || time < 1) return [Link]('Please specify a valid time
in seconds.');
await [Link](time);
[Link](`Slowmode has been set to ${time} seconds.`);
return;
}

// Messaging Commands
if (command === 'announce') {
if (![Link]([Link]))
{
return [Link]('You need the "Manage Messages" permission to use this
command.');
}
const channel = [Link]();
const announcement = [Link](1).join(' ');
if (!channel || !announcement) {
return [Link]('Please mention a channel and provide a message.');
}
const embed = new EmbedBuilder()
.setTitle('Announcement')
.setDescription(announcement)
.setColor('Gold')
.setTimestamp();
[Link]({ embeds: [embed] });
return;
}

if (command === 'dm') {


const user = [Link]();
const dmMessage = [Link](1).join(' ');
if (!user || !dmMessage) {
return [Link]('Please mention a user and provide a message to send.');
}
try {
await [Link](dmMessage);
[Link](`Successfully sent the message to ${[Link]}`);
} catch (error) {
[Link]('I could not DM this user. They may have DMs disabled.');
}
return;
}

if (command === 'spam') {


const count = parseInt(args[0]);
const spamMessage = [Link](1).join(' ');
if (isNaN(count) || count <= 0 || count > 100) {
return [Link]('Please provide a valid number between 1 and 100 for the
spam count.');
}
if (!spamMessage) {
return [Link]('Please provide a message to spam.');
}
for (let i = 0; i < count; i++) {
[Link](spamMessage);
}
return;
}

if (command === 'giveaway') {


[Link]('Giveaway command triggered');
const duration = args[0];
const winnersCount = parseInt(args[1]);
const prize = [Link](2).join(' ');

if (!duration || !winnersCount || !prize) {


return [Link]('Usage: !giveaway <duration s/m/h/d> <winners>
<prize>');
}

const ms = require('ms');
const time = ms(duration); // Convert the duration into milliseconds

if (!time) {
return [Link]('Invalid duration format. Please use s, m, h, or d.');
}

const embed = new EmbedBuilder()


.setTitle('🎉 Giveaway 🎉')
.setDescription(`Prize: **${prize}**\nReact with 🎉 to enter!\nEnds in: $
{duration}`)
.setFooter({ text: `Hosted by ${[Link]}` })
.setColor('Gold');

// Send the giveaway embed and react with 🎉


const msg = await [Link]({ embeds: [embed] });
await [Link]('🎉');

// Set timeout for the giveaway to end after the specified duration
setTimeout(async () => {
const reaction = [Link]('🎉');
if (!reaction) return [Link]('No reactions found.');

const users = await [Link](); // Fetch all users who reacted


const filtered = [Link](u => ![Link]); // Filter out bot users

if ([Link] === 0) {
return [Link]('No valid entries.');
}
const winners = [Link](winnersCount); // Randomly pick winners
from filtered users
[Link](`🎉 Winner(s): ${[Link](w => [Link]()).join(',
')}\nPrize: ${prize}`);
}, time); // End the giveaway after the specified duration
} // Close the 'giveaway' command block

if (command === 'reroll') {


const msgID = args[0];
try {
const fetched = await [Link](msgID);
const reaction = [Link]('🎉');
const users = await [Link]();
const filtered = [Link](u => ![Link]);
if ([Link] === 0) return [Link]('No valid entries.');
const winner = [Link]();
[Link](`🎉 New winner: ${winner}`);
} catch {
[Link]('Message not found or invalid.');
}
}
});

[Link](''); //token of your bot

You might also like