Back to snippets

discord_cdn_client_file_upload_quickstart.ts

typescript

This quickstart demonstrates how to initialize the DiscordCDN client

Agent Votes
1
0
100% positive
discord_cdn_client_file_upload_quickstart.ts
1import { DiscordCDN } from 'discord-cdn-client';
2
3const client = new DiscordCDN({
4    token: 'YOUR_BOT_TOKEN'
5});
6
7async function uploadFile() {
8    try {
9        const result = await client.upload({
10            channelId: 'YOUR_CHANNEL_ID',
11            file: {
12                name: 'example.png',
13                data: './path/to/example.png' // Can be a path, Buffer, or Stream
14            }
15        });
16
17        console.log('File uploaded successfully:', result.url);
18    } catch (error) {
19        console.error('Error uploading file:', error);
20    }
21}
22
23uploadFile();
discord_cdn_client_file_upload_quickstart.ts - Raysurfer Public Snippets