* Radio Bot Implementation
This commit is contained in:
16
README.md
16
README.md
@@ -1,8 +1,8 @@
|
|||||||
<h1 align="center">LULBOT</h1>
|
<h1 align="center">RADIO BOT</h1>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="assets/logo.png" alt="lul-bot-logo" width="120px" height="120px"/>
|
<img src="assets/logo.png" alt="lul-bot-logo" width="120px" height="120px"/>
|
||||||
<br>
|
<br>
|
||||||
<i>A Discord bot written for your server</i>
|
<i>A Discord Radio bot written for your server</i>
|
||||||
<br>
|
<br>
|
||||||
</p>
|
</p>
|
||||||
<hr>
|
<hr>
|
||||||
@@ -20,11 +20,17 @@
|
|||||||
Before running this project you must create a ```.env``` file which should contains the following keys (This can be changed in the source code)
|
Before running this project you must create a ```.env``` file which should contains the following keys (This can be changed in the source code)
|
||||||
<br>
|
<br>
|
||||||
```
|
```
|
||||||
LUL_BOT_TKN=Your_Discord_Bot_token
|
RADIO_BOT_TKN=Your_Discord_Bot_token
|
||||||
TENOR_TOKEN=Tenor_token // this used for generating gifs
|
RADIO_CHANNEL= A Voice Channel ID // this voice channel is used for playing music
|
||||||
AIRTABLE_KEY=Airtable_key // this is currently used to store data for my CoD mobile loadouts
|
NOW_PLAYING_CHANNEL=A Text Channel ID // this channel is used for displaying now playing notifications
|
||||||
|
ADMIN_ID = Admin User ID // This is the ID of the admin user who has permission to stop and start Radio
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
```
|
||||||
|
!radioStart // Command to start the Radio
|
||||||
|
!radioStop // Command to stop the radio
|
||||||
|
```
|
||||||
### Credits
|
### Credits
|
||||||
[CodeLyon][codelyon] - For discord.js getting started videos
|
[CodeLyon][codelyon] - For discord.js getting started videos
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
const axios = require('axios').default;
|
|
||||||
const { MessageEmbed } = require('discord.js');
|
|
||||||
const instance = axios.create({
|
|
||||||
baseURL: 'https://breaking-bad-quotes.herokuapp.com/v1'
|
|
||||||
});
|
|
||||||
|
|
||||||
async function getRandomQuotes(message, args) {
|
|
||||||
const randomQuotesUrl = "/quotes";
|
|
||||||
try {
|
|
||||||
const result = await instance.get(randomQuotesUrl);
|
|
||||||
const { quote, author } = result.data[0];
|
|
||||||
const randomQuoteMessage = new MessageEmbed()
|
|
||||||
.setDescription(quote)
|
|
||||||
.setFooter(`${author}`);
|
|
||||||
message.channel.send(randomQuoteMessage);
|
|
||||||
} catch (error) {
|
|
||||||
const errorMessage = new MessageEmbed()
|
|
||||||
.setTitle("Stay out of territory: Error getting quotes from Walter White")
|
|
||||||
.setColor("RED");
|
|
||||||
message.channel.send(errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
execute(client, message, args) {
|
|
||||||
getRandomQuotes(message, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
const axios = require('axios').default;
|
|
||||||
const { MessageEmbed } = require('discord.js');
|
|
||||||
const instance = axios.create({
|
|
||||||
baseURL: 'https://dark-api.herokuapp.com/api/v1'
|
|
||||||
});
|
|
||||||
|
|
||||||
async function getRandomQuotes(message, args) {
|
|
||||||
const randomQuotesUrl = "/quote/random";
|
|
||||||
try {
|
|
||||||
const result = await instance.get(randomQuotesUrl);
|
|
||||||
const { author, season, episode, quote } = result.data;
|
|
||||||
const randomQuoteMessage = new MessageEmbed()
|
|
||||||
.setDescription(quote)
|
|
||||||
.setFooter(`${author}, S${season} : Episode - ${episode}`);
|
|
||||||
message.channel.send(randomQuoteMessage);
|
|
||||||
} catch (error) {
|
|
||||||
const errorMessage = new MessageEmbed()
|
|
||||||
.setTitle("Something went wrong: Error getting quotes from Mikkel Nielsen")
|
|
||||||
.setColor("RED");
|
|
||||||
message.channel.send(errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
execute(client, message, args) {
|
|
||||||
getRandomQuotes(message, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
const axios = require('axios').default;
|
|
||||||
const { MessageEmbed } = require('discord.js');
|
|
||||||
const instance = axios.create({
|
|
||||||
baseURL: 'https://game-of-thrones-quotes.herokuapp.com/v1'
|
|
||||||
});
|
|
||||||
|
|
||||||
async function getRandomQuotes(message, args) {
|
|
||||||
const randomQuotesUrl = "/random";
|
|
||||||
try {
|
|
||||||
const result = await instance.get(randomQuotesUrl);
|
|
||||||
const { sentence, character: { name, house: { name: houseName } } } = result.data;
|
|
||||||
const randomQuoteMessage = new MessageEmbed()
|
|
||||||
.setDescription(sentence)
|
|
||||||
.setFooter(`${name}, ${houseName}`);
|
|
||||||
message.channel.send(randomQuoteMessage);
|
|
||||||
} catch (error) {
|
|
||||||
const errorMessage = new MessageEmbed()
|
|
||||||
.setTitle("Something went wrong: Error getting quotes from Arya Stark")
|
|
||||||
.setColor("RED");
|
|
||||||
message.channel.send(errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
execute(client, message, args) {
|
|
||||||
getRandomQuotes(message, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
const fetch = require('node-fetch');
|
|
||||||
|
|
||||||
function randomJokes(message) {
|
|
||||||
message.channel.startTyping();
|
|
||||||
getJokes().then(response => {
|
|
||||||
message.channel.stopTyping();
|
|
||||||
if (response) {
|
|
||||||
message.channel.startTyping();
|
|
||||||
message.reply(response.setup);
|
|
||||||
setTimeout(() => {
|
|
||||||
message.channel.stopTyping();
|
|
||||||
message.reply(`||${response.punchline}||`);
|
|
||||||
}, 5000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getJokes() {
|
|
||||||
return fetch(`https://official-joke-api.appspot.com/jokes/random`)
|
|
||||||
.then(res => res.json())
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
execute(client,message, args) {
|
|
||||||
randomJokes(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
const Airtable = require('airtable');
|
|
||||||
const {MessageEmbed} = require('discord.js');
|
|
||||||
Airtable.configure({
|
|
||||||
endpointUrl: 'https://api.airtable.com',
|
|
||||||
apiKey: process.env.AIRTABLE_KEY
|
|
||||||
});
|
|
||||||
const base = Airtable.base('appppieGLc8loZp5H');
|
|
||||||
const AirTableConfigs = {
|
|
||||||
MAIN_TABLE: 'cod_loadout',
|
|
||||||
WEAPONS_TYPE_TABLE: 'Weapon Types',
|
|
||||||
WEAPONS_TABLE: 'Weapons',
|
|
||||||
GRID_VIEW: 'Grid view',
|
|
||||||
WEAPON_TYPE: 'cod_weapon_type',
|
|
||||||
WEAPON_NAME: 'cod_weapon_name',
|
|
||||||
MATCH_TYPE: 'cod_match_type',
|
|
||||||
ATTACHMENTS: 'cod_weapon_attachments',
|
|
||||||
};
|
|
||||||
|
|
||||||
async function getCodMLoadOut(message, args) {
|
|
||||||
const codUserName = args[0];
|
|
||||||
if (!codUserName) return;
|
|
||||||
base(AirTableConfigs.MAIN_TABLE).select({
|
|
||||||
maxRecords: 2,
|
|
||||||
view: AirTableConfigs.GRID_VIEW,
|
|
||||||
filterByFormula: `({cod_username} = '${args[0]}')`
|
|
||||||
}).eachPage((records, fetchNextPage) => {
|
|
||||||
if (records && records.length > 0) {
|
|
||||||
records.forEach(async (record) => {
|
|
||||||
const weaponType = await getWeaponType(record.get(AirTableConfigs.WEAPON_TYPE));
|
|
||||||
const weaponName = await getWeaponName(record.get(AirTableConfigs.WEAPON_NAME));
|
|
||||||
const loadOutMessage = new MessageEmbed()
|
|
||||||
.setTitle(`Loadout of ${codUserName} : ${record.get(AirTableConfigs.MATCH_TYPE)}`)
|
|
||||||
.addField('Weapon Name', weaponName, true)
|
|
||||||
.addField('Weapon Type', weaponType, true)
|
|
||||||
.addField('Attachments', record.get(AirTableConfigs.ATTACHMENTS), true)
|
|
||||||
.setColor("RANDOM");
|
|
||||||
message.channel.send(loadOutMessage);
|
|
||||||
});
|
|
||||||
fetchNextPage();
|
|
||||||
} else {
|
|
||||||
message.channel.send(`No Loadout found for ***${codUserName}***`);
|
|
||||||
}
|
|
||||||
|
|
||||||
}, function done(err) {
|
|
||||||
if (err) { console.error(err); return; }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getWeaponType(weaponType) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
base(AirTableConfigs.WEAPONS_TYPE_TABLE).find(weaponType, (error, record) => {
|
|
||||||
if (error) {
|
|
||||||
console.log(error);
|
|
||||||
reject();
|
|
||||||
} else {
|
|
||||||
resolve(record.get(AirTableConfigs.WEAPON_TYPE));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getWeaponName(weaponName) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
base(AirTableConfigs.WEAPONS_TABLE).find(weaponName, (error, record) => {
|
|
||||||
if (error) {
|
|
||||||
console.log(error);
|
|
||||||
reject();
|
|
||||||
} else {
|
|
||||||
resolve(record.get(AirTableConfigs.WEAPON_NAME));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
execute(client,message, args) {
|
|
||||||
getCodMLoadOut(message,args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
const ytdl = require('ytdl-core');
|
|
||||||
const ytSearch = require('yt-search');
|
|
||||||
async function playMusik(client, message, args) {
|
|
||||||
const voiceChannel = message.member.voice.channel;
|
|
||||||
if (!voiceChannel) {
|
|
||||||
return message.channel.send("Join a voice channel to Play Music");
|
|
||||||
}
|
|
||||||
const permission = voiceChannel.permissionsFor(message.client.user);
|
|
||||||
if (!permission.has('CONNECT') || !permission.has('SPEAK')) {
|
|
||||||
return message.channel.send("You don't have the permission to play music. 😥");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!args.length) {
|
|
||||||
return message.channel.send("Please pass something to play as second argument");
|
|
||||||
}
|
|
||||||
|
|
||||||
const connection = await voiceChannel.join();
|
|
||||||
let videoUrl = false;
|
|
||||||
let video;
|
|
||||||
const youtubeRegex = /(http:|https:)?\/\/(www\.)?(youtube.com|youtu.be)\/(watch)?(\?v=)?(\S+)?/;
|
|
||||||
if (youtubeRegex.test(args[0])) {
|
|
||||||
video = args[0];
|
|
||||||
videoUrl = true;
|
|
||||||
} else {
|
|
||||||
video = await searchVideo(args.join(' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (video) {
|
|
||||||
const youtubeStream = ytdl(videoUrl ? video : video.url, { filter: 'audioonly' });
|
|
||||||
client.user.setPresence({ activity: { name: `${video.title}`, type: 'LISTENING' } });
|
|
||||||
connection.play(youtubeStream, { seek: 0, volume: 1 })
|
|
||||||
.on('finish', () => {
|
|
||||||
voiceChannel.leave();
|
|
||||||
client.user.setPresence({ activity: { name: ` ` } });
|
|
||||||
});
|
|
||||||
await message.reply(`Now Playing ${videoUrl ? args[0] : video.title}...`);
|
|
||||||
} else {
|
|
||||||
message.channel.send("No music found to play for you mate. Try again! 👍");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function searchVideo(query) {
|
|
||||||
const searchResult = await ytSearch(query);
|
|
||||||
return (searchResult.videos.length > 1) ? searchResult.videos[0] : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
execute(client,message, args) {
|
|
||||||
playMusik(client,message,args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
54
src/commands/radioStart.js
Normal file
54
src/commands/radioStart.js
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
const { VoiceChannel, TextChannel, MessageEmbed } = require("discord.js");
|
||||||
|
const axios = require('axios').default;
|
||||||
|
|
||||||
|
const instance = axios.create({
|
||||||
|
baseURL: 'http://retrowave.ru/api/v1'
|
||||||
|
});
|
||||||
|
|
||||||
|
const resourceUrl = 'http://retrowave.ru'
|
||||||
|
|
||||||
|
async function broadcastRadio(client, args, message, voiceChannel, textChannel) {
|
||||||
|
const connection = await voiceChannel.join();
|
||||||
|
try {
|
||||||
|
playRadio(connection, textChannel);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
textChannel.send('Something went wrong. RADIO MON got ill...😱😱');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async function playRadio(connection,textChannel) {
|
||||||
|
const nextMusic = await getNextMusic();
|
||||||
|
const { id, title, streamUrl, artworkUrl } = nextMusic;
|
||||||
|
const nowPlayingMessage = new MessageEmbed()
|
||||||
|
.setTitle("Now Playing")
|
||||||
|
.setDescription(title)
|
||||||
|
.setColor('LUMINOUS_VIVID_PINK')
|
||||||
|
.setThumbnail(`${resourceUrl}${artworkUrl}`);
|
||||||
|
textChannel.send(nowPlayingMessage)
|
||||||
|
connection.play(`${resourceUrl}${streamUrl}`, { seek: 0, volume: 1 })
|
||||||
|
.on('finish', () => {
|
||||||
|
playRadio(connection,textChannel);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getNextMusic() {
|
||||||
|
const result = await instance.get('/tracks?cursor=1&limit=1');
|
||||||
|
return result.data.body.tracks[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
async execute(client, message, args) {
|
||||||
|
const { RADIO_CHANNEL, NOW_PLAYING_CHANNEL } = process.env;
|
||||||
|
if (!RADIO_CHANNEL) return message.reply(`Please add RADIO_CHANNEL to .env with a Voice Channel ID`);
|
||||||
|
if (!NOW_PLAYING_CHANNEL) return message.reply(`Please add NOW_PLAYING_CHANNEL to .env with a Text Channel ID`);
|
||||||
|
|
||||||
|
const voiceChannel = await client.channels.fetch(process.env.RADIO_CHANNEL);
|
||||||
|
const nowPlayingChannel = await client.channels.fetch(process.env.NOW_PLAYING_CHANNEL);
|
||||||
|
if (!(voiceChannel instanceof VoiceChannel)) return message.reply(`Please provice a Voice Channel ID to the RADIO_CHANNEL`);
|
||||||
|
if (!(nowPlayingChannel instanceof TextChannel)) return message.reply(`Please provice a Text Channel ID to the NOW_PLAYING_CHANNEL`);
|
||||||
|
|
||||||
|
broadcastRadio(client, args, message, voiceChannel, nowPlayingChannel);
|
||||||
|
}
|
||||||
|
}
|
||||||
23
src/commands/radioStop.js
Normal file
23
src/commands/radioStop.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
const { VoiceChannel, TextChannel } = require("discord.js");
|
||||||
|
|
||||||
|
async function stopRadioBroadcast(client, args, message, voiceChannel, textChannel) {
|
||||||
|
if (voiceChannel) {
|
||||||
|
await voiceChannel.leave();
|
||||||
|
textChannel.send('RADIO Stopped');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
async execute(client, message, args) {
|
||||||
|
const { RADIO_CHANNEL, NOW_PLAYING_CHANNEL } = process.env;
|
||||||
|
if (!RADIO_CHANNEL) return message.reply(`Please add RADIO_CHANNEL to .env with a Voice Channel ID`);
|
||||||
|
if (!NOW_PLAYING_CHANNEL) return message.reply(`Please add NOW_PLAYING_CHANNEL to .env with a Text Channel ID`);
|
||||||
|
|
||||||
|
const voiceChannel = await client.channels.fetch(process.env.RADIO_CHANNEL);
|
||||||
|
const nowPlayingChannel = await client.channels.fetch(process.env.NOW_PLAYING_CHANNEL);
|
||||||
|
if (!(voiceChannel instanceof VoiceChannel)) return message.reply(`Please provice a Voice Channel ID to the RADIO_CHANNEL`);
|
||||||
|
if (!(nowPlayingChannel instanceof TextChannel)) return message.reply(`Please provice a Text Channel ID to the NOW_PLAYING_CHANNEL`);
|
||||||
|
|
||||||
|
stopRadioBroadcast(client, args, message, voiceChannel, nowPlayingChannel);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
async function stopMusik(client,message) {
|
|
||||||
const voiceChannel = message.member.voice.channel;
|
|
||||||
|
|
||||||
if (!voiceChannel) {
|
|
||||||
return message.channel.send("Join a voice channel to Execute this command");
|
|
||||||
}
|
|
||||||
|
|
||||||
await voiceChannel.leave();
|
|
||||||
await message.channel.send("Stoping Music... Baye Baye.... 😅");
|
|
||||||
client.user.setPresence({ activity: { name: `COMMANDS`, type: 'LISTENING' } });
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
execute(client,message, args) {
|
|
||||||
stopMusik(client, message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
const axios = require('axios').default;
|
|
||||||
const {MessageEmbed} = require('discord.js');
|
|
||||||
const instance = axios.create({
|
|
||||||
baseURL: 'https://cdn-api.co-vin.in/api/v2',
|
|
||||||
headers: {
|
|
||||||
'accept': '*/*',
|
|
||||||
'accept-language': 'en-US',
|
|
||||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
async function getVaccineAvailablity(message, args) {
|
|
||||||
const [pincode, date] = args;
|
|
||||||
const url = `/appointment/sessions/public/findByPin?${new URLSearchParams({ pincode, date })}`;
|
|
||||||
instance.get(url).then(res => {
|
|
||||||
if (res.data && res.data.sessions) {
|
|
||||||
const {sessions} = res.data;
|
|
||||||
if (sessions && sessions.length > 0 ){
|
|
||||||
sessions.forEach(async (session) => {
|
|
||||||
const vaccineMessage = new MessageEmbed()
|
|
||||||
.setTitle(`${session.name} : ${session.address}`)
|
|
||||||
.addField('State', session.state_name, true)
|
|
||||||
.addField('District', session.district_name, true)
|
|
||||||
.addField('Vaccine', session.vaccine, true)
|
|
||||||
.addField('Available Capacity', session.available_capacity, true)
|
|
||||||
.addField('Available SLots', session.slots.join("/"), true)
|
|
||||||
.setColor("RANDOM");
|
|
||||||
message.channel.send(vaccineMessage);
|
|
||||||
})
|
|
||||||
|
|
||||||
}else {
|
|
||||||
message.channel.send(`No Vaccine Available at place with pincode => ${pincode} on ${date}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).catch(error => message.channel.send(`Error Fetching Data from Cowin`));
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
execute(client, message, args) {
|
|
||||||
getVaccineAvailablity(message, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
const {MessageEmbed} = require('discord.js');
|
|
||||||
const fetch = require('node-fetch');
|
|
||||||
function generateConfusionGif(message) {
|
|
||||||
message.channel.startTyping();
|
|
||||||
const embed = new MessageEmbed()
|
|
||||||
.setDescription(`I dont understand what you are saying <@${process.env.KLIAS_TAG}> do you know what this guy is asking?`)
|
|
||||||
.setColor("RANDOM");
|
|
||||||
const randomIndex = Math.floor(Math.random() * 49);
|
|
||||||
fetch(`https://api.tenor.com/v1/random?key=${process.env.TENOR_TOKEN}&q=I%20dont%20understand&limit=50`)
|
|
||||||
.then(res => res.json())
|
|
||||||
.then(response => {
|
|
||||||
embed.setImage(response.results[randomIndex].media[0].gif.url);
|
|
||||||
message.channel.stopTyping();
|
|
||||||
message.channel.send(embed);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
execute(message) {
|
|
||||||
generateConfusionGif(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +1,14 @@
|
|||||||
{
|
{
|
||||||
"commands" :[
|
"commands" :[
|
||||||
{
|
{
|
||||||
"name": "jokes",
|
"name": "radioStart",
|
||||||
"description": "Bad Jokes Command",
|
"description": "Start Radio",
|
||||||
"file": "./commands/jokes.js"
|
"file": "./commands/radioStart.js"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "play",
|
"name": "radioStop",
|
||||||
"description": "Play Music",
|
"description": "Stop Radio",
|
||||||
"file": "./commands/play.js"
|
"file": "./commands/radioStop.js"
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stop",
|
|
||||||
"description": "Stop Music",
|
|
||||||
"file": "./commands/stop.js"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "loadout",
|
|
||||||
"description": "Get CoD Mobile User Loadout",
|
|
||||||
"file": "./commands/loadout.js"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "vaccine",
|
|
||||||
"description": "Get Vaccine Availability by Pincode",
|
|
||||||
"file": "./commands/vaccine.js"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "got",
|
|
||||||
"description": "Game of Thrones Quotes",
|
|
||||||
"file": "./commands/got.js"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "bb",
|
|
||||||
"description": "Breaking Bad Quotes",
|
|
||||||
"file": "./commands/bb.js"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "dark",
|
|
||||||
"description": "Dark Series Quotes",
|
|
||||||
"file": "./commands/dark.js"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,20 +1 @@
|
|||||||
{
|
{}
|
||||||
"hi": "Hey 🙋♂️. How Are You?",
|
|
||||||
"hello": "Hey 🙋♂️. How Are You?",
|
|
||||||
"ഹലോ": "ഹല്ലാ.... ഇതാരാ.. സുഖം തന്നെ?",
|
|
||||||
"ഹി": "ഹല്ലാ.... ഇതാരാ.. സുഖം തന്നെ?",
|
|
||||||
"എന്തൊക്കെ ഉണ്ട് വിശേഷം": "അങ്ങിനെ പോണു...🤷♂️ സുഖങ്ങളൊക്കെ തന്നെ?",
|
|
||||||
"enthokke und vishesham": "അങ്ങിനെ പോണു...🤷♂️ സുഖങ്ങളൊക്കെ തന്നെ?",
|
|
||||||
"മനുസ്സനല്ലേ പുള്ളെ": "ഇറച്ചിയും ബറോട്ടയും വേണായിരിക്കും... 🤣🤣🤣",
|
|
||||||
"manusanalle pulle": "ഇറച്ചിയും ബറോട്ടയും വേണായിരിക്കും... 🤣🤣🤣",
|
|
||||||
"നീ ആരാ": "താൻ ആരാണെന്ന് തനിക്ക് അറിയാന്മേലെങ്കിൽ താൻ എന്നോട് ചോയ്ക്ക് താൻ ആരാണെന്ന്??? തനിക്ക് ഞാൻ പറഞ്ഞു തരാം താൻ ആരാണെന്ന്... 🤪🤪",
|
|
||||||
"nee araa": "താൻ ആരാണെന്ന് തനിക്ക് അറിയാന്മേലെങ്കിൽ താൻ എന്നോട് ചോയ്ക്ക് താൻ ആരാണെന്ന്??? തനിക്ക് ഞാൻ പറഞ്ഞു തരാം താൻ ആരാണെന്ന്... 🤪🤪",
|
|
||||||
"kya banana hei": "Thumarah banana kaha hei...🤣🤣",
|
|
||||||
"ക്യാ ബനാന ഹേയ്": "തുമരഹ് ബനാന കഹാ ഹേയ്...🤣🤣",
|
|
||||||
"good night": "Good Night 🌉. See you tomorrow. 👋👋",
|
|
||||||
"ola": "ഓല അല്ല തേങ്ങാ",
|
|
||||||
"അങ്ങിനെ പറയാതെ": "പിന്നെ എങ്ങിനെ പറയണം!!",
|
|
||||||
"kool": "എത്രെ ഡിഗ്രീ ഉണ്ട്? 🤣🤣",
|
|
||||||
"cool": "എത്രെ ഡിഗ്രീ ഉണ്ട്? 🤣🤣",
|
|
||||||
"adipoli": "മ് മ്"
|
|
||||||
}
|
|
||||||
33
src/main.js
33
src/main.js
@@ -1,32 +1,23 @@
|
|||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { Client, Collection } = require('discord.js');
|
const { Client, Collection } = require('discord.js');
|
||||||
const confusion = require('./commons/confusion');
|
const { env } = require('process');
|
||||||
|
|
||||||
const client = new Client();
|
const client = new Client();
|
||||||
client.commands = new Collection();
|
client.commands = new Collection();
|
||||||
let casualMessages = {};
|
|
||||||
const CMD_PREFIX = "!";
|
const CMD_PREFIX = "!";
|
||||||
|
|
||||||
client.on('message', (message) => {
|
client.on('message', (message) => {
|
||||||
if (message.author.bot) return;
|
if (message.author.bot) return;
|
||||||
|
if(message.author.id !== process.env.ADMIN_ID) return;
|
||||||
if (message.content.startsWith(CMD_PREFIX)) {
|
if (message.content.startsWith(CMD_PREFIX)) {
|
||||||
const commandReply = parseCMD(message);
|
const commandReply = parseCMD(message);
|
||||||
if (!commandReply) {
|
}
|
||||||
confusion.execute(message);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const replyMessage = parseCasualMessage(message);
|
|
||||||
if (replyMessage) {
|
|
||||||
message.reply(replyMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('ready', () => {
|
client.on('ready', () => {
|
||||||
console.log("BOT is now LIVE");
|
console.log("RADIO BOT is now LIVE");
|
||||||
initConfig();
|
initConfig();
|
||||||
initLanguages();
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function initConfig() {
|
function initConfig() {
|
||||||
@@ -42,20 +33,6 @@ function initConfig() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function initLanguages() {
|
|
||||||
fs.readFile('src/language/language.json', 'utf8', (error, data) => {
|
|
||||||
if (error) throw error;
|
|
||||||
casualMessages = JSON.parse(data);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseCasualMessage(message) {
|
|
||||||
const { content } = message;
|
|
||||||
const parsedMessage = content.trim().toLowerCase();
|
|
||||||
if (!casualMessages.hasOwnProperty(parsedMessage)) return null;
|
|
||||||
return casualMessages[parsedMessage];
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseCMD(message) {
|
function parseCMD(message) {
|
||||||
const [CMD_NAME, ...args] = message.content
|
const [CMD_NAME, ...args] = message.content
|
||||||
.trim()
|
.trim()
|
||||||
@@ -73,7 +50,7 @@ function parseCMD(message) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
client.login(process.env.LUL_BOT_TKN)
|
client.login(process.env.RADIO_BOT_TKN)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error("BOT Login Failed ", error);
|
console.error("BOT Login Failed ", error);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user