Skocz do zawartości

Dołącz do społeczności!

👋 Witaj na MPCForum!

Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

  • ✅ Pełny dostęp do działów i ukrytych treści
  • ✅ Możliwość pisania i odpowiadania w tematach
  • ✅ System prywatnych wiadomości
  • ✅ Zbieranie reputacji i rozwijanie swojego profilu
  • ✅ Członkostwo w jednej z największych społeczności graczy

👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

Zarejestruj się teraz

bot na discord nie odpowiada

Rekomendowane odpowiedzi

Opublikowano

index.js

 

const Discord = require('discord.js');

const fs = require('fs');

 

const client = new Discord.Client({

    intents: [

        Discord.Intents.FLAGS.GUILDS,

        Discord.Intents.FLAGS.GUILD_MEMBERS

    ]

});

 

client.commands = new Discord.Collection();

 

const commandFolders = fs.readdirSync('./commands');

 

for (const folder of commandFolders) {

    const commandFiles = fs.readdirSync(`./commands/${folder}`).filter(file => file.endsWith('.js'));

 

    for(const file of commandFiles) {

        const command = require(`./commands/${folder}/${file}`);

        client.commands.set(command.name, command);

    }

}

 

const prefix = '!';

 

client.once('ready', () =>

{

    console.log('Bot jest aktywny!');

 

    client.user.setActivity('Young Leosie', {type:'LISTENING'})

});

 

client.on('messageCreate', async message =>

{

    if(!message.content.startWich(prefix) || message.author.bot) return;

 

    const args = message.content.slice(prefix.length).trim().split(/ +/);

    const commandName = args.shift().toLowerCase();

 

    if(!client.commands.has(commandName)) return;

 

    const command = client.commands.get(commandName);

 

    try {

        command.execute(message, args);

    } catch (error) {

        console.error(error);

        message.reply('ta komenda nie działa');

    }

 

przykładowa komenda

 

const Discord = require('discord.js');

 

module.exports = {

    name: 'embed',

    description: 'Wysyła embed na kanał',

    usage: '!embed',

    execute: async(message, args) => {

        const embed = new Discord.MessageEmbed()

        .setcolor('#2f3136')

        .serTitle('Tytuł embed')

        .setDescription('test')

 

        message.channel.send({ embeds: [embed] });

 

    }

}

 

wersja discord.js 12.5.3

 

 

Teraz, Advez_ napisał:

index.js

 

const Discord = require('discord.js');

const fs = require('fs');

 

const client = new Discord.Client({

    intents: [

        Discord.Intents.FLAGS.GUILDS,

        Discord.Intents.FLAGS.GUILD_MEMBERS

    ]

});

 

client.commands = new Discord.Collection();

 

const commandFolders = fs.readdirSync('./commands');

 

for (const folder of commandFolders) {

    const commandFiles = fs.readdirSync(`./commands/${folder}`).filter(file => file.endsWith('.js'));

 

    for(const file of commandFiles) {

        const command = require(`./commands/${folder}/${file}`);

        client.commands.set(command.name, command);

    }

}

 

const prefix = '!';

 

client.once('ready', () =>

{

    console.log('Bot jest aktywny!');

 

    client.user.setActivity('Young Leosie', {type:'LISTENING'})

});

 

client.on('messageCreate', async message =>

{

    if(!message.content.startWich(prefix) || message.author.bot) return;

 

    const args = message.content.slice(prefix.length).trim().split(/ +/);

    const commandName = args.shift().toLowerCase();

 

    if(!client.commands.has(commandName)) return;

 

    const command = client.commands.get(commandName);

 

    try {

        command.execute(message, args);

    } catch (error) {

        console.error(error);

        message.reply('ta komenda nie działa');

    }

 

przykładowa komenda

 

const Discord = require('discord.js');

 

module.exports = {

    name: 'embed',

    description: 'Wysyła embed na kanał',

    usage: '!embed',

    execute: async(message, args) => {

        const embed = new Discord.MessageEmbed()

        .setcolor('#2f3136')

        .serTitle('Tytuł embed')

        .setDescription('test')

 

        message.channel.send({ embeds: [embed] });

 

    }

}

 

wersja discord.js 12.5.3

 

 

w terminalu nie pokazuje żadnego błędu 

  • 2 tygodnie później...
Opublikowano

napewno bot jest online i pokazuje status?

1 minutę temu, nkcf napisał:

napewno bot jest online i pokazuje status?

+ mozesz uzyc oficjalnej dokumentacji Discord.js oraz uzyj najnowszej wersji discord.js

Ostatnio przeglądający 0

  • Brak zarejestrowanych użytkowników przeglądających tę stronę.

Konto

Nawigacja

Skonfiguruj powiadomienia push w przeglądarce

Chrome (Android)
  1. Stuknij ikonę kłódki obok paska adresu.
  2. Stuknij Uprawnienia → Powiadomienia.
  3. Dostosuj swoje ustawienie.
Chrome (Komputer)
  1. Kliknij ikonę kłódki na pasku adresu.
  2. Wybierz Ustawienia witryny.
  3. Znajdź Powiadomienia i dostosuj swoje ustawienie.