Skip to content
Sign upLog in
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
3

DISCORD.JS poll command

Bruno08432190
Bruno08432190

// Load modules
const Discord = require("discord.js"),
backup = require("discord-backup"),
client = new Discord.Client(),

settings = {
prefix: "YOUR-PREFIX",
token: "YOUR-TOKEN"
};
require('http').createServer((req, res) => res.end(Bot online)).listen(3000);

function presence(){
client.user.setPresence({
status:"online",
activity: {
name: "how to make a poll command",
type: "WATCHING"
}
})
}
client.once('ready', () => {
console.log("Ready!");
presence();
});

client.on("message", async message => {

// This reads the first part of your message behind your prefix to see which command you want to use. let command = message.content.toLowerCase().slice(settings.prefix.length).split(" ")[0]; // These are the arguments behind the commands. let args = message.content.split(" ").slice(1); // If the message does not start with your prefix return. // If the user that types a message is a bot account return. // If the command comes from DM return. if (!message.content.startsWith(settings.prefix) || message.author.bot || !message.guild) return;

if(command === "poll"){

let msgArgs = args.join(' ')
if(!msgArgs) return message.channel.send("You need write something").then(message => message.delete({ timeout: 5000 }))
message.delete().catch()
message.channel.send(msgArgs + "?").then(messageReaction => {
messageReaction.react("✅")
messageReaction.react("❎")
})
}
});
client.login(settings.token);

2 years ago
You are viewing a single comment. View All
1
Jasonkingtou
Jasonkingtou

advance poll command

const { MessageEmbed, Discord } = require("discord.js");

module.exports = {
name: "poll",
cooldown:10000,
category: "Info",
description: "poll Your Message To Channel",
uimage:'https://media.discordapp.net/attachments/803290746496221264/803502251074125834/unknown.png',
usage: "poll <#channel> <content>",
run: async (client, message, args) => {
message.delete();

if(!message.member.hasPermission("ADMINISTRATOR")) return message.channel.send("You don't have premmsions to do that!"); let sayChannel = message.mentions.channels.first(); if (!sayChannel) return message.channel.send(`:x:| ${message.author} mention a channel First`) let sayMsg = args.slice(1 || 0, args.length).join(" "); if (!sayMsg) return message.channel.send(` Say Some Message To Poll`) var role = message.member.highestRole; var embed = new MessageEmbed() .setColor("RANDOM") .setAuthor(`Poll made for ${message.guild.name}`) .setFooter('Poll By: ' + `${message.author.username}`) .addField(`Poll message: ${sayMsg}`) .addField(`Server ${message.guild.name}`) .addField(`Author ${message.author.username}`) .setImage(`https://cdn.discordapp.com/attachments/883889484658245633/912424602033090681/standard_2.gif`) .setTimestamp() message.channel.send(`Your poll Is Ready On <#${sayChannel.id}>`) sayChannel.send({embed}).then(m => { m.react('✅'); m.react('❌'); m.react('🤔'); }) .catch({}); }

};

1 year ago