Search in sources :

Example 26 with UserDto

use of toby.jpa.dto.UserDto in project toby-bot by ml404.

the class AdjustUserCommand method createNewUser.

private void createNewUser(TextChannel channel, Member targetMember, int deleteDelay) {
    // Database did not contain an entry for the user we have made a request against, so make one.
    UserDto newDto = new UserDto();
    newDto.setDiscordId(targetMember.getIdLong());
    newDto.setGuildId(targetMember.getGuild().getIdLong());
    userService.createNewUser(newDto);
    channel.sendMessageFormat("User %s's permissions did not exist in this server's database, they have now been created", targetMember.getNickname()).queue(message -> ICommand.deleteAfter(message, deleteDelay));
}
Also used : UserDto(toby.jpa.dto.UserDto)

Example 27 with UserDto

use of toby.jpa.dto.UserDto in project toby-bot by ml404.

the class Kf2RandomMapCommand method handle.

@Override
@SuppressWarnings("unchecked")
public void handle(CommandContext ctx, String prefix, UserDto requestingUserDto, Integer deleteDelay) {
    ICommand.deleteAfter(ctx.getMessage(), deleteDelay);
    final TextChannel channel = ctx.getChannel();
    try {
        WikiFetcher wikiFetcher = new WikiFetcher(cache);
        List<String> kf2Maps = wikiFetcher.fetchFromWiki(cacheName, kf2WebUrl, className, "b");
        channel.sendMessage(RandomCommand.getRandomElement(kf2Maps)).queue(message -> ICommand.deleteAfter(message, deleteDelay));
    } catch (IOException ignored) {
        channel.sendMessage("Huh, the website I pull data from must have returned something unexpected.").queue(message -> ICommand.deleteAfter(message, deleteDelay));
    }
}
Also used : CommandContext(toby.command.CommandContext) WikiFetcher(toby.helpers.WikiFetcher) Arrays(java.util.Arrays) List(java.util.List) UserDto(toby.jpa.dto.UserDto) ICommand(toby.command.ICommand) Cache(toby.helpers.Cache) IOException(java.io.IOException) TextChannel(net.dv8tion.jda.api.entities.TextChannel) RandomCommand(toby.command.commands.misc.RandomCommand) TextChannel(net.dv8tion.jda.api.entities.TextChannel) WikiFetcher(toby.helpers.WikiFetcher) IOException(java.io.IOException)

Aggregations

UserDto (toby.jpa.dto.UserDto)27 CommandContext (toby.command.CommandContext)16 ICommand (toby.command.ICommand)16 List (java.util.List)15 TextChannel (net.dv8tion.jda.api.entities.TextChannel)14 Arrays (java.util.Arrays)10 MusicDto (toby.jpa.dto.MusicDto)9 Collectors (java.util.stream.Collectors)8 Message (net.dv8tion.jda.api.entities.Message)8 Member (net.dv8tion.jda.api.entities.Member)6 IUserService (toby.jpa.service.IUserService)6 IOException (java.io.IOException)4 Test (org.junit.jupiter.api.Test)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 UserDtoHelper.calculateUserDto (toby.helpers.UserDtoHelper.calculateUserDto)4 ConfigDto (toby.jpa.dto.ConfigDto)4 IConfigService (toby.jpa.service.IConfigService)4 Objects (java.util.Objects)3 Optional (java.util.Optional)3 Random (java.util.Random)3