dcanaliz
v1.0.1
Published
Discord moderation analytics API client for Node.js
Maintainers
Readme
DcAnaliz - Discord Moderation Analytics API Client
English
get(userID) (English)
Used for fast queries; typically returns a single user, record, or event.
📚 Table of Contents
userID(string|number): The Discord user ID to query- Overview
- Installation
- Quick Start
- API Documentation
Note: This
get()method is designed to be faster than the generalfetch()method — typical response time is very low and is expected not to exceed 1 second. - Examples
- Features
- Requirements
- Support & Community
Overview
DcAnaliz is a lightweight and efficient Node.js client library for the DcAnaliz API. It provides comprehensive moderation analytics, staff member tracking, and event monitoring for Discord servers. With simple and intuitive methods, you can easily integrate Discord moderation data into your applications.
- **Lightweight**: Minimal dependencies
- **Real-time**: SSE (Server-Sent Events) support for real-time updates
- **TypeScript Ready**: JSDoc comments and TypeScript definitions included
- **Developer Friendly**: Comprehensive error handling and clear documentation
- **Discord-focused**: Built specifically for Discord server management
### Installation
#### NPM
```bash
npm install dcanalizYarn
yarn add dcanalizPNPM
pnpm add dcanalizNode.js Version Requirement
- Minimum: Node.js 14 or higher
- Recommended: Node.js 16 or higher
Quick Start
const { DcAnaliz, Types } = require('dcanaliz');
##### `get(userId)`
Hızlı sorgulama için kullanılır; genellikle tek bir mesaj, kayıt veya olay verisini döndürür.
**Parametreler:**
- `userId` (string|number): Sorgulanacak Discord Kullanıcı ID'si
**Döner:** Promise<Object>
**Not:** Bu `get()` yöntemi, genel `fetch()` yöntemine göre daha hızlı olacak şekilde tasarlanmıştır — tipik yanıt süresi çok düşüktür ve en geç 1 saniyeyi geçmeyecek şekilde yanıt alınması beklenir.
**Örnek:**
```javascript
const { DcAnaliz } = require('dcanaliz');
const client = new DcAnaliz("<DcAnaliz API Key>")
client.get("985023331130552331").then(data => {
console.log(data);
}).catch(err => {
console.error(err);
});// Initialize the client with your API key const api = new DcAnaliz('your-api-key');
// Fetch fast user information const user = await api.get('user-id'); console.log(user);
// Fetch user information const user = await api.fetch('user-id'); console.log(user);
// Apply a punishment const result = await api.punitivesSet('user-id', Types.Ban, 'Reason'); console.log(result);
### API Documentation
#### Class: DcAnaliz
The main client class for interacting with the DcAnaliz API.
##### Constructor
```javascript
new DcAnaliz(apiKey)Parameters:
apiKey(string): Your DcAnaliz API key (can be set later withsetKey())
Example:
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
// Or set key later
const api = new DcAnaliz();
api.setKey('your-api-key');Available Punishment Types
const { Types } = require('dcanaliz');
console.log(Types);
// Output:
// {
// Ban: 'Ban',
// ForceBan: 'ForceBan',
// Jail: 'Jail',
// ChatMute: 'ChatMute',
// VoiceMute: 'VoiceMute',
// Timeout: 'Timeout',
// Warning: 'Warning',
// Underworld: 'Underworld',
// UnBan: 'UnBan',
// UnForceBan: 'UnForceBan',
// UnJail: 'UnJail',
// UnChatMute: 'UnChatMute',
// UnVoiceMute: 'UnVoiceMute',
// UnTimeout: 'UnTimeout',
// UnUnderworld: 'UnUnderworld'
// }Methods
setKey(apiKey)
Sets the API key for authenticated requests.
Parameters:
apiKey(string): Your DcAnaliz API key
Throws: Error if apiKey is empty
Example:
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz();
api.setKey('your-api-key');setClient(client)
Connects a Discord.js client to receive real-time events like staff member leaving guilds.
Parameters:
client(Object): Discord.js client instance
Throws: Error if client is invalid
Example:
const { Client, GatewayIntentBits } = require('discord.js');
const { DcAnaliz } = require('dcanaliz');
const discordClient = new Client({ intents: [GatewayIntentBits.Guilds] });
const api = new DcAnaliz('your-api-key');
api.setClient(discordClient);
// Listen for staff leave events
discordClient.on('otherGuildsStaffLeave', (staffData) => {
console.log('Staff member left:', staffData);
});fetch(userId)
Retrieves complete user information including member details, guilds, activities, and punishments.
Parameters:
userId(string|number): Discord User ID
Returns: Promise
User Object Properties: The returned User object contains all member information plus:
guilds(array): List of guilds the user is inactivities(object):Seen: Last seen timestampActivities: Array of activity items
punitives(array): List of punishments applied to the user- Plus all member properties from the API response (username, avatar, etc.)
Example:
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
const user = await api.fetch('987654321');
console.log('User Info:', user);
console.log('Guilds:', user.guilds);
console.log('Last Seen:', user.activities.Seen);
console.log('Punishments:', user.punitives);punitivesSet(userId, type, reason)
Applies a punishment to a user. Type can be a string or use the Types constant.
Parameters:
userId(string|number): Discord User IDtype(string): Punishment type (see Available Punishment Types above)reason(string, optional): Reason for the punishment
Returns: Promise
Example:
const { DcAnaliz, Types } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
// Using Types constant
const result = await api.punitivesSet('987654321', Types.Ban, 'Spam in general chat');
console.log('Punishment applied:', result);
// Or using string
const result2 = await api.punitivesSet('987654321', 'Ban', 'Spam in general chat');
console.log('Punishment applied:', result2);getLiveEvents(options)
Retrieves live events.
Parameters:
options(object, optional):limit(number): Number of events to retrieve (default: 50)channel(string, optional): Filter by channel
Returns: Promise
Example:
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
const events = await api.getLiveEvents({ limit: 100 });
console.log('Live events:', events);listServers(options)
Lists available servers with optional filtering.
Parameters:
options(object, optional):filter(string, optional): Filter criteriaq(string, optional): Search query
Returns: Promise
Example:
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
const servers = await api.listServers({ q: 'My Server' });
console.log('Found servers:', servers);types (getter)
Returns available punishment types.
Example:
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
const availableTypes = api.types;
console.log(availableTypes.Ban); // 'Ban'
console.log(availableTypes.ChatMute); // 'ChatMute'Examples
Example 1: Fetch User Information
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
async function getUserInfo() {
try {
const userId = '987654321';
const user = await api.fetch(userId);
console.log('Complete User Information:');
console.log(user); // All member details are included
console.log('Guilds:', user.guilds);
console.log('Last Seen:', user.activities.Seen);
console.log('Punishments:', user.punitives);
} catch (error) {
console.error('Error fetching user:', error.message);
}
}
getUserInfo();Example 2: Apply a Punishment with Types
const { DcAnaliz, Types } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
async function applyPunishment() {
try {
const userId = '987654321';
// Using Types constant
const result = await api.punitivesSet(userId, Types.Ban, 'Spam in general chat');
console.log('✅ Punishment Applied Successfully');
console.log('Response:', result);
} catch (error) {
console.error('Error applying punishment:', error.message);
}
}
applyPunishment();Example 3: List All Available Punishment Types
const { Types } = require('dcanaliz');
console.log('Available Punishment Types:');
Object.entries(Types).forEach(([key, value]) => {
console.log(` ${key}: ${value}`);
});
// Output:
// Ban: Ban
// ForceBan: ForceBan
// Jail: Jail
// ChatMute: ChatMute
// VoiceMute: VoiceMute
// Timeout: Timeout
// Warning: Warning
// Underworld: Underworld
// UnBan: UnBan
// UnForceBan: UnForceBan
// UnJail: UnJail
// UnChatMute: UnChatMute
// UnVoiceMute: UnVoiceMute
// UnTimeout: UnTimeout
// UnUnderworld: UnUnderworldExample 4: Discord.js Integration with Real-time Events
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const { DcAnaliz } = require('dcanaliz');
const discordClient = new Client({
intents: Object.values(GatewayIntentBits),
partials: Object.values(Partials)
});
const api = new DcAnaliz('your-api-key');
discordClient.once('ready', () => {
console.log(`Bot logged in as ${discordClient.user.tag}`);
// Connect DcAnaliz to listen for events
api.setClient(discordClient);
});
// Listen for staff member leaving other guilds
discordClient.on('otherGuildsStaffLeave', (staffData) => {
console.log('🚨 Staff Member Left Another Guild');
console.log('Staff Data:', staffData);
});
discordClient.login('your-discord-token');Example 5: Get Live Events
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
async function getLiveEvents() {
try {
const events = await api.getLiveEvents({ limit: 100 });
console.log('Live Events:', events);
} catch (error) {
console.error('Error fetching live events:', error.message);
}
}
getLiveEvents();Example 6: List Servers
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
async function findServers() {
try {
const servers = await api.listServers({ q: 'MyServer' });
console.log('Found Servers:', servers);
} catch (error) {
console.error('Error listing servers:', error.message);
}
}
findServers();Example 7: Multiple Punishments
const { DcAnaliz, Types } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
async function demonstratePunishments() {
try {
const userId = '987654321';
// Ban user
await api.punitivesSet(userId, Types.Ban, 'Violation of rules');
console.log('✅ User banned');
// Mute user in chat
await api.punitivesSet(userId, Types.ChatMute, 'Spam detected');
console.log('✅ User chat muted');
// Give warning
await api.punitivesSet(userId, Types.Warning, 'First warning');
console.log('✅ Warning issued');
// Apply voice timeout
await api.punitivesSet(userId, Types.Timeout, 'Voice spam');
console.log('✅ Timeout applied');
} catch (error) {
console.error('Error:', error.message);
}
}
demonstratePunishments();Features
✅ User Information - Retrieve detailed user data
✅ Punishment Management - Apply various types of punishments
✅ Server Listing - Filter and search servers
✅ Live Events - Track real-time events
✅ Discord.js Integration - Listen to staff leave events
✅ Error Handling - Comprehensive error messages
✅ TypeScript Support - Full type definitions
✅ Promise-based - Modern async/await support
Requirements
- Node.js: 14.0.0 or higher
- npm or yarn or pnpm
- Valid DcAnaliz API Key (optional, for authorized endpoints)
Support & Community
- Website: https://dcanaliz.com/
- API Documentation: https://api.dcanaliz.com/
- Discord Community: https://discord.gg/dcanaliz
Türkçe
📚 İçindekiler
- Genel Bakış
- Kurulum
- Hızlı Başlangıç
- API Belgelendirmesi
- Örnekler
- Özellikler
- Gereksinimler
- Destek & Topluluk
Genel Bakış
DcAnaliz, DcAnaliz API'si için hafif ve etkili bir Node.js istemci kütüphanesidir. Discord sunucularınız için kapsamlı moderasyon analitiği, personel üyesi takibi ve event izleme sağlar. Basit ve sezgisel metotlarla Discord moderasyon verilerini uygulamalarınıza kolayca entegre edebilirsiniz.
- Hafif: Minimum bağımlılık
- Gerçek Zamanlı: Server-Sent Events (SSE) desteği
- TypeScript Hazır: JSDoc açıklamaları ve TypeScript tanımlamaları
- Geliştirici Dostu: Kapsamlı hata işleme ve açık belgelendirme
- Discord Odaklı: Discord sunucu yönetimi için özel olarak tasarlandı
Kurulum
NPM
npm install dcanalizYarn
yarn add dcanalizPNPM
pnpm add dcanalizNode.js Sürüm Gereksinimi
- Minimum: Node.js 14 veya daha yüksek
- Önerilen: Node.js 16 veya daha yüksek
Hızlı Başlangıç
const { DcAnaliz, Types } = require('dcanaliz');
// İstemciyi başlatın
const api = new DcAnaliz('your-api-key');
// Daha hızlı basit kullanıcı bilgilerini çekin
const user = await api.get('user-id');
console.log(user);
// Kullanıcı bilgilerini çekin
const user = await api.fetch('user-id');
console.log(user);
// Ceza uygulayın
const result = await api.punitivesSet('user-id', Types.Ban, 'Nedeni');
console.log(result);API Belgelendirmesi
Sınıf: DcAnaliz
DcAnaliz API'si ile etkileşim için ana istemci sınıfı.
Yapıcı (Constructor)
new DcAnaliz(apiKey)Parametreler:
apiKey(string): DcAnaliz API anahtarı (daha sonrasetKey()ile ayarlanabilir)
Örnek:
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
// Veya anahtarı daha sonra ayarlayın
const api = new DcAnaliz();
api.setKey('your-api-key');Mevcut Ceza Türleri
const { Types } = require('dcanaliz');
console.log(Types);
// Çıktı:
// {
// Ban: 'Ban',
// ForceBan: 'ForceBan',
// Jail: 'Jail',
// ChatMute: 'ChatMute',
// VoiceMute: 'VoiceMute',
// Timeout: 'Timeout',
// Warning: 'Warning',
// Underworld: 'Underworld',
// UnBan: 'UnBan',
// UnForceBan: 'UnForceBan',
// UnJail: 'UnJail',
// UnChatMute: 'UnChatMute',
// UnVoiceMute: 'UnVoiceMute',
// UnTimeout: 'UnTimeout',
// UnUnderworld: 'UnUnderworld'
// }Metotlar
setKey(apiKey)
Yetkili istekler için API anahtarını ayarlar.
Parametreler:
apiKey(string): DcAnaliz API anahtarı
Hata Fırlatır: apiKey boş ise
Örnek:
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz();
api.setKey('your-api-key');setClient(client)
Discord.js istemcisini bağlayarak personel ayrılması gibi gerçek zamanlı olayları alır.
Parametreler:
client(Object): Discord.js istemci nesnesi
Hata Fırlatır: İstemci geçersiz ise
Örnek:
const { Client, GatewayIntentBits } = require('discord.js');
const { DcAnaliz } = require('dcanaliz');
const discordClient = new Client({ intents: [GatewayIntentBits.Guilds] });
const api = new DcAnaliz('your-api-key');
api.setClient(discordClient);
// Personel ayrılma olaylarını dinleyin
discordClient.on('otherGuildsStaffLeave', (staffData) => {
console.log('Personel ayrıldı:', staffData);
});fetch(userId)
Sunucular, aktiviteler, cezalar ve tüm üye bilgileri dahil eksiksiz kullanıcı bilgilerini alır.
Parametreler:
userId(string|number): Discord Kullanıcı ID'si
Döndürdüğü Değer: Promise
User Nesnesi Özellikleri: Döndürülen User nesnesi API'den tüm üye bilgileri içerir ve ayrıca:
guilds(array): Kullanıcının bulunduğu sunucuların listesiactivities(object):Seen: Son görülme zaman damgasıActivities: Aktivite öğeleri dizisi
punitives(array): Kullanıcıya uygulanan cezaların listesi- Artı API yanıtından tüm üye özellikleri (kullanıcı adı, avatar, vb.)
Örnek:
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
const user = await api.fetch('987654321');
console.log('Kullanıcı Bilgileri:', user);
console.log('Sunucular:', user.guilds);
console.log('Son Görülme:', user.activities.Seen);
console.log('Cezalar:', user.punitives);punitivesSet(userId, type, reason)
Bir kullanıcıya ceza uygular. Tip string veya Types sabitini kullanabilirsiniz.
Parametreler:
userId(string|number): Discord Kullanıcı ID'sitype(string): Ceza türü (yukarıdaki Mevcut Ceza Türlerine bakınız)reason(string, opsiyonel): Cezanın nedeni
Döndürdüğü Değer: Promise
Örnek:
const { DcAnaliz, Types } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
// Types sabitini kullanarak
const result = await api.punitivesSet('987654321', Types.Ban, 'Genel sohbette spam');
console.log('Ceza uygulandı:', result);
// Veya string kullanarak
const result2 = await api.punitivesSet('987654321', 'Ban', 'Genel sohbette spam');
console.log('Ceza uygulandı:', result2);getLiveEvents(options)
Canlı olayları alır.
Parametreler:
options(object, opsiyonel):limit(number): Alınacak olay sayısı (varsayılan: 50)channel(string, opsiyonel): Kanala göre filtrele
Döndürdüğü Değer: Promise
Örnek:
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
const events = await api.getLiveEvents({ limit: 100 });
console.log('Canlı olaylar:', events);listServers(options)
Opsiyonel filtreleme ile sunucuları listeler.
Parametreler:
options(object, opsiyonel):filter(string, opsiyonel): Filtre kriteriq(string, opsiyonel): Arama sorgusu
Döndürdüğü Değer: Promise
Örnek:
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
const servers = await api.listServers({ q: 'Benim Sunucum' });
console.log('Bulunan sunucular:', servers);types (getter)
Mevcut ceza türlerini döndürür.
Örnek:
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
const availableTypes = api.types;
console.log(availableTypes.Ban); // 'Ban'
console.log(availableTypes.ChatMute); // 'ChatMute'Örnekler
Örnek 1: Kullanıcı Bilgilerini Çekme
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
async function getUserInfo() {
try {
const userId = '987654321';
const user = await api.fetch(userId);
console.log('Eksiksiz Kullanıcı Bilgileri:');
console.log(user); // Tüm üye detayları dahildir
console.log('Sunucular:', user.guilds);
console.log('Son Görülme:', user.activities.Seen);
console.log('Cezalar:', user.punitives);
} catch (error) {
console.error('Kullanıcı bilgileri çekilirken hata:', error.message);
}
}
getUserInfo();Örnek 2: Types ile Ceza Uygulama
const { DcAnaliz, Types } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
async function applyPunishment() {
try {
const userId = '987654321';
// Types sabitini kullanarak
const result = await api.punitivesSet(userId, Types.Ban, 'Genel sohbette spam');
console.log('✅ Ceza Başarıyla Uygulandı');
console.log('Yanıt:', result);
} catch (error) {
console.error('Ceza uygulanırken hata:', error.message);
}
}
applyPunishment();Örnek 3: Tüm Mevcut Ceza Türlerini Listeleme
const { Types } = require('dcanaliz');
console.log('Mevcut Ceza Türleri:');
Object.entries(Types).forEach(([key, value]) => {
console.log(` ${key}: ${value}`);
});
// Çıktı:
// Ban: Ban
// ForceBan: ForceBan
// Jail: Jail
// ChatMute: ChatMute
// VoiceMute: VoiceMute
// Timeout: Timeout
// Warning: Warning
// Underworld: Underworld
// UnBan: UnBan
// UnForceBan: UnForceBan
// UnJail: UnJail
// UnChatMute: UnChatMute
// UnVoiceMute: UnVoiceMute
// UnTimeout: UnTimeout
// UnUnderworld: UnUnderworldÖrnek 4: Discord.js Entegrasyonu ve Gerçek Zamanlı Olaylar
const { Client, GatewayIntentBits, Partials } = require('discord.js');
const { DcAnaliz } = require('dcanaliz');
const discordClient = new Client({
intents: Object.values(GatewayIntentBits),
partials: Object.values(Partials)
});
const api = new DcAnaliz('your-api-key');
discordClient.once('ready', () => {
console.log(`Bot ${discordClient.user.tag} olarak giriş yaptı!`);
// DcAnaliz'i olayları dinlemek için bağlayın
api.setClient(discordClient);
});
// Personel üyesi başka bir sunucudan ayrıldığında dinleyin
discordClient.on('otherGuildsStaffLeave', (staffData) => {
console.log('🚨 Personel Başka Bir Sunucudan Ayrıldı');
console.log('Personel:', staffData);
});
discordClient.login('your-discord-token');Örnek 5: Canlı Olayları Alın
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
async function getLiveEvents() {
try {
const events = await api.getLiveEvents({ limit: 100 });
console.log('Canlı Olaylar:', events);
} catch (error) {
console.error('Canlı olaylar çekilirken hata:', error.message);
}
}
getLiveEvents();Örnek 6: Sunucuları Listele
const { DcAnaliz } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
async function findServers() {
try {
const servers = await api.listServers({ q: 'BenimSunucum' });
console.log('Bulunan Sunucular:', servers);
} catch (error) {
console.error('Sunucuları listelenirken hata:', error.message);
}
}
findServers();Örnek 7: Farklı Ceza Türlerini Uygulama
const { DcAnaliz, Types } = require('dcanaliz');
const api = new DcAnaliz('your-api-key');
async function demonstratePunishments() {
try {
const userId = '987654321';
// Kullanıcıyı yasakla
await api.punitivesSet(userId, Types.Ban, 'Kuralları ihlal');
console.log('✅ Kullanıcı yasaklandı');
// Kullanıcıyı sohbette sessize al
await api.punitivesSet(userId, Types.ChatMute, 'Spam tespit edildi');
console.log('✅ Kullanıcı sessize alındı');
// Uyarı ver
await api.punitivesSet(userId, Types.Warning, 'İlk uyarı');
console.log('✅ Uyarı verildi');
// Ses zaman aşımı uygula
await api.punitivesSet(userId, Types.Timeout, 'Ses spamı');
console.log('✅ Zaman aşımı uygulandı');
} catch (error) {
console.error('Hata:', error.message);
}
}
demonstratePunishments();Özellikler
✅ Kullanıcı Bilgileri - Detaylı kullanıcı verilerini alın
✅ Ceza Yönetimi - Farklı ceza türlerini uygulayın
✅ Sunucu Listeleme - Sunucuları filtreleyin ve arayın
✅ Canlı Olaylar - Gerçek zamanlı olayları takip edin
✅ Discord.js Entegrasyonu - Personel ayrılma olaylarını dinleyin
✅ Hata Yönetimi - Kapsamlı hata mesajları
✅ TypeScript Desteği - Tam tip tanımlamaları
✅ Promise Tabanlı - Modern async/await desteği
Gereksinimler
- Node.js: 14.0.0 veya daha yüksek
- npm veya yarn veya pnpm
- Geçerli DcAnaliz API Anahtarı (opsiyonel, yetkili endpoints için)
Destek & Topluluk
- Website: https://dcanaliz.com/
- API Belgelendirmesi: https://api.dcanaliz.com/
- Discord Topluluğu: https://discord.gg/dcanaliz
License
MIT License - See LICENSE file for details / MIT Lisansı - Ayrıntılar için LICENSE dosyasına bakınız
Made with ❤️ by Acarfx
Daha fazla bilgi ve güncellemeler için bizi ziyaret edin: https://dcanaliz.com/
