Skip to content

Instantly share code, notes, and snippets.

@macedonga
Created March 22, 2021 09:21
Show Gist options
  • Save macedonga/2ac027ca427f0e7065e70ff7c35194bc to your computer and use it in GitHub Desktop.
Save macedonga/2ac027ca427f0e7065e70ff7c35194bc to your computer and use it in GitHub Desktop.
Cheese
const Discord = require('discord.js')
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
const replace = [
/ /g,
/\*/g,
/-/g,
/_/g,
/;/g,
/:/g,
/!/g,
/\"/g,
/'/g,
/&/g,
/%/g,
/:/g,
/,/g,
/</g,
/>/g,
/]/g,
/"#/g,
/@/g,
/§/g,
/{/g,
/}/g,
/ç/g,
/°/g
]
const WH = {
"cheese": {
username: 'cheese',
avatarURL: 'https://media.istockphoto.com/photos/cheese-on-white-picture-id1127471287?k=6&m=1127471287&s=612x612&w=0&h=UeS8tmYvojVM_ezFGg8NAKqi925-iJuzR4GNhxWSvFQ='
}
};
client.on('message', async msg => {
if (msg.author.bot || !msg.channel) return;
var content = msg.content;
content = content.toLowerCase();
replace.forEach((rep) => content = content.replace(rep, ""));
const webhooks = await msg.channel.fetchWebhooks();
var webhook = webhooks.first();
if (!webhook) webhook = await msg.channel.createWebhook('cheese bot');
if (content.includes("cheese")) webhook.send(":cheese:", WH.cheese);
});
client.login(process.env.TOKEN);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment