Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =const Discord = require('discord.js')
- const client = new Discord.Client();
- client.on('ready', () => {
- console.log('ready');
- });
- client.on('message', message => {
- //console.log(message.content);
- if(message.content.startsWith(`$kick`)) {
- //message.channel.send("kick")
- let member = message.mentions.members.first();
- member.kick().then((member) => {
- message.channel.send("**Kick completed**")
- })
- }
- });
- client.on('message', message => {
- //console.log(message.content);
- if(message.content.startsWith(`$ban`)) {
- //message.channel.send("ban")
- let member = message.mentions.members.first();
- member.ban().then((member) => {
- message.channel.send("**BAN completed**")
- })
- }
- });
- client.on('ready', () => {
- var generalChannel = client.channels.get("631749384790343691") // Replace with known channel ID
- generalChannel.send("PatrickTheStar is now **online!**")
- });
- client.on('message', (receivedMessage) => {
- if (receivedMessage.author == client.user) { // Prevent bot from responding to its own messages
- return
- }
- // You can copy/paste the actual unicode emoji in the code (not _every_ unicode emoji works)
- receivedMessage.react("👍")
- receivedMessage.react("😎")
- // Unicode emojis: https://unicode.org/emoji/charts/full-emoji-list.html
- // Get every custom emoji from the server (if any) and react with each one
- receivedMessage.guild.emojis.forEach(customEmoji => {
- console.log(`Reacting with custom emoji: ${customEmoji.name} (${customEmoji.id})`)
- receivedMessage.react(customEmoji)
- })
- // If you know the ID of the custom emoji you want, you can get it directly with:
- // let customEmoji = receivedMessage.guild.emojis.get(emojiId)
- });
- client.on('ready', () => {
- // Set bot status to: "Playing with JavaScript"
- client.user.setActivity("Public Beta Testing!")
- // Alternatively, you can set the activity to any of the following:
- // PLAYING, STREAMING, LISTENING, WATCHING
- // For example:
- // client.user.setActivity("TV", {type: "WATCHING"})
- });
- client.on('message', (receivedMessage) => {
- if (receivedMessage.author == client.user) { // Prevent bot from responding to its own messages
- return
- }
- if (receivedMessage.content.startsWith("$")) {
- processCommand(receivedMessage)
- }
- })
- function processCommand(receivedMessage) {
- let fullCommand = receivedMessage.content.substr(1) // Remove the leading exclamation mark
- let splitCommand = fullCommand.split(" ") // Split the message up in to pieces for each space
- let primaryCommand = splitCommand[0] // The first word directly after the exclamation is the command
- let arguments = splitCommand.slice(1) // All other words are arguments/parameters/options for the command
- console.log("Command received: " + primaryCommand)
- console.log("Arguments: " + arguments) // There may not be any arguments
- if (primaryCommand == "help") {
- helpCommand(arguments, receivedMessage)
- } else if (primaryCommand == "multiply") {
- multiplyCommand(arguments, receivedMessage)
- } else {
- receivedMessage.channel.send("I don't understand the command. Try `$help` or `$multiply`")
- }
- }
- function helpCommand(arguments, receivedMessage) {
- if (arguments.length > 0) {
- receivedMessage.channel.send("It looks like you might need help with " + arguments)
- } else {
- receivedMessage.channel.send("I'm not sure what you need help with. Try `$help [topic]`")
- }
- }
- function multiplyCommand(arguments, receivedMessage) {
- if (arguments.length < 2) {
- receivedMessage.channel.send("Not enough values to multiply. Try `!multiply 2 4 10` or `!multiply 5.2 7`")
- return
- }
- let product = 1
- arguments.forEach((value) => {
- product = product * parseFloat(value)
- })
- receivedMessage.channel.send("The product of " + arguments + " multiplied together is: " + product.toString())
- }
- client.on('ready', () => {
- // List servers the bot is connected to
- console.log("Servers:")
- client.guilds.forEach((guild) => {
- console.log(" - " + guild.name)
- })
- })
- client.on('message', message => {
- //console.log(message.content);
- if(message.content.startsWith(`$test`)) {
- message.channel.send("test")
- })
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement