Giter Club home page Giter Club logo

core's Introduction

👋・About me

My name is Raphael, and I'm a 20-year-old maritime student. However, development is a hobby that I am passionate about. Since high school, I have discovered my interest in development and started exploring this fascinating field. Initially, I started creating Discord bots, but over time, I have expanded my skills. Currently, I focus on building small web applications. On my GitHub, you will find utility projects that can be helpful for your own projects. I'm excited to share my creations with you.

💻・Programming Languages

programming

🌐・ Technologies & Frameworks

technologies_frameworks inertia (1)

📊・ Databases

databases

🛠️・ Tools

tools

📩・ Contact

contact_discord contact_twitter

core's People

Contributors

akira13345 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

core's Issues

Call redundancy in the cache

A call to the cache to retrieve a channel is repeated every minute in a setInterval.
The latter could be exported outside the callback to avoid this redundancy.

const client = require('../../../index');
const axios = require('axios');

const CONNECTED_USERS_CHANNEL_ID = process.env.CONNECTED_USERS_CHANNEL_ID;
const MEMBERS_CHANNEL_ID = process.env.MEMBERS_CHANNEL_ID;
const IP = process.env.IP;

client.on("ready", () => {
    const channel = client.channels.cache.get(CONNECTED_USERS_CHANNEL_ID)
    async function updateStatus() {
        try {
            const response = await axios.get(`https://api.mcsrvstat.us/2/${IP}`);
            const json = response.data;

            await channel.setName(`🚀 Connectés: ${json.players.online}`);

            const guild = client.guilds.cache.first();
            client.channels.cache.get(MEMBERS_CHANNEL_ID).setName(`🌏 Membres: ${guild.memberCount}`);
        } catch (error) {
            console.error("Une erreur s'est produite:", error);
        }
    }

    setInterval(updateStatus, 60000); // 1 minute
});

The action can of course be repeated on the guild and the other channel recovered from the cache.

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.