JavaScript
2
Вклад в тег
const token = "Your Token" // Bearer токен
var details = {
'token': token,
'client_id': 'Your clientId',
'client_secret': 'Your clientSecret'
};
var formBody = [];
for (var property in details) {
var encodedKey = encodeURIComponent(property);
var encodedValue = encodeURIComponent(details[property]);
formBody.push(encodedKey + "=" + encodedValue);
}
formBody = formBody.join("&");
const json = fetch('https://discord.com/api/v8/oauth2/token/revoke', {
method: 'POST',
headers: {
'Authorization': "Bearer " + token,
'Content-Type': 'application/x-www-form-urlencoded'
},
body: formBody
})
const {Client, Intents} = require("discord.js");
const config = require('./config.json')
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MEMBERS] });
client.login(config.token);
const arr = [];
const afkRoleId = "967509853557891152"
const noAfkRoleId = "967509879642275851"
client.on("messageCreate", async (message) => {
const arrMember = arr.filter((member) => member.id === message.member.id);
if (arrMember.length > 0) {
delete arr.filter((member) => member.id === message.member.id)
}
await message.member.roles.remove(afkRoleId)
await message.member.roles.add(noAfkRoleId)
arr.push({id: message.member.id})
const sec = 3; // Запуск через 3 секунды
setTimeout(() => {
const member = arr.filter((member) => member.id === message.member.id)
if (member.length > 0) {
message.member.roles.add(afkRoleId)
message.member.roles.remove(noAfkRoleId)
}
}, sec * 1000)
})