Commit 386e273 1 parent 9c50b12 commit 386e273 Copy full SHA for 386e273
File tree 1 file changed +16
-0
lines changed
src/main/java/dev/qixils/quasicord/locale
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 10
10
import net .dv8tion .jda .api .entities .Member ;
11
11
import net .dv8tion .jda .api .entities .Message ;
12
12
import net .dv8tion .jda .api .entities .User ;
13
+ import net .dv8tion .jda .api .entities .channel .Channel ;
14
+ import net .dv8tion .jda .api .entities .channel .middleman .GuildMessageChannel ;
13
15
import net .dv8tion .jda .api .entities .channel .middleman .MessageChannel ;
14
16
import net .dv8tion .jda .api .interactions .DiscordLocale ;
15
17
import net .dv8tion .jda .api .interactions .Interaction ;
@@ -123,6 +125,20 @@ public interface Context {
123
125
return context .build ();
124
126
}
125
127
128
+ /**
129
+ * Creates a context from a {@link Channel channel}.
130
+ *
131
+ * @param channel the channel
132
+ * @return a context
133
+ */
134
+ static @ NonNull Context fromChannel (@ NonNull MessageChannel channel ) {
135
+ Builder context = builder ()
136
+ .channel (channel );
137
+ if (channel instanceof GuildMessageChannel guildChannel )
138
+ context .guild (guildChannel .getGuild ()).guildLocale (guildChannel .getGuild ());
139
+ return context .build ();
140
+ }
141
+
126
142
/**
127
143
* An empty context.
128
144
*/
You can’t perform that action at this time.
0 commit comments