mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-10 01:08:07 +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();
|
||||
(async() => {
|
||||
Logger.info('Removing exclamation marks from nicknames...');
|
||||
await removeExclamationFromNicknames();
|
||||
await removeExclamationFromNicknames(config.client.token);
|
||||
Logger.info('Removing is done!');
|
||||
})();
|
||||
await loadCommands();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Logger } from "./Logger";
|
||||
|
||||
export const getDiscordGuildMembers = async() => {
|
||||
export const getDiscordGuildMembers = async(token: string) => {
|
||||
let oldId;
|
||||
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}` : ''}`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bot ${process.env.DISCORD_BOT_TOKEN}`,
|
||||
Authorization: `Bot ${token}`,
|
||||
},
|
||||
}
|
||||
)).json();
|
||||
|
@ -27,14 +27,14 @@ export const getDiscordGuildMembers = async() => {
|
|||
return result;
|
||||
}
|
||||
|
||||
export const removeExclamationFromNicknames = async() => {
|
||||
for (const member of await getDiscordGuildMembers()) {
|
||||
export const removeExclamationFromNicknames = async(token: string) => {
|
||||
for (const member of await getDiscordGuildMembers(token)) {
|
||||
if (!member.nickname?.startsWith?.('!')) continue;
|
||||
|
||||
await fetch(`https://discord.com/api/v8/guilds/${process.env.DISCORD_GUILD_ID}/members/${member.id}`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
Authorization: `Bot ${process.env.DISCORD_BOT_TOKEN}`,
|
||||
Authorization: `Bot ${token}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
|
|
Loading…
Reference in a new issue