main a2bc611c1fef cached
6 files
6.8 KB
1.8k tokens
2 symbols
1 requests
Download .txt
Repository: polemikal/discord-welcome-bot
Branch: main
Commit: a2bc611c1fef
Files: 6
Total size: 6.8 KB

Directory structure:
gitextract_91z_bdp_/

├── .gitignore
├── LICENSE
├── README.md
├── app.js
├── config.json
└── package.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
node_modules


================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2021 polemikal

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
# discord-welcome-bot

A great intro sounds for Discord servers!

# Setup the Project

1. Download or clone this project.
2. Setup the project options from `config.json` file.
3. Upload the required audio files in `default_files` path and enter audio files name in `config.json`.
4. Run `app.js` file from terminal. (Example run command: `node app.js`)

**(!) DO NOT FORGET** You must install **FFMPEG** on your system to run.

# Information

**(!)** If there is something that can be added to this project or if you have found anything missing in this project, you can let us know and help us improve the project! [Let us know!](https://github.com/polemikal/discord-slash-commands-bot/issues)

**(!)** This project is shared on behalf of [Serendia Squad](https://discord.com/invite/serendia). If you need any help about this project, you can join this platform and ask questions in your mind.






================================================
FILE: app.js
================================================
const { Client, VoiceChannel, GuildMember } = require("discord.js");

const fs = require("fs");
const CONFIG = JSON.parse(fs.readFileSync("./config.json", { encoding: "utf-8" }));

const moment = require("moment");
require("moment-duration-format");

const Voice = new Client({ fetchAllMembers: true, disableMentions: "none" });
Voice.staffJoined = false;
Voice.playingVoice = false;
Voice.voiceConnection = null;
Voice.channelID = null;

Voice.on("ready", async() => {

    Voice.user.setPresence({
        status: "dnd",
        activity: {
            name: CONFIG.DEFAULTS.ACTIVITY_TEXT
        }
    });

    Voice.log(`Voice client \'${Voice.user.username}\' has been activated!`);

    const Guild = Voice.guilds.cache.get(CONFIG.DEFAULTS.GUILD_ID) || Voice.guilds.cache.first();
    if(!Guild) {
        Voice.error("Guild not found!");
        return Voice.destroy();
    }
    
    const Channel = Guild.channels.cache.get(CONFIG.DEFAULTS.VOICE_CHANNEL);
    if(!Channel) {
        Voice.error("Channel not found!");
        return Voice.destroy();
    }

    Channel.join().then(connection =>{
            
        Voice.voiceConnection = connection;
        Voice.channelID = Channel.id;
        Voice.log("The audio file is playing now...")
        if(!Channel.hasStaff()) playVoice(Voice);
        else Voice.staffJoined = true;

    }).catch(err => {
        Voice.error(`Cannot connect to voice channel (${Channel.name}) (${Channel.id}): ` + err.message)
        return Voice.destroy();
    });

});

Voice.on("voiceStateUpdate", async(oldState, newState) => {
    if(
        newState.channelID && (oldState.channelID !== newState.channelID) &&
        newState.member.isStaff() &&
        newState.channelID === Voice.channelID &&
        !newState.channel.hasStaff(newState.member)
    ) {
        Voice.staffJoined = true;
        return playVoice(Voice);
    }
    if( 
        oldState.channelID && 
        (oldState.channelID !== newState.channelID) && 
        newState.member.isStaff() && 
        oldState.channelID === Voice.channelID &&
        !oldState.channel.hasStaff()
    ) {
        Voice.staffJoined = false;
        return playVoice(Voice);
    }
});

Voice.login(CONFIG.TOKEN).catch(err => {
    Voice.error("An occured error while connecting to Voice client: " + err.message);
    return Voice.destroy();
});

/**
 * 
 * @param {Client} Voice 
 */
function playVoice(Voice) {
    try {

        const Path = Voice.staffJoined === true ? "./" + CONFIG.FILES.STAFF : "./" + CONFIG.FILES.WELCOME;
        Voice.playingVoice = true;
        Voice.voiceConnection.play(Path, {
            volume: 1
        }).on("finish", async() => {
            Voice.playingVoice = false;
            if(Voice.staffJoined === true) return;
            playVoice(Voice);
        });

    } catch(err) {

        return Voice.log("An occured error while playing voice file: " + err.message);
        
    }
};

Client.prototype.log = function(content) {
    return console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] [VOICE BOT] ${content}`);
};

Client.prototype.error = function(content) {
    return console.error(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] [VOICE BOT] ERR! ${content}`);
};

VoiceChannel.prototype.hasStaff = function(checkMember = false) {
    if(this.members.some(m => (checkMember !== false ? m.user.id !== checkMember.id : true) && !m.user.bot && m.roles.highest.position >= m.guild.roles.cache.get(CONFIG.DEFAULTS.MIN_STAFF_ROLE).position)) return true; // m.roles.highest.position >= this.guild.roles.cache.get(CONFIG.DEFAULTS.MIN_STAFF_ROLE).position
    return false;
}

VoiceChannel.prototype.getStaffs = function(checkMember = false) {
    return this.members.filter(m => (checkMember !== false ? m.user.id !== checkMember.id : true) && !m.user.bot && m.roles.highest.position >= m.guild.roles.cache.get(CONFIG.DEFAULTS.MIN_STAFF_ROLE).position).size
}

GuildMember.prototype.isStaff = function() {
    if(
        !this.user.bot &&
        ([...CONFIG.DEFAULTS.AUTHORS].includes(this.id) ||
        this.hasPermission("ADMINISTRATOR") ||
        this.roles.highest.position >= this.guild.roles.cache.get(CONFIG.DEFAULTS.MIN_STAFF_ROLE).position
        )
    ) return true;
    return false;
}



================================================
FILE: config.json
================================================
{
    "DEFAULTS": {
        "AUTHORS": [],
        "ACTIVITY_TEXT": "Polemikal Voice System",
        "GUILD_ID": "",
        "VOICE_CHANNEL": "",
        "MIN_STAFF_ROLE": ""
    },
    "FILES": {
        "WELCOME": "default_files/<welcome-voice>.mp3",
        "STAFF": "default_files/<staff-voice>.mp3"
    },
    "TOKEN": "BOT_TOKEN"
}

================================================
FILE: package.json
================================================
{
  "name": "dark-voice-bots",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "polemikal",
  "license": "ISC",
  "dependencies": {
    "@discordjs/opus": "^0.3.3",
    "discord.js": "^12.5.1",
    "fs": "0.0.1-security",
    "moment": "^2.29.1",
    "moment-duration-format": "^2.3.2",
    "opusscript": "0.0.7"
  }
}
Download .txt
gitextract_91z_bdp_/

├── .gitignore
├── LICENSE
├── README.md
├── app.js
├── config.json
└── package.json
Download .txt
SYMBOL INDEX (2 symbols across 1 files)

FILE: app.js
  constant CONFIG (line 4) | const CONFIG = JSON.parse(fs.readFileSync("./config.json", { encoding: "...
  function playVoice (line 84) | function playVoice(Voice) {
Condensed preview — 6 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (8K chars).
[
  {
    "path": ".gitignore",
    "chars": 13,
    "preview": "node_modules\n"
  },
  {
    "path": "LICENSE",
    "chars": 1066,
    "preview": "MIT License\n\nCopyright (c) 2021 polemikal\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\n"
  },
  {
    "path": "README.md",
    "chars": 898,
    "preview": "# discord-welcome-bot\n\nA great intro sounds for Discord servers!\n\n# Setup the Project\n\n1. Download or clone this project"
  },
  {
    "path": "app.js",
    "chars": 4253,
    "preview": "const { Client, VoiceChannel, GuildMember } = require(\"discord.js\");\n\nconst fs = require(\"fs\");\nconst CONFIG = JSON.pars"
  },
  {
    "path": "config.json",
    "chars": 338,
    "preview": "{\n    \"DEFAULTS\": {\n        \"AUTHORS\": [],\n        \"ACTIVITY_TEXT\": \"Polemikal Voice System\",\n        \"GUILD_ID\": \"\",\n  "
  },
  {
    "path": "package.json",
    "chars": 424,
    "preview": "{\n  \"name\": \"dark-voice-bots\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"app.js\",\n  \"scripts\": {\n    \"test\":"
  }
]

About this extraction

This page contains the full source code of the polemikal/discord-welcome-bot GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 6 files (6.8 KB), approximately 1.8k tokens, and a symbol index with 2 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!