Ana içeriğe atla

Gateway Client

GatewayClient Nedir#

GatewayClient, dclist'in graphql API'si ile etkileşim kurmanızı sağlayan sınıftır

Constructor#

GatewayClient'ın constructor metodu birince parametre olarak nesne kabul eder. Kabul edilen nesnenin özellikleri:

ÖzellikTipiİsteğe BağlıAçıklama
tokenstringHayırWeb sitesinden alınan token
client*EvetKullandığınız kütüphanenin client objesi
enablePosterbooleanEvetVarsayılan false. Eğer botunuzun verilerini otomatik göndermek istiyorsanız true olarak değiştirin
import { GatewayClient } from '@dclist/sdk'
const dclClient = new GatewayClient({
token: 'SENIN_TOKENIN'
})

Metodlar#

getBotById#

Verilen id ile botu çeker. | Özellik | Tipi | İsteğe Bağlı | Açıklama | | ------------- |:-------------:|:------------:| ----------------------------------------- | | botId | string | Hayır | Botun Discord id'si | | fieldSelector | FieldSelector | Evet | Gelişmiş kullanım için özel FieldSelector | | Dönenler | Promise Bot | | Bot nesnesi döndüren bir Promise döndürür |

Normal bot çekmek#

const bot = await dclClient.getBotById('690214077490004030')
console.log(bot)
// Konsole Çıktısı :
{
id: '690214077490004030',
username: 'Techno Bot',
discriminator: '1197',
avatar: 'ffa1ff0c8616ef03c9a87871a654ae3e',
stats: { ... },
prefix: 't!',
prefixType: 'DYNAMIC',
website: 'https://technobot.xyz/',
github: null,
tags: [ 'turkish', 'game', 'dashboard' ]
}

Özel FieldSelector ile bot çekmek#

import { FieldSelector, Bot } from '@dclist/sdk'
const customFieldSelector = new FieldSelector<Bot>({
// Burayı kendinize göre değiştirin
id: 1,
username: 1,
avatar: 1,
})
const bot = await dclClient.getBotById('690214077490004030', customFieldSelector)
console.log(bot)
// Konsol Çıktısı :
{
id: '690214077490004030',
username: 'Techno Bot',
avatar: 'ffa1ff0c8616ef03c9a87871a654ae3e'
}

getUserById#

Verilen id ile kullanıcıyı çeker. | Özellik | Tipi | İsteğe Bağlı | Açıklama | | ------------- |:-----------------:|:------------:| ----------------------------------------------- | | userId | string | Hayır | Kullanıcının Discord id'si | | fieldSelector | FieldSelector | Evet | Gelişmiş kullanım için özel FieldSelector | | Dönenler | Promise Kullanıcı | | Kullanıcı nesnesi döndüren bir Promise döndürür |

Normal kullanıcı çekmek#

const user = await dclClient.getUserById('685124491466113096')
console.log(user)
// Konsol Çıktısı :
{
id: '685124491466113096',
username: 'technoeren',
discriminator: '7608',
avatar: '95d834bd53399f6fe4b9b7fee2dcc38c',
website: 'https://technobot.xyz/',
github: null
}

Özel FieldSelector ile kullanıcı çekmek#

import { FieldSelector, User } from '@dclist/sdk'
const customFieldSelector = new FieldSelector<User>({
// Burayı kendinize göre değiştirin
id: 1,
username: 1,
avatar: 1,
})
const user = await dclClient.getUserById('685124491466113096', customFieldSelector)
console.log(user)
// Konsol Çıktısı :
{
id: '685124491466113096',
username: 'technoeren',
avatar: '95d834bd53399f6fe4b9b7fee2dcc38c'
}

isUserVoted#

Kullanıcının son 12 saat içerisinde bota oy verip vermediğini kontrol eder. | Özellik | Tipi | İsteğe Bağlı | Açıklama | | -------- |:---------------:|:------------:| ------------------------------------- | | userId | string | Hayır | Kullanıcının Discord id'si | | Dönenler | Promise boolean | | Boolean döndüren bir Promise döndürür |

const isVoted = await dclClient.isUserVoted('685124491466113096')
console.log(isVoted)
// Konsol Çıktısı :
true

getUserComment#

Kullanıcı tarafından botunuza yapılan yorumu çeker

ÖzellikTipiİsteğe BağlıAçıklama
userIdstringHayırKullanıcının Discord id'si
fieldSelectorFieldSelectorEvetGelişmiş kullanım için özel FieldSelector
DönenlerPromise YorumYorum nesnesi döndüren bir Promise döndürür

Kullanıcı yorumunu çekmek#

const comment = await dclClient.getUserComment('685124491466113096')
console.log(comment)
// Konsol Çıktısı :
{
// Yorum yapılan bot
subject: {
id: '690214077490004030',
username: 'Techno Bot',
discriminator: '1197',
avatar: 'ffa1ff0c8616ef03c9a87871a654ae3e',
},
// Yorum yapan kullanıcı
author: {
id: '685124491466113096',
username: 'technoeren',
discriminator: '7608',
avatar: 'a0cca1132a472eae99373585c8a784c1'
},
type: 'PARENT',
like: 666,
content: '...'
}

Özel FieldSelector ile kullanıcı yorumu çekmek#

import { FieldSelector, Comment } from '@dclist/sdk'
const customFieldSelector = new FieldSelector<Comment>({
// Burayı kendinize göre değiştirin
author: {
id: 1,
username: 1,
avatar: 1,
},
like: 1,
content: 1,
})
const comment = await dclClient.getUserComment('685124491466113096', customFieldSelector)
console.log(comment)
// Konsol Çıktısı :
{
author: {
id: '685124491466113096',
username: 'technoeren',
avatar: 'a0cca1132a472eae99373585c8a784c1'
},
like: 666,
content: '...'
}

subscribeTo#

Verilen konulara abone olur. Etkinlikler hakkında daha fazla bilgi için özel rehber. | Özellik | Tipi | İsteğe Bağlı | Açıklama | | ------------- |:--------------------:|:------------:| -------------------------------------------------------- | | topics | string array | Hayır | Abone olmak istediğiniz konuların listesi | | fieldSelector | FieldSelector object | Evet | Gelişmiş kullanım için her konu için özel FieldSelectors | | Dönenler | array string | | Abone olunan konuların listesi |

Yeni oy etkinliğine abone olmak#

import { SubscriptionsTopicsEnum } from '@dclist/sdk'
const subTopics = await dclClient.subscribeTo([SubscriptionsTopicsEnum.NEW_VOTE])
console.log(subTopics)
// Konsole Çıktısı :
[ 'SDK_NEW_VOTE' ]