mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-22 14:41:05 +01:00
fix: use token from config
This commit is contained in:
parent
04d462ebb1
commit
14b0c6d252
2 changed files with 6 additions and 6 deletions
|
@ -19,7 +19,7 @@ await fetchIssues();
|
||||||
await fetchPullRequests();
|
await fetchPullRequests();
|
||||||
(async() => {
|
(async() => {
|
||||||
Logger.info('Removing exclamation marks from nicknames...');
|
Logger.info('Removing exclamation marks from nicknames...');
|
||||||
await removeExclamationFromNicknames();
|
await removeExclamationFromNicknames(config.client.token);
|
||||||
Logger.info('Removing is done!');
|
Logger.info('Removing is done!');
|
||||||
})();
|
})();
|
||||||
await loadCommands();
|
await loadCommands();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Logger } from "./Logger";
|
import { Logger } from "./Logger";
|
||||||
|
|
||||||
export const getDiscordGuildMembers = async() => {
|
export const getDiscordGuildMembers = async(token: string) => {
|
||||||
let oldId;
|
let oldId;
|
||||||
const result: any[] = [];
|
const result: any[] = [];
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ export const getDiscordGuildMembers = async() => {
|
||||||
`https://discord.com/api/v8/guilds/${process.env.DISCORD_GUILD_ID}/members?limit=1000${oldId ? `&after=${oldId}` : ''}`,
|
`https://discord.com/api/v8/guilds/${process.env.DISCORD_GUILD_ID}/members?limit=1000${oldId ? `&after=${oldId}` : ''}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bot ${process.env.DISCORD_BOT_TOKEN}`,
|
Authorization: `Bot ${token}`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)).json();
|
)).json();
|
||||||
|
@ -27,14 +27,14 @@ export const getDiscordGuildMembers = async() => {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const removeExclamationFromNicknames = async() => {
|
export const removeExclamationFromNicknames = async(token: string) => {
|
||||||
for (const member of await getDiscordGuildMembers()) {
|
for (const member of await getDiscordGuildMembers(token)) {
|
||||||
if (!member.nickname?.startsWith?.('!')) continue;
|
if (!member.nickname?.startsWith?.('!')) continue;
|
||||||
|
|
||||||
await fetch(`https://discord.com/api/v8/guilds/${process.env.DISCORD_GUILD_ID}/members/${member.id}`, {
|
await fetch(`https://discord.com/api/v8/guilds/${process.env.DISCORD_GUILD_ID}/members/${member.id}`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bot ${process.env.DISCORD_BOT_TOKEN}`,
|
Authorization: `Bot ${token}`,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
|
Loading…
Reference in a new issue