Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gifCommand: {
- command: ['gif', 'giphy'],
- rank: 'user',
- type: 'startsWith',
- functionality: function (chat, cmd) {
- if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0);
- if (!basicBot.commands.executable(this.rank, chat)) return void (0);
- else {
- var msg = chat.message;
- if (msg.length !== cmd.length) {
- function get_id(api_key, fixedtag, func)
- {
- $.getJSON(
- "https://tv.giphy.com/v1/gifs/random?",
- {
- "format": "json",
- "api_key": api_key,
- "rating": rating,
- "tag": fixedtag
- },
- function(response)
- {
- func(response.data.id);
- }
- )
- }
- var api_key = "dc6zaTOxFJmzC"; // public beta key
- var rating = "pg-13"; // PG 13 gifs
- var tag = msg.substr(cmd.length + 1);
- var fixedtag = tag.replace(/ /g,"+");
- var commatag = tag.replace(/ /g,", ");
- get_id(api_key, tag, function(id) {
- if (typeof id !== 'undefined') {
- API.sendChat(subChat(basicBot.chat.validgiftags, {name: chat.un, id: id, tags: commatag}));
- } else {
- API.sendChat(subChat(basicBot.chat.invalidgiftags, {name: chat.un, tags: commatag}));
- }
- });
- }
- else {
- function get_random_id(api_key, func)
- {
- $.getJSON(
- "https://tv.giphy.com/v1/gifs/random?",
- {
- "format": "json",
- "api_key": api_key,
- "rating": rating
- },
- function(response)
- {
- func(response.data.id);
- }
- )
- }
- var api_key = "dc6zaTOxFJmzC"; // public beta key
- var rating = "pg-13"; // PG 13 gifs
- get_random_id(api_key, function(id) {
- if (typeof id !== 'undefined') {
- API.sendChat(subChat(basicBot.chat.validgifrandom, {name: chat.un, id: id}));
- } else {
- API.sendChat(subChat(basicBot.chat.invalidgifrandom, {name: chat.un}));
- }
- });
- }
- }
- }
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement