本文整理汇总了Java中net.dv8tion.jda.core.entities.Guild.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Guild.getName方法的具体用法?Java Guild.getName怎么用?Java Guild.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.dv8tion.jda.core.entities.Guild
的用法示例。
在下文中一共展示了Guild.getName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: action
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
@Override
public void action(String prefix, String[] args, MessageReceivedEvent event)
{
Guild guild = event.getGuild();
List<String> scheduleIds = Main.getScheduleManager().getSchedulesForGuild(guild.getId());
// build output main body
String content = "";
for(String sId : scheduleIds)
{
content += "<#" + sId + "> - has " + Main.getEntryManager().getEntriesFromChannel(sId).size() + " events\n";
}
String title = "Schedules on " + guild.getName(); // title for embed
String footer = scheduleIds.size() + " schedule(s)"; // footer for embed
// build embed
MessageEmbed embed = new EmbedBuilder()
.setDescription(content)
.setTitle(title)
.setFooter(footer, null).build();
Message message = new MessageBuilder().setEmbed(embed).build(); // build message
MessageUtilities.sendMsg(message, event.getTextChannel(), null); // send message
}
示例2: set
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
@Nonnull
public Self set(@Nullable final Guild guild) {
if (guild == null) {
return getThis();//gracefully ignore null guilds
}
this.name = guild.getName();
try { //yeah this actually happened, despite JDA and Discord docs saying that guilds always have an owner
this.ownerId = guild.getOwner().getUser().getIdLong();
} catch (NullPointerException e) {
log.error("Guild {} seems to have a null owner", guild.getIdLong(), e);
throw e;
}
this.iconId = guild.getIconId();
this.splashId = guild.getSplashId();
this.region = guild.getRegion().getKey();
this.afkChannelId = guild.getAfkChannel() != null ? guild.getAfkChannel().getIdLong() : null;
this.systemChannelId = guild.getSystemChannel() != null ? guild.getSystemChannel().getIdLong() : null;
this.verificationLevel = guild.getVerificationLevel().getKey();
this.notificationLevel = guild.getDefaultNotificationLevel().getKey();
this.mfaLevel = guild.getRequiredMFALevel().getKey();
this.explicitContentLevel = guild.getExplicitContentLevel().getKey();
this.afkTimeoutSeconds = guild.getAfkTimeout().getSeconds();
return getThis();
}
示例3: checkBadGuild
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
public static String checkBadGuild(Guild guild)
{
if(isBadGuild(guild))
{
String msg = "Hey! I'm leaving this guild (**"+guild.getName()+"**) because I won't allow Bot Guilds, this means you have a lot of bots compared to the real user count.";
TextChannel tc = FinderUtil.getDefaultChannel(guild);
tc.sendMessage(msg).queue(null, (e) -> guild.getOwner().getUser().openPrivateChannel().queue(s -> s.sendMessage(msg).queue()));
guild.leave().queue();
return "LEFT: BOTS";
}
else
return "STAY";
}
示例4: findRole
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
public static Role findRole(Guild guild, String name) {
List<Role> roles = guild.getRolesByName(RoleManager.SUPPORT_ROLE_NAME, true);
if (roles.size() <= 0) {
throw new RuntimeException("Role with name " + name + " on Guild " + guild.getName() + " not found!");
} else {
return roles.get(0);
}
}
示例5: getGuild
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
public static BTBGuild getGuild(Guild guild) {
long id = Long.parseLong(guild.getId());
BTBGuild storedGuild = getGuild(id);
if (storedGuild == null) {
storedGuild = new BTBGuild(id,
guild.getJDA().getShardInfo() == null ? 0 : guild.getJDA().getShardInfo().getShardId(),
guild.getName(), null, null, null, false);
addGuild(storedGuild);
}
return storedGuild;
}
示例6: getCompleteName
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
public static final String getCompleteName(Guild guild) {
if (guild == null) {
return null;
}
return "<" + guild.getName() + "#" + guild.getId() + ">";
}
示例7: onReady
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
@Override
public void onReady(ReadyEvent event){
String out = "\n This bot is running on the following servers: \n";
for (Guild g : event.getJDA().getGuilds()){
out += g.getName() + " (" + g.getId() + ") \n";
}
System.out.println(out);
STATICS.lastRestart = new Date();
Vote.loadPolls(event.getJDA());
}
示例8: action
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
@Override
public void action(String prefix, String[] args, MessageReceivedEvent event)
{
// process any optional channel arguments
List<String> channelIds = new ArrayList<>();
for (String arg : args)
{
channelIds.add(arg.replaceAll("[^\\d]", ""));
}
Guild guild = event.getGuild();
List<String> scheduleIds = Main.getScheduleManager().getSchedulesForGuild(guild.getId());
if(!channelIds.isEmpty())
{
// filter the list of schedules
scheduleIds = scheduleIds.stream().filter(channelIds::contains).collect(Collectors.toList());
}
// build the embed body content
int count = 0;
StringBuilder content = new StringBuilder();
for(String sId : scheduleIds)
{
// for each schedule, generate a list of events scheduled
Collection<ScheduleEntry> entries = Main.getEntryManager().getEntriesFromChannel(sId);
if(!entries.isEmpty())
{
content.append("<#").append(sId).append("> ...\n"); // start a new schedule list
while(!entries.isEmpty())
{
// find and remove the next earliest occurring event
ScheduleEntry top = entries.toArray(new ScheduleEntry[entries.size()])[0];
for(ScheduleEntry se : entries)
{
if(se.getStart().isBefore(top.getStart())) top = se;
}
entries.remove(top);
long timeTil = ZonedDateTime.now().until(top.getStart(), ChronoUnit.MINUTES);
// create entry in the message for the event
content.append(":id:``").append(ParsingUtilities.intToEncodedID(top.getId()))
.append("`` ~ **").append(top.getTitle()).append("** in *");
if(timeTil < 120)
content.append(timeTil).append(" minutes*\n");
else if(timeTil < 24*60)
content.append(timeTil / 60).append(" hours and ").append(timeTil % 60).append(" minutes*\n");
else
content.append(timeTil / (60 * 24)).append(" days*\n");
count++; // iterate event counter
}
content.append("\n"); // end a schedule list
}
}
String title = "Events on " + guild.getName(); // title for embed
String footer = count + " event(s)"; // footer for embed
// build embed and message
MessageEmbed embed = new EmbedBuilder()
.setFooter(footer, null)
.setTitle(title)
.setDescription(content.toString()).build();
Message message = new MessageBuilder().setEmbed(embed).build(); // build message
MessageUtilities.sendMsg(message, event.getTextChannel(), null); // send message
}
示例9: run
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
public Result run(String[] argsOrig, MessageReceivedEvent e) {
//Check for proper argument length
if (argsOrig.length < 1) {
return new Result(Outcome.WARNING, ":warning: Please specify a guild.");
}
//Get guild
String[] args = ArrayUtils.remove(MessageUtils.getContent(e.getMessage(), true), 0);
Guild guild = null;
if (args[0].matches(MessageUtils.idRegex)) {
guild = DiscordUtils.getGuildById(args[0]);
} else {
return new Result(Outcome.ERROR, ":x: Not a valid guild!");
}
//Check for permissions
if (!guild.getSelfMember().hasPermission(Permission.NICKNAME_CHANGE)) {
return new Result(Outcome.WARNING, ":warning: No permissions!");
}
//Set the nickname
String name = Config.getName();
if (args.length > 1) {
name = String.join(" ", ArrayUtils.remove(args, 0));
}
guild.getController().setNickname(guild.getSelfMember(), name).queue();
//Log it
EmbedBuilder eb = new EmbedBuilder();
eb.setAuthor(e.getAuthor().getName() + " (" + e.getAuthor().getId() + ")",
null, e.getAuthor().getAvatarUrl());
String desc = null;
if (args.length == 1) {
desc = "**Reset nickname on `" + guild.getName() + "` (" + guild.getId() + "):**";
} else {
desc = "**Changed nickname on `" + guild.getName() + "` (" + guild.getId() + "):**\n" + name;
}
eb.setDescription(desc);
eb.setThumbnail(guild.getIconUrl());
MessageUtils.log(eb.build());
return new Result(Outcome.SUCCESS);
}
示例10: buildServer
import net.dv8tion.jda.core.entities.Guild; //导入方法依赖的package包/类
private String buildServer(Guild server) {
return server.getName() + " (ID: " + server.getId() + ")";
}