简体   繁体   English

如何使用在 onMessageReveived 事件之前收到的 slashcommand 中提供的通道?

[英]How to use a channel, which is provided in a slashcommand received before in a onMessageReveived event?

I started coding a new project today and I'm having some issues.我今天开始编写一个新项目,但遇到了一些问题。 The bot should check every message in a channel provided in a slash command whether it's equal to a word, also provided in the slash command.机器人应检查斜杠命令中提供的频道中的每条消息是否等于单词,斜杠命令中也提供了该单词。 For that I would normally need an onMessageReceived event, but I can't use something, which was provided in a slash command there.为此,我通常需要一个 onMessageReceived 事件,但我不能使用那里的斜线命令中提供的东西。 Has anyone an idea how to fix that?有谁知道如何解决这个问题?

I tried some things, but you can't make a public string in an onSlashCommandInteractionEvent.我尝试了一些方法,但您不能在 onSlashCommandInteractionEvent 中创建公共字符串。 I don't know how I could fix that problem otherwise, because I would normally do something like我不知道如何解决这个问题,因为我通常会做类似的事情

event.getOption("channel").getAsChannel().asTextChannel()

but you can only do that in the event.但你只能在活动中这样做。 There you can't use it in another event though.在那里你不能在另一个事件中使用它。

You have to store the data on the channel somewhere, preferably in a separate file, but you can also make a public List<TextChannel> and work on that, only problem being it will be reset every time you restart the project.您必须将数据存储在通道上的某个地方,最好是在一个单独的文件中,但您也可以创建一个公共List<TextChannel>并对其进行处理,唯一的问题是每次重新启动项目时它都会被重置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Apache Flink Channel在完成当前部分记录之前收到了一个事件 - Apache Flink Channel received an event before completing the current partial record SonarQube“在方法外部提供,使用前未经消毒” - SonarQube “is provided externally to the method and not sanitized before use” 在 spring 提供的这么多事件中 - 哪个事件是监听我的应用程序缓存数据的正确事件 - Out of so many events provided by spring - Which event is the right event to listen to cache the data for my application 如何使用提供的密钥库对jar文件进行签名 - How to use a provided keystore to sign a jar file 如何在Spring中使用WebLogic提供的JNDI DataSource? - How to use JNDI DataSource provided by WebLogic in Spring? 如何在运行报告之前使用提供的参数评估表达式? - How to evaluate expression with provided parameters before running the report? 如何在Spring中使用Tomcat提供的JNDI DataSource? - How to use JNDI DataSource provided by Tomcat in Spring? 如何引用JAR文件中提供的JSF托管bean? - How to reference JSF managed beans which are provided in a JAR file? 在处理程序收到Netty事件之前,如何将对象附加到通道? - How attach an object to a channel before handlers receive events with Netty? Android通知通道如何使用getSystemService - How to use getSystemService for Android notification channel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM