Sample discord bot using clashofclans.js and discord.js

Overview

Clash of Clans sample discord bot using NodeJs

Test

discord.js-badge clashofclans.js-badge

https://img.shields.io/github/issues/r-priyam/cocjs-smaple-bot https://img.shields.io/github/forks/r-priyam/cocjs-smaple-bot https://img.shields.io/github/license/r-priyam/cocjs-smaple-bot

Introduction


This sample bot project aims to help you get started with interacting Clash of Clans API using discord.js and clashofclans.js.

Before You Start

Before you dive into running this project, I expect you to have these things ready:

After completing the above steps, do invite the bot to your server.

Important Links


Getting Started


  1. Clone the project using git clone https://github.com/r-priyam/cocjs-smaple-bot.git
  2. Install dependencies using npm install
  3. Make .env file in the project root directory and set the following values:
    • DATABASE_URL: Your postgres database connection string
    • CLASH_EMAIL - Clash of Clans API account email address
    • CLASH_PASSWORD - Password for the account of CLASH_EMAIL
    • PROJECT_NAME - Your project name
    • BOT_CLIENT_ID - Bot client id
    • TEST_GUILD_ID - Guild id of the test guild in which bot was added
    • BOT_TOKEN - Discord bot token of your bot account created on Discord
    • CLAN_TAGS: Clan tags separated by comma to be added to the clashofclans.js for receiving clan events.
    • MEMBER_REPORTING_CHANNEL_ID: Channel id of the channel where member join/leave reporting is to be done.
  4. Synchronize the Application commands(Slash commands) with the test guild using npm run sync:commands. This will add the commands to the test guild. Please note that it takes sometime to cache the commands in guild but not much when we are adding commands specifically for guild only. Have some patience.
  5. Run the bot using npm run start.

Once the bot is running and slash commands are reflecting in the test server then you can try running the commands.

Commands


  • /player - To get player information
  • /clan - To get clan information
  • /war - To get clan war information
  • /link - To link a clan or a player to your discord account.

Tag is an optional parameter in /player, /clan and /war commands. If you don't provide it then it will attempt to get the respective tag information from the database for the user who sent the command and will return the data for the first tag found in the database.

If you provide the tag then it will attempt to query the data directly from the API and will return the data for the tag provided.

FAQ's


  • Q: Why it requires my Clash of Clans API account credentials?

    • A: It is required to get the access token to interact with clash of clans api. If you don't want to give your account credentials, you can use the Clash of Clans API website directly to get the access token and then you can setup the CLASH_TOKEN environment variable. It will then require you do some extra steps to get the clasofclans.js to work. To use API token diectly do these changes in the following files -

    In index.ts

    - client.coc = new ClashClient({ cache: true });
    + client.coc = new ClashClient({ keys: [ENV.CLASH_TOKEN], cache: true });

    In utils/EnvValidator.ts

    interface EnviromentVariables {
        // ...
    +   CLASH_TOKEN: string;
    }
    
    const envVarsSchema = joi
    .object()
    .keys({
        // ...
    +   CLASH_TOKEN: joi.string().required(),
    })
    .unknown();
  • Q: Why adding commands to the test guild only and not globally?

    • A: When adding commands globally then it takes at least 1 hour ~ to cache commands on discord side and then reflect in the servers in which bot is added into but not much when we are adding commands specifically for guild only. So, it is better to add commands to the test guild only when developing.
  • Q: How can I add commands globally?

    • A: Please read discordjs guide here and follow the steps to add commands globally.
  • Q: How can I add more commands?

    • A: Please read discordjs guide here and follow the steps to add more commands.

If you have any questions or suggestions, please feel free to open an issue here.

Comments
Releases(v0.0.2)
Owner
Priyam
Priyam
Discord-Bot - You can use the discord bot codes that are updated in every video of the codes I use in the discord bot making series that I have published on my youtube channel.

Discord-Bot You can use the discord bot codes that are updated in every video of the codes I use in the discord bot making series that I have publishe

Umut Bayraktar 114 Jan 3, 2023
Gitlift Discord Bot is a discord bot which is listening Discord Messages to reply with user gitlift profile and total contributions.

Remoklify - Gitlift Discord Bot Gitlift Discord Bot is a discord bot which is listening Discord Messages to reply with user gitlift profile and total

Remoklify 3 Mar 20, 2022
New base bot WhatsApp 🈴 bukan self bot lagi atau buka bot yang bisa di pakai oleh bot sendiri 😎

Installation • Thanks to • Donate Official Group Bot • Settings Instalasi Heroku Buildpack Click the deploy icon below ! > heroku/nodejs > https://g

zeeone 27 Feb 9, 2022
About Discord bot draft that does not contain ready-made commands, compatible with discord.js v14. Create your own discord bot with this command handler.

discordJS-V14 About Discord bot draft that does not contain ready-made commands, compatible with discord.js v14. Create your own discord bot with this

Umut Bayraktar 36 Dec 28, 2022
This bot is a cool Discord bot made in discord.js using Node.JS

Anti-Crosspost Discord Bot This bot is a cool Discord bot made in discord.js using Node.JS. It detects when a user cross-posts a message in multiple c

Muhammad Usman Mithani 4 May 31, 2022
It is a discord bot bot which can play lofi song in different language 24/7. It has premium system and cool embed looks with buttons. It can play youtube songs, playlists. This bot code was made by Supreme#2401. It uses djs V12

Lofi-Radio-Music-Bot It is a discord bot bot which can play lofi song in different language 24/7. It has premium system and cool embed looks with butt

Diwas Atreya 89 Jan 2, 2023
A discord bot made using discord.js and discord-player

Musx A custom discord bot that can play music in your server ?? Add the bot to your server If you are looking for a music bot for your Discord server

Shashwat Singh 4 Mar 28, 2022
Co-Pilot is a discord Bot designed to be the all-in-one, open-source Discord bot that handles all your server needs.

Welcome to Co-Pilot Bot repo! ?? ?? Co-Pilot (All-in-one Discord Bot) Co-Pilot is a discord Bot designed to be the all-in-one, open-source Discord bot

YMafalha 19 Nov 11, 2022
A discord bot using @discord.js and mongoose. Used for music, moderation, and entertainment.

hazel A discord bot using @discord.js and mongoose. Used for music, moderation, and entertainment. Features Music ― supporting YouTube, Spotify and So

yushi 27 Dec 31, 2022
A simple & easy2use API for obtaining information about a discord user, discord bot or discord guild and their use for some purpose on websites!

discord-web-api A simple & easy2use API for obtaining information about a discord user, discord bot or discord guild and their use for some purpose on

InvalidLenni 2 Jun 28, 2022
Ini Adalah Tools Bot WhatsApp,Pengodean Ulang Dari Sc Bot Kanna Bot

Node Modules Belum Selesai Unduh File Bot Lengkap Node Modules Click Here Lord Bot FOR DEPLOY HEROKU USER Instal Buildpack heroku/nodejs https://githu

Creator Lord-Botz 8 Jul 1, 2022
This bot can raise your mood. This bot send joke often our channel for users. Sometimes bot don't work because we have not server for this project...)

Hi, welcome to send-joke-bot telegram bot project ?? What can do this bot ? This bot can raise your mood. This bot send joke often our channel for use

Muhammadamin 5 Sep 26, 2022
Discord Neura - a Discord bot framework built on discord.js

Discord Neura Description Discord Neura is a Discord bot framework built on discord.js. Features Command Handler, Arguments, Preconditions and Listene

Discord Neura 3 Mar 23, 2022
A multipurpose Discord-bot created using discord.js.

Flame A multipurpose Discord-bot with music, economy, utils, and also auto-moderation. Flame is a powerfull, multipurpose and fully modular Discord-bo

Flame 38 Nov 14, 2021
A bot Similar to the reaction roles discord bot, but free. Written in JavaScript, and uses MongoDB.

Discord Reaction Roles bot About • Features • Installation • Setting Up About An open source reaction roles bot to anyone who needs one in their serve

null 52 Dec 22, 2022
This project was created to help discord.js developers start their own bot, you can take this project as a basic for your bot and add things to it as you want. 🙂

Discord.js Starter-Bot A small & basic discord.js bot to help you get started ??️ This project was created to help discord.js developers start their o

Strike 3 Nov 29, 2022
Vio-MD is multi-device whatsapp bot using library @adiwajshing/baileys and example bot of Violetics API

Vio Multi Device WhatsApp Bot Use at your own risk! Build with Baileys and JavaScript's native Map class ( as a command handler ), using https://viole

Violetics 4 May 31, 2022
Açık kaynaklı bir discord bot list botu. Bot list sunucularına özel yapılmıştır. Tanıtım videosu MoTion42 Kanalında bulunuyor. Umarım beğenirsiniz.

?? Bot Bilgilendirme Açık kaynaklı bir discord bot list botu. Bot list sunucularına özel yapılmıştır. Tanıtım videosu MoTion42 Kanalında bulunuyor. Um

`Motion 1 Sep 11, 2021
A Discord bot library to make the development of a bot a little bit easier.

Discord Bot Framework (DBF) A basic Discord bot framework to allow for easier creation of bots. With this library, you can easily parse and handle com

Yoo-Babobo 1 Dec 23, 2021