diff --git a/package.json b/package.json index 445395f..5f99d83 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "@material-ui/core": "^3.0.1", "@material-ui/icons": "^3.0.1", "apollo-boost": "^0.1.4", - "eris": "^0.14.0", + "eris": "^0.15.0", "graphql": "^14.0.2", "graphql-yoga": "^1.16.7", "isomorphic-unfetch": "^2.0.0", diff --git a/server/bot/commands/api.ts b/server/bot/commands/api.ts index ded16a1..bf19dd0 100644 --- a/server/bot/commands/api.ts +++ b/server/bot/commands/api.ts @@ -1,4 +1,3 @@ - // All the types! import { Command } from '../imports/types' // All the tools! @@ -61,6 +60,7 @@ export const handleOcr: Command = { if (text.length > 2000 || useHastebin) { const { result } = await fetch('https://api.paste.gg/v1/pastes', { method: 'POST', + headers: { 'content-type': 'application/json' }, body: JSON.stringify({ name: 'IveBot /ocr result', files: [{ content: { format: 'text', value: text } }] }) @@ -75,7 +75,7 @@ export const handleOcr: Command = { return { content: hastebin ? `🤔 **Text recognition result uploaded to paste.gg${!useHastebin ? ' due to length' : ''}:** -https://paste.gg/p/anonymous/${id} (use this key to delete: \`${deletionKey}\`)` +https://paste.gg/p/anonymous/${hastebin} (use this key to delete: \`${deletionKey}\`)` : '🤔 **Text recognition result:**\n' + text, embed: { color: 0x666666, @@ -123,10 +123,11 @@ export const handleHastebin: Command = { // Now send the request. const req = await fetch('https://api.paste.gg/v1/pastes', { method: 'POST', + headers: { 'content-type': 'application/json' }, body: JSON.stringify({ - name: 'IveBot /ocr result', + name: 'IveBot paste.gg upload', files: [{ - name: message.attachments.length ? message.attachments[0].name : 'pastefile1', + name: message.attachments.length ? message.attachments[0].filename : 'pastefile1', content: { format: 'text', value: text.toString('utf8') } }] }) @@ -135,7 +136,7 @@ export const handleHastebin: Command = { // Parse the response. const res = await req.json() const { id, deletion_key: deletionKey } = res.result - return res.key + return id ? `**paste.gg URL:**\nhttps://paste.gg/p/anonymous/${id}\nDeletion key: ${deletionKey}` : 'Failed to upload text to paste.gg!' } catch (e) { return `Invalid text file, you ${getInsult()}.` } diff --git a/server/bot/commands/tools.ts b/server/bot/commands/tools.ts index 533a726..0e1bee5 100644 --- a/server/bot/commands/tools.ts +++ b/server/bot/commands/tools.ts @@ -171,7 +171,8 @@ export const handleEval: Command = { const res = inspect(await Promise.resolve(eval(toEval)), false, 0) // const res = eval(`(async () => { const a = ${toEval}; return a })()`) message.addReaction('✅') - return res !== 'undefined' ? `${'```'}${res}${'```'}`.replace(client.token, 'censored') : undefined + const token = (client as unknown as { _token: string })._token + return res !== 'undefined' ? `${'```'}${res}${'```'}`.replace(token, 'censored') : undefined } catch (e) { const channel = await client.getDMChannel(host) message.addReaction('❌') @@ -214,7 +215,8 @@ getContent/getCleanContent(messageID), createMessage(content), getReactions(mess }) const res = inspect(await Promise.resolve(result), false, 0) message.addReaction('✅') - return res !== 'undefined' ? `${'```'}${res}${'```'}` : undefined + const token = (context.client as unknown as { _token: string })._token + return res !== 'undefined' ? `${'```'}${res.replace(token, '')}${'```'}` : undefined } catch (e) { message.addReaction('❌') return `**Error:** diff --git a/server/bot/commands/utilities.ts b/server/bot/commands/utilities.ts index c0fd8da..847368e 100644 --- a/server/bot/commands/utilities.ts +++ b/server/bot/commands/utilities.ts @@ -1,5 +1,5 @@ // All the types! -import Eris, { Message, GuildTextableChannel } from 'eris' +import Eris, { Message, GuildTextableChannel, Constants } from 'eris' import { Command } from '../imports/types' // All the needs! import { getIdFromMention, getInsult, getUser } from '../imports/tools' @@ -172,7 +172,8 @@ export const handlePermissions: Command = { const color = member ? (member.roles.map(i => member.guild.roles.get(i)).sort( (a, b) => a.position > b.position ? -1 : 1 ).find(i => i.color !== 0) || { color: 0 }).color : 0 - const permissions = member.permission + const permissions = member.permissions + const permissionKeys = Object.keys(permissions.json) as (keyof Constants['Permissions'])[] const channelPerm = (message.channel as GuildTextableChannel).permissionsOf(user.id) return { content: `✅ **Permissions of ${user.username}:**`, @@ -190,7 +191,8 @@ export const handlePermissions: Command = { ? 'Owner! (use `/perms --ignore-admin` to show perms regardless)' : permissions.has('administrator') && !ignoreAdmin ? 'Administrator! (use `/perms --ignore-admin` to show perms regardless)' - : Object.keys(permissions.json).filter(perm => permissions.has(perm)) + : permissionKeys + .filter(perm => permissions.has(perm)) .map(perm => (perm.substr(0, 1).toUpperCase() + perm.substr(1)) .replace(/[A-Z]+/g, s => ' ' + s)) .join(', ').replace('TTSMessages', 'TTS Messages') @@ -198,15 +200,18 @@ export const handlePermissions: Command = { !(message.member.guild.ownerID === user.id || permissions.has('administrator')) || ignoreAdmin ? { name: 'Channel Permissions', - value: (Object.keys(permissions.json) - .filter(perm => !permissions.has(perm) && channelPerm.has(perm)) - .map(perm => (perm.substr(0, 1).toUpperCase() + perm.substr(1)) - .replace(/[A-Z]+/g, s => ' ' + s)) - .join(', ') + Object.keys(permissions.json) - .filter(perm => permissions.has(perm) && !channelPerm.has(perm)) - .map(perm => '**!(' + (perm.substr(0, 1).toUpperCase() + perm.substr(1)) - .replace(/[^(][A-Z]+/g, s => s.substr(0, 1) + ' ' + s.substr(1)) + ')**') - .join(', ')).replace('TTSMessages', 'TTS Messages') + value: ( + permissionKeys + .filter(perm => !permissions.has(perm) && channelPerm.has(perm)) + .map(perm => (perm.substr(0, 1).toUpperCase() + perm.substr(1)) + .replace(/[A-Z]+/g, s => ' ' + s)) + .join(', ') + + permissionKeys + .filter(perm => permissions.has(perm) && !channelPerm.has(perm)) + .map(perm => '**!(' + (perm.substr(0, 1).toUpperCase() + perm.substr(1)) + .replace(/[^(][A-Z]+/g, s => s.substr(0, 1) + ' ' + s.substr(1)) + ')**') + .join(', ') + ).replace('TTSMessages', 'TTS Messages') } : { name: '', value: '' } ].filter(e => !!e.value), footer: { text: 'User ID: ' + user.id } diff --git a/server/bot/index.ts b/server/bot/index.ts index ef94c8a..e3a5fb8 100644 --- a/server/bot/index.ts +++ b/server/bot/index.ts @@ -107,6 +107,10 @@ export default async (message: Message, client: Client, tempDB: DB, db: Db) => { // Auto responses and easter eggs. if (command.startsWith('is dot a good boy')) sendResponse('Shame on you. He\'s undefined.') else if (command.startsWith('iphone x')) sendResponse(`You don't deserve it. 😎`) + else if (command.startsWith('iphone 11')) sendResponse(`You don't deserve it. 😎`) + else if (command.startsWith('iphone 12')) sendResponse(`You don't deserve it. 😎`) + else if (command.startsWith('iphone 13')) sendResponse(`You don't deserve it. 😎`) + else if (command.startsWith('iphone se')) sendResponse(`lol peasant`) else if (command.startsWith('triggered')) sendResponse('Ah, pathetic people again.') else if (command.startsWith('ayy')) sendResponse('lmao') // Handle answers to gunfight. diff --git a/server/index.ts b/server/index.ts index ba09160..7d1a80d 100644 --- a/server/index.ts +++ b/server/index.ts @@ -32,7 +32,7 @@ const dev = process.env.NODE_ENV !== 'production' const port = parseInt(process.env.PORT, 10) || 3000 // If port variable has been set. // Create a client to connect to Discord API Gateway. -const client = new Client(token === 'dotenv' ? process.env.IVEBOT_TOKEN : token, { +const client = new Client('Bot ' + token === 'dotenv' ? process.env.IVEBOT_TOKEN : token, { allowedMentions: { everyone: false, roles: true, users: true }, autoreconnect: true, restMode: true diff --git a/yarn.lock b/yarn.lock index ddff363..51c3103 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1491,6 +1491,13 @@ are-we-there-yet@~1.1.2: delegates "^1.0.0" readable-stream "^2.0.6" +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + arr-diff@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" @@ -2813,14 +2820,14 @@ enhanced-resolve@^4.1.0: memory-fs "^0.4.0" tapable "^1.0.0" -eris@^0.14.0: - version "0.14.0" - resolved "https://registry.yarnpkg.com/eris/-/eris-0.14.0.tgz#0d13391c0fc1a7b678b2f8d1fc3ec6aef05700d3" - integrity sha512-/W6X0SFR2swtA9oc4ga5Wh1TQcZtPgbUaDDdwYc67fvFUAtwC+V1xzWUZq2yDeJnTfB8Uot9SJWA8Lthe2sDtQ== +eris@^0.15.0: + version "0.15.0" + resolved "https://registry.yarnpkg.com/eris/-/eris-0.15.0.tgz#d0744d993d508b2951bc6d0ab380ae39b63c0666" + integrity sha512-muBdi5XyMXdxFQ8xUG6yofq40/Z02CHlqJP7zIdHhpdDiHvFM/mybGiFAHuoSYcsVTTvEfbUaAJ+SDEmMjARYw== dependencies: ws "^7.2.1" optionalDependencies: - opusscript "^0.0.7" + opusscript "^0.0.8" tweetnacl "^1.0.1" errno@^0.1.2, errno@^0.1.3, errno@^0.1.4, errno@~0.1.7: @@ -3093,6 +3100,11 @@ espree@^5.0.1: acorn-jsx "^5.0.0" eslint-visitor-keys "^1.0.0" +esprima@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + esquery@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708" @@ -5434,10 +5446,10 @@ optionator@^0.8.2: type-check "~0.3.2" word-wrap "~1.2.3" -opusscript@^0.0.7: - version "0.0.7" - resolved "https://registry.yarnpkg.com/opusscript/-/opusscript-0.0.7.tgz#7dd7ec55b302d26bf588e6fc3feb090b8c7da856" - integrity sha512-DcBadTdYTUuH9zQtepsLjQn4Ll6rs3dmeFvN+SD0ThPnxRBRm/WC1zXWPg+wgAJimB784gdZvUMA57gDP7FdVg== +opusscript@^0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/opusscript/-/opusscript-0.0.8.tgz#00b49e81281b4d99092d013b1812af8654bd0a87" + integrity sha512-VSTi1aWFuCkRCVq+tx/BQ5q9fMnQ9pVZ3JU4UHKqTkf0ED3fKEPdr+gKAAl3IA2hj9rrP6iyq3hlcJq3HELtNQ== os-browserify@^0.3.0: version "0.3.0" @@ -6664,6 +6676,11 @@ split-string@^3.0.1, split-string@^3.0.2: dependencies: extend-shallow "^3.0.0" +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= + ssri@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8"