Skocz do zawartoś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

Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto

Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.

Zarejestruj nowe konto

Załóż nowe konto. To bardzo proste!

Zarejestruj się

Zaloguj się

Zaloguj się poniżej.

Zaloguj się
×
×
  • Dodaj nową pozycję...