Added proper license, removed unused stuff, more twitter bot work
This commit is contained in:
parent
143319a7e2
commit
e1347fcf52
14 changed files with 81 additions and 27 deletions
|
@ -2,3 +2,4 @@ const { Collection } = require("eris");
|
|||
|
||||
exports.commands = new Collection();
|
||||
exports.aliases = new Collection();
|
||||
exports.voiceConnections = new Collection();
|
||||
|
|
|
@ -15,5 +15,17 @@ const xpSchema = new mongoose.Schema({
|
|||
});
|
||||
const XP = mongoose.model("XP", xpSchema);
|
||||
|
||||
const tweetSchema = new mongoose.Schema({
|
||||
tweets: [String],
|
||||
replies: [String],
|
||||
media: [String],
|
||||
phrases: [String],
|
||||
games: [String],
|
||||
characters: [String],
|
||||
enabled: Boolean
|
||||
});
|
||||
const TweetCollection = mongoose.model("TweetCollection", tweetSchema);
|
||||
|
||||
exports.guilds = Guild;
|
||||
exports.xp = XP;
|
||||
exports.xp = XP;
|
||||
exports.tweets = TweetCollection;
|
|
@ -29,15 +29,16 @@ exports.clean = async (text) => {
|
|||
};
|
||||
|
||||
// get random tweet to post
|
||||
exports.getTweet = async (twitter, reply = false) => {
|
||||
const randomTweet = this.random(reply ? twitter.tweets.replies : twitter.tweets.tweets);
|
||||
exports.getTweet = async (tweets, reply = false) => {
|
||||
const randomTweet = this.random(reply ? tweets.replies : tweets.tweets);
|
||||
if (randomTweet.match("{{message}}")) {
|
||||
const randomMessage = await this.getRandomMessage();
|
||||
return randomTweet.replace("{{message}}", randomMessage);
|
||||
} else {
|
||||
return randomTweet.replace("{{media}}", this.random(twitter.tweets.media))
|
||||
.replace("{{games}}", this.random(twitter.tweets.games))
|
||||
.replace("{{phrases}}", this.random(twitter.tweets.phrases));
|
||||
return randomTweet.replace("{{media}}", this.random(tweets.media))
|
||||
.replace("{{games}}", this.random(tweets.games))
|
||||
.replace("{{phrases}}", this.random(tweets.phrases))
|
||||
.replace("{{characters}}", this.random(tweets.characters));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,27 +1,32 @@
|
|||
const client = require("./client.js");
|
||||
const fs = require("fs");
|
||||
const logger = require("./logger.js");
|
||||
const connections = require("./collections.js").voiceConnections;
|
||||
|
||||
module.exports = async (sound, message) => {
|
||||
if (message.member.voiceState.channelID) {
|
||||
if (!message.channel.guild.members.get(client.user.id).permission.has("voiceConnect") || !message.channel.permissionsOf(client.user.id).has("voiceConnect")) return client.createMessage(message.channel.id, `${message.author.mention}, I can't join this voice channel!`);
|
||||
const voiceChannel = message.channel.guild.channels.get(message.member.voiceState.channelID);
|
||||
if (!voiceChannel.permissionsOf(client.user.id).has("voiceConnect")) return client.createMessage(message.channel.id, `${message.author.mention}, I don't have permission to join this voice channel!`);
|
||||
const checkConnection = connections.get(message.channel.guild.id);
|
||||
const connection = checkConnection ? checkConnection : await voiceChannel.join();
|
||||
const playingMessage = await client.createMessage(message.channel.id, "🔊 Playing sound...");
|
||||
const connection = await client.joinVoiceChannel(voiceChannel.id);
|
||||
console.log(connection.current);
|
||||
connections.set(message.channel.guild.id, connection);
|
||||
if (connection.playing) {
|
||||
connection.stopPlaying();
|
||||
connection.play(fs.createReadStream(sound));
|
||||
} else {
|
||||
connection.play(fs.createReadStream(sound));
|
||||
}
|
||||
connection.play(fs.createReadStream(sound));
|
||||
connection.on("error", (error) => {
|
||||
connections.delete(message.channel.guild.id);
|
||||
voiceChannel.leave();
|
||||
playingMessage.delete();
|
||||
logger.error(error);
|
||||
});
|
||||
connection.on("warn", (warn) => {
|
||||
logger.warn(warn);
|
||||
});
|
||||
connection.once("end", () => {
|
||||
connections.delete(message.channel.guild.id);
|
||||
voiceChannel.leave();
|
||||
playingMessage.delete();
|
||||
});
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
const Twit = require("twit");
|
||||
const tweets = require("../tweets.json");
|
||||
const T = new Twit({
|
||||
consumer_key: process.env.TWITTER_KEY,
|
||||
consumer_secret: process.env.CONSUMER_SECRET,
|
||||
access_token: process.env.ACCESS_TOKEN,
|
||||
access_token_secret: process.env.ACCESS_SECRET
|
||||
});
|
||||
module.exports = {
|
||||
client: T,
|
||||
tweets: tweets
|
||||
};
|
||||
exports.client = T;
|
||||
require("../utils/database.js").tweets.find({ enabled: true }, (error, docs) => {
|
||||
if (error) throw error;
|
||||
exports.tweets = docs[0];
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue