mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
chore: merge v12-dev master into stable
This commit is contained in:
BIN
test/blobReach.png
Normal file
BIN
test/blobReach.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
44
test/disableMentions.js
Normal file
44
test/disableMentions.js
Normal file
@@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
const { token, prefix } = require('./auth');
|
||||
const Discord = require('../src');
|
||||
const { Util } = Discord;
|
||||
|
||||
const client = new Discord.Client({
|
||||
// To see a difference, comment out disableMentions and run the same tests using disableEveryone
|
||||
// You will notice that all messages will mention @everyone
|
||||
// disableEveryone: true
|
||||
disableMentions: 'everyone',
|
||||
});
|
||||
|
||||
const tests = [
|
||||
// Test 1
|
||||
// See https://github.com/discordapp/discord-api-docs/issues/1189
|
||||
'@\u202eeveryone @\u202ehere',
|
||||
|
||||
// Test 2
|
||||
// See https://github.com/discordapp/discord-api-docs/issues/1241
|
||||
// TL;DR: Characters like \u0300 will only be stripped if more than 299 are present
|
||||
`${'\u0300@'.repeat(150)}@\u0300everyone @\u0300here`,
|
||||
|
||||
// Test 3
|
||||
// Normal @everyone/@here mention
|
||||
'@everyone @here',
|
||||
];
|
||||
|
||||
client.on('ready', () => console.log('Ready!'));
|
||||
|
||||
client.on('message', message => {
|
||||
// Check if message starts with prefix
|
||||
if (!message.content.startsWith(prefix)) return;
|
||||
const [command, ...args] = message.content.substr(prefix.length).split(' ');
|
||||
|
||||
// Clean content and log each character
|
||||
console.log(Util.cleanContent(args.join(' '), message).split(''));
|
||||
|
||||
if (command === 'test1') message.reply(tests[0]);
|
||||
else if (command === 'test2') message.reply(tests[1]);
|
||||
else if (command === 'test3') message.reply(tests[2]);
|
||||
});
|
||||
|
||||
client.login(token).catch(console.error);
|
||||
195
test/escapeMarkdown.test.js
Normal file
195
test/escapeMarkdown.test.js
Normal file
@@ -0,0 +1,195 @@
|
||||
'use strict';
|
||||
|
||||
/* eslint-disable max-len, no-undef */
|
||||
|
||||
const Util = require('../src/util/Util');
|
||||
const testString = "`_Behold!_`\n||___~~***```js\n`use strict`;\nrequire('discord.js');```***~~___||";
|
||||
|
||||
describe('escapeCodeblock', () => {
|
||||
test('shared', () => {
|
||||
expect(Util.escapeCodeBlock(testString)).toBe(
|
||||
"`_Behold!_`\n||___~~***\\`\\`\\`js\n`use strict`;\nrequire('discord.js');\\`\\`\\`***~~___||",
|
||||
);
|
||||
});
|
||||
|
||||
test('basic', () => {
|
||||
expect(Util.escapeCodeBlock('```test```')).toBe('\\`\\`\\`test\\`\\`\\`');
|
||||
});
|
||||
});
|
||||
|
||||
describe('escapeInlineCode', () => {
|
||||
test('shared', () => {
|
||||
expect(Util.escapeInlineCode(testString)).toBe(
|
||||
"\\`_Behold!_\\`\n||___~~***```js\n\\`use strict\\`;\nrequire('discord.js');```***~~___||",
|
||||
);
|
||||
});
|
||||
|
||||
test('basic', () => {
|
||||
expect(Util.escapeInlineCode('`test`')).toBe('\\`test\\`');
|
||||
});
|
||||
});
|
||||
|
||||
describe('escapeBold', () => {
|
||||
test('shared', () => {
|
||||
expect(Util.escapeBold(testString)).toBe(
|
||||
"`_Behold!_`\n||___~~*\\*\\*```js\n`use strict`;\nrequire('discord.js');```\\*\\**~~___||",
|
||||
);
|
||||
});
|
||||
|
||||
test('basic', () => {
|
||||
expect(Util.escapeBold('**test**')).toBe('\\*\\*test\\*\\*');
|
||||
});
|
||||
});
|
||||
|
||||
describe('escapeItalic', () => {
|
||||
test('shared', () => {
|
||||
expect(Util.escapeItalic(testString)).toBe(
|
||||
"`\\_Behold!\\_`\n||\\___~~\\***```js\n`use strict`;\nrequire('discord.js');```**\\*~~__\\_||",
|
||||
);
|
||||
});
|
||||
|
||||
test('basic (_)', () => {
|
||||
expect(Util.escapeItalic('_test_')).toBe('\\_test\\_');
|
||||
});
|
||||
|
||||
test('basic (*)', () => {
|
||||
expect(Util.escapeItalic('*test*')).toBe('\\*test\\*');
|
||||
});
|
||||
});
|
||||
|
||||
describe('escapeUnderline', () => {
|
||||
test('shared', () => {
|
||||
expect(Util.escapeUnderline(testString)).toBe(
|
||||
"`_Behold!_`\n||_\\_\\_~~***```js\n`use strict`;\nrequire('discord.js');```***~~\\_\\__||",
|
||||
);
|
||||
});
|
||||
|
||||
test('basic', () => {
|
||||
expect(Util.escapeUnderline('__test__')).toBe('\\_\\_test\\_\\_');
|
||||
});
|
||||
});
|
||||
|
||||
describe('escapeStrikethrough', () => {
|
||||
test('shared', () => {
|
||||
expect(Util.escapeStrikethrough(testString)).toBe(
|
||||
"`_Behold!_`\n||___\\~\\~***```js\n`use strict`;\nrequire('discord.js');```***\\~\\~___||",
|
||||
);
|
||||
});
|
||||
|
||||
test('basic', () => {
|
||||
expect(Util.escapeStrikethrough('~~test~~')).toBe('\\~\\~test\\~\\~');
|
||||
});
|
||||
});
|
||||
|
||||
describe('escapeSpoiler', () => {
|
||||
test('shared', () => {
|
||||
expect(Util.escapeSpoiler(testString)).toBe(
|
||||
"`_Behold!_`\n\\|\\|___~~***```js\n`use strict`;\nrequire('discord.js');```***~~___\\|\\|",
|
||||
);
|
||||
});
|
||||
|
||||
test('basic', () => {
|
||||
expect(Util.escapeSpoiler('||test||')).toBe('\\|\\|test\\|\\|');
|
||||
});
|
||||
});
|
||||
|
||||
describe('escapeMarkdown', () => {
|
||||
test('shared', () => {
|
||||
expect(Util.escapeMarkdown(testString)).toBe(
|
||||
"\\`\\_Behold!\\_\\`\n\\|\\|\\_\\_\\_\\~\\~\\*\\*\\*\\`\\`\\`js\n\\`use strict\\`;\nrequire('discord.js');\\`\\`\\`\\*\\*\\*\\~\\~\\_\\_\\_\\|\\|",
|
||||
);
|
||||
});
|
||||
|
||||
test('no codeBlock', () => {
|
||||
expect(Util.escapeMarkdown(testString, { codeBlock: false })).toBe(
|
||||
"\\`\\_Behold!\\_\\`\n\\|\\|\\_\\_\\_\\~\\~\\*\\*\\*```js\n\\`use strict\\`;\nrequire('discord.js');```\\*\\*\\*\\~\\~\\_\\_\\_\\|\\|",
|
||||
);
|
||||
});
|
||||
|
||||
test('no inlineCode', () => {
|
||||
expect(Util.escapeMarkdown(testString, { inlineCode: false })).toBe(
|
||||
"`\\_Behold!\\_`\n\\|\\|\\_\\_\\_\\~\\~\\*\\*\\*\\`\\`\\`js\n`use strict`;\nrequire('discord.js');\\`\\`\\`\\*\\*\\*\\~\\~\\_\\_\\_\\|\\|",
|
||||
);
|
||||
});
|
||||
|
||||
test('no bold', () => {
|
||||
expect(Util.escapeMarkdown(testString, { bold: false })).toBe(
|
||||
"\\`\\_Behold!\\_\\`\n\\|\\|\\_\\_\\_\\~\\~\\***\\`\\`\\`js\n\\`use strict\\`;\nrequire('discord.js');\\`\\`\\`**\\*\\~\\~\\_\\_\\_\\|\\|",
|
||||
);
|
||||
});
|
||||
|
||||
test('no italic', () => {
|
||||
expect(Util.escapeMarkdown(testString, { italic: false })).toBe(
|
||||
"\\`_Behold!_\\`\n\\|\\|_\\_\\_\\~\\~*\\*\\*\\`\\`\\`js\n\\`use strict\\`;\nrequire('discord.js');\\`\\`\\`\\*\\**\\~\\~\\_\\__\\|\\|",
|
||||
);
|
||||
});
|
||||
|
||||
test('no underline', () => {
|
||||
expect(Util.escapeMarkdown(testString, { underline: false })).toBe(
|
||||
"\\`\\_Behold!\\_\\`\n\\|\\|\\___\\~\\~\\*\\*\\*\\`\\`\\`js\n\\`use strict\\`;\nrequire('discord.js');\\`\\`\\`\\*\\*\\*\\~\\~__\\_\\|\\|",
|
||||
);
|
||||
});
|
||||
|
||||
test('no strikethrough', () => {
|
||||
expect(Util.escapeMarkdown(testString, { strikethrough: false })).toBe(
|
||||
"\\`\\_Behold!\\_\\`\n\\|\\|\\_\\_\\_~~\\*\\*\\*\\`\\`\\`js\n\\`use strict\\`;\nrequire('discord.js');\\`\\`\\`\\*\\*\\*~~\\_\\_\\_\\|\\|",
|
||||
);
|
||||
});
|
||||
|
||||
test('no spoiler', () => {
|
||||
expect(Util.escapeMarkdown(testString, { spoiler: false })).toBe(
|
||||
"\\`\\_Behold!\\_\\`\n||\\_\\_\\_\\~\\~\\*\\*\\*\\`\\`\\`js\n\\`use strict\\`;\nrequire('discord.js');\\`\\`\\`\\*\\*\\*\\~\\~\\_\\_\\_||",
|
||||
);
|
||||
});
|
||||
|
||||
describe('code content', () => {
|
||||
test('no code block content', () => {
|
||||
expect(Util.escapeMarkdown(testString, { codeBlockContent: false })).toBe(
|
||||
"\\`\\_Behold!\\_\\`\n\\|\\|\\_\\_\\_\\~\\~\\*\\*\\*\\`\\`\\`js\n`use strict`;\nrequire('discord.js');\\`\\`\\`\\*\\*\\*\\~\\~\\_\\_\\_\\|\\|",
|
||||
);
|
||||
});
|
||||
|
||||
test('no inline code content', () => {
|
||||
expect(Util.escapeMarkdown(testString, { inlineCodeContent: false })).toBe(
|
||||
"\\`_Behold!_\\`\n\\|\\|\\_\\_\\_\\~\\~\\*\\*\\*\\`\\`\\`js\n\\`use strict\\`;\nrequire('discord.js');\\`\\`\\`\\*\\*\\*\\~\\~\\_\\_\\_\\|\\|",
|
||||
);
|
||||
});
|
||||
|
||||
test('neither inline code or code block content', () => {
|
||||
expect(Util.escapeMarkdown(testString, { inlineCodeContent: false, codeBlockContent: false }))
|
||||
// eslint-disable-next-line max-len
|
||||
.toBe(
|
||||
"\\`_Behold!_\\`\n\\|\\|\\_\\_\\_\\~\\~\\*\\*\\*\\`\\`\\`js\n`use strict`;\nrequire('discord.js');\\`\\`\\`\\*\\*\\*\\~\\~\\_\\_\\_\\|\\|",
|
||||
);
|
||||
});
|
||||
|
||||
test('neither code blocks or code block content', () => {
|
||||
expect(Util.escapeMarkdown(testString, { codeBlock: false, codeBlockContent: false })).toBe(
|
||||
"\\`\\_Behold!\\_\\`\n\\|\\|\\_\\_\\_\\~\\~\\*\\*\\*```js\n`use strict`;\nrequire('discord.js');```\\*\\*\\*\\~\\~\\_\\_\\_\\|\\|",
|
||||
);
|
||||
});
|
||||
|
||||
test('neither inline code or inline code content', () => {
|
||||
expect(Util.escapeMarkdown(testString, { inlineCode: false, inlineCodeContent: false })).toBe(
|
||||
"`_Behold!_`\n\\|\\|\\_\\_\\_\\~\\~\\*\\*\\*\\`\\`\\`js\n`use strict`;\nrequire('discord.js');\\`\\`\\`\\*\\*\\*\\~\\~\\_\\_\\_\\|\\|",
|
||||
);
|
||||
});
|
||||
|
||||
test('edge-case odd number of fenses with no code block content', () => {
|
||||
expect(
|
||||
Util.escapeMarkdown('**foo** ```**bar**``` **fizz** ``` **buzz**', {
|
||||
codeBlock: false,
|
||||
codeBlockContent: false,
|
||||
}),
|
||||
).toBe('\\*\\*foo\\*\\* ```**bar**``` \\*\\*fizz\\*\\* ``` \\*\\*buzz\\*\\*');
|
||||
});
|
||||
|
||||
test('edge-case odd number of backticks with no inline code content', () => {
|
||||
expect(
|
||||
Util.escapeMarkdown('**foo** `**bar**` **fizz** ` **buzz**', { inlineCode: false, inlineCodeContent: false }),
|
||||
).toBe('\\*\\*foo\\*\\* `**bar**` \\*\\*fizz\\*\\* ` \\*\\*buzz\\*\\*');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/* eslint-enable max-len, no-undef */
|
||||
121
test/random.js
121
test/random.js
@@ -1,16 +1,20 @@
|
||||
/* eslint-disable */
|
||||
|
||||
'use strict';
|
||||
|
||||
const Discord = require('../');
|
||||
const request = require('superagent');
|
||||
const fs = require('fs');
|
||||
const ytdl = require('ytdl-core');
|
||||
const { token, song } = require('./auth.js');
|
||||
const Discord = require('../');
|
||||
|
||||
console.time('magic');
|
||||
|
||||
const client = new Discord.Client({ fetchAllMembers: true, apiRequestMethod: 'sequential' });
|
||||
|
||||
const { email, password, token, usertoken, song } = require('./auth.json');
|
||||
|
||||
client.login(token).then(atoken => console.log('logged in with token ' + atoken)).catch(console.error);
|
||||
client
|
||||
.login(token)
|
||||
.then(() => console.log('logged in'))
|
||||
.catch(console.error);
|
||||
|
||||
client.on('ready', () => {
|
||||
console.log(`ready with ${client.users.size} users`);
|
||||
@@ -33,8 +37,9 @@ client.on('message', message => {
|
||||
if (message.content === 'imma queue pls') {
|
||||
let count = 0;
|
||||
let ecount = 0;
|
||||
for(let x = 0; x < 4000; x++) {
|
||||
message.channel.send(`this is message ${x} of 3999`)
|
||||
for (let x = 0; x < 4000; x++) {
|
||||
message.channel
|
||||
.send(`this is message ${x} of 3999`)
|
||||
.then(m => {
|
||||
count++;
|
||||
console.log('reached', count, ecount);
|
||||
@@ -48,8 +53,9 @@ client.on('message', message => {
|
||||
}
|
||||
|
||||
if (message.content === 'myperms?') {
|
||||
message.channel.send('Your permissions are:\n' +
|
||||
JSON.stringify(message.channel.permissionsFor(message.author).serialize(), null, 4));
|
||||
message.channel.send(
|
||||
`Your permissions are:\n${JSON.stringify(message.channel.permissionsFor(message.author).serialize(), null, 4)}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (message.content === 'delchann') {
|
||||
@@ -65,22 +71,26 @@ client.on('message', message => {
|
||||
}
|
||||
|
||||
if (message.content.startsWith('botavatar')) {
|
||||
request
|
||||
.get('url')
|
||||
.end((err, res) => {
|
||||
client.user.setAvatar(res.body).catch(console.error)
|
||||
.then(user => message.channel.send('Done!'));
|
||||
});
|
||||
request.get('url').end((err, res) => {
|
||||
client.user
|
||||
.setAvatar(res.body)
|
||||
.catch(console.error)
|
||||
.then(user => message.channel.send('Done!'));
|
||||
});
|
||||
}
|
||||
|
||||
if (message.content.startsWith('gn')) {
|
||||
message.guild.setName(message.content.substr(3))
|
||||
message.guild
|
||||
.setName(message.content.substr(3))
|
||||
.then(guild => console.log('guild updated to', guild.name))
|
||||
.catch(console.error);
|
||||
}
|
||||
|
||||
if (message.content === 'leave') {
|
||||
message.guild.leave().then(guild => console.log('left guild', guild.name)).catch(console.error);
|
||||
message.guild
|
||||
.leave()
|
||||
.then(guild => console.log('left guild', guild.name))
|
||||
.catch(console.error);
|
||||
}
|
||||
|
||||
if (message.content === 'stats') {
|
||||
@@ -90,22 +100,29 @@ client.on('message', message => {
|
||||
m += `I am aware of ${client.channels.size} channels overall\n`;
|
||||
m += `I am aware of ${client.guilds.size} guilds overall\n`;
|
||||
m += `I am aware of ${client.users.size} users overall\n`;
|
||||
message.channel.send(m).then(msg => msg.edit('nah')).catch(console.error);
|
||||
message.channel
|
||||
.send(m)
|
||||
.then(msg => msg.edit('nah'))
|
||||
.catch(console.error);
|
||||
}
|
||||
|
||||
if (message.content === 'messageme!') {
|
||||
message.author.send('oh, hi there!').catch(e => console.log(e.stack));
|
||||
}
|
||||
|
||||
if (message.content === 'don\'t dm me') {
|
||||
if (message.content === "don't dm me") {
|
||||
message.author.deleteDM();
|
||||
}
|
||||
|
||||
if (message.content.startsWith('kick')) {
|
||||
message.guild.member(message.mentions[0]).kick().then(member => {
|
||||
console.log(member);
|
||||
message.channel.send('Kicked!' + member.user.username);
|
||||
}).catch(console.error);
|
||||
message.guild
|
||||
.member(message.mentions[0])
|
||||
.kick()
|
||||
.then(member => {
|
||||
console.log(member);
|
||||
message.channel.send(`Kicked!${member.user.username}`);
|
||||
})
|
||||
.catch(console.error);
|
||||
}
|
||||
|
||||
if (message.content === 'ratelimittest') {
|
||||
@@ -122,55 +139,72 @@ client.on('message', message => {
|
||||
}
|
||||
|
||||
if (message.content === 'makerole') {
|
||||
message.guild.createRole().then(role => {
|
||||
message.channel.send(`Made role ${role.name}`);
|
||||
}).catch(console.error);
|
||||
message.guild
|
||||
.createRole()
|
||||
.then(role => {
|
||||
message.channel.send(`Made role ${role.name}`);
|
||||
})
|
||||
.catch(console.error);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function nameLoop(user) {
|
||||
// user.setUsername(user.username + 'a').then(nameLoop).catch(console.error);
|
||||
// User.setUsername(user.username + 'a').then(nameLoop).catch(console.error);
|
||||
}
|
||||
|
||||
function chanLoop(channel) {
|
||||
channel.setName(channel.name + 'a').then(chanLoop).catch(console.error);
|
||||
channel
|
||||
.setName(`${channel.name}a`)
|
||||
.then(chanLoop)
|
||||
.catch(console.error);
|
||||
}
|
||||
|
||||
client.on('message', msg => {
|
||||
if (msg.content.startsWith('?raw')) {
|
||||
msg.channel.send('```' + msg.content + '```');
|
||||
msg.channel.send(`\`\`\`${msg.content}\`\`\``);
|
||||
}
|
||||
|
||||
if (msg.content.startsWith('#eval') && msg.author.id === '66564597481480192') {
|
||||
try {
|
||||
const com = eval(msg.content.split(" ").slice(1).join(" "));
|
||||
msg.channel.send('```\n' + com + '```');
|
||||
} catch(e) {
|
||||
msg.channel.send('```\n' + e + '```');
|
||||
const com = eval(
|
||||
msg.content
|
||||
.split(' ')
|
||||
.slice(1)
|
||||
.join(' '),
|
||||
);
|
||||
msg.channel.send(`\`\`\`\n${com}\`\`\``);
|
||||
} catch (e) {
|
||||
msg.channel.send(`\`\`\`\n${e}\`\`\``);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const ytdl = require('ytdl-core');
|
||||
|
||||
let disp, con;
|
||||
|
||||
client.on('message', msg => {
|
||||
if (msg.content.startsWith('/play')) {
|
||||
console.log('I am now going to play', msg.content);
|
||||
const chan = msg.content.split(' ').slice(1).join(' ');
|
||||
const s = ytdl(chan, {filter:'audioonly'}, { passes : 3 });
|
||||
const chan = msg.content
|
||||
.split(' ')
|
||||
.slice(1)
|
||||
.join(' ');
|
||||
const s = ytdl(chan, { filter: 'audioonly' }, { passes: 3 });
|
||||
s.on('error', e => console.log(`e w stream 1 ${e}`));
|
||||
con.playStream(s);
|
||||
}
|
||||
if (msg.content.startsWith('/join')) {
|
||||
const chan = msg.content.split(' ').slice(1).join(' ');
|
||||
msg.channel.guild.channels.get(chan).join()
|
||||
const chan = msg.content
|
||||
.split(' ')
|
||||
.slice(1)
|
||||
.join(' ');
|
||||
msg.channel.guild.channels
|
||||
.get(chan)
|
||||
.join()
|
||||
.then(conn => {
|
||||
con = conn;
|
||||
msg.reply('done');
|
||||
const s = ytdl(song, {filter:'audioonly'}, { passes : 3 });
|
||||
const s = ytdl(song, { filter: 'audioonly' }, { passes: 3 });
|
||||
s.on('error', e => console.log(`e w stream 2 ${e}`));
|
||||
disp = conn.playStream(s);
|
||||
conn.player.on('debug', console.log);
|
||||
@@ -198,10 +232,13 @@ client.on('message', m => {
|
||||
reaction.fetchUsers().then(users => {
|
||||
m.channel.send(
|
||||
`The following gave that message ${reaction.emoji}:\n` +
|
||||
`${users.map(u => u.username).map(t => `- ${t}`).join('\n')}`
|
||||
`${users
|
||||
.map(u => u.username)
|
||||
.map(t => `- ${t}`)
|
||||
.join('\n')}`,
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
147
test/sendtest.js
Normal file
147
test/sendtest.js
Normal file
@@ -0,0 +1,147 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const util = require('util');
|
||||
const fetch = require('node-fetch');
|
||||
const { owner, token } = require('./auth.js');
|
||||
const Discord = require('../src');
|
||||
|
||||
const client = new Discord.Client();
|
||||
|
||||
const fill = c => Array(4).fill(c.repeat(1000));
|
||||
const buffer = l => fetch(l).then(res => res.buffer());
|
||||
const read = util.promisify(fs.readFile);
|
||||
const readStream = fs.createReadStream;
|
||||
const wait = util.promisify(setTimeout);
|
||||
|
||||
const linkA = 'https://lolisafe.moe/iiDMtAXA.png';
|
||||
const linkB = 'https://lolisafe.moe/9hSpedPh.png';
|
||||
const fileA = path.join(__dirname, 'blobReach.png');
|
||||
|
||||
const embed = () => new Discord.MessageEmbed();
|
||||
const attach = (attachment, name) => new Discord.MessageAttachment(attachment, name);
|
||||
|
||||
const tests = [
|
||||
m => m.channel.send('x'),
|
||||
m => m.channel.send(['x', 'y']),
|
||||
|
||||
m => m.channel.send('x', { code: true }),
|
||||
m => m.channel.send('1', { code: 'js' }),
|
||||
m => m.channel.send('x', { code: '' }),
|
||||
|
||||
m => m.channel.send(fill('x'), { split: true }),
|
||||
m => m.channel.send(fill('1'), { code: 'js', split: true }),
|
||||
m => m.channel.send(fill('x'), { reply: m.author, code: 'js', split: true }),
|
||||
m => m.channel.send(fill('xyz '), { split: { char: ' ' } }),
|
||||
|
||||
m => m.channel.send('x', { embed: { description: 'a' } }),
|
||||
m => m.channel.send({ embed: { description: 'a' } }),
|
||||
m => m.channel.send({ files: [{ attachment: linkA }] }),
|
||||
m =>
|
||||
m.channel.send({
|
||||
embed: { description: 'a' },
|
||||
files: [{ attachment: linkA, name: 'xyz.png' }],
|
||||
}),
|
||||
|
||||
m => m.channel.send('x', embed().setDescription('a')),
|
||||
m => m.channel.send(embed().setDescription('a')),
|
||||
m => m.channel.send({ embed: embed().setDescription('a') }),
|
||||
m => m.channel.send([embed().setDescription('a'), embed().setDescription('b')]),
|
||||
|
||||
m => m.channel.send('x', attach(linkA)),
|
||||
m => m.channel.send(attach(linkA)),
|
||||
m => m.channel.send({ files: [linkA] }),
|
||||
m => m.channel.send({ files: [attach(linkA)] }),
|
||||
async m => m.channel.send(attach(await buffer(linkA))),
|
||||
async m => m.channel.send({ files: [await buffer(linkA)] }),
|
||||
async m => m.channel.send({ files: [{ attachment: await buffer(linkA) }] }),
|
||||
m => m.channel.send([attach(linkA), attach(linkB)]),
|
||||
|
||||
m => m.channel.send({ embed: { description: 'a' } }).then(m2 => m2.edit('x')),
|
||||
m => m.channel.send(embed().setDescription('a')).then(m2 => m2.edit('x')),
|
||||
m => m.channel.send({ embed: embed().setDescription('a') }).then(m2 => m2.edit('x')),
|
||||
|
||||
m => m.channel.send('x').then(m2 => m2.edit({ embed: { description: 'a' } })),
|
||||
m => m.channel.send('x').then(m2 => m2.edit(embed().setDescription('a'))),
|
||||
m => m.channel.send('x').then(m2 => m2.edit({ embed: embed().setDescription('a') })),
|
||||
|
||||
m => m.channel.send({ embed: { description: 'a' } }).then(m2 => m2.edit({ embed: null })),
|
||||
m => m.channel.send(embed().setDescription('a')).then(m2 => m2.edit({ embed: null })),
|
||||
|
||||
m => m.channel.send(['x', 'y'], [embed().setDescription('a'), attach(linkB)]),
|
||||
m => m.channel.send(['x', 'y'], [attach(linkA), attach(linkB)]),
|
||||
|
||||
m => m.channel.send([embed().setDescription('a'), attach(linkB)]),
|
||||
m =>
|
||||
m.channel.send({
|
||||
embed: embed().setImage('attachment://two.png'),
|
||||
files: [attach(linkB, 'two.png')],
|
||||
}),
|
||||
m =>
|
||||
m.channel.send({
|
||||
embed: embed()
|
||||
.setImage('attachment://two.png')
|
||||
.attachFiles([attach(linkB, 'two.png')]),
|
||||
}),
|
||||
async m =>
|
||||
m.channel.send(['x', 'y', 'z'], {
|
||||
code: 'js',
|
||||
embed: embed()
|
||||
.setImage('attachment://two.png')
|
||||
.attachFiles([attach(linkB, 'two.png')]),
|
||||
files: [{ attachment: await buffer(linkA) }],
|
||||
}),
|
||||
|
||||
m => m.channel.send('x', attach(fileA)),
|
||||
m => m.channel.send({ files: [fileA] }),
|
||||
m => m.channel.send(attach(fileA)),
|
||||
async m => m.channel.send({ files: [await read(fileA)] }),
|
||||
async m =>
|
||||
m.channel.send(fill('x'), {
|
||||
reply: m.author,
|
||||
code: 'js',
|
||||
split: true,
|
||||
embed: embed().setImage('attachment://zero.png'),
|
||||
files: [attach(await buffer(linkA), 'zero.png')],
|
||||
}),
|
||||
|
||||
m => m.channel.send('x', attach(readStream(fileA))),
|
||||
m => m.channel.send({ files: [readStream(fileA)] }),
|
||||
m => m.channel.send({ files: [{ attachment: readStream(fileA) }] }),
|
||||
async m =>
|
||||
m.channel.send(fill('xyz '), {
|
||||
reply: m.author,
|
||||
code: 'js',
|
||||
split: { char: ' ', prepend: 'hello! ', append: '!!!' },
|
||||
embed: embed().setImage('attachment://zero.png'),
|
||||
files: [linkB, attach(await buffer(linkA), 'zero.png'), readStream(fileA)],
|
||||
}),
|
||||
|
||||
m => m.channel.send('Done!'),
|
||||
];
|
||||
|
||||
client.on('message', async message => {
|
||||
if (message.author.id !== owner) return;
|
||||
const match = message.content.match(/^do (.+)$/);
|
||||
if (match && match[1] === 'it') {
|
||||
/* eslint-disable no-await-in-loop */
|
||||
for (const [i, test] of tests.entries()) {
|
||||
await message.channel.send(`**#${i}**\n\`\`\`js\n${test.toString()}\`\`\``);
|
||||
await test(message).catch(e => message.channel.send(`Error!\n\`\`\`\n${e}\`\`\``));
|
||||
await wait(1000);
|
||||
}
|
||||
/* eslint-enable no-await-in-loop */
|
||||
} else if (match) {
|
||||
const n = parseInt(match[1]) || 0;
|
||||
const test = tests.slice(n)[0];
|
||||
const i = tests.indexOf(test);
|
||||
await message.channel.send(`**#${i}**\n\`\`\`js\n${test.toString()}\`\`\``);
|
||||
await test(message).catch(e => message.channel.send(`Error!\n\`\`\`\n${e}\`\`\``));
|
||||
}
|
||||
});
|
||||
|
||||
client.login(token);
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
process.on('unhandledRejection', console.error);
|
||||
@@ -1,18 +1,25 @@
|
||||
const Discord = require('../');
|
||||
'use strict';
|
||||
|
||||
const { token } = require('./auth.json');
|
||||
const Discord = require('../');
|
||||
|
||||
const client = new Discord.Client({
|
||||
shardId: process.argv[2],
|
||||
shardID: process.argv[2],
|
||||
shardCount: process.argv[3],
|
||||
});
|
||||
|
||||
client.on('message', msg => {
|
||||
if (msg.content.startsWith('?eval') && msg.author.id === '66564597481480192') {
|
||||
try {
|
||||
const com = eval(msg.content.split(' ').slice(1).join(' '));
|
||||
msg.channel.sendMessage('```\n' + com + '```');
|
||||
const com = eval(
|
||||
msg.content
|
||||
.split(' ')
|
||||
.slice(1)
|
||||
.join(' '),
|
||||
);
|
||||
msg.channel.send(com, { code: true });
|
||||
} catch (e) {
|
||||
msg.channel.sendMessage('```\n' + e + '```');
|
||||
msg.channel.send(e, { code: true });
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -20,12 +27,13 @@ client.on('message', msg => {
|
||||
process.send(123);
|
||||
|
||||
client.on('ready', () => {
|
||||
console.log('Ready', client.options.shardId);
|
||||
if (client.options.shardId === 0)
|
||||
console.log('Ready', client.options.shardID);
|
||||
if (client.options.shardID === 0) {
|
||||
setTimeout(() => {
|
||||
console.log('kek dying');
|
||||
client.destroy();
|
||||
}, 5000);
|
||||
}
|
||||
});
|
||||
|
||||
client.login(token).catch(console.error);
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
const { token } = require('./auth');
|
||||
const Discord = require('../');
|
||||
|
||||
const sharder = new Discord.ShardingManager(`${process.cwd()}/test/shard.js`, 4, false);
|
||||
const sharder = new Discord.ShardingManager(`${process.cwd()}/test/shard.js`, { token, respawn: false });
|
||||
|
||||
sharder.on('launch', shard => console.log(`launched ${shard.id}`));
|
||||
|
||||
sharder.spawn(4);
|
||||
sharder.spawn();
|
||||
|
||||
56
test/tester1000.js
Normal file
56
test/tester1000.js
Normal file
@@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
|
||||
const { token, prefix, owner } = require('./auth.js');
|
||||
const Discord = require('../src');
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
const log = (...args) => console.log(process.uptime().toFixed(3), ...args);
|
||||
|
||||
const client = new Discord.Client({
|
||||
shardCount: 2,
|
||||
});
|
||||
|
||||
client.on('debug', log);
|
||||
client.on('ready', () => {
|
||||
log('READY', client.user.tag, client.user.id);
|
||||
});
|
||||
client.on('rateLimit', log);
|
||||
client.on('error', console.error);
|
||||
|
||||
const commands = {
|
||||
eval: message => {
|
||||
if (message.author.id !== owner) return;
|
||||
let res;
|
||||
try {
|
||||
res = eval(message.content);
|
||||
if (typeof res !== 'string') res = require('util').inspect(res);
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err.stack);
|
||||
res = err.message;
|
||||
}
|
||||
message.channel.send(res, { code: 'js' });
|
||||
},
|
||||
ping: message => message.reply('pong'),
|
||||
};
|
||||
|
||||
client.on('message', message => {
|
||||
if (!message.content.startsWith(prefix) || message.author.bot) return;
|
||||
|
||||
message.content = message.content
|
||||
.replace(prefix, '')
|
||||
.trim()
|
||||
.split(' ');
|
||||
const command = message.content.shift();
|
||||
message.content = message.content.join(' ');
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('COMMAND', command, message.content);
|
||||
|
||||
if (command in commands) commands[command](message);
|
||||
});
|
||||
|
||||
client.login(token);
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
process.on('unhandledRejection', console.error);
|
||||
@@ -1,78 +1,66 @@
|
||||
/* eslint no-console: 0 */
|
||||
'use strict';
|
||||
|
||||
const Discord = require('../');
|
||||
const ytdl = require('ytdl-core');
|
||||
const auth = require('./auth.js');
|
||||
const Discord = require('../');
|
||||
|
||||
const client = new Discord.Client({ fetchAllMembers: false, apiRequestMethod: 'sequential' });
|
||||
const client = new Discord.Client({ fetchAllMembers: false, partials: [], apiRequestMethod: 'sequential' });
|
||||
|
||||
const auth = require('./auth.json');
|
||||
|
||||
client.login(auth.token).then(() => console.log('logged')).catch(console.error);
|
||||
client
|
||||
.login(auth.token)
|
||||
.then(() => console.log('logged'))
|
||||
.catch(console.error);
|
||||
|
||||
const connections = new Map();
|
||||
|
||||
let broadcast;
|
||||
client.on('debug', console.log);
|
||||
client.on('error', console.log);
|
||||
|
||||
process.on('unhandledRejection', console.log);
|
||||
|
||||
client.on('presenceUpdate', (a, b) => {
|
||||
if (b.userID !== '66564597481480192') return;
|
||||
console.log(a ? a.status : null, b.status, b.user.username);
|
||||
});
|
||||
|
||||
client.on('messageDelete', async m => {
|
||||
if (m.channel.id !== '80426989059575808') return;
|
||||
console.log(m.channel.recipient);
|
||||
console.log(m.channel.partial);
|
||||
await m.channel.fetch();
|
||||
console.log('\n\n\n\n');
|
||||
console.log(m.channel);
|
||||
});
|
||||
|
||||
client.on('message', m => {
|
||||
if (!m.guild) return;
|
||||
if (m.author.id !== '66564597481480192') return;
|
||||
if (m.content.startsWith('/join')) {
|
||||
const channel = m.guild.channels.get(m.content.split(' ')[1]) || m.member.voiceChannel;
|
||||
const channel = m.guild.channels.get(m.content.split(' ')[1]) || m.member.voice.channel;
|
||||
if (channel && channel.type === 'voice') {
|
||||
channel.join().then(conn => {
|
||||
conn.receiver.createStream(m.author, true).on('data', b => console.log(b.toString()));
|
||||
conn.player.on('error', (...e) => console.log('player', ...e));
|
||||
if (!connections.has(m.guild.id)) connections.set(m.guild.id, { conn, queue: [] });
|
||||
m.reply('ok!');
|
||||
conn.play(ytdl('https://www.youtube.com/watch?v=_XXOSf0s2nk', { filter: 'audioonly' }, { passes: 3 }));
|
||||
});
|
||||
} else {
|
||||
m.reply('Specify a voice channel!');
|
||||
}
|
||||
} else if (m.content.startsWith('/play')) {
|
||||
if (connections.has(m.guild.id)) {
|
||||
const connData = connections.get(m.guild.id);
|
||||
const queue = connData.queue;
|
||||
const url = m.content.split(' ').slice(1).join(' ')
|
||||
.replace(/</g, '')
|
||||
.replace(/>/g, '');
|
||||
queue.push({ url, m });
|
||||
if (queue.length > 1) {
|
||||
m.reply(`OK, that's going to play after ${queue.length - 1} songs`);
|
||||
return;
|
||||
}
|
||||
doQueue(connData);
|
||||
}
|
||||
} else if (m.content.startsWith('/skip')) {
|
||||
if (connections.has(m.guild.id)) {
|
||||
const connData = connections.get(m.guild.id);
|
||||
if (connData.dispatcher) {
|
||||
connData.dispatcher.end();
|
||||
}
|
||||
}
|
||||
} else if (m.content.startsWith('#eval') && m.author.id === '66564597481480192') {
|
||||
try {
|
||||
const com = eval(m.content.split(' ').slice(1).join(' '));
|
||||
m.channel.sendMessage(`\`\`\`\n${com}\`\`\``);
|
||||
const com = eval(
|
||||
m.content
|
||||
.split(' ')
|
||||
.slice(1)
|
||||
.join(' '),
|
||||
);
|
||||
m.channel.send(com, { code: true });
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
m.channel.sendMessage(`\`\`\`\n${e}\`\`\``);
|
||||
m.channel.send(e, { code: true });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function doQueue(connData) {
|
||||
const conn = connData.conn;
|
||||
const queue = connData.queue;
|
||||
const item = queue[0];
|
||||
if (!item) return;
|
||||
const stream = ytdl(item.url, { filter: 'audioonly' }, { passes: 3 });
|
||||
const dispatcher = conn.playStream(stream);
|
||||
stream.on('info', info => {
|
||||
item.m.reply(`OK, playing **${info.title}**`);
|
||||
});
|
||||
dispatcher.on('end', () => {
|
||||
queue.shift();
|
||||
doQueue(connData);
|
||||
});
|
||||
dispatcher.on('error', (...e) => console.log('dispatcher', ...e));
|
||||
connData.dispatcher = dispatcher;
|
||||
}
|
||||
|
||||
152
test/webhooktest.js
Normal file
152
test/webhooktest.js
Normal file
@@ -0,0 +1,152 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const util = require('util');
|
||||
const fetch = require('node-fetch');
|
||||
const { owner, token, webhookChannel, webhookToken } = require('./auth.js');
|
||||
const Discord = require('../src');
|
||||
|
||||
const client = new Discord.Client();
|
||||
|
||||
const fill = c => Array(4).fill(c.repeat(1000));
|
||||
const buffer = l => fetch(l).then(res => res.buffer());
|
||||
const read = util.promisify(fs.readFile);
|
||||
const readStream = fs.createReadStream;
|
||||
const wait = util.promisify(setTimeout);
|
||||
|
||||
const linkA = 'https://lolisafe.moe/iiDMtAXA.png';
|
||||
const linkB = 'https://lolisafe.moe/9hSpedPh.png';
|
||||
const fileA = path.join(__dirname, 'blobReach.png');
|
||||
|
||||
const embed = () => new Discord.MessageEmbed();
|
||||
const attach = (attachment, name) => new Discord.MessageAttachment(attachment, name);
|
||||
|
||||
const tests = [
|
||||
(m, hook) => hook.send('x'),
|
||||
(m, hook) => hook.send(['x', 'y']),
|
||||
|
||||
(m, hook) => hook.send('x', { code: true }),
|
||||
(m, hook) => hook.send('1', { code: 'js' }),
|
||||
(m, hook) => hook.send('x', { code: '' }),
|
||||
|
||||
(m, hook) => hook.send(fill('x'), { split: true }),
|
||||
(m, hook) => hook.send(fill('1'), { code: 'js', split: true }),
|
||||
(m, hook) => hook.send(fill('x'), { reply: m.author, code: 'js', split: true }),
|
||||
(m, hook) => hook.send(fill('xyz '), { split: { char: ' ' } }),
|
||||
|
||||
(m, hook) => hook.send({ embeds: [{ description: 'a' }] }),
|
||||
(m, hook) => hook.send({ files: [{ attachment: linkA }] }),
|
||||
(m, hook) =>
|
||||
hook.send({
|
||||
embeds: [{ description: 'a' }],
|
||||
files: [{ attachment: linkA, name: 'xyz.png' }],
|
||||
}),
|
||||
|
||||
(m, hook) => hook.send('x', embed().setDescription('a')),
|
||||
(m, hook) => hook.send(embed().setDescription('a')),
|
||||
(m, hook) => hook.send({ embeds: [embed().setDescription('a')] }),
|
||||
(m, hook) => hook.send([embed().setDescription('a'), embed().setDescription('b')]),
|
||||
|
||||
(m, hook) => hook.send('x', attach(linkA)),
|
||||
(m, hook) => hook.send(attach(linkA)),
|
||||
(m, hook) => hook.send({ files: [linkA] }),
|
||||
(m, hook) => hook.send({ files: [attach(linkA)] }),
|
||||
async (m, hook) => hook.send(attach(await buffer(linkA))),
|
||||
async (m, hook) => hook.send({ files: [await buffer(linkA)] }),
|
||||
async (m, hook) => hook.send({ files: [{ attachment: await buffer(linkA) }] }),
|
||||
(m, hook) => hook.send([attach(linkA), attach(linkB)]),
|
||||
|
||||
(m, hook) => hook.send(embed().setDescription('a')),
|
||||
|
||||
(m, hook) => hook.send({ embeds: [{ description: 'a' }] }),
|
||||
(m, hook) => hook.send(embed().setDescription('a')),
|
||||
|
||||
(m, hook) => hook.send(['x', 'y'], [embed().setDescription('a'), attach(linkB)]),
|
||||
(m, hook) => hook.send(['x', 'y'], [attach(linkA), attach(linkB)]),
|
||||
|
||||
(m, hook) => hook.send([embed().setDescription('a'), attach(linkB)]),
|
||||
(m, hook) =>
|
||||
hook.send({
|
||||
embeds: [embed().setImage('attachment://two.png')],
|
||||
files: [attach(linkB, 'two.png')],
|
||||
}),
|
||||
(m, hook) =>
|
||||
hook.send({
|
||||
embeds: [
|
||||
embed()
|
||||
.setImage('attachment://two.png')
|
||||
.attachFiles([attach(linkB, 'two.png')]),
|
||||
],
|
||||
}),
|
||||
async (m, hook) =>
|
||||
hook.send(['x', 'y', 'z'], {
|
||||
code: 'js',
|
||||
embeds: [
|
||||
embed()
|
||||
.setImage('attachment://two.png')
|
||||
.attachFiles([attach(linkB, 'two.png')]),
|
||||
],
|
||||
files: [{ attachment: await buffer(linkA) }],
|
||||
}),
|
||||
|
||||
(m, hook) => hook.send('x', attach(fileA)),
|
||||
(m, hook) => hook.send({ files: [fileA] }),
|
||||
(m, hook) => hook.send(attach(fileA)),
|
||||
async (m, hook) => hook.send({ files: [await read(fileA)] }),
|
||||
async (m, hook) =>
|
||||
hook.send(fill('x'), {
|
||||
reply: m.author,
|
||||
code: 'js',
|
||||
split: true,
|
||||
embeds: [embed().setImage('attachment://zero.png')],
|
||||
files: [attach(await buffer(linkA), 'zero.png')],
|
||||
}),
|
||||
|
||||
(m, hook) => hook.send('x', attach(readStream(fileA))),
|
||||
(m, hook) => hook.send({ files: [readStream(fileA)] }),
|
||||
(m, hook) => hook.send({ files: [{ attachment: readStream(fileA) }] }),
|
||||
async (m, hook) =>
|
||||
hook.send(fill('xyz '), {
|
||||
reply: m.author,
|
||||
code: 'js',
|
||||
split: { char: ' ', prepend: 'hello! ', append: '!!!' },
|
||||
embeds: [embed().setImage('attachment://zero.png')],
|
||||
files: [linkB, attach(await buffer(linkA), 'zero.png'), readStream(fileA)],
|
||||
}),
|
||||
|
||||
(m, hook) => hook.send('Done!'),
|
||||
];
|
||||
|
||||
client.on('message', async message => {
|
||||
if (message.author.id !== owner) return;
|
||||
const match = message.content.match(/^do (.+)$/);
|
||||
const hooks = [
|
||||
{ type: 'WebhookClient', hook: new Discord.WebhookClient(webhookChannel, webhookToken) },
|
||||
{ type: 'TextChannel#fetchWebhooks', hook: await message.channel.fetchWebhooks().then(x => x.first()) },
|
||||
{ type: 'Guild#fetchWebhooks', hook: await message.guild.fetchWebhooks().then(x => x.first()) },
|
||||
];
|
||||
if (match && match[1] === 'it') {
|
||||
/* eslint-disable no-await-in-loop */
|
||||
for (const { type, hook } of hooks) {
|
||||
for (const [i, test] of tests.entries()) {
|
||||
await message.channel.send(`**#${i}-Hook: ${type}**\n\`\`\`js\n${test.toString()}\`\`\``);
|
||||
await test(message, hook).catch(e => message.channel.send(`Error!\n\`\`\`\n${e}\`\`\``));
|
||||
await wait(1000);
|
||||
}
|
||||
}
|
||||
/* eslint-enable no-await-in-loop */
|
||||
} else if (match) {
|
||||
const n = parseInt(match[1]) || 0;
|
||||
const test = tests.slice(n)[0];
|
||||
const i = tests.indexOf(test);
|
||||
/* eslint-disable no-await-in-loop */
|
||||
for (const { type, hook } of hooks) {
|
||||
await message.channel.send(`**#${i}-Hook: ${type}**\n\`\`\`js\n${test.toString()}\`\`\``);
|
||||
await test(message, hook).catch(e => message.channel.send(`Error!\n\`\`\`\n${e}\`\`\``));
|
||||
}
|
||||
/* eslint-enable no-await-in-loop */
|
||||
}
|
||||
});
|
||||
|
||||
client.login(token);
|
||||
@@ -1,31 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>discord.js Webpack test</title>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript" src="../webpack/discord.11.4.2.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
(() => {
|
||||
const client = window.client = new Discord.Client();
|
||||
<head>
|
||||
<title>discord.js Webpack test</title>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript" src="../webpack/discord.js"></script>
|
||||
<script type="text/javascript">
|
||||
(() => {
|
||||
const client = (window.client = new Discord.Client());
|
||||
|
||||
client.on('ready', () => {
|
||||
console.log('[CLIENT] Ready!');
|
||||
});
|
||||
client.on('ready', () => {
|
||||
console.log('[CLIENT] Ready!');
|
||||
});
|
||||
|
||||
client.on('error', console.error);
|
||||
client.on('debug', console.log);
|
||||
|
||||
client.ws.on('close', (event) => console.log('[CLIENT] Disconnect!', event));
|
||||
client.on('error', console.error);
|
||||
|
||||
client.on('message', (message) => {
|
||||
console.log(message.author.username, message.author.id, message.content);
|
||||
console.log(message.guild.roles.find("name", "Sever Staff"));
|
||||
});
|
||||
client.ws.on('close', event => console.log('[CLIENT] Disconnect!', event));
|
||||
|
||||
client.login(localStorage.token || window.token || prompt('token pls', 'abcdef123456'))
|
||||
.then((token) => localStorage.token = token);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
client.on('message', message => {
|
||||
console.log(message.author.username, message.author.id, message.content);
|
||||
});
|
||||
|
||||
client
|
||||
.login(localStorage.token || window.token || prompt('token pls', 'abcdef123456'))
|
||||
.then(token => (localStorage.token = token), console.log);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user