Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

broadcastbot.js

node v18.11.0
version: 1.0.0
endpointsharetweet
This is a playground to test JavaScript. It runs a completely standard copy of Node.js on a virtual server created just for you. Every one of npm’s 300,000+ packages are pre-installed, so try it out:
broadcastbotjs const { Client, GatewayIntentBits } = require('discord.js'); const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] }); client.once('ready', () => { console.log(`Logged in as ${client.user.tag}!`); }); // Command to broadcast a message client.on('messageCreate', message => { if (message.content.startsWith('!broadcast')) { const broadcastMessage = message.content.replace('!broadcast ', ''); message.guild.channels.cache.forEach(channel => { if (channel.type === 'GUILD_TEXT') { channel.send(broadcastMessage); } }); } }); // Login to Discord with your app's token client.login('MTI5MTk4NDM4MDkxODUwMTUyOA.GInzOw.LnVQiJnds7Xq_S-2Haj1KSzuVydk0z3fOmJ_eU');
274877945857
Loading…

no comments

    sign in to comment