在Heroku上进行BOT java jda部署

时间:2018-04-16 18:52:09

标签: java discord

您好我想在heroku上推送我的discord bot,但我使用JDA的librairy,当我在heroku上时,我将我的github项目链接到他,我有这个错误:

 !     No default language could be detected for this app.
        HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
        See https://devcenter.heroku.com/articles/buildpacks

但我有一些java文件,我想知道我的代码和我的图书馆是否可以放在heroku上

附件:

我的主要:

    package fr.Bot;

import net.dv8tion.jda.client.entities.Group;

import net.dv8tion.jda.core.*;
import net.dv8tion.jda.core.entities.*;
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import net.dv8tion.jda.core.hooks.ListenerAdapter;
import net.dv8tion.jda.core.requests.RestAction;

import javax.security.auth.login.LoginException;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Scanner;


public class MainBot extends ListenerAdapter
{
    private static boolean stop=false;
    private GestionCommande GCommand;
    private GestionServer Gserver;
    private boolean GserverInitialise = false;
    private TextChannel Information;
    private Message c;
    private Timer t;
    private User Bot;
    JDA jda ;



    /**
     * This is the method where the program starts.
     */
    public static void main(String[] args)
    {
        MainBot run = new MainBot();
        run.run(args);
    }

    private void run(String[] args) {
        initCommand();
        initServeur();
        try
        {
            jda = new JDABuilder(AccountType.BOT)
                    .setToken(args[0])
                    .addEventListener(this)
                    .buildBlocking();
            Information = jda.getTextChannelById("435171789589577748");
            Bot = jda.getSelfUser();
            jda.getPresence().setGame(Game.of(Game.GameType.DEFAULT,"SoulWorker.Spy.Srv | s!help","https://www.g-status.com/game/soulworker"));
        }
        catch (LoginException e)
        {
            e.printStackTrace();
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }
        clean();
        Information.sendTyping().queue();
        Information.sendMessage("Hello everyone").queue();
        Information.sendMessage(GCommand.CommandEtat(Gserver,Bot).build()).queue();
        t = new Timer(3000, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                cleanMsg();
            }

            private void cleanMsg() {
                c.delete().reason("clean").queue();
                t.stop();
            }
        });
        Timer timer;
        timer = new Timer(30000, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                onChangeServer();
            }
        });
        timer.start();
        while (!stop) {
            Scanner scanner = new Scanner(System.in);
            String cmd = scanner.next();
            if (cmd.equalsIgnoreCase("stop")) {
                exit();
            }
        }
    }

    @Override
    public void onMessageReceived(MessageReceivedEvent event)
    {

        // event management

我的github:https://github.com/EscapeManOZK/BotDiscord

1 个答案:

答案 0 :(得分:0)

是的,你可以,但是为了让heroku自动检测你的Java应用,你需要使用maven并包含pom.xml。请检查此https://devcenter.heroku.com/articles/java-support