const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Bot ${client.user.tag} adı ile giriş yaptı!`);
});
client.on('message', message => {
if (!message.guild) return;
// If the message content starts with "!at"
if (message.content.startsWith('+at')) {
// Assuming we mention someone in the message, this will return the user
// Read more about mentions over at https://discord.js.org/#/docs/main/stable/class/MessageMentions
const user = message.mentions.users.first();
// If we have a user mentioned
if (user) {
// Now we get the member from the user
const member = message.guild.member(user);
// If the member is in the guild
if (member) {
/**
* Kick the member
* Make sure you run this on a member, not a user!
* There are big differences between a user and a member
*/
member.kick('Optional reason that will display in the audit logs').then(() => {
// We let the message author know we were able to kick the person
message.reply(`Atıldı! ${user.tag}`);
}).catch(err => {
// An error happened
// This is generally due to the bot not being able to kick the member,
// either due to missing permissions or role hierarchy
message.reply('Atamıyorum aq!');
// Log the error
console.error(err);
});
} else {
// The mentioned user isn't in this guild
message.reply('Kullanıcı burada değil.');
}
// Otherwise, if no user was mentioned
} else {
message.reply('Atmak için birini etiketleyin.');
}
}
});
msg.channel.sendMessage('mal aq!');
}
client.login(my bots' token);
This isn’t the error you are experiencing but use message.channel.send and not message.channel.sendMessage.
Unexpected token means you have something somehwere, maybe an extra comma or random text, that isn’t supposed to be there.
If you’re still having this problem I think the issue is with the closing of your client message handler. The change I think you need is pretty small at the very end of the code you provided. Something like this ought to fix that error:
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Bot ${client.user.tag} adı ile giriş yaptı!`);
});
client.on('message', message => {
if (!message.guild) return;
// If the message content starts with "!at"
if (message.content.startsWith('+at')) {
// Assuming we mention someone in the message, this will return the user
// Read more about mentions over at https://discord.js.org/#/docs/main/stable/class/MessageMentions
const user = message.mentions.users.first();
// If we have a user mentioned
if (user) {
// Now we get the member from the user
const member = message.guild.member(user);
// If the member is in the guild
if (member) {
/**
* Kick the member
* Make sure you run this on a member, not a user!
* There are big differences between a user and a member
*/
member.kick('Optional reason that will display in the audit logs').then(() => {
// We let the message author know we were able to kick the person
message.reply(`Atıldı! ${user.tag}`);
}).catch(err => {
// An error happened
// This is generally due to the bot not being able to kick the member,
// either due to missing permissions or role hierarchy
message.reply('Atamıyorum aq!');
// Log the error
console.error(err);
});
} else {
// The mentioned user isn't in this guild
message.reply('Kullanıcı burada değil.');
}
// Otherwise, if no user was mentioned
} else {
message.reply('Atmak için birini etiketleyin.');
}
}
msg.channel.sendMessage('mal aq!');
});
client.login(my bots ' token);