Compare commits
No commits in common. "ba42ef6f376bec215a6374e80ad6cb853a243432" and "1269403787cac73e43f610cf27f215bf243d1ee4" have entirely different histories.
ba42ef6f37
...
1269403787
5 changed files with 89 additions and 71 deletions
|
@ -1,6 +1,6 @@
|
||||||
import { SlashCommandBuilder } from 'discord.js';
|
import { SlashCommandBuilder } from 'discord.js';
|
||||||
import { EmbedBuilder } from 'discord.js';
|
import { EmbedBuilder } from 'discord.js';
|
||||||
import { TwitterApi } from 'twitter-api-v2';
|
import Twit from 'twit';
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import os from 'node:os';
|
import os from 'node:os';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
|
@ -114,11 +114,11 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const userClient = new TwitterApi({
|
const T = new Twit({
|
||||||
appKey: twiConsumer,
|
consumer_key: twiConsumer,
|
||||||
appSecret: twiConsumerSecret,
|
consumer_secret: twiConsumerSecret,
|
||||||
accessToken: twiToken,
|
access_token: twiToken,
|
||||||
accessSecret: twiTokenSecret,
|
access_token_secret: twiTokenSecret,
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -140,9 +140,7 @@ export default {
|
||||||
return interaction.editReply({ content: 'Gifs can\'t be larger than 15 MB!' });
|
return interaction.editReply({ content: 'Gifs can\'t be larger than 15 MB!' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const image = await userClient.v1.uploadMedia(`${os.tmpdir()}/${attachment.name}`);
|
const b64Image = fs.readFileSync(`${os.tmpdir()}/${attachment.name}`, { encoding: 'base64' });
|
||||||
Tweet(image);
|
|
||||||
/*
|
|
||||||
T.post('media/upload', { media_data: b64Image }, function(err, data) {
|
T.post('media/upload', { media_data: b64Image }, function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('OH NO AN ERROR!!!!!!!');
|
console.log('OH NO AN ERROR!!!!!!!');
|
||||||
|
@ -153,7 +151,6 @@ export default {
|
||||||
Tweet(data);
|
Tweet(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await interaction.editReply({ content: 'File type not supported, you can only send jpg/png/gif' });
|
await interaction.editReply({ content: 'File type not supported, you can only send jpg/png/gif' });
|
||||||
|
@ -170,22 +167,44 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function Tweet(img) {
|
function Tweet(data) {
|
||||||
console.log(img);
|
let options = {
|
||||||
let options = null;
|
status: tweet,
|
||||||
if (img) {
|
};
|
||||||
options = { media: { media_ids: new Array(img) } };
|
|
||||||
|
if (data && tweet) {
|
||||||
|
options = {
|
||||||
|
status: tweet,
|
||||||
|
media_ids: new Array(data.media_id_string),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else if (data) {
|
||||||
|
options = {
|
||||||
|
media_ids: new Array(data.media_id_string),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
const tweeted = await userClient.v2.tweet(tweet, options);
|
|
||||||
|
|
||||||
console.log(tweeted);
|
T.post('statuses/update', options, function(err, response) {
|
||||||
|
if (err) {
|
||||||
|
// Rate limit exceeded
|
||||||
|
if (err.code == 88) return interaction.editReply({ content: err.interaction });
|
||||||
|
// Tweet needs to be a bit shorter.
|
||||||
|
if (err.code == 186) return interaction.editReply({ content: `${err.interaction} Your interaction was ${tweet.length} characters, you need to remove ${tweet.length - 280} characters (This count may be inaccurate if your interaction contained link)` });
|
||||||
|
// Status is a duplicate.
|
||||||
|
if (err.code == 187) return interaction.editReply({ content: err.interaction });
|
||||||
|
// To protect our users from spam and other malicious activity, this account is temporarily locked.
|
||||||
|
if (err.code == 326) return interaction.editReply({ content: err.interaction });
|
||||||
|
console.error('OH NO!!!!');
|
||||||
|
console.error(err);
|
||||||
|
return interaction.editReply({ content: 'OH NO!!! AN ERROR HAS occurred!!! please hold on while i find what\'s causing this issue!' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const tweetid = response.id_str;
|
||||||
const tweetid = tweeted.data.id;
|
|
||||||
const FunnyWords = ['oppaGangnamStyle', '69', '420', 'cum', 'funnyMan', 'GUCCISmartToilet', 'TwitterForClowns', 'fart', 'ok', 'hi', 'howAreYou', 'WhatsNinePlusTen', '21'];
|
const FunnyWords = ['oppaGangnamStyle', '69', '420', 'cum', 'funnyMan', 'GUCCISmartToilet', 'TwitterForClowns', 'fart', 'ok', 'hi', 'howAreYou', 'WhatsNinePlusTen', '21'];
|
||||||
const TweetLink = `https://twitter.com/${FunnyWords[Math.floor((Math.random() * FunnyWords.length))]}/status/${tweetid}`;
|
const TweetLink = `https://twitter.com/${FunnyWords[Math.floor((Math.random() * FunnyWords.length))]}/status/${tweetid}`;
|
||||||
|
|
||||||
let channel = await client.channels.resolve(twiChannel);
|
// Im too lazy for now to make an entry in config.json
|
||||||
|
let channel = client.channels.resolve(twiChannel);
|
||||||
channel.send(TweetLink);
|
channel.send(TweetLink);
|
||||||
|
|
||||||
const Embed = new EmbedBuilder()
|
const Embed = new EmbedBuilder()
|
||||||
|
@ -212,9 +231,10 @@ export default {
|
||||||
|
|
||||||
if (attachment) Embed.setImage(attachment.url);
|
if (attachment) Embed.setImage(attachment.url);
|
||||||
|
|
||||||
channel = await client.channels.resolve(twiLogChannel);
|
channel = client.channels.resolve(twiLogChannel);
|
||||||
channel.send({ embeds: [Embed] });
|
channel.send({ embeds: [Embed] });
|
||||||
return interaction.editReply({ content: `Go see ur epic tweet ${TweetLink}` });
|
return interaction.editReply({ content: `Go see ur epic tweet ${TweetLink}` });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { ActivityType } from 'discord.js';
|
import { ActivityType } from 'discord.js';
|
||||||
import game from '../../json/playing.json' assert {type: 'json'};
|
import game from '../../json/playing.json' assert {type: 'json'};
|
||||||
import music from '../../json/listening.json' assert {type: 'json'};
|
|
||||||
import watch from '../../json/watching.json' assert {type: 'json'};
|
import watch from '../../json/watching.json' assert {type: 'json'};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -15,7 +14,7 @@ export default {
|
||||||
}, 1800000);
|
}, 1800000);
|
||||||
|
|
||||||
async function setStatus() {
|
async function setStatus() {
|
||||||
const random = Math.floor((Math.random() * 3));
|
const random = Math.floor((Math.random() * 2));
|
||||||
let types, status;
|
let types, status;
|
||||||
// Random "Watching" status taken from json
|
// Random "Watching" status taken from json
|
||||||
if (random === 0) {
|
if (random === 0) {
|
||||||
|
@ -36,15 +35,6 @@ export default {
|
||||||
console.log(`Setting status to: ${status}`);
|
console.log(`Setting status to: ${status}`);
|
||||||
types = [ ActivityType.Playing, ActivityType.Competing ];
|
types = [ ActivityType.Playing, ActivityType.Competing ];
|
||||||
}
|
}
|
||||||
else if (random === 2) {
|
|
||||||
console.log('Status type: \x1b[32mPlaying\x1b[0m');
|
|
||||||
|
|
||||||
status = music[Math.floor((Math.random() * music.length))];
|
|
||||||
status = status + ' | Now with slash commands!';
|
|
||||||
|
|
||||||
console.log(`Setting status to: ${status}`);
|
|
||||||
types = [ ActivityType.Listening ];
|
|
||||||
}
|
|
||||||
await client.user.setActivity(status, { type: types[Math.floor((Math.random() * types.length))] });
|
await client.user.setActivity(status, { type: types[Math.floor((Math.random() * types.length))] });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[
|
|
||||||
"psychometricBussdown by oddballTheatre"
|
|
||||||
]
|
|
21
package-lock.json
generated
21
package-lock.json
generated
|
@ -19,7 +19,7 @@
|
||||||
"safe-regex": "github:davisjam/safe-regex",
|
"safe-regex": "github:davisjam/safe-regex",
|
||||||
"sequelize": "^6.21.3",
|
"sequelize": "^6.21.3",
|
||||||
"turndown": "^7.1.1",
|
"turndown": "^7.1.1",
|
||||||
"twitter-api-v2": "^1.15.0",
|
"twit": "^1.1.20",
|
||||||
"ytpplus-node": "github:Supositware/ytpplus-node"
|
"ytpplus-node": "github:Supositware/ytpplus-node"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -5159,6 +5159,11 @@
|
||||||
"set-blocking": "^2.0.0"
|
"set-blocking": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/oauth": {
|
||||||
|
"version": "0.9.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/oauth/-/oauth-0.9.9.tgz",
|
||||||
|
"integrity": "sha512-kjdfbdtIFcfvHTdvh+pbR5RMOxrihCmMtDjOCAieetr4NoUOuRjl1q9gyGnvpPNDOalH8moHqur150XYGPQFeA=="
|
||||||
|
},
|
||||||
"node_modules/object-assign": {
|
"node_modules/object-assign": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||||
|
@ -6817,10 +6822,16 @@
|
||||||
"domino": "^2.1.6"
|
"domino": "^2.1.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/twitter-api-v2": {
|
"node_modules/twit": {
|
||||||
"version": "1.15.0",
|
"version": "1.1.20",
|
||||||
"resolved": "https://registry.npmjs.org/twitter-api-v2/-/twitter-api-v2-1.15.0.tgz",
|
"resolved": "https://registry.npmjs.org/twit/-/twit-1.1.20.tgz",
|
||||||
"integrity": "sha512-Cqg3pIGhSwPyFBndpBrucdeNXecNFnYcXy3ixQ4brJHd/3k1CAtBVcX0e3s6jRYl/QIx5BmyGXS/SHEGtYZ3gw=="
|
"integrity": "sha512-5Wb4b+1mqSxOXGrTe5O4GIB6/IQnh5anAub34M+VfAdA1g+9QfUuod4C94xf9NNcaz+rNZ/3LRUSTpn8wLMnYA==",
|
||||||
|
"dependencies": {
|
||||||
|
"oauth": "0.9.9"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.6.0"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"node_modules/type": {
|
"node_modules/type": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
"safe-regex": "github:davisjam/safe-regex",
|
"safe-regex": "github:davisjam/safe-regex",
|
||||||
"sequelize": "^6.21.3",
|
"sequelize": "^6.21.3",
|
||||||
"turndown": "^7.1.1",
|
"turndown": "^7.1.1",
|
||||||
"twitter-api-v2": "^1.15.0",
|
"twit": "^1.1.20",
|
||||||
"ytpplus-node": "github:Supositware/ytpplus-node"
|
"ytpplus-node": "github:Supositware/ytpplus-node"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
Loading…
Reference in a new issue