Skip to content

Commit

Permalink
Merge pull request #34 from Team-Gigabyte/mention
Browse files Browse the repository at this point in the history
Mention
  • Loading branch information
bhargavgv authored Sep 11, 2020
2 parents 5d4854e + d3380c2 commit 10d0c3b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const norm = text => { // "normalize" text
.toLowerCase()
.replace(/\s+/, " ");
}
const escapeRegex = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
let token = undefined;
if (configFile.token == "your-token-here-inside-these-quotes") {
token = envVars.QBTOKEN;
Expand Down Expand Up @@ -93,8 +94,8 @@ bot.once('ready', () => {
"username": "@" + bot.user.username + "#" + bot.user.discriminator,
"invite link": invText, "status": helpDomain,
"server count": bot.guilds.cache.size,
"weather key defined?": (configFile["weather-token"] || envVars.QBWEATHER ? "✅" : "🚫"
), "help link": (configFile.helpURL || "default")
"weather key defined?": (configFile["weather-token"] || envVars.QBWEATHER ? "✅" : "🚫"),
"help link": (configFile.helpURL || "default"),
})
if (helpDomain) {
bot.user.setActivity(helpDomain, { type: 'WATCHING' }); // Custom status "Watching example.qb"
Expand All @@ -105,18 +106,18 @@ if (!token) {
}
bot.login(token);
bot.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const prefixRegex = new RegExp(`^(<@!?${bot.user.id}>|${escapeRegex(prefix)})\\s*`);
if ((!prefixRegex.test(message.content)) || message.author.bot) return;
const [matchedPrefix] = message.content.match(prefixRegex);
const args = message.content.slice(matchedPrefix.length).trim().split(/ +/);
const command = args.shift().trim().toLowerCase();
switch (command) {
case 'testdm':
message.author.send("Looks like the DM worked! You can send commands in here.")
.catch(error => {
if (error.message == "Cannot send messages to this user") {
message.reply("Oof, you seem to have DMs off.");
} else {
console.error(error);
}
} else { console.error(error); }
});
break;
case 'help':
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quotobot",
"version": "2.1.1",
"version": "2.1.2",
"description": "A Discord bot that tells quotes",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 10d0c3b

Please sign in to comment.