mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-21 05:32:43 +00:00
added command to show the avatar of member
This commit is contained in:
@@ -0,0 +1,57 @@
|
|||||||
|
package dev.sheldan.abstracto.utility.commands;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.command.UtilityModuleInterface;
|
||||||
|
import dev.sheldan.abstracto.core.command.condition.AbstractConditionableCommand;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.CommandConfiguration;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.HelpInfo;
|
||||||
|
import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||||
|
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||||
|
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||||
|
import dev.sheldan.abstracto.core.command.execution.ContextConverter;
|
||||||
|
import dev.sheldan.abstracto.core.config.FeatureEnum;
|
||||||
|
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||||
|
import dev.sheldan.abstracto.utility.config.features.UtilityFeature;
|
||||||
|
import dev.sheldan.abstracto.utility.models.template.commands.ShowAvatarModel;
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ShowAvatar extends AbstractConditionableCommand {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ChannelService channelService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandResult execute(CommandContext commandContext) {
|
||||||
|
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||||
|
Member memberToShow = parameters.size() == 1 ? (Member) parameters.get(0) : commandContext.getUserInitiatedContext().getMember();
|
||||||
|
ShowAvatarModel model = (ShowAvatarModel) ContextConverter.fromCommandContext(commandContext, ShowAvatarModel.class);
|
||||||
|
model.setMemberInfo(memberToShow);
|
||||||
|
channelService.sendEmbedTemplateInChannel("showAvatar_response", model, commandContext.getChannel());
|
||||||
|
return CommandResult.fromSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandConfiguration getConfiguration() {
|
||||||
|
List<Parameter> parameters = new ArrayList<>();
|
||||||
|
parameters.add(Parameter.builder().type(Member.class).name("member").templated(true).optional(true).build());
|
||||||
|
HelpInfo helpInfo = HelpInfo.builder().templated(true).build();
|
||||||
|
return CommandConfiguration.builder()
|
||||||
|
.name("showAvatar")
|
||||||
|
.module(UtilityModuleInterface.UTILITY)
|
||||||
|
.templated(true)
|
||||||
|
.causesReaction(false)
|
||||||
|
.parameters(parameters)
|
||||||
|
.help(helpInfo)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FeatureEnum getFeature() {
|
||||||
|
return UtilityFeature.UTILITY;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ import dev.sheldan.abstracto.core.config.FeatureEnum;
|
|||||||
import dev.sheldan.abstracto.core.service.BotService;
|
import dev.sheldan.abstracto.core.service.BotService;
|
||||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||||
import dev.sheldan.abstracto.utility.config.features.UtilityFeature;
|
import dev.sheldan.abstracto.utility.config.features.UtilityFeature;
|
||||||
import dev.sheldan.abstracto.utility.models.template.commands.userinfo.UserInfoModel;
|
import dev.sheldan.abstracto.utility.models.template.commands.UserInfoModel;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"author": {
|
||||||
|
"name": "${memberInfo.user.name}#${memberInfo.user.discriminator}",
|
||||||
|
"avatar": "${memberInfo.user.effectiveAvatarUrl}"
|
||||||
|
},
|
||||||
|
"color" : {
|
||||||
|
"r": 200,
|
||||||
|
"g": 0,
|
||||||
|
"b": 255
|
||||||
|
},
|
||||||
|
"imageUrl": "${memberInfo.user.effectiveAvatarUrl}",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "<#include "showAvatar_response_embed_user_field_title">",
|
||||||
|
"value": "${memberInfo.user.name}#${memberInfo.user.discriminator}",
|
||||||
|
"inline": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "<#include "showAvatar_response_embed_image_field_title">",
|
||||||
|
"value": "[<#include "showAvatar_response_embed_image_field_value_display">](${memberInfo.user.effectiveAvatarUrl})",
|
||||||
|
"inline": "true"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package dev.sheldan.abstracto.utility.models.template.commands;
|
||||||
|
|
||||||
|
import dev.sheldan.abstracto.core.models.context.UserInitiatedServerContext;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@SuperBuilder
|
||||||
|
public class ShowAvatarModel extends UserInitiatedServerContext {
|
||||||
|
private Member memberInfo;
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package dev.sheldan.abstracto.utility.models.template.commands.userinfo;
|
package dev.sheldan.abstracto.utility.models.template.commands;
|
||||||
|
|
||||||
import dev.sheldan.abstracto.core.models.context.UserInitiatedServerContext;
|
import dev.sheldan.abstracto.core.models.context.UserInitiatedServerContext;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Shows the avatar of a user
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Shows the avatar of a member and provides a link to easier access it.
|
||||||
|
Takes a member as a parameter, if this parameter is not available, it uses the member executing the command.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
The member you want to see the avatar for. If not provided will use the member executing the command.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
showAvatar [member]
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Image
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Link
|
||||||
Reference in New Issue
Block a user