refactor: rename events to be consistent with WS names (#6010)

Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
Antonio Román
2021-07-03 14:23:53 +02:00
committed by GitHub
parent 7dd1a8da08
commit a11a10525b
13 changed files with 50 additions and 83 deletions

View File

@@ -42,7 +42,7 @@ client.on('debug', console.log);
client.on('error', m => console.log('debug', new Error(m).stack));
client.on('reconnecting', m => console.log('reconnecting', m));
client.on('message', message => {
client.on('messageCreate', message => {
if (true) {
if (message.content === 'makechann') {
if (message.channel.guild) {
@@ -178,7 +178,7 @@ function chanLoop(channel) {
.catch(console.error);
}
client.on('message', msg => {
client.on('messageCreate', msg => {
if (msg.content.startsWith('?raw')) {
msg.channel.send(`\`\`\`${msg.content}\`\`\``);
}
@@ -200,7 +200,7 @@ client.on('message', msg => {
let disp, con;
client.on('message', msg => {
client.on('messageCreate', msg => {
if (msg.content.startsWith('/play')) {
console.log('I am now going to play', msg.content);
const chan = msg.content
@@ -243,7 +243,7 @@ client.on('messageReactionRemove', (reaction, user) => {
reaction.message.channel.send(`${user.username} removed reaction ${reaction.emoji}, count is now ${reaction.count}`);
});
client.on('message', m => {
client.on('messageCreate', m => {
if (m.content.startsWith('#reactions')) {
const mID = m.content.split(' ')[1];
m.channel.messages.fetch(mID).then(rM => {

View File

@@ -89,7 +89,7 @@ const tests = [
m => m.channel.send('Done!'),
];
client.on('message', async message => {
client.on('messageCreate', async message => {
if (message.author.id !== owner) return;
const match = message.content.match(/^do (.+)$/);
if (match && match[1] === 'it') {

View File

@@ -7,10 +7,9 @@ const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
shards: process.argv[2],
shardCount: process.argv[3],
intents: Discord.Intents.NON_PRIVILEGED,
});
client.on('message', msg => {
client.on('messageCreate', msg => {
if (msg.content.startsWith('?eval') && msg.author.id === '66564597481480192') {
try {
const com = eval(msg.content.split(' ').slice(1).join(' '));

View File

@@ -6,7 +6,7 @@ const { Client } = require('../src');
const client = new Client({ intents: ['GUILDS', 'GUILD_MESSAGES'] });
client
.on('ready', () => console.log('ready'))
.on('message', async message => {
.on('messageCreate', async message => {
try {
const templates = await message.guild.fetchTemplates();
if (!templates.size) {

View File

@@ -9,7 +9,6 @@ const log = (...args) => console.log(process.uptime().toFixed(3), ...args);
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
shardCount: 2,
intents: Discord.Intents.NON_PRIVILEGED,
});
client.on('debug', log);
@@ -36,7 +35,7 @@ const commands = {
ping: message => message.channel.send('pong'),
};
client.on('message', message => {
client.on('messageCreate', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
message.content = message.content.replace(prefix, '').trim().split(' ');

View File

@@ -1,64 +0,0 @@
/* eslint no-console: 0 */
'use strict';
const ytdl = require('ytdl-core');
const auth = require('./auth.js');
const { Client, Intents } = require('../src');
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_PRESENCES],
partials: [],
});
client
.login(auth.token)
.then(() => console.log('logged'))
.catch(console.error);
const connections = new Map();
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.cache.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.channel.send('ok!');
conn.play(ytdl('https://www.youtube.com/watch?v=_XXOSf0s2nk', { filter: 'audioonly' }, { passes: 3 }));
});
} else {
m.channel.send('Specify a voice channel!');
}
} else if (m.content.startsWith('#eval') && m.author.id === '66564597481480192') {
try {
const com = eval(m.content.split(' ').slice(1).join(' '));
m.channel.send(com, { code: true });
} catch (e) {
console.log(e);
m.channel.send(String(e), { code: true });
}
}
});

View File

@@ -93,7 +93,7 @@ const tests = [
(m, hook) => hook.send('Done!'),
];
client.on('message', async message => {
client.on('messageCreate', async message => {
if (message.author.id !== owner) return;
const match = message.content.match(/^do (.+)$/);
const hooks = [