const Discord = require('discord.js');
const client = new Discord.Client();
const env = require('./env.json');
const store = new Map();
const commands = new Map([
['reply', message => {
if (store.has(message.channel.guild.id)) {
const guild = store.get(message.channel.guild.id);
if (guild.has(message.channel.id)) {
const channel = guild.get(message.channel.id);
message.delete();
if (channel.has(message.author.id)) {
message.channel.send(`${message.author.username}: ${channel.get(message.author.id)}`);
}
}
}
}]
]);
const prefix = '!';
client.on('ready', () => {
console.log(`Бот ${client.user.tag} запущен`);
});
client.on('message', message => {
if (message.content.startsWith(prefix)) {
const command = message.content.slice(prefix.length);
if (commands.has(command)) {
commands.get(command)(message);
}
} else {
const guild = store.has(message.channel.guild.id)
? store.get(message.channel.guild.id)
: new Map();
const channel = guild.has(message.channel.id)
? guild.get(message.channel.id)
: new Map();
channel.set(message.author.id, message.content);
guild.set(message.channel.id, channel);
store.set(message.channel.guild.id, guild);
}
});
client.login(env.token);
const links = document.querySelectorAll('a');
for (let link of links) {
link.addEventListener('click', () => {
const target = document.querySelector(link.getAttribute('href'));
target.scrollIntoView({
behavior: 'smooth'
});
});
}
App.vue
там у #app
text-align: center;
стоит.App.vue
methods
поставили в data
, а надо рядом расположить. export default {
...,
data: function () { ... },
methods: { ... }
}
class Some {
constructor() {
this.data = null;
Promise.all([this.init()]).then(() => {
this.start();
});
}
start() {
console.log('START', this.data);
}
async init() {
const response = await fetch('https://jsonplaceholder.typicode.com/todos');
this.data = await response.json();
}
}
new Some();
loginig
у Вас ничего не принимает от сервера, как Вы хотите узнать о завершении операции? const loadScript = (url, callback) => {
const script = document.createElement('script');
script.addEventListener('load', () => {
callback();
});
script.src = url;
document.body.append(script);
};
loadScript('SOME_URL', () => {
console.log('Скрипт загружен');
});
const loadScript = url => new Promise(resolve => {
const script = document.createElement('script');
script.addEventListener('load', () => {
resolve();
});
script.src = url;
document.body.append(script);
});
loadScript('SOME_URL').then(() => {
console.log('Скрипт загружен');
});