SyntaxError: missing ) after argument list hatası

Poykisol61

Hectopat
Katılım
1 Mayıs 2021
Mesajlar
145
Makaleler
2
Çözümler
1
Daha fazla  
Cinsiyet
Erkek
Merhaba, eski altyapıyla bot yapıyorum discord.js.org ile ben bu hatayı alıyorum, çözümü nedir?
Kodlar:
[CODE title="Bot.js"]const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Botun ${client.user.tag} aktifleştirildi!`);
});

client.on('message', msg => {
if (msg.content.toLowerCase() === 'sa') {
msg.reply('Aleykümselam kanka, naber?');
}


if (msg.content.toLowerCase() === 'merhaba') {
msg.reply('Hoşgeldin :)');
}


if (msg.content.toLowerCase() === 'napim') {
msg.channel.send('Terbiyemizi bozma lan!');
}


if (msg.content.toLowerCase() === 'ch!yardım') {
msg.channel.send('Chatter Bot sohbet amacıyla kuruldu ama yinede bazı komutları var :)')

msg.channel.send('Prefix=ch!')

msg.channel.send('`kodlamadili`=Botun yazıldığı dili görürsünüz')

msg.channel.send('`web`= web sitemizi görürsünüz')

msg.channel.send('`kurucu`= kurucuyu görürsünüz')

msg.channel.send('`token`= tokeni alırsınız :D')

msg.channel.send('nsfw:flushed: =bahsetmek istemiyorum 0_0')

msg.channel.send('`davet`= botu sunucunuza davet edersiniz')

msg.channel.send('`desteksunucusu`= destek sunucumuza katılırsınız')

msg.channel.send('`altyapı`= altyapıyı görürsünüz')

msg.channel.send('`errorfix`=Js dilindeki bazı hataların çözümlerini görürsünüz. (BAKIMDA) ')
}
if (msg.content.toLowerCase() === 'ch!kurucu') {
msg.channel.send('İşte Chatter Bot kurucusu= `! Poykisol61#8584` ');
}
if (msg.content.toLowerCase() === 'ch!kodlamadili') {
msg.channel.send('***JavaScript (JS)*** ile yazıldım. Altyapım=https://discord.js.org ');
}


if (msg.content.toLowerCase() === 'ch!desteksunucusu') {
msg.channel.send('Destek sunucumuza katılmayıı unutmayın ! https://discord.gg/WdZzgRs9nM');
}


if (msg.content.toLowerCase() === 'ch!arkadaşbotlar') {
msg.channel.send('ch!Xaine ch!Frizone');
}


if (msg.content.toLowerCase() === 'ch!xaine') {
msg.channel.send('Bot adı:Xaine * Kurucu:! TREFAX#0362 * Destek Sunucusu: https://discord.gg/s2tJtaCTkg ');
}


if (msg.content.toLowerCase() === 'ch!frizone') {
msg.channel.send('Bot adı:Frizone * Kurucu:Ahmet Samet#8698 * https://discord.gg/9PVFhmJTnV ');
}


if (msg.content.toLowerCase() === 'ch!nsfw') {
msg.channel.send('Terbiyesizlik yapıp nsfw bakma oğlum günah :x:');
}


if (msg.content.toLowerCase() === 'chatter sa') {
msg.channel.send('as bro ');
}


if (msg.content.toLowerCase() === 'chatter') {
msg.channel.send('Merhaba dostum bir sorun mu vardı?');
}


if (msg.content.toLowerCase() === 'chatter *********') { //yıldızlı yerde technopat kurallarına uygun olmayan yazı var
msg.channel.send('Lafını geri al');
}


if (msg.content.toLowerCase() === 'chatter neden') {
msg.channel.send('ne neden? ');
}


if (msg.content.toLowerCase() === 'andı ne lan') {
msg.channel.send('şey mi dostum, yine yangınlar yine ben.');
}


if (msg.content.toLowerCase() === 'chatter bana küfret') {
msg.reply('sen istedin. Ama küfretmicem :D');
}


if (msg.content.toLowerCase() === 'chatter hg') {
msg.reply('Hoşbulduk dostum.');
}


if (msg.content.toLowerCase() === 'chatter naber') {
msg.reply('Napalım işte iyiyiz çok şükür senden naber');
}


if (msg.content.toLowerCase() === 'chatter xaine yi tanıyon mu') {
msg.reply('Evet kendisi çok yakın dostum:heart::v: @Xaine#2841');
}


if (msg.content.toLowerCase() === 'chatter piyango bana çıkar mı') {
msg.reply('E Şans işi ');
}


if (msg.content.toLowerCase() === 'chatter bende iyi') {
msg.reply('Sevindim ');
}
if (msg.content.toLowerCase() === 'chatter frizone yi tanıyon mu') {
msg.reply('Evet kendisi çok yakın arkadaşım :heart::v: @Frizone#4647');
}
if (msg.content.toLowerCase() === '31') {
msg.reply('Evet çok komik :unamused:');
}
if (msg.content.toLowerCase() === 'chatter neden bana küfretmicen') {
msg.reply('Ayıp olur');
}
if (msg.content.toLowerCase() === 'ch!web') {
msg.reply('Chatter Bot Web Sitesi! https://chatterbotweb.glitch.me/');
}
if (msg.content.toLowerCase() === 'chatter nbr') {
msg.reply('iyi sen?');
}
if (msg.content.toLowerCase() === 'chatter malsın') {
msg.reply('saol sende');
}
if (msg.content.toLowerCase() === 'chatter kötü') {
msg.reply('Aga be.');
}
if (msg.content.toLowerCase() === 'chatter iyi') {
msg.reply('Bu arada yapımcımı tanıyor musunuz?');
}
if (msg.content.toLowerCase() === 'chatter ta kendisiyim') {
msg.reply('Ha... Merhaba kurucum ulu ! Poykisol#8584, Bir kahve ister misiniz?');
}
if (msg.content.toLowerCase() === 'kahveyi severim') {
msg.reply('Size bir Türk Kahvesi yapıyorum. Şekerli mi şekersiz mi?');
}
if (msg.content.toLowerCase() === 'şekerli') {
msg.reply('Hazır. Afiyet olsun ulu kurucum.');
}
if (msg.content.toLowerCase() === 'ch!token') {
msg.reply('Kurucum hep bana tokenini kimselere verme derdi.');
}
if (msg.content.toLowerCase() === 'ch!davet') {
msg.reply('Chatter botu sunucuna ekle! https://discord.com/oauth2/authorize?client_id=843423617522073600&scope=bot&permissions=805314622 ');
};
if (msg.content.toLowerCase() === 'ilk') {
msg.reply('<==ilk yazmayınca olur gibi :hot_face:');
};
if (msg.content.toLowerCase() === 'chatter iyi sen') {
msg.reply('Bende iyiyim demiyimde orta halliyim işte.');
};
if (msg.content.toLowerCase() === 'ch!altyapı') {
msg.channel.send('Botun altyapısı! https://discord.js.org');
};
if (msg.content.toLowerCase() === 'chatter dostum')
msg.reply('Efendim kanki:heart:')
}
if (msg.content.toLowerCase() === 'ch!errorfix')
msg.channel.send('HATA :x: Bir hata yaşadınız tekrar deneyin. `hatakodu:komut_bakimda` ')
}
if (msg.content.toLowerCase() === 'ch!errorfix')
msg.channel.send('HATA :x: Bir hata yaşadınız tekrar deneyin. `hatakodu:komut_bakimda` ')
}
});

client.login('Burada token var');[/CODE]
 
Tam hata nedir?

Düzenleme: 23-45. satırlar arası ve bazı aradaki fonksiyonlarda fonksiyon sonları noktaları virgül eksikmiş, ve en altta 180, 183, 186 satırlarda süslü parantez başlangıcı eksik. Düzenlenmiş hali;

Kod:
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
  console.log(`Botun ${client.user.tag} aktifleştirildi!`);
});

client.on('message', msg => {
  if (msg.content.toLowerCase() === 'sa') {
    msg.reply('Aleykümselam kanka, naber?');
  }


if (msg.content.toLowerCase() === 'merhaba') {
    msg.reply('Hoşgeldin :)');
  }


if (msg.content.toLowerCase() === 'napim') {
    msg.channel.send('Terbiyemizi bozma lan!');
}


if (msg.content.toLowerCase() === 'ch!yardım') {
    msg.channel.send('Chatter Bot sohbet amacıyla kuruldu ama yinede bazı komutları var :)');
        
    msg.channel.send('Prefix=ch!');

    msg.channel.send('`kodlamadili`=Botun yazıldığı dili görürsünüz');

    msg.channel.send('`web`= web sitemizi görürsünüz');

    msg.channel.send('`kurucu`= kurucuyu görürsünüz');

    msg.channel.send('`token`= tokeni alırsınız :D');

    msg.channel.send('nsfw:flushed: =bahsetmek istemiyorum 0_0');

    msg.channel.send('`davet`= botu sunucunuza davet edersiniz');

    msg.channel.send('`desteksunucusu`= destek sunucumuza katılırsınız');

    msg.channel.send('`altyapı`= altyapıyı görürsünüz');

    msg.channel.send('`errorfix`=Js dilindeki bazı hataların çözümlerini görürsünüz. (BAKIMDA) ');
}
if (msg.content.toLowerCase() === 'ch!kurucu') {
    msg.channel.send('İşte Chatter Bot kurucusu= `!  Poykisol61#8584` ');
}
if (msg.content.toLowerCase() === 'ch!kodlamadili') {
    msg.channel.send('***JavaScript (JS)*** ile yazıldım. Altyapım=https://discord.js.org  ');
}


if (msg.content.toLowerCase() === 'ch!desteksunucusu') {
    msg.channel.send('Destek sunucumuza katılmayıı unutmayın ! https://discord.gg/WdZzgRs9nM');
}


if (msg.content.toLowerCase() === 'ch!arkadaşbotlar') {
    msg.channel.send('ch!Xaine ch!Frizone');
}


if (msg.content.toLowerCase() === 'ch!xaine') {
    msg.channel.send('Bot adı:Xaine * Kurucu:! TREFAX#0362 * Destek Sunucusu: https://discord.gg/s2tJtaCTkg ');
}


if (msg.content.toLowerCase() === 'ch!frizone') {
    msg.channel.send('Bot adı:Frizone * Kurucu:Ahmet Samet#8698 * https://discord.gg/9PVFhmJTnV ');
}


if (msg.content.toLowerCase() === 'ch!nsfw') {
    msg.channel.send('Terbiyesizlik yapıp nsfw bakma oğlum günah :x:');
}


if (msg.content.toLowerCase() === 'chatter sa') {
    msg.channel.send('as bro ');
}


if (msg.content.toLowerCase() === 'chatter') {
    msg.channel.send('Merhaba dostum bir sorun mu vardı?');
}


if (msg.content.toLowerCase() === 'chatter  *********') {  //yıldızlı yerde technopat kurallarına uygun olmayan yazı var
    msg.channel.send('Lafını geri al');
}


if (msg.content.toLowerCase() === 'chatter neden') {
    msg.channel.send('ne neden? ');
}


if (msg.content.toLowerCase() === 'andı ne lan') {
    msg.channel.send('şey mi dostum, yine yangınlar yine ben.');
}


if (msg.content.toLowerCase() === 'chatter bana küfret') {
msg.reply('sen istedin. Ama küfretmicem :D');
}


if (msg.content.toLowerCase() === 'chatter hg') {
msg.reply('Hoşbulduk dostum.');
}


if (msg.content.toLowerCase() === 'chatter naber') {
msg.reply('Napalım işte iyiyiz çok şükür senden naber');
}


if (msg.content.toLowerCase() === 'chatter xaine yi tanıyon mu') {
msg.reply('Evet kendisi çok yakın dostum:heart::v: @Xaine#2841');
}


if (msg.content.toLowerCase() === 'chatter piyango bana çıkar mı') {
msg.reply('E Şans işi ');
}


if (msg.content.toLowerCase() === 'chatter bende iyi') {
msg.reply('Sevindim  ');
}
if (msg.content.toLowerCase() === 'chatter frizone yi tanıyon mu') {
msg.reply('Evet kendisi çok yakın arkadaşım :heart::v: @Frizone#4647');
}
if (msg.content.toLowerCase() === '31') {
msg.reply('Evet çok komik :unamused:');
}
if (msg.content.toLowerCase() === 'chatter neden bana küfretmicen') {
msg.reply('Ayıp olur');
}
if (msg.content.toLowerCase() === 'ch!web') {
msg.reply('Chatter Bot Web Sitesi! https://chatterbotweb.glitch.me/');
}
if (msg.content.toLowerCase() === 'chatter nbr') {
msg.reply('iyi sen?');
}
if (msg.content.toLowerCase() === 'chatter malsın') {
msg.reply('saol sende');
}
if (msg.content.toLowerCase() === 'chatter kötü') {
msg.reply('Aga be.');
}
if (msg.content.toLowerCase() === 'chatter iyi') {
msg.reply('Bu arada yapımcımı tanıyor musunuz?');
}
if (msg.content.toLowerCase() === 'chatter ta kendisiyim') {
msg.reply('Ha... Merhaba kurucum ulu !  Poykisol#8584, Bir kahve ister misiniz?');
}
if (msg.content.toLowerCase() === 'kahveyi severim') {
msg.reply('Size bir Türk Kahvesi yapıyorum. Şekerli mi şekersiz mi?');
}
if (msg.content.toLowerCase() === 'şekerli') {
msg.reply('Hazır. Afiyet olsun ulu kurucum.');
}
if (msg.content.toLowerCase() === 'ch!token') {
msg.reply('Kurucum hep bana tokenini kimselere verme derdi.');
}
if (msg.content.toLowerCase() === 'ch!davet') {
msg.reply('Chatter botu sunucuna ekle! https://discord.com/oauth2/authorize?client_id=843423617522073600&scope=bot&permissions=805314622 ');
}
if (msg.content.toLowerCase() === 'ilk') {
msg.reply('<==ilk yazmayınca olur gibi :hot_face:');
}
if (msg.content.toLowerCase() === 'chatter iyi sen') {
msg.reply('Bende iyiyim demiyimde orta halliyim işte.');
}
if (msg.content.toLowerCase() === 'ch!altyapı') {
msg.channel.send('Botun altyapısı! https://discord.js.org');
}
  if (msg.content.toLowerCase() === 'chatter dostum') {
    msg.reply('Efendim kanki:heart:');
}
  if (msg.content.toLowerCase() === 'ch!errorfix') {
   msg.channel.send('HATA :x: Bir hata yaşadınız tekrar deneyin. `hatakodu:komut_bakimda` ');
}
  if (msg.content.toLowerCase() === 'ch!errorfix') {
   msg.channel.send('HATA :x: Bir hata yaşadınız tekrar deneyin. `hatakodu:komut_bakimda` ');
}
});

client.login('Burada token var');
 
Son düzenleme:
Yok o en sonda açılmış. Tüm komutlari bir message eventine sığdırmış.
Anladım. Bu kodu asıl yazan kişi sanırım SRP'nin ne olduğundan bi' haber.

Neredeyse tüm kodları tek bir anonymous arrow function'a sığdırmak iyimiş.

JavaScript:
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
  console.log(`Botun ${client.user.tag} aktifleştirildi!`);
});

client.on('message', msg => {
  if (msg.content.toLowerCase() === 'sa') {
    msg.reply('Aleykümselam kanka, naber?');
  }
  if (msg.content.toLowerCase() === 'merhaba') {
    msg.reply('Hoşgeldin :)');
  }
  if (msg.content.toLowerCase() === 'napim') {
    msg.channel.send('Terbiyemizi bozma lan!');
  }
  if (msg.content.toLowerCase() === 'ch!yardım') {
    msg.channel.send('Chatter Bot sohbet amacıyla kuruldu ama yinede bazı komutları var :)')

    msg.channel.send('Prefix=ch!')

    msg.channel.send('`kodlamadili`=Botun yazıldığı dili görürsünüz')

    msg.channel.send('`web`= web sitemizi görürsünüz')

    msg.channel.send('`kurucu`= kurucuyu görürsünüz')

    msg.channel.send('`token`= tokeni alırsınız :D')

    msg.channel.send('nsfw:flushed: =bahsetmek istemiyorum 0_0')

    msg.channel.send('`davet`= botu sunucunuza davet edersiniz')

    msg.channel.send('`desteksunucusu`= destek sunucumuza katılırsınız')

    msg.channel.send('`altyapı`= altyapıyı görürsünüz')

    msg.channel.send('`errorfix`=Js dilindeki bazı hataların çözümlerini görürsünüz. (BAKIMDA) ')
  }
  if (msg.content.toLowerCase() === 'ch!kurucu') {
    msg.channel.send('İşte Chatter Bot kurucusu= `!  Poykisol61#8584` ');
  }
  if (msg.content.toLowerCase() === 'ch!kodlamadili') {
    msg.channel.send('***JavaScript (JS)*** ile yazıldım. Altyapım=https://discord.js.org  ');
  }
  if (msg.content.toLowerCase() === 'ch!desteksunucusu') {
    msg.channel.send('Destek sunucumuza katılmayıı unutmayın ! https://discord.gg/WdZzgRs9nM');
  }
  if (msg.content.toLowerCase() === 'ch!arkadaşbotlar') {
    msg.channel.send('ch!Xaine ch!Frizone');
  }
  if (msg.content.toLowerCase() === 'ch!xaine') {
    msg.channel.send('Bot adı:Xaine * Kurucu:! TREFAX#0362 * Destek Sunucusu: https://discord.gg/s2tJtaCTkg ');
  }
  if (msg.content.toLowerCase() === 'ch!frizone') {
    msg.channel.send('Bot adı:Frizone * Kurucu:Ahmet Samet#8698 * https://discord.gg/9PVFhmJTnV ');
  }
  if (msg.content.toLowerCase() === 'ch!nsfw') {
    msg.channel.send('Terbiyesizlik yapıp nsfw bakma oğlum günah :x:');
  }
  if (msg.content.toLowerCase() === 'chatter sa') {
    msg.channel.send('as bro ');
  }
  if (msg.content.toLowerCase() === 'chatter') {
    msg.channel.send('Merhaba dostum bir sorun mu vardı?');
  }
  if (msg.content.toLowerCase() === 'chatter  *********') {  //yıldızlı yerde technopat kurallarına uygun olmayan yazı var
    msg.channel.send('Lafını geri al');
  }
  if (msg.content.toLowerCase() === 'chatter neden') {
    msg.channel.send('ne neden? ');
  }
  if (msg.content.toLowerCase() === 'andı ne lan') {
    msg.channel.send('şey mi dostum, yine yangınlar yine ben.');
  }
  if (msg.content.toLowerCase() === 'chatter bana küfret') {
    msg.reply('sen istedin. Ama küfretmicem :D');
  }
  if (msg.content.toLowerCase() === 'chatter hg') {
    msg.reply('Hoşbulduk dostum.');
  }
  if (msg.content.toLowerCase() === 'chatter naber') {
    msg.reply('Napalım işte iyiyiz çok şükür senden naber');
  }
  if (msg.content.toLowerCase() === 'chatter xaine yi tanıyon mu') {
    msg.reply('Evet kendisi çok yakın dostum:heart::v: @Xaine#2841');
  }
  if (msg.content.toLowerCase() === 'chatter piyango bana çıkar mı') {
    msg.reply('E Şans işi ');
  }
  if (msg.content.toLowerCase() === 'chatter bende iyi') {
    msg.reply('Sevindim  ');
  }
  if (msg.content.toLowerCase() === 'chatter frizone yi tanıyon mu') {
    msg.reply('Evet kendisi çok yakın arkadaşım :heart::v: @Frizone#4647');
  }
  if (msg.content.toLowerCase() === '31') {
    msg.reply('Evet çok komik :unamused:');
  }
  if (msg.content.toLowerCase() === 'chatter neden bana küfretmicen') {
    msg.reply('Ayıp olur');
  }
  if (msg.content.toLowerCase() === 'ch!web') {
    msg.reply('Chatter Bot Web Sitesi! https://chatterbotweb.glitch.me/');
  }
  if (msg.content.toLowerCase() === 'chatter nbr') {
    msg.reply('iyi sen?');
  }
  if (msg.content.toLowerCase() === 'chatter malsın') {
    msg.reply('saol sende');
  }
  if (msg.content.toLowerCase() === 'chatter kötü') {
    msg.reply('Aga be.');
  }
  if (msg.content.toLowerCase() === 'chatter iyi') {
    msg.reply('Bu arada yapımcımı tanıyor musunuz?');
  }
  if (msg.content.toLowerCase() === 'chatter ta kendisiyim') {
    msg.reply('Ha... Merhaba kurucum ulu !  Poykisol#8584, Bir kahve ister misiniz?');
  }
  if (msg.content.toLowerCase() === 'kahveyi severim') {
    msg.reply('Size bir Türk Kahvesi yapıyorum. Şekerli mi şekersiz mi?');
  }
  if (msg.content.toLowerCase() === 'şekerli') {
    msg.reply('Hazır. Afiyet olsun ulu kurucum.');
  }
  if (msg.content.toLowerCase() === 'ch!token') {
    msg.reply('Kurucum hep bana tokenini kimselere verme derdi.');
  }
  if (msg.content.toLowerCase() === 'ch!davet') {
    msg.reply('Chatter botu sunucuna ekle! https://discord.com/oauth2/authorize?client_id=843423617522073600&scope=bot&permissions=805314622 ');
  }
  if (msg.content.toLowerCase() === 'ilk') {
    msg.reply('<==ilk yazmayınca olur gibi :hot_face:');
  }
  if (msg.content.toLowerCase() === 'chatter iyi sen') {
    msg.reply('Bende iyiyim demiyimde orta halliyim işte.');
  }
  if (msg.content.toLowerCase() === 'ch!altyapı') {
    msg.channel.send('Botun altyapısı! https://discord.js.org');
  }
  if (msg.content.toLowerCase() === 'chatter dostum') {
    msg.reply('Efendim kanki:heart:')
  }
  if (msg.content.toLowerCase() === 'ch!errorfix') {
    msg.channel.send('HATA :x: Bir hata yaşadınız tekrar deneyin. `hatakodu:komut_bakimda` ')
  }
  if (msg.content.toLowerCase() === 'ch!errorfix') {
    msg.channel.send('HATA :x: Bir hata yaşadınız tekrar deneyin. `hatakodu:komut_bakimda` ')
  }
});

client.login('Burada token var');

WebStorm ile hataları temizledim. 5-6 farklı yerde süslü parantez eksikliği vardı bu yüzden tüm kodlar 2-3 satır kaymış.
 
Son düzenleme:
SRP'nin ne olduğunu ilk kez sizden duyuyorum. Anonymous arrow function'u da öyle.
SOLID ilkelerinin ilki olan Single Responsibility Principle. Tekil sorumluluk prensibi. Bir fonksiyon/method bir şey yapmalı, sadece tek bir şey yapmalı.

() => {} Bu yapının ismi Arrow Function.
const greetUser = (user) => console.log("Hello", user) Bu şekilde olursa Named Arrow Function

(user) => console.log("Hello", user) Bu da Anonymous. Yani isimsiz. Sadece oluşturulduğu yerde tanımlı.
 
SOLID ilkelerinin ilki olan Single Responsibility Principle. Tekil sorumluluk ilkesi. Bir fonksiyon/method bir şey yapmalı, sadece bir şey yapmalı.

() => {} Bu yapının ismi Arrow Function.
const greetUser = (user) => console.log("Hello", user) Bu şekilde olursa Named Arrow Function

(user) => console.log("Hello", user) Bu da Anonymous. Yani isimsiz. Sadece oluşturulduğu yerde tanımlı.
Tamamdır, teşekkürler. (Düzenleme: SRP'nin ne olduğunu tam olarak anlayamamış olabilirim. Ama önemli değil.)
 
Solid ilkelerinin ilki olan Single responsibility principle. Tekil sorumluluk prensibi. Bir fonksiyon/method bir şey yapmalı, sadece tek bir şey yapmalı.

Tek işlevi mesaj karşılaştırması yapmak olan bir callback fonksiyonundan nasıl bir yapı bekliyorsunuz? Eleştiri yaparken en azından bir kısmınıda doğru olduğunu düşündüğünüz şekilde düzenleyip ekleyin ki daha yararlı olsun.
 
Uyarı! Bu konu 5 yıl önce açıldı.
Muhtemelen daha fazla tartışma gerekli değildir ki bu durumda yeni bir konu başlatmayı öneririz. Eğer yine de cevabınızın gerekli olduğunu düşünüyorsanız buna rağmen cevap verebilirsiniz.

Technopat Haberler

Geri
Yukarı