File tree Expand file tree Collapse file tree 7 files changed +0
-34
lines changed
services/libs/integrations/src/integrations/discord/api Expand file tree Collapse file tree 7 files changed +0
-34
lines changed Original file line number Diff line number Diff line change @@ -2,14 +2,12 @@ import axios, { AxiosRequestConfig } from 'axios'
22import { handleDiscordError } from './errorHandler'
33import { DiscordApiChannel } from '../types'
44import { IProcessStreamContext } from '../../../types'
5- import { getRateLimiter } from './handleRateLimit'
65
76export const getChannel = async (
87 channelId : string ,
98 token : string ,
109 ctx : IProcessStreamContext ,
1110) : Promise < DiscordApiChannel > => {
12- const rateLimiter = getRateLimiter ( ctx )
1311 const config : AxiosRequestConfig = {
1412 method : 'get' ,
1513 url : `https://discord.com/api/v10/channels/${ channelId } ` ,
@@ -19,8 +17,6 @@ export const getChannel = async (
1917 }
2018
2119 try {
22- await rateLimiter . checkRateLimit ( 'getChannel' )
23- await rateLimiter . incrementRateLimit ( )
2420 const response = await axios ( config )
2521 return response . data
2622 } catch ( err ) {
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import { timeout } from '@crowd/common'
33import { DiscordApiChannel , DiscordGetChannelsInput , DiscordGetMessagesInput } from '../types'
44import getMessages from './getMessages'
55import { IProcessStreamContext } from '../../../types'
6- import { getRateLimiter } from './handleRateLimit'
76import { handleDiscordError } from './errorHandler'
87
98/**
@@ -33,8 +32,6 @@ async function getChannels(
3332 ctx : IProcessStreamContext ,
3433 tryChannels = true ,
3534) : Promise < DiscordApiChannel [ ] > {
36- const rateLimiter = getRateLimiter ( ctx )
37-
3835 const config = {
3936 method : 'get' ,
4037 url : `https://discord.com/api/v10/guilds/${ input . guildId } /channels?` ,
@@ -44,9 +41,6 @@ async function getChannels(
4441 }
4542
4643 try {
47- await rateLimiter . checkRateLimit ( 'getChannels' )
48- await rateLimiter . incrementRateLimit ( )
49-
5044 const response = await axios ( config )
5145 // eslint-disable-next-line @typescript-eslint/no-explicit-any
5246 const result : any = response . data
Original file line number Diff line number Diff line change @@ -2,16 +2,13 @@ import axios, { AxiosRequestConfig } from 'axios'
22import { DiscordApiMember } from '../types'
33import { handleDiscordError } from './errorHandler'
44import { IProcessStreamContext } from '../../../types'
5- import { getRateLimiter } from './handleRateLimit'
65
76export const getMember = async (
87 guildId : string ,
98 userId : string ,
109 token : string ,
1110 ctx : IProcessStreamContext ,
1211) : Promise < DiscordApiMember > => {
13- const rateLimiter = getRateLimiter ( ctx )
14-
1512 // eslint-disable-next-line @typescript-eslint/no-explicit-any
1613 const config : AxiosRequestConfig < any > = {
1714 method : 'get' ,
@@ -22,8 +19,6 @@ export const getMember = async (
2219 }
2320
2421 try {
25- await rateLimiter . checkRateLimit ( 'getMember' )
26- await rateLimiter . incrementRateLimit ( )
2722 const response = await axios ( config )
2823 return response . data
2924 } catch ( err ) {
Original file line number Diff line number Diff line change 11import axios from 'axios'
22import { DiscordApiMember , DiscordGetMembersInput , DiscordGetMembersOutput } from '../types'
33import { IProcessStreamContext } from '../../../types'
4- import { getRateLimiter } from './handleRateLimit'
54import { handleDiscordError } from './errorHandler'
65
76async function getMembers (
87 input : DiscordGetMembersInput ,
98 ctx : IProcessStreamContext ,
109) : Promise < DiscordGetMembersOutput > {
11- const rateLimiter = getRateLimiter ( ctx )
12-
1310 let url = `https://discord.com/api/v10/guilds/${ input . guildId } /members?limit=${ input . perPage } `
1411 if ( input . page !== undefined && input . page !== '' ) {
1512 url += `&after=${ input . page } `
@@ -23,8 +20,6 @@ async function getMembers(
2320 } ,
2421 }
2522 try {
26- await rateLimiter . checkRateLimit ( 'getMembers' )
27- await rateLimiter . incrementRateLimit ( )
2823 const response = await axios ( config )
2924 const records : DiscordApiMember [ ] = response . data
3025 const limit = parseInt ( response . headers [ 'x-ratelimit-remaining' ] , 10 )
Original file line number Diff line number Diff line change 11import axios , { AxiosRequestConfig } from 'axios'
22import { handleDiscordError } from './errorHandler'
33import { IProcessStreamContext } from '../../../types'
4- import { getRateLimiter } from './handleRateLimit'
54
65export const getMessage = async (
76 channelId : string ,
87 messageId : string ,
98 token : string ,
109 ctx : IProcessStreamContext ,
1110) => {
12- const rateLimiter = getRateLimiter ( ctx )
13-
1411 const config : AxiosRequestConfig = {
1512 method : 'get' ,
1613 url : `https://discord.com/api/v10/channels/${ channelId } /messages/${ messageId } ` ,
@@ -20,8 +17,6 @@ export const getMessage = async (
2017 }
2118
2219 try {
23- await rateLimiter . checkRateLimit ( 'getMessage' )
24- await rateLimiter . incrementRateLimit ( )
2520 const response = await axios ( config )
2621 return response . data
2722 } catch ( err ) {
Original file line number Diff line number Diff line change 11import axios from 'axios'
22import { DiscordApiMessage , DiscordParsedReponse , DiscordGetMessagesInput } from '../types'
33import { IProcessStreamContext } from '../../../types'
4- import { getRateLimiter } from './handleRateLimit'
54import { handleDiscordError } from './errorHandler'
65
76async function getMessages (
87 input : DiscordGetMessagesInput ,
98 ctx : IProcessStreamContext ,
109 showErrors = true ,
1110) : Promise < DiscordParsedReponse > {
12- const rateLimiter = getRateLimiter ( ctx )
13-
1411 let url = `https://discord.com/api/v10/channels/${ input . channelId } /messages?limit=${ input . perPage } `
1512 if ( input . page !== undefined && input . page !== '' ) {
1613 url += `&before=${ input . page } `
@@ -25,8 +22,6 @@ async function getMessages(
2522 }
2623
2724 try {
28- await rateLimiter . checkRateLimit ( 'getMessages' )
29- await rateLimiter . incrementRateLimit ( )
3025 const response = await axios ( config )
3126 const records : DiscordApiMessage [ ] = response . data
3227
Original file line number Diff line number Diff line change 11import axios from 'axios'
22import { DiscordApiChannel , DiscordGetChannelsInput } from '../types'
33import { IProcessStreamContext } from '../../../types'
4- import { getRateLimiter } from './handleRateLimit'
54import { handleDiscordError } from './errorHandler'
65
76async function getThreads (
87 input : DiscordGetChannelsInput ,
98 ctx : IProcessStreamContext ,
109) : Promise < DiscordApiChannel [ ] > {
11- const rateLimiter = getRateLimiter ( ctx )
1210 const config = {
1311 method : 'get' ,
1412 url : `https://discord.com/api/v10/guilds/${ input . guildId } /threads/active?` ,
@@ -17,8 +15,6 @@ async function getThreads(
1715 } ,
1816 }
1917 try {
20- await rateLimiter . checkRateLimit ( 'getThreads' )
21- await rateLimiter . incrementRateLimit ( )
2218 const response = await axios ( config )
2319 return response . data . threads
2420 } catch ( err ) {
You can’t perform that action at this time.
0 commit comments