今日已更新 80 条资讯 | 累计 20052 条内容
关于我们

标签:#esports

找到 1 篇相关文章

AI 资讯

How to build a CS2 live score Discord bot

Original post: tachiosports.com What we're building By the end of this guide, you'll have a Discord bot that posts live CS2 match scores to a channel, updates every 60 seconds, and shows team names, current map, and odds. No database required — everything comes straight from the API. Prerequisites You'll need Node.js installed (v18 or newer), a Discord bot token from the Discord Developer Portal, and a free Tachio Sports API key. Sign up on the homepage with GitHub to get yours. Step 1 — Create the Discord bot Go to discord.com/developers/applications and create a new application. Under the Bot tab, click Add Bot and copy the token. Invite the bot to your server with the 'bot' and 'Send Messages' permissions. Keep your token secret — it's like a password for your bot. Step 2 — Set up the project mkdir cs2-discord-bot cd cs2-discord-bot npm init -y npm install discord.js Step 3 — The complete bot code const { Client , GatewayIntentBits , EmbedBuilder } = require ( " discord.js " ); const DISCORD_TOKEN = process . env . DISCORD_TOKEN ; const API_KEY = process . env . TACHIO_API_KEY ; const CHANNEL_ID = process . env . CHANNEL_ID ; const client = new Client ({ intents : [ GatewayIntentBits . Guilds , GatewayIntentBits . GuildMessages , ], }); async function fetchLiveMatches () { const res = await fetch ( " https://api.tachiosports.com/esports/live/cs2 " , { headers : { " x-api-key " : API_KEY } }, ); if ( ! res . ok ) return []; const data = await res . json (); return data . matches ?? []; } function buildEmbed ( match ) { const home = match . teams . home . name ?? " TBD " ; const away = match . teams . away . name ?? " TBD " ; const score = match . score ?. display ?? " vs " ; const map = match . current_map ?? "" ; const format = match . match_format ?? "" ; const league = match . league . name ?? "" ; const oddsHome = match . odds . match_winner . home ?? " – " ; const oddsAway = match . odds . match_winner . away ?? " – " ; return new EmbedBuilder () . setColor (

2026-06-28 原文 →