Coder Social home page Coder Social logo

snakecord's Introduction

Snakecord

You've heard of the famous Snake game, right? Well, this npm/yarn package allows you to create your own CUSTOM Snake games, directly inside Discord via Discord bots!

Installation

npm install snakecord
# or
yarn add snakecord

Features

  • Easy to use
  • Clean and focused
  • Actively maintained

Example

const SnakeGame = require('snakecord');
const Discord = require('discord.js');
const client = new Discord.Client(); // remember to add the intents that you need

const snakeGame = new SnakeGame({
    title: 'Snake Game',
    color: 'GREEN',
    timestamp: false,
    gameOverTitle: 'Game Over'
});

const config = {
    token: 'TOKEN',
    prefix: 't!'
}

client.on('ready', () => {
    console.log('Ready!');
    client.user.setActivity(`${config.prefix}help`);
});

client.on('message', async message => {
    if(!message.content.startsWith(config.prefix) || message.author.bot) {
        return;
    }

    const args = message.content.slice(config.prefix.length).trim().split(/ +/);
    const command = args.shift().toLowerCase();

    if(command === 'test') {
        return message.channel.send('Test command works.');
    } else if(command === 'snake' || command === 'snakegame') {
        return await snakeGame.newGame(message);
    } else if(command === 'help' || command === 'h') {
        const embed = new Discord.MessageEmbed()
            .setTitle('Help Menu')
            .addFields(
                { name: 'test', value: 'Check the command handler', inline: true },
                { name: 'snake', value: 'Play the snake game', inline: true },
                { name: 'help', value: 'Show this list', inline: true }
            )
            .setColor('RANDOM')
            .setTimestamp();

        return message.channel.send({ embeds: [embed] });
    }
});

client.login(config.token);

In Action

1

2

To-Do

  • Optimizations and more optimizations
  • Rewrite the whole thing in TypeScript
  • Add JSDocs for easier development
  • Add more features (including but not limited to)
    • Board size customizations
    • Server highscore tracking/leaderboards
    • Color customizations

Authors

snakecord's People

Contributors

terra-rian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.