Skip to content

Instantly share code, notes, and snippets.

@Aiden-Garth
Last active October 18, 2018 21:17
Show Gist options
  • Save Aiden-Garth/b2d7a14788b2f89630933f536cba7f47 to your computer and use it in GitHub Desktop.
Save Aiden-Garth/b2d7a14788b2f89630933f536cba7f47 to your computer and use it in GitHub Desktop.
THU 18/10/2018 ~ TrueBot Error
const Discord = require("discord.js");
const client = new Discord.Client();
require("dotenv").config();
const env = process.env;
const version = "v1.0.1 - 2018-10-18";
const mainColor = "#7289DA";
const github = "https://github.com/True-Coder-Ltd/TrueBot";
client.login(env.TOKEN);
client.on("ready", () => {
console.log(`Logged in as ${client.user.username}`);
});
client.user.setActivity(`${client.guilds.size} Servers`, {
type: "LISTENING",
url: github
});
client.on("guildMemberAdd", (member) => {
const channel = member.guild.channels.find((ch) => ch.name === "join-leave");
if (!channel) return;
channel.send(`Welcome to ${member.guild.name}, ${member.user.username}!`);
});
client.on("message", (messageRaw) => {
if (messageRaw.author.bot) return;
if (!messageRaw.content.startsWith(env.PREFIX)) return;
if (!messageRaw.guild) return;
const message = messageRaw.content;
// t!help - Replies with the current version of TrueBot
if (message.startsWith(`${env.PREFIX}version`)) {
messageRaw.channel.send(version)
};
// t!help ~ Shows a help message about the bot
if (message.startsWith(`${env.PREFIX}help`)) {
let embed = new Discord.RichEmbed()
.setAuthor(client.user.username)
.setColor(mainColor)
.setTitle(`${client.user.username} - Help`)
.setURL(github)
.setFooter(`A help message about ${client.user.username}`)
.addField("Server Count", client.guilds.size)
.addField("Creator", "Truecoder Ltd")
.addField("Version", version)
.addField("Project Respiratory", github)
.addField("Commands", `Please use \`${env.PREFIX}commands\` to get commands`);
messageRaw.channel.send(embed);
};
if (message.startsWith(`${env.PREFIX}commands`)) {
let embed = new Discord.RichEmbed()
.setAuthor(client.user.username)
.setColor(mainColor)
.setTitle(`${client.user.username} - Commands`)
.setURL(github)
.setFooter(`A list of commands for ${client.user.username}`)
.addField(`${env.PREFIX}help`, "Shows a help message")
.addField(`${env.PREFIX}version`, `Shows the current version of ${client.user.username}`)
.addField(`${env.PREFIX}commands`, "Shows this message");
messageRaw.channel.send(embed);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment