Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
115 views
in Technique[技术] by (71.8m points)

python - Imported GitHub files and folders for Minigames to my bot and I get a long Traceback

I imported this github (https://github.com/whuybrec/whuybrec.github.io) to my repl.it project with my Discord.py bot and I'm trying to get it to work but I get this error, what am I doing wromg and what do you need me to provide? Here's main.py:

from minigamesbot import MiniGamesBot
from Other.private import Private



bot = MiniGamesBot("!")
bot.run(Private.TOKEN)

It's just from the github, I copied basically everything from there. And here's my minigamebot.py

import discord
import discord.client
from discord.ext.commands import Bot
from discord.utils import find
from keep_alive import keep_alive

from Commands.developer import delete_command, say_command
from Commands.minigames import blackjack_command, chess_command, connect4_command, quiz_command, hangman_command, 
    scramble_command, uno_command, guessword_command, checkers_command
from Commands.miscellaneous import help_command, set_prefix_command
from Other.private import Private
from Other.variables import on_startup
from Database.database import DataBase

class MiniGamesBot(Bot):
    def __init__(self, prefix):
        self.prefix = prefix
        super().__init__(command_prefix=self.prefix)
        self.on_startup()
        self.called = False

        self.my_commands = [help_command.HelpCommand, blackjack_command.BlackjackCommand, chess_command.ChessCommand,
                            connect4_command.Connect4Command, hangman_command.HangmanCommand, quiz_command.QuizCommand,
                            guessword_command.GuesswordCommand, scramble_command.ScrambleCommand, uno_command.UnoCommand,
                            delete_command.DeleteCommand, say_command.SayCommand, set_prefix_command.SetPrefixCommand,
                            checkers_command.CheckersCommand]
        for command in self.my_commands:
            command.add_command(self)

    async def on_message(self, message):
        if isinstance(message.channel, discord.DMChannel):
            return
        if str(message.channel.guild.id) in Private.prefixes.keys():
            if message.content.startswith(Private.prefixes[str(message.channel.guild.id)]):
                message.content = self.prefix + message.content[len(Private.prefixes[str(message.channel.guild.id)]):]
            else:
                return

        ctxt = await self.get_context(message)
        await self.invoke(ctxt)
    
    keep_alive()
    def on_startup(self):
        print("Loading database...")
        DataBase.initialize(self)
        print("Loading files...")
        on_startup()
        print("Done!")

Here's my variables.py

import random
import json
from Other.private import Private

class Variables:
    game_names = ["hangman", "connect4", "scramble", "guessword", "blackjack", "quiz", "uno", "chess"]
    database_file = "Data/user_statistics.db"

    EXTRA = "New MiniGame: CHESS! If you encounter any bugs/suggestions, " 
            "let me know on my github page or use the bug command!
"

    TIMEOUT = 360
    eng_dict = None
    questions_dict = None
    randwords = list()

    games_names_short = ["hm", "c4", "sc", "gw", "bj", "qz", "uno", "chess"]

    quiz_categories = ["General Knowledge", "Sports", "Films", "Music", "Video Games"]

    colors_uno = {"Blue": "??", "Green": "??", "Red": "??", "Yellow": "??"}
    white = {"White": "?"}

    SPLIT_EMOJI = "??"
    INC_EMOJI1 = "??"
    INC_EMOJI2 = "?"
    STOP_EMOJI = "?"
    BACK_EMOJI = "?"
    FORWARD_EMOJI = "??"
    REPEAT_EMOJI = "??"
    NEXT_EMOJI = "??"
    DICT_ALFABET = {'a': '??', 'b': '??', 'c': '??', 'd': '??', 'e': '??', 'f': '??', 'g': '??', 'h': '??',
                    'i': '??', 'j': '??',
                    'k': '??', 'l': '??', 'm': '??', 'n': '??', 'o': '??', 'p': '??', 'q': '??', 'r': '??',
                    's': '??', 't': '??',
                    'u': '??', 'v': '??', 'w': '??', 'x': '??', 'y': '??', 'z': '??'}  # letter: emoji
    NUMBERS = ["0??", "1??", "2??", "3??", "4??", "5??", "6??", "7??", "8??", "9??"]
    REACTIONS_CONNECT4 = ["1??", "2??", "3??", "4??", "5??", "6??", "7??"]

    HANGMAN0 = ""

    HANGMAN1 = "  |
" 
               "  |
" 
               "  |
" 
               "  |
" 
               " _|_ _ _"

    HANGMAN2 = " _____
" 
               " |
" 
               " |
" 
               " |
" 
               " |
" 
               "_|_ _ _"

    HANGMAN3 = " _____
" 
               " |/
" 
               " |
" 
               " |
" 
               " |
" 
               "_|_ _ _"

    HANGMAN4 = " _____
" 
               " |/  |
" 
               " |
" 
               " |
" 
               " |
" 
               "_|_ _ _"

    HANGMAN5 = " _____
" 
               " |/  |
" 
               " |   0
" 
               " |
" 
               " |
" 
               "_|_ _ _"

    HANGMAN6 = " _____
" 
               " |/  |
" 
               " |   o
" 
               " |   |
" 
               " |
" 
               "_|_ _ _"

    HANGMAN7 = " _____
" 
               " |/  |
" 
               " |   o
" 
               " |  /|
" 
               " |
" 
               "_|_ _ _"

    HANGMAN8 = " _____
" 
               " |/  |
" 
               " |   o
" 
               " |  /| 
" 
               " |
" 
               "_|_ _ _"

    HANGMAN9 = " _____
" 
               " |/  |
" 
               " |   o
" 
               " |  /| 
" 
               " |  /
" 
               "_|_ _ _"

    HANGMAN10 = " _____
" 
                " |/  |
" 
                " |   o
" 
                " |  /| 
" 
                " |  /  
" 
                "_|_ _ _"

    hangmen = [HANGMAN0, HANGMAN1, HANGMAN2, HANGMAN3, HANGMAN4,
               HANGMAN5, HANGMAN6, HANGMAN7, HANGMAN8, HANGMAN9, HANGMAN10]

    BJRULES = "Ace is worth either 1 or 11 points.
" 
              "Jack, Queen and King are worth 10 points.
" 
              "The other cards are worth their number.
" 
              "If the first two cards are the same, the player can choose to split their hand.
" 
              "If the player chooses to split, then he or she can play the rest of the game with 2 hands.
" 
              "If the player has 21 points from the start, he or she has BlackJack.
" 
              "The dealer (bot) has one card open untill the player is done playing.
" 
              "The dealer stops asking for cards as soon as it gets passed 17 points (included).
" 
              "The player wins the game when he or she has a higher score than the dealer but below 21 (included).
" 
              "The player draws with the dealer if they both end up with the same number of points.
" 
              "In all other cases the player loses.
" 
              "Press the indicated reactions on the message to make your move.
" 
              "Press " + STOP_EMOJI + " to close the game.
"
    C4RULES = "Who starts is chosen randomly.
" 
              "You can only play when it is your turn.
" 
              "A player wins when there are 4 coins of his or hers color " 
              "diagonally/horizontally/vertically next to eachother.
" 
              "Press the indicated reactions on the message to make your move.
"
    GWRULES = "Guess the word from the given definition.
" 
              "Press the indicated reactions on the message to make your move.
" 
              "Press " + STOP_EMOJI + " to close the game.
"
    HMRULES = "Try to guess the hidden word.
" 
              "There are only lowercase letters in the word.
" 
              "Press the indicated reactions on the message to make your move.
" 
              "Press " + STOP_EMOJI + " to close the game.
"
    SCRULES = "Try to unscramble the letters that the bot scrambled.
" 
              "Press the indicated reactions on the message to make your move.
" 
              "Press " + STOP_EMOJI + " to close the game.
"
    QZRULES = "Try to give the correct answer to the questions.
" 
              "Questions are always multiple choice and have 4 possible answers.
" 
              "Only one answer is the correct one.
" 
              "There are different categories available.
" 
              "You can get a new question after answering the previous one with " + NEXT_EMOJI + ".
" 
              "Press the indicated reactions on the message to make your move.
" 
              "Press " + STOP_EMOJI + " to close the game.
"
    UNORULES = "Every message you type in the bot DM will be visible to other players in the "CHAT" message.
" 
               "Only the person who's turn it is can play.
" 
               "Playable cards are marked with an emoji.
" 
               "Match cards by color or value.
" 
               "Wild cards and Wild Draw 4 cards can be played without matching color or value.
" 
               "Press " + STOP_EMOJI + " to draw a card.
" 
               "If you need to draw multiple cards, use " + INC_EMOJI2 + " to take cards.
" 
               "After drawn a card, use " + NEXT_EMOJI + " to end turn.
" 
               "When you have on card remaining type "uno" in chat." 
               "Players can type "no uno" in chat to catch someone not saying uno.
" 
               "The rest of the rules are according to the official Uno rules.
"
    CHESSRULES = "Start a game of chess with 2 players, one game per channel allowed.
" 
                 "Making moves is done by typing the coordinates in the chat, for example: A7 to A5.
" 
                 "Close the game by clicking on the " + STOP_EMOJI + " ."
    CHECKERSRULES = "Start a game of checkers (English draughts) with 2 players, one game per channel allowed.
" 
                 "Making moves is done by typing the coordinates in the chat, for example: B6 to C5.
" 
                 "Close the game by clicking on the " + STOP_EMOJI + " ."


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...