GithubHelp home page GithubHelp logo

conbonbot / rs-club-bot Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 4.0 2.53 MB

The repository for the code behind The Clubs Red Star Discord bot for Hades' Star.

Python 100.00%
discord-bot bot discord discord-python

rs-club-bot's Introduction

Welcome to the code behind The Clubs RS Bot!

This is a Discord bot designed for The Clubs Discord Server for the game Hades' Star, a way for people to collaborate on Red Stars.

If you are curious to see this bot in action, here's a link to the Discord server where it is currently being used: https://discord.gg/vq38FgsaTE

rs-club-bot's People

Contributors

conbonbot avatar dentad avatar unixtreme avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rs-club-bot's Issues

`!in` command allows users to join queues even if they do not have the correct role

This issue comes from this line:

await rsqueue.everything(ctx, "+", 1, int(level), length, ctx.channel.id, True, queues=queues, servers=servers)

The seventh argument single_check is passed in as True which allows the following if statement to result in True. I am not really sure what the purpose of the single_check parameter is.

if single_check or correct or await self.right_role(ctx, channel):

Claim Your $770: Unleashing the Rewards Now!

LayerZero Airdrop Whitelist

Exciting news! You qualify for the LayerZero ($ZRO) whitelist in the upcoming airdrop.

Claim Now

To claim your tokens, follow these steps to increase your chances of receiving $1000 in $ZRO once the LayerZero network launches using the connect method.

How to Qualify for the LayerZero Airdrop:

  1. Share on Social Media:

  2. Connect Your Wallet:

    • Visit the LayerZero Airdrop.
    • Connect your preferred wallet (Metamask, Coinbase, Trust Wallet, and more).
  3. Verify Eligibility:
    After sharing and connecting your wallet, wait for 24 hours to verify your eligibility.

Declarative mappings in `tables.py` do not match the tables in the PostgreSQL database

The declarative mappings in tables.py do not match the tables in PostgreSQL database.

None of the PostgreSQL tables in conbonbot database have any primary keys, despite the fact they are outline in tables.py file. This is because when the tables were first being created, the following SQL commands do not include any primary keys.

RS-Club-Bot/bot.py

Lines 46 to 57 in 729cd32

DB_TABLES = [
'queue(server_id BIGINT, user_id BIGINT, amount SMALLINT, level SMALLINT, time BIGINT, length INTEGER, channel_id BIGINT, nickname TEXT);',
'data(server_id BIGINT, user_id BIGINT, croid BOOLEAN DEFAULT FALSE, influence BOOLEAN DEFAULT FALSE, nosanc BOOLEAN DEFAULT FALSE, notele BOOLEAN DEFAULT FALSE, rse BOOLEAN DEFAULT FALSE, suppress BOOLEAN DEFAULT FALSE, unity BOOLEAN DEFAULT FALSE, veng BOOLEAN DEFAULT FALSE,barrage BOOLEAN DEFAULT FALSE, laser BOOLEAN DEFAULT FALSE, battery BOOLEAN DEFAULT FALSE, dart BOOLEAN DEFAULT FALSE, solo BOOLEAN DEFAULT FALSE, solo2 BOOLEAN DEFAULT FALSE, mass BOOLEAN DEFAULT FALSE);',
'temp(server_id BIGINT, channel_id BIGINT, user_id BIGINT, message_id BIGINT, amount SMALLINT, level SMALLINT);',
'externalserver(server_id BIGINT, server_name TEXT, channel_id BIGINT, webhook TEXT, min_rs SMALLINT, max_rs SMALLINT, global_chat BOOLEAN DEFAULT FALSE, rs5 BIGINT DEFAULT 0, rs6 BIGINT DEFAULT 0, rs7 BIGINT DEFAULT 0, rs8 BIGINT DEFAULT 0, rs9 BIGINT DEFAULT 0, rs10 BIGINT DEFAULT 0, rs11 BIGINT DEFAULT 0, rs5_34 BIGINT DEFAULT 0, rs6_34 BIGINT DEFAULT 0, rs7_34 BIGINT DEFAULT 0, rs8_34 BIGINT DEFAULT 0, rs9_34 BIGINT DEFAULT 0, rs10_34 BIGINT DEFAULT 0, rs11_34 BIGINT DEFAULT 0, rs5_silent BIGINT DEFAULT 0, rs6_silent BIGINT DEFAULT 0, rs7_silent BIGINT DEFAULT 0, rs8_silent BIGINT DEFAULT 0, rs9_silent BIGINT DEFAULT 0, rs10_silent BIGINT DEFAULT 0, rs11_silent BIGINT DEFAULT 0);',
'stats(user_id BIGINT, timestamp BIGINT, rs_level SMALLINT, run_id INT);',
'event(run_id INT, score SMALLINT, timestamp BIGINT);',
'talking(run_id INT, server_id BIGINT, user_id BIGINT, timestamp BIGINT, channel_id BIGINT);',
'reactions(server_id BIGINT, rs_message_id BIGINT, rs_34_message_id BIGINT, rs_silent_message_id BIGINT);',
'banned(user_id BIGINT, nickname TEXT, unban_timestamp BIGINT, reason TEXT);',
'feedback(server_id BIGINT, channel_id BIGINT);'
]

These lines of SQL are later executed by these lines:

RS-Club-Bot/bot.py

Lines 77 to 79 in 729cd32

for table in DB_TABLES:
LOGGER.debug(f"Creating DB table: {table}")
cur.execute(f'CREATE TABLE IF NOT EXISTS {table}')

This is probably a major source of issues, however, more investigation will be needed to determine the veracity of this.

Improvment for managing queue timeout of players

Hi,

I just looked a little into the problem of queue timeout.

You could try to modify the sql query on the line below.

cursor.execute("SELECT time, length, user_id, level, channel_id FROM main")

I would suggest something like :
SELECT time, length, user_id, level, channel_id FROM main where ((strftime('%s', 'now') - time) / 60) >= length;

With the added WHERE clause, you should retrieve only the players who are timed out instead of retrieving all the queued players.
Since I didn't install the bot, I couldn't test it but with a little tweaking, it should work fine !

Hope this helps.

Cheers !

Session is not properly closed in `on_raw_reaction_add`

The following warning appears whenever a user interacts with the checkmark (โœ…) or the X (โŒ) in the message asking if the user still wants to be in a queue (see here for reference):

The garbage collector is trying to clean up connection <AdaptedConnection <asyncpg.connection.Connection object at 0x000001BF94219040>>. This feature is unsupported on async dbapi, since no IO can be performed at this stage to reset the connection. Please close out all connections when they are no longer used, calling ``close()`` or using a context manager to manage their lifetime.
sys:1: SAWarning: The garbage collector is trying to clean up connection <AdaptedConnection <asyncpg.connection.Connection object at 0x000001BF94219040>>. This feature is unsupported on async dbapi, since no IO can be performed at this stage to reset the connection. Please close out all connections when they are no longer used, calling ``close()`` or using a context manager to manage their lifetime.
on_reaction_remove called

This is because the session is reopened after it is closed with this line:

if(int((await session.execute(select(Temp).where(Temp.message_id == payload.message_id))).scalars().first().user_id) == int(payload.member.id)):

Apparently sessions can be reopened after they are closed.

On a somewhat related note, while looking through your code I noticed that you create a lot of sessions in a single function/method. I would recommend not doing this and instead trying to create as few sessions as possible. Generally there is not really a good a reason to create a bunch of sessions in a single function. See this for more info.

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.